#include "TFile.h" #include "TTree.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TCanvas.h" #include "TAxis.h" void drawphipIM2g( Int_t hist1D = 0, Int_t hist1Dlog = 0, Int_t hist2D = 1, Int_t hist2Dlog = 1, Int_t hist3D = 0) { TString fileDataName = "./histroot/ana_p2gamma_phip_para.root"; TString fileMCName = "./histroot/ana_p2gamma_phip_perp.root"; TFile *fdata = TFile::Open(fileDataName); TFile *fmc = TFile::Open(fileMCName); TString figsDir = "./figsComp/"; cout<<"root file is: "<Get(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); canvName01->SaveAs(figNameData11); } } if(hist2Dlog) { const int maxTH2DLogHistNum = 2; TString histTH2DLogName[maxTH2DLogHistNum] ={"Phi_Proton_vs_IM2g_cutBE", "Acci_Phi_Proton_vs_IM2g_cutBE"}; 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); canvName01->SaveAs(figNameData11); } } }