Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-09 08:12:16

0001 #include "../PreparedNdEtaEach.h"
0002 
0003 R__LOAD_LIBRARY(../libPreparedNdEtaEach.so)
0004 
0005 
0006 std::map<std::string, TH1D*> GetAlphaCorrectionH1DMap(std::string alpha_correction_input_directory, std::vector<std::string> map_name_in){
0007   
0008   TFile * file_in = TFile::Open(alpha_correction_input_directory.c_str());
0009   std::map<std::string, TH1D*> h1D_alpha_correction_map; h1D_alpha_correction_map.clear();
0010   
0011   
0012   for (TObject* keyAsObj : *file_in->GetListOfKeys()){
0013     auto key = dynamic_cast<TKey*>(keyAsObj);
0014     std::string hist_name  = key->GetName();
0015     std::string class_name = key->GetClassName();
0016 
0017     if (class_name != "TH1D") {continue;}
0018     if (std::find(map_name_in.begin(), map_name_in.end(), hist_name) == map_name_in.end()) {continue;}
0019 
0020     h1D_alpha_correction_map.insert(
0021       std::make_pair(
0022         hist_name,
0023         (TH1D*)file_in->Get(hist_name.c_str())
0024       )
0025     );
0026   }
0027 
0028   for (auto &pair : h1D_alpha_correction_map){
0029     // pair.second->SetDirectory(0);
0030     std::cout << "alpha correction name : " << pair.first << std::endl;
0031   }
0032 
0033   return h1D_alpha_correction_map;
0034 }
0035 
0036 string Run_PreparedNdEtaEach(
0037   int process_id = 1,
0038   int run_num = -1,
0039   string input_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_TrackHist/completed",
0040   string input_filename = "MC_TrackletHistogram_vtxZReweight_INTT_vtxZ_QA_SecondRun_merged_001.root",
0041   string output_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_dNdEta",
0042   
0043   // todo : modify here
0044   std::string output_file_name_suffix = "_SecondRun",
0045 
0046   bool ApplyAlphaCorr = false,
0047   bool isTypeA = false,
0048   std::pair<double,double> cut_INTTvtxZ = {-10, 10},
0049   int SelectedMbin = 70
0050 )
0051 {
0052 
0053   PreparedNdEtaEach * PNEE = new PreparedNdEtaEach(
0054     process_id,
0055     run_num,
0056     input_directory,
0057     input_filename,
0058     output_directory,
0059 
0060     output_file_name_suffix,
0061 
0062     ApplyAlphaCorr,
0063     isTypeA,
0064     cut_INTTvtxZ,
0065     SelectedMbin
0066   );
0067   
0068 
0069   std::vector<std::string> final_output_file_name = PNEE->GetOutputFileName();
0070   for (auto filename : final_output_file_name){
0071     cout<<"final_output_file_name: "<<filename<<endl;
0072     system(Form("if [ -f %s/completed/%s ]; then rm %s/completed/%s; fi;", output_directory.c_str(), filename.c_str(), output_directory.c_str(), filename.c_str()));  
0073   }
0074   
0075 
0076   PNEE -> PrepareStacks();
0077   std::cout<<111<<endl;
0078   PNEE -> DoFittings();
0079   std::cout<<222<<endl;
0080   PNEE -> PrepareMultiplicity();
0081   std::cout<<333<<endl;
0082   PNEE -> PreparedNdEtaHist();
0083   std::cout<<444<<endl;
0084   PNEE -> DeriveAlphaCorrection();
0085   std::cout<<555<<endl;
0086   PNEE -> EndRun();
0087 
0088     string dNdEta_file_out;
0089 
0090   for (auto filename : final_output_file_name){
0091     system(Form("mv %s/%s %s/completed", output_directory.c_str(), filename.c_str(), output_directory.c_str()));
0092 
0093     if (filename.find("_dNdEta.root") != std::string::npos){
0094       dNdEta_file_out = output_directory + "/completed/" + filename;
0095     }
0096   }
0097 
0098   std::cout<<"dNdEta_file_out: "<<dNdEta_file_out<<std::endl;
0099 
0100   return dNdEta_file_out;
0101 }
0102 
0103 
0104 string Run_PreparedNdEtaEach_ApplyAlphaCorr(
0105   int process_id = 2,
0106   int run_num = -1,
0107   string input_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_TrackHist/completed",
0108   string input_filename = "MC_TrackletHistogram_vtxZReweight_INTT_vtxZ_QA_SecondRun_merged_002.root",
0109   string output_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_dNdEta",
0110   
0111   // todo : modify here
0112   std::string output_file_name_suffix = "_SecondRun", 
0113 
0114   bool ApplyAlphaCorr = true,
0115   bool isTypeA = false,
0116   std::pair<double,double> cut_INTTvtxZ = {-10, 10},
0117   int SelectedMbin = 70,
0118   std::pair<bool, std::pair<double,double>> setEtaRange = {true, {-1.9, 1.9}},
0119 
0120   string alpha_correction_input_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_dNdEta/completed/MC_PreparedNdEtaEach_AllSensor_VtxZ10_Mbin70_SecondRun_00001_dNdEta.root"
0121 )
0122 {
0123 
0124   PreparedNdEtaEach * PNEE = new PreparedNdEtaEach(
0125     process_id,
0126     run_num,
0127     input_directory,
0128     input_filename,
0129     output_directory,
0130 
0131     output_file_name_suffix,
0132 
0133     ApplyAlphaCorr,
0134     isTypeA,
0135     cut_INTTvtxZ,
0136     SelectedMbin
0137   );
0138 
0139   PNEE -> SetAlphaCorrectionH1DMap(
0140     GetAlphaCorrectionH1DMap(
0141       alpha_correction_input_directory,
0142       PNEE->GetAlphaCorrectionNameMap()
0143     )
0144   );
0145 
0146   if (setEtaRange.first) {PNEE -> SetSelectedEtaRange(setEtaRange.second);}
0147 
0148   std::vector<std::string> final_output_file_name = PNEE->GetOutputFileName();
0149   for (auto filename : final_output_file_name){
0150     cout<<"final_output_file_name: "<<filename<<endl;
0151     system(Form("if [ -f %s/completed/%s ]; then rm %s/completed/%s; fi;", output_directory.c_str(), filename.c_str(), output_directory.c_str(), filename.c_str()));  
0152   }
0153   
0154 
0155   PNEE -> PrepareStacks();
0156   std::cout<<111<<endl;
0157   PNEE -> DoFittings();
0158   std::cout<<222<<endl;
0159   PNEE -> PrepareMultiplicity();
0160   std::cout<<333<<endl;
0161   PNEE -> PreparedNdEtaHist();
0162   std::cout<<444<<endl;
0163   PNEE -> DeriveAlphaCorrection();
0164   std::cout<<555<<endl;
0165   PNEE -> EndRun();
0166 
0167     string dNdEta_file_out;
0168 
0169   for (auto filename : final_output_file_name){
0170     system(Form("mv %s/%s %s/completed", output_directory.c_str(), filename.c_str(), output_directory.c_str()));
0171 
0172     if (filename.find("_dNdEta.root") != std::string::npos){
0173       dNdEta_file_out = output_directory + "/completed/" + filename;
0174     }
0175   }
0176 
0177   std::cout<<"dNdEta_file_out: "<<dNdEta_file_out<<std::endl;
0178 
0179   return dNdEta_file_out;
0180 }
0181 
0182 
0183 
0184 string Run_PreparedNdEtaEach_ApplyAlphaCorr_54280(
0185   int process_id = 0,
0186   int run_num = 54280,
0187   string input_directory = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Dec042024/completed/Run24NewCode_TrackHist/completed",
0188   string input_filename = "Data_TrackletHistogram_BcoFullDiffCut_INTT_vtxZ_QA_SecondRun_00054280_merged.root",
0189   string output_directory = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Dec042024/completed/Run24NewCode_TrackHist/completed/Run24NewCode_dNdEta",
0190   
0191   // todo : modify here
0192   std::string output_file_name_suffix = "_SecondRun", 
0193 
0194   bool ApplyAlphaCorr = true,
0195   bool isTypeA = false,
0196   std::pair<double,double> cut_INTTvtxZ = {-10, 10},
0197   int SelectedMbin = 70,
0198   std::pair<bool, std::pair<double,double>> setEtaRange = {true, {-1.9, 1.9}},
0199 
0200   string alpha_correction_input_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_dNdEta/completed/MC_PreparedNdEtaEach_AllSensor_VtxZ10_Mbin70_SecondRun_00001_dNdEta.root"
0201 )
0202 {
0203 
0204   PreparedNdEtaEach * PNEE = new PreparedNdEtaEach(
0205     process_id,
0206     run_num,
0207     input_directory,
0208     input_filename,
0209     output_directory,
0210 
0211     output_file_name_suffix,
0212 
0213     ApplyAlphaCorr,
0214     isTypeA,
0215     cut_INTTvtxZ,
0216     SelectedMbin
0217   );
0218 
0219   PNEE -> SetAlphaCorrectionH1DMap(
0220     GetAlphaCorrectionH1DMap(
0221       alpha_correction_input_directory,
0222       PNEE->GetAlphaCorrectionNameMap()
0223     )
0224   );
0225 
0226   if (setEtaRange.first) {PNEE -> SetSelectedEtaRange(setEtaRange.second);}
0227 
0228   std::vector<std::string> final_output_file_name = PNEE->GetOutputFileName();
0229   for (auto filename : final_output_file_name){
0230     cout<<"final_output_file_name: "<<filename<<endl;
0231     system(Form("if [ -f %s/completed/%s ]; then rm %s/completed/%s; fi;", output_directory.c_str(), filename.c_str(), output_directory.c_str(), filename.c_str()));  
0232   }
0233   
0234 
0235   PNEE -> PrepareStacks();
0236   std::cout<<111<<endl;
0237   PNEE -> DoFittings();
0238   std::cout<<222<<endl;
0239   PNEE -> PrepareMultiplicity();
0240   std::cout<<333<<endl;
0241   PNEE -> PreparedNdEtaHist();
0242   std::cout<<444<<endl;
0243   PNEE -> DeriveAlphaCorrection();
0244   std::cout<<555<<endl;
0245   PNEE -> EndRun();
0246 
0247 
0248   string dNdEta_file_out;
0249 
0250   for (auto filename : final_output_file_name){
0251     system(Form("mv %s/%s %s/completed", output_directory.c_str(), filename.c_str(), output_directory.c_str()));
0252 
0253     if (filename.find("_dNdEta.root") != std::string::npos){
0254       dNdEta_file_out = output_directory + "/completed/" + filename;
0255     }
0256   }
0257 
0258   std::cout<<"dNdEta_file_out: "<<dNdEta_file_out<<std::endl;
0259 
0260   return dNdEta_file_out;
0261 }
0262 
0263 int DataMcComp(string data_directory_in, string MC_directory_in, string output_directory_in, string output_filename_in)
0264 {
0265     TFile * file_in_data = TFile::Open(data_directory_in.c_str());
0266     TFile * file_in_mc = TFile::Open(MC_directory_in.c_str());
0267 
0268     TH1D * data_h1D_BestPair_RecoTrackletEtaPerEvt = (TH1D*)file_in_data->Get("h1D_BestPair_RecoTrackletEtaPerEvt");
0269     TH1D * data_h1D_RotatedBkg_RecoTrackletEtaPerEvt = (TH1D*)file_in_data->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvt");
0270     TH1D * data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_data->Get("h1D_BestPair_RecoTrackletEtaPerEvtPostAC");
0271     TH1D * data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_data->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC");
0272 
0273     data_h1D_BestPair_RecoTrackletEtaPerEvt -> SetMarkerColor(1);
0274     data_h1D_BestPair_RecoTrackletEtaPerEvt -> SetLineColor(1);
0275 
0276     data_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetMarkerColor(1);
0277     data_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetLineColor(1);
0278 
0279     data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(1);
0280     data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetLineColor(1);
0281 
0282     data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(1);
0283     data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetLineColor(1);
0284 
0285 
0286 
0287     TH1D * MC_h1D_BestPair_RecoTrackletEtaPerEvt = (TH1D*)file_in_mc->Get("h1D_BestPair_RecoTrackletEtaPerEvt");
0288     TH1D * MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt = (TH1D*)file_in_mc->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvt");
0289     TH1D * MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_mc->Get("h1D_BestPair_RecoTrackletEtaPerEvtPostAC");
0290     TH1D * MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_mc->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC");
0291 
0292     MC_h1D_BestPair_RecoTrackletEtaPerEvt -> SetMarkerColor(2); // note : red
0293     MC_h1D_BestPair_RecoTrackletEtaPerEvt -> SetLineColor(2);
0294 
0295     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetMarkerColor(2);
0296     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetLineColor(2);
0297 
0298     MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(2);
0299     MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetLineColor(2);
0300 
0301     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(2);
0302     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetLineColor(2);
0303 
0304     
0305 
0306     TH1D * h1D_TruedNdEta = (TH1D*)file_in_mc->Get("h1D_TruedNdEta");
0307     h1D_TruedNdEta -> SetLineColor(3); // note : green 
0308 
0309 
0310     TFile * file_out = new TFile(Form("%s/%s",output_directory_in.c_str(), output_filename_in.c_str()), "RECREATE");
0311     TCanvas * c1 = new TCanvas("c1", "c1", 800, 600);
0312 
0313     c1 -> cd();
0314     data_h1D_BestPair_RecoTrackletEtaPerEvt -> Draw("ep");
0315     MC_h1D_BestPair_RecoTrackletEtaPerEvt -> Draw("hist same");
0316     c1 -> Write("h1D_BestPair_RecoTrackletEtaPerEvt");
0317     c1 -> Clear();
0318 
0319     c1 -> cd();
0320     data_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> Draw("ep");
0321     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> Draw("hist same");
0322     c1 -> Write("h1D_RotatedBkg_RecoTrackletEtaPerEvt");
0323     c1 -> Clear();
0324 
0325     c1 -> cd();
0326     data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> Draw("ep");
0327     MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> Draw("hist same");
0328     h1D_TruedNdEta -> SetFillColorAlpha(2,0);
0329     h1D_TruedNdEta -> Draw("hist same");
0330     c1 -> Write("h1D_BestPair_RecoTrackletEtaPerEvtPostAC");
0331     c1 -> Clear();
0332 
0333     c1 -> cd();
0334     data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> Draw("ep");
0335     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> Draw("hist same");
0336     h1D_TruedNdEta -> Draw("hist same");
0337     
0338     c1 -> Write("h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC");
0339     c1 -> Clear();
0340 
0341     file_out -> Close();
0342 
0343     
0344 
0345     return 0;
0346 }
0347 
0348 int McMcComp(string MC1_directory_in, string MC2_directory_in, string output_directory_in, string output_filename_in)
0349 {
0350     TFile * file_in_data = TFile::Open(MC1_directory_in.c_str());
0351     TFile * file_in_mc = TFile::Open(MC2_directory_in.c_str());
0352 
0353     TH1D * data_h1D_BestPair_RecoTrackletEtaPerEvt = (TH1D*)file_in_data->Get("h1D_BestPair_RecoTrackletEtaPerEvt");
0354     TH1D * data_h1D_RotatedBkg_RecoTrackletEtaPerEvt = (TH1D*)file_in_data->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvt");
0355     TH1D * data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_data->Get("h1D_BestPair_RecoTrackletEtaPerEvtPostAC");
0356     TH1D * data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_data->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC");
0357 
0358     data_h1D_BestPair_RecoTrackletEtaPerEvt -> SetMarkerColor(1);
0359     data_h1D_BestPair_RecoTrackletEtaPerEvt -> SetLineColor(1);
0360 
0361     data_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetMarkerColor(1);
0362     data_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetLineColor(1);
0363 
0364     data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(1);
0365     data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetLineColor(1);
0366 
0367     data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(1);
0368     data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetLineColor(1);
0369 
0370     TH1D * data_h1D_TruedNdEta = (TH1D*)file_in_data->Get("h1D_TruedNdEta");
0371     data_h1D_TruedNdEta -> SetFillColorAlpha(1,0);
0372     data_h1D_TruedNdEta -> SetLineColor(4); // note : blue
0373 
0374 
0375 
0376     TH1D * MC_h1D_BestPair_RecoTrackletEtaPerEvt = (TH1D*)file_in_mc->Get("h1D_BestPair_RecoTrackletEtaPerEvt");
0377     TH1D * MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt = (TH1D*)file_in_mc->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvt");
0378     TH1D * MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_mc->Get("h1D_BestPair_RecoTrackletEtaPerEvtPostAC");
0379     TH1D * MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC = (TH1D*)file_in_mc->Get("h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC");
0380 
0381     MC_h1D_BestPair_RecoTrackletEtaPerEvt -> SetMarkerColor(2);
0382     MC_h1D_BestPair_RecoTrackletEtaPerEvt -> SetLineColor(2);
0383 
0384     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetMarkerColor(2);
0385     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> SetLineColor(2);
0386 
0387     MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(2);
0388     MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> SetLineColor(2);
0389 
0390     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetMarkerColor(2);
0391     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> SetLineColor(2);
0392 
0393     
0394 
0395     TH1D * MC_h1D_TruedNdEta = (TH1D*)file_in_mc->Get("h1D_TruedNdEta");
0396     MC_h1D_TruedNdEta -> SetFillColorAlpha(2,0);
0397     MC_h1D_TruedNdEta -> SetLineColor(3); // note : green
0398 
0399 
0400     TFile * file_out = new TFile((output_directory_in+"/"+output_filename_in).c_str(), "RECREATE");
0401     TCanvas * c1 = new TCanvas("c1", "c1", 800, 600);
0402 
0403     c1 -> cd();
0404     data_h1D_BestPair_RecoTrackletEtaPerEvt -> Draw("ep");
0405     MC_h1D_BestPair_RecoTrackletEtaPerEvt -> Draw("hist same");
0406     c1 -> Write("h1D_BestPair_RecoTrackletEtaPerEvt");
0407     c1 -> Clear();
0408 
0409     c1 -> cd();
0410     data_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> Draw("ep");
0411     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvt -> Draw("hist same");
0412     c1 -> Write("h1D_RotatedBkg_RecoTrackletEtaPerEvt");
0413     c1 -> Clear();
0414 
0415     c1 -> cd();
0416     data_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> Draw("ep");
0417     MC_h1D_BestPair_RecoTrackletEtaPerEvtPostAC -> Draw("hist same");
0418     MC_h1D_TruedNdEta -> Draw("hist same");
0419     data_h1D_TruedNdEta -> Draw("hist same");
0420     c1 -> Write("h1D_BestPair_RecoTrackletEtaPerEvtPostAC");
0421     c1 -> Clear();
0422 
0423     c1 -> cd();
0424     data_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> Draw("ep");
0425     MC_h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC -> Draw("hist same");
0426     MC_h1D_TruedNdEta -> Draw("hist same");
0427     data_h1D_TruedNdEta -> Draw("hist same");
0428     c1 -> Write("h1D_RotatedBkg_RecoTrackletEtaPerEvtPostAC");
0429     c1 -> Clear();
0430 
0431     c1 -> cd();
0432     MC_h1D_TruedNdEta -> Draw("hist");
0433     data_h1D_TruedNdEta -> Draw("ep same");
0434     c1 -> Write("h1D_TruedNdEta");
0435     c1 -> Clear();
0436 
0437     file_out -> Close();
0438 
0439     
0440 
0441     return 0;
0442 }
0443 
0444 int CombinedMacro()
0445 {   
0446     // note : for all common
0447     std::string output_file_name_suffix = "_SecondRun"; 
0448 
0449     bool isTypeA = false;
0450     std::pair<double,double> cut_INTTvtxZ = {-10, 10};
0451     int SelectedMbin = 70;
0452     std::pair<double,double> cut_EtaRange = {-1.9, 1.9};
0453     string output_directory = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Dec042024/completed/TrackHistNew_WithClusQA/completed";
0454 
0455     string output_suffix = "dNdEta";
0456     output_suffix += (isTypeA) ? "_TypeA" : "_AllSensor";
0457     output_suffix += Form("_VtxZ%d_Mbin%d", (int)cut_INTTvtxZ.second, SelectedMbin);
0458 
0459     string final_output_directory = output_directory + "/" + output_suffix;
0460     
0461     // string alpha_correction_input_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/Run24NewCode_dNdEta/completed/MC_PreparedNdEtaEach_AllSensor_VtxZ10_Mbin70_SecondRun_00001_dNdEta.root";    
0462     
0463     // note : MC common
0464     string MC_input_directory = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/sPH_dNdeta/Run24AuAuMC/Sim_Ntuple_HIJING_ana443_20241102/TrackHistNew_WithClusQA/completed";
0465     string MC_output_directory = final_output_directory;
0466 
0467     // note : MC1 deriving the alpha corrections
0468     string MC1_input_filename = "MC_TrackHist_vtxZReweight_VtxZQA_ClusQAAdc35PhiSize500_SecondRun_merged_001.root";
0469     int    MC1_process_id = 1;
0470     int    MC1_run_num = -1;
0471     bool   MC1_ApplyAlphaCorr = false;
0472     std::pair<bool, std::pair<double,double>> MC1_setEtaRange = {false, cut_EtaRange};
0473 
0474     // note : MC2 applying the alpha corrections
0475     string MC2_input_filename = "MC_TrackHist_vtxZReweight_VtxZQA_ClusQAAdc35PhiSize500_SecondRun_merged_002.root";
0476     int    MC2_process_id = 2;
0477     int    MC2_run_num = -1;
0478     bool   MC2_ApplyAlphaCorr = true;
0479     std::pair<bool, std::pair<double,double>> MC2_setEtaRange = {true, cut_EtaRange};
0480     
0481     // note : for data
0482     string data_input_directory  = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Dec042024/completed/TrackHistNew_WithClusQA/completed";
0483     string data_input_filename   = "Data_TrackHist_BcoFullDiffCut_VtxZQA_ClusQAAdc35PhiSize500_SecondRun_00054280_merged.root";
0484     string data_output_directory = final_output_directory;
0485     int    data_process_id = 0;
0486     int    data_run_num = 54280;
0487     bool   data_ApplyAlphaCorr = true;
0488     std::pair<bool, std::pair<double,double>> data_setEtaRange = {true, cut_EtaRange};
0489 
0490     system(Form("if [ ! -d %s/completed ]; then mkdir -p %s/completed; fi;", final_output_directory.c_str(), final_output_directory.c_str()));
0491 
0492     string MC1_dNdeta_file = Run_PreparedNdEtaEach(
0493         MC1_process_id,
0494         MC1_run_num,
0495         MC_input_directory,
0496         MC1_input_filename,
0497         MC_output_directory,
0498 
0499         output_file_name_suffix,
0500 
0501         MC1_ApplyAlphaCorr,
0502         isTypeA,
0503         cut_INTTvtxZ,
0504         SelectedMbin
0505     );
0506 
0507     string alpha_correction_input_directory = MC1_dNdeta_file;
0508 
0509 
0510     string MC2_dNdeta_file = Run_PreparedNdEtaEach_ApplyAlphaCorr(
0511         MC2_process_id,
0512         MC2_run_num,
0513         MC_input_directory,
0514         MC2_input_filename,
0515         MC_output_directory,
0516 
0517         output_file_name_suffix,
0518 
0519         MC2_ApplyAlphaCorr,
0520         isTypeA,
0521         cut_INTTvtxZ,
0522         SelectedMbin,
0523         MC2_setEtaRange,
0524 
0525         alpha_correction_input_directory
0526     );
0527 
0528 
0529     string data_dNdeta_file = Run_PreparedNdEtaEach_ApplyAlphaCorr_54280(
0530         data_process_id,
0531         data_run_num,
0532         data_input_directory,
0533         data_input_filename,
0534         data_output_directory,
0535 
0536         output_file_name_suffix,
0537 
0538         data_ApplyAlphaCorr,
0539         isTypeA,
0540         cut_INTTvtxZ,
0541         SelectedMbin,
0542         data_setEtaRange,
0543 
0544         alpha_correction_input_directory
0545     );
0546 
0547     DataMcComp(data_dNdeta_file, MC1_dNdeta_file, final_output_directory, "DataMc1Comp.root");
0548     DataMcComp(data_dNdeta_file, MC2_dNdeta_file, final_output_directory, "DataMc2Comp.root");
0549     McMcComp(MC1_dNdeta_file, MC2_dNdeta_file, final_output_directory, "McMcComp.root");
0550     
0551 
0552     return 0;
0553 }