#include "TFile.h" #include "TTree.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TCanvas.h" #include "TAxis.h" void drawbackgroundlog(Int_t hist1D = 0, Int_t hist1Dlog = 1, Int_t hist2D = 0, Int_t hist2Dlog = 0, Int_t hist3D = 0) { TString fileMCName = "./histroot/hist_p2gamma_inc_010000.root"; TFile *fmc = TFile::Open(fileMCName); TString fileDataName = "./histroot/ana_p2gamma_Cuts_NewData.root"; TFile *fdata = TFile::Open(fileDataName); TString figsDir = "./figsbkgIncMC/"; cout<<"root file is: "<Get(treeName01); histName01->Sumw2(); TH1D* histName02 = (TH1D*)fmc->Get(treeName02); histName02->Sumw2(); TH1D* histName18 = (TH1D*)fmc->Get(treeName18); histName18->Sumw2(); TH1D* histName03 = new TH1D(Form("histName03_%d", i), treeName03, 100, minx[i], maxx[i]); histName03->Sumw2(); histName03->Add(histName01, histName02, 1, 1); TH1D* histName33 = new TH1D(Form("histName33_%d", i), treeName33, 100, minx[i], maxx[i]); histName33->Sumw2(); histName33->Add(histName18, histName03, 1, 1); double maximum = histName33->GetMaximum(); maximum *= 220; TH1D* histNamemc04 = (TH1D*)fmc->Get(treeName04); TH1D* histNamedata04 = (TH1D*)fdata->Get(treeName04); double maximum_sig = histNamemc04->GetMaximum(); maximum_sig *= 220; double norm = histNamemc04->Integral()/histNamedata04->Integral(); histNamedata04->Scale(norm); TH1D* histNamemc14 = (TH1D*)fmc->Get(treeName14); TH1D* histNamedata14 = (TH1D*)fdata->Get(treeName14); double maximum_sig_14 = histNamemc14->GetMaximum(); maximum_sig_14 *= 220; double norm_14 = histNamemc14->Integral()/histNamedata14->Integral(); histNamedata14->Scale(norm_14); TH1D* histName05 = (TH1D*)fmc->Get(treeName05); histName05->Sumw2(); TH1D* histName06 = (TH1D*)fmc->Get(treeName06); histName06->Sumw2(); TH1D* histName07 = new TH1D(Form("histName07_%d", i), treeName07, 100, minx[i], maxx[i]); histName07->Sumw2(); histName07->Add(histName05, histName06, 1, 1); double maximum_t_a = histName07->GetMaximum(); maximum_t_a *= 220; TH1D* histName15 = (TH1D*)fmc->Get(treeName15); histName15->Sumw2(); TH1D* histName16 = (TH1D*)fmc->Get(treeName16); histName16->Sumw2(); TH1D* histName17 = new TH1D(Form("histName17_%d", i), treeName17, 100, minx[i], maxx[i]); histName17->Sumw2(); histName17->Add(histName15, histName16, 1, 1); double maximum_t_a_17 = histName17->GetMaximum(); maximum_t_a_17 *= 220; TH1D* histName08 = (TH1D*)fmc->Get(treeName08); histName08->Sumw2(); TH1D* histName09 = (TH1D*)fmc->Get(treeName09); histName09->Sumw2(); TH1D* histName10 = (TH1D*)fmc->Get(treeName10); histName10->Sumw2(); TH1D* histName11 = new TH1D(Form("histName11_%d", i), treeName11, 100, minx[i], maxx[i]); histName11->Sumw2(); histName11->Add(histName08, histName09, 1, 1); TH1D* histName12 = new TH1D(Form("histName12_%d", i), treeName12, 100, minx[i], maxx[i]); histName12->Sumw2(); histName12->Add(histName10, histName11, 1, 1); double maximum_eta = histName12->GetMaximum(); maximum_eta *= 220; TCanvas* canvName01 = new TCanvas("canvName01", titleCan01, 1020,760); canvName01->Divide(3,2); canvName01->cd(1); gPad->SetLogy(); //gPad->SetLeftMargin(0.3); histName33->SetMinimum(0.1); histName33->SetMaximum(maximum); histName01->SetLineColor(kBlack); //histName00->GetYaxis()->SetTitleOffset(1.4); //histName01->GetYaxis()->SetLabelSize(0.03); histName01->SetLineStyle(2); histName02->SetLineColor(kBlue); histName02->SetLineStyle(3); histName18->SetLineColor(kGreen); histName18->SetLineStyle(5); histName33->SetLineColor(kRed); histName33->SetLineStyle(1); histName33->GetXaxis()->SetTitle(histTitle[i]); histName33->GetYaxis()->SetTitle("Counts"); histName33->Draw("h"); histName01->Draw("h SAME"); histName02->Draw("h SAME"); histName18->Draw("h SAME"); TLegend *leg = new TLegend(0.12,0.66, 0.48, 0.86); //leg->SetHeader("The #pi^{0} background"); leg->SetTextSize(0.04); leg->AddEntry(histName01, "3#pi", "l"); leg->AddEntry(histName02, "2#pi^{0}", "l"); leg->AddEntry(histName18, "omega", "l"); leg->AddEntry(histName33, "3#pi + 2#pi^{0} + omega", "l"); leg->Draw(); canvName01->cd(2); gPad->SetLogy(); histName07->SetMinimum(0.1); histName07->SetMaximum(maximum_t_a); histName05->SetLineColor(kBlack); histName05->SetLineStyle(2); //histName00->GetYaxis()->SetTitleOffset(1.4); //histName01->GetYaxis()->SetLabelSize(0.03); histName06->SetLineColor(kBlue); histName06->SetLineStyle(5); histName07->SetLineColor(kRed); histName07->SetLineStyle(1); histName07->GetXaxis()->SetTitle(histTitle[i]); histName07->GetYaxis()->SetTitle("Counts"); histName07->Draw("h"); histName05->Draw("h SAME"); histName06->Draw("h SAME"); TLegend *leg2 = new TLegend(0.12,0.66, 0.48, 0.86); //leg2->SetHeader("True/Accidental"); leg2->SetTextSize(0.04); leg2->AddEntry(histName05, "True signal", "l"); leg2->AddEntry(histName06, "Accidental", "l"); leg2->AddEntry(histName07, "True + Accidental", "l"); leg2->Draw(); canvName01->cd(3); gPad->SetLogy(); histName17->SetMinimum(0.1); histName17->SetMaximum(maximum_t_a_17); histName15->SetLineColor(kBlack); histName15->SetLineStyle(2); //histName00->GetYaxis()->SetTitleOffset(1.4); //histName01->GetYaxis()->SetLabelSize(0.03); histName16->SetLineColor(kBlue); histName16->SetLineStyle(5); histName17->SetLineColor(kRed); histName17->SetLineStyle(1); histName17->GetXaxis()->SetTitle(histTitle[i]); histName17->GetYaxis()->SetTitle("Counts"); histName17->Draw("h"); histName15->Draw("h SAME"); histName16->Draw("h SAME"); TLegend *leg12 = new TLegend(0.12,0.66, 0.48, 0.86); //leg12->SetHeader("True/Accidental"); leg12->SetTextSize(0.04); leg12->AddEntry(histName05, "True signal", "l"); leg12->AddEntry(histName06, "Accidental", "l"); leg12->AddEntry(histName07, "True + Accidental", "l"); leg12->Draw(); canvName01->cd(4); gPad->SetLogy(); histName12->SetMinimum(0.1); histName12->SetMaximum(maximum_eta); histName08->SetLineColor(kBlack); histName08->SetLineStyle(2); //histName08->SetLineWidth(4); //histName00->GetYaxis()->SetTitleOffset(1.4); //histName01->GetYaxis()->SetLabelSize(0.03); histName09->SetLineColor(kBlue); //histName09->SetLineWidth(4); histName09->SetLineStyle(3); histName10->SetLineColor(kGreen); histName10->SetLineStyle(5); //histName10->SetLineWidth(4); histName12->SetLineColor(kRed); //histName12->SetLineWidth(4); histName12->SetLineStyle(1); histName12->GetXaxis()->SetTitle(histTitle[i]); histName12->GetYaxis()->SetTitle("Counts"); histName12->Draw("h"); histName08->Draw("h SAME"); histName09->Draw("h SAME"); histName10->Draw("h SAME"); TLegend *leg3 = new TLegend(0.12,0.66, 0.48, 0.86); //leg3->SetHeader("The eta background"); leg3->SetTextSize(0.04); leg3->AddEntry(histName08, "omega", "l"); leg3->AddEntry(histName09, "pipieta", "l"); leg3->AddEntry(histName10, "pi0eta", "l"); leg3->AddEntry(histName12, "add of 3 above", "l"); leg3->Draw(); canvName01->cd(5); gPad->SetLogy(); histNamemc04->SetMinimum(0.1); histNamemc04->SetMaximum(maximum_sig); histNamemc04->SetLineColor(kBlack); histNamemc04->SetLineStyle(2); //histName08->SetLineWidth(4); //histName00->GetYaxis()->SetTitleOffset(1.4); //histName01->GetYaxis()->SetLabelSize(0.03); histNamemc04->SetTitle("Comparison of MC and Data for #pi^{0}"); histNamemc04->GetXaxis()->SetTitle(histTitle[i]); histNamemc04->GetYaxis()->SetTitle("Counts"); histNamemc04->Draw(); histNamedata04->SetLineColor(kRed); histNamedata04->SetLineStyle(1); histNamedata04->Draw("SAME"); TLegend *leg4 = new TLegend(0.12,0.66, 0.48, 0.86); //leg4->SetHeader("The signal"); leg4->SetTextSize(0.04); leg4->AddEntry(histNamemc04, "MC", "l"); leg4->AddEntry(histNamedata04, "Data", "l"); leg4->Draw(); canvName01->cd(6); gPad->SetLogy(); histNamemc14->SetMinimum(0.1); histNamemc14->SetMaximum(maximum_sig_14); histNamemc14->SetLineColor(kBlack); histNamemc14->SetLineStyle(2); //histName08->SetLineWidth(4); //histName00->GetYaxis()->SetTitleOffset(1.4); //histName01->GetYaxis()->SetLabelSize(0.03); histNamemc14->SetTitle("Comparison of MC and Data for #eta"); histNamemc14->GetXaxis()->SetTitle(histTitle[i]); histNamemc14->GetYaxis()->SetTitle("Counts"); histNamemc14->Draw(); histNamedata14->SetLineColor(kRed); histNamedata14->SetLineStyle(1); histNamedata14->Draw("SAME"); TLegend *leg14 = new TLegend(0.12,0.66, 0.48, 0.86); //leg14->SetHeader("The signal"); leg14->SetTextSize(0.04); leg14->AddEntry(histNamemc14, "MC", "l"); leg14->AddEntry(histNamedata14, "Data", "l"); leg14->Draw(); canvName01->SaveAs(figName01); canvName01->SaveAs(figName11); } } }