File indexing completed on 2025-08-06 08:12:38
0001 int ratio_check()
0002 {
0003 string hist_name = "h2D_Mbin_NClus";
0004
0005 string zf_data_file = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Feb102025/Run6_EvtZFitWidthChange/EvtVtxZ/completed/Data_MBin70_NClus.root";
0006 string zf_mc_file = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/sPH_dNdeta/Run24AuAuMC/Sim_HIJING_MDC2_ana472_20250307/Run7/EvtVtxZ/completed/MC_MBin70_NClus.root";
0007
0008 TCanvas * c1 = new TCanvas("c1", "c1", 2400,600);
0009 c1 -> Divide(4,1);
0010
0011 TFile * zf_data = TFile::Open(zf_data_file.c_str());
0012 TH2D * zf_data_hist = (TH2D*)zf_data->Get(hist_name.c_str());
0013 zf_data_hist -> GetYaxis() -> SetTitle("NClus (data)");
0014 TProfile * zf_data_profile = zf_data_hist -> ProfileX("zf_data_profile");
0015 zf_data_profile -> SetMarkerStyle(20);
0016 zf_data_profile -> SetMarkerSize(0.8);
0017 zf_data_profile -> SetMarkerColor(kRed);
0018 c1 -> cd(1);
0019 zf_data_hist -> Draw("colz0");
0020 zf_data_profile -> Draw("pl same");
0021
0022
0023
0024 TFile * zf_mc = TFile::Open(zf_mc_file.c_str());
0025 TH2D * zf_mc_hist = (TH2D*)zf_mc->Get(hist_name.c_str());
0026 zf_mc_hist -> GetYaxis() -> SetTitle("NClus (MC)");
0027 TProfile * zf_mc_profile = zf_mc_hist -> ProfileX("zf_mc_profile");
0028 zf_mc_hist -> SetMarkerStyle(20);
0029 zf_mc_hist -> SetMarkerSize(0.8);
0030 zf_mc_hist -> SetMarkerColor(kYellow);
0031 c1 -> cd(2);
0032 zf_mc_hist -> Draw("colz0");
0033 zf_mc_profile -> Draw("pl same");
0034
0035 c1 -> cd(3);
0036 zf_data_profile -> GetYaxis() -> SetTitle("NClus");
0037 zf_data_profile -> Draw("pl");
0038 zf_mc_profile -> Draw("pl same");
0039
0040 c1 -> cd(4);
0041 TH1D * zf_data_profile_Backh1D = (TH1D*)zf_data_profile->Clone("zf_data_profile_Backh1D");
0042 TH1D * zf_mc_profile_Backh1D = (TH1D*)zf_mc_profile->Clone("zf_mc_profile_Backh1D");
0043
0044 TH1D * zf_ratio = new TH1D("zf_ratio", "zf_ratio;centrality;data/MC", zf_data_hist->GetNbinsX(), zf_data_hist->GetXaxis()->GetXmin(), zf_data_hist->GetXaxis()->GetXmax());
0045 zf_ratio -> SetMarkerStyle(20);
0046 zf_ratio -> SetMarkerSize(0.8);
0047
0048 zf_ratio -> Divide(zf_data_profile_Backh1D, zf_mc_profile_Backh1D);
0049
0050 zf_ratio -> SetMinimum(0.5);
0051 zf_ratio -> SetMaximum(1.5);
0052
0053 TF1 * f1 = new TF1("f1", "pol1", 0, 100);
0054 f1 -> SetLineColor(kRed);
0055 f1 -> SetLineStyle(2);
0056 zf_ratio -> Fit(f1, "", "", 61, 81);
0057 f1 -> SetRange(61., 100.);
0058 f1 -> Draw("same");
0059
0060 zf_ratio -> Draw("p");
0061
0062 TPad * pad5 = new TPad("pad5", "pad5", 0.2,0.2,0.55,0.5);
0063 pad5 -> Draw();
0064 pad5 -> cd();
0065
0066 TH1D * zf_ratio_clone = new TH1D("zf_ratio_clone", "zf_ratio_clone;centrality;Diff", zf_data_hist->GetNbinsX(), zf_data_hist->GetXaxis()->GetXmin(), zf_data_hist->GetXaxis()->GetXmax());
0067 for (int i = 1; i <= zf_ratio_clone->GetNbinsX(); i++)
0068 {
0069 zf_ratio_clone -> SetBinContent(i, zf_ratio->GetBinContent(i) - f1->Eval(zf_ratio_clone->GetBinCenter(i)));
0070 zf_ratio_clone -> SetBinError(i, sqrt(pow(zf_ratio->GetBinError(i),2) + pow(f1->GetParError(0),2)));
0071
0072 }
0073
0074 zf_ratio_clone -> GetXaxis()->SetRangeUser(61, 100);
0075 zf_ratio_clone -> SetMinimum(-0.1);
0076 zf_ratio_clone -> SetMaximum(0.1);
0077 zf_ratio_clone -> Draw("ep");
0078
0079 TLine * line = new TLine(61, 0, 100, 0);
0080 line -> SetLineColor(kRed);
0081 line -> SetLineStyle(2);
0082 line -> Draw("same");
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 return 111;
0104 }