#include "TFile.h" #include "TTree.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TCanvas.h" #include "TAxis.h" void drawCompare_Cuts( Int_t hist1D = 1, Int_t hist1Dlog = 1, Int_t hist2D = 1, Int_t hist2Dlog = 1, Int_t hist3D = 0) { TString fileDataName = "./histroot/ana_p2gamma_Cuts_NewData.root"; TString fileMCName = "./histroot/hist_p2gamma_inc_010000.root"; TFile *fdata = TFile::Open(fileDataName); TFile *fmc = TFile::Open(fileMCName); TString figsDir = "./figsComp/"; cout<<"root file is: "<Get(treeName01); TH1D* histNameMC01 = (TH1D*)fmc->Get(treeName01); TCanvas* canvName01 = new TCanvas("canvName01", titleCan01, 960, 320); canvName01->Divide(2,1); canvName01->cd(1); histNameData01->SetMinimum(0.0); histNameData01->GetYaxis()->SetTitleOffset(1.2); histNameData01->Draw(); canvName01->cd(2); histNameMC01->SetMinimum(0.0); histNameMC01->GetYaxis()->SetTitleOffset(1.2); histNameMC01->Draw(); canvName01->SaveAs(figNameData01); } } if(hist1Dlog) { const int maxTH1DLogHistNum = 8; TString histTH1DLogName[maxTH1DLogHistNum] = {"NU_Unused_Energy_pi0", "NU_Unused_Energy_1_pi0", "NU_Unused_Energy_eta", "NU_Unused_Energy_1_eta", "t_pi0", "t_eta", "Acci_t_pi0", "Acci_t_eta"}; // add any TH1D histogram name for(int i=0; iGet(treeName01); TH1D* histNameMC01 = (TH1D*)fmc->Get(treeName01); TCanvas* canvName01 = new TCanvas("canvName01", titleCan01, 960, 320); canvName01->Divide(2,1); canvName01->cd(1); gPad->SetLogy(); histNameData01->SetMinimum(0.1); histNameData01->GetYaxis()->SetTitleOffset(1.2); histNameData01->Draw(); canvName01->cd(2); gPad->SetLogy(); histNameMC01->SetMinimum(0.1); histNameMC01->GetYaxis()->SetTitleOffset(1.2); histNameMC01->Draw(); canvName01->SaveAs(figNameData01); } } if(hist2D) { const int maxTH2DHistNum = 82; TString histTH2DName[maxTH2DHistNum] = {"DPSB_Phi_Proton_vs_t_pi0", "DPSB_Phi_Proton_vs_t_eta", "Phi_Proton_vs_BE_cut6", "Acci_Phi_Proton_vs_BE_cut6", "Phi_Proton_vs_IM2g_cutBE", "Acci_Phi_Proton_vs_IM2g_cutBE", "dEdx_vs_p_Proton_0", "Acci_dEdx_vs_p_Proton_0", "dEdx_vs_p_Proton_1", "Acci_dEdx_vs_p_Proton_1", "dEdx_vs_p_Proton_2", "Acci_dEdx_vs_p_Proton_2", "dEdx_vs_p_Proton_3", "Acci_dEdx_vs_p_Proton_3", "dEdx_vs_p_Proton_4", "Acci_dEdx_vs_p_Proton_4", "dEdx_vs_p_Proton_5", "Acci_dEdx_vs_p_Proton_5", "dEdx_vs_p_Proton_6", "Acci_dEdx_vs_p_Proton_6", "dEdx_vs_p_Proton_7", "Acci_dEdx_vs_p_Proton_7", "dEdx_vs_p_Proton_8", "Acci_dEdx_vs_p_Proton_8", "dEdx_vs_p_Proton_9", "Acci_dEdx_vs_p_Proton_9", "dEdx_vs_p_Proton_10", "Acci_dEdx_vs_p_Proton_10", "dEdx_vs_p_Proton_11", "Acci_dEdx_vs_p_Proton_11", "dEdx_vs_p_Proton_12", "Acci_dEdx_vs_p_Proton_12", "ME_vs_Phi_Proton_cut6", "ME_vs_theta_Photon_min_cut6", "ME_vs_theta_Photon_min_20_cut6", "ME_vs_theta_Photon_min_all_cut6", "Acci_ME_vs_Phi_Proton_cut6", "Acci_ME_vs_theta_Photon_min_cut6", "Acci_ME_vs_theta_Photon_min_20_cut6", "Acci_ME_vs_theta_Photon_min_all_cut6", "X_Y_FCAL_g1", "X_Y_FCAL_g2", "E_g1_vs_E_g2", "Acci_X_Y_FCAL_g1", "Acci_X_Y_FCAL_g2", "Acci_E_g1_vs_E_g2", "theta_Photon1_vs_phi_Photon1_2", "theta_Photon2_vs_phi_Photon2_2", "theta_Proton_vs_phi_Proton_2", "Phi_Proton_vs_t_2", "Phi_Proton_vs_t_5_2", "Phi_Proton_vs_t_15_2", "Acci_theta_Photon1_vs_phi_Photon1_2", "Acci_theta_Photon2_vs_phi_Photon2_2", "Acci_theta_Proton_vs_phi_Proton_2", "Acci_Phi_Proton_vs_t_2", "Acci_Phi_Proton_vs_t_5_2", "Acci_Phi_Proton_vs_t_15_2", "theta_Photon1_vs_phi_Photon1_5", "theta_Photon2_vs_phi_Photon2_5", "theta_Proton_vs_phi_Proton_5", "Phi_Proton_vs_t_5", "Phi_Proton_vs_t_5_5", "Phi_Proton_vs_t_15_5", "Acci_theta_Photon1_vs_phi_Photon1_5", "Acci_theta_Photon2_vs_phi_Photon2_5", "Acci_theta_Proton_vs_phi_Proton_5", "Acci_Phi_Proton_vs_t_5", "Acci_Phi_Proton_vs_t_5_5", "Acci_Phi_Proton_vs_t_15_5", "Phi_Proton_vs_t_1", "Phi_Proton_vs_t_5_1", "Phi_Proton_vs_t_15_1", "Acci_Phi_Proton_vs_t_1", "Acci_Phi_Proton_vs_t_5_1", "Acci_Phi_Proton_vs_t_15_1", "Phi_Proton_vs_t_4", "Phi_Proton_vs_t_5_4", "Phi_Proton_vs_t_15_4", "Acci_Phi_Proton_vs_t_4", "Acci_Phi_Proton_vs_t_5_4", "Acci_Phi_Proton_vs_t_15_4"}; // add any TH2D histogram name for(int i=0; iGet(treeName01); TH2D* histNameMC21 = (TH2D*)fmc->Get(treeName01); TCanvas* canvName01 = new TCanvas("canvName01", titleCan01, 960, 320); canvName01->Divide(2,1); canvName01->cd(1); // histNameData01->SetStats(0); histNameData21->Draw("COLZ1"); canvName01->cd(2); // histNameMC01->SetStats(0); histNameMC21->Draw("COLZ1"); canvName01->SaveAs(figNameData01); } } if(hist2Dlog) { const int maxTH2DLogHistNum = 30; TString histTH2DLogName[maxTH2DLogHistNum] = {"Phi_Proton_vs_BE_cut6", "Acci_Phi_Proton_vs_BE_cut6", "Phi_Proton_vs_IM2g_cutBE", "Acci_Phi_Proton_vs_IM2g_cutBE", "ME_vs_Phi_Proton_cut6", "Acci_ME_vs_Phi_Proton_cut6", "Phi_Proton_vs_t_2", "Phi_Proton_vs_t_5_2", "Phi_Proton_vs_t_15_2", "Acci_Phi_Proton_vs_t_2", "Acci_Phi_Proton_vs_t_5_2", "Acci_Phi_Proton_vs_t_15_2", "Phi_Proton_vs_t_5", "Phi_Proton_vs_t_5_5", "Phi_Proton_vs_t_15_5", "Acci_Phi_Proton_vs_t_5", "Acci_Phi_Proton_vs_t_5_5", "Acci_Phi_Proton_vs_t_15_5", "Phi_Proton_vs_t_1", "Phi_Proton_vs_t_5_1", "Phi_Proton_vs_t_15_1", "Acci_Phi_Proton_vs_t_1", "Acci_Phi_Proton_vs_t_5_1", "Acci_Phi_Proton_vs_t_15_1", "Phi_Proton_vs_t_4", "Phi_Proton_vs_t_5_4", "Phi_Proton_vs_t_15_4", "Acci_Phi_Proton_vs_t_4", "Acci_Phi_Proton_vs_t_5_4", "Acci_Phi_Proton_vs_t_15_4"}; // add any TH2D histogram name for(int i=0; iGet(treeName01); TH2D* histNameMC21 = (TH2D*)fmc->Get(treeName01); TCanvas* canvName01 = new TCanvas("canvName01", titleCan01, 960, 320); canvName01->Divide(2,1); canvName01->cd(1); // histNameData01->SetStats(0); gPad->SetLogz(); histNameData21->Draw("COLZ1"); canvName01->cd(2); // histNameMC01->SetStats(0); gPad->SetLogz(); histNameMC21->Draw("COLZ1"); canvName01->SaveAs(figNameData01); } } if(hist3D) { const int maxTH3DHistNum = 0; TString histTH3DName[maxTH3DHistNum] = {""}; // add any TH3D histogram name for(int i=0; iGet(treeName01); TH3D* histNameMC31 = (TH2D*)fmc->Get(treeName01); TCanvas* canvNameData01 = new TCanvas("canvName01", titleCan01, 960, 320); canvName01->Divide(2,1); canvName01->cd(1); // histNameData01->SetStats(0); histNameData31->Draw("COLZ1"); canvName01->cd(2); // histNameMC01->SetStats(0); histNameMC31->Draw("COLZ1"); canvName01->SaveAs(figNameData01); } } }