/* this program compares the two branches of the two tree or the two branches from the same tree. first 5 variables are root file name var1 is the variable that we want to plot var2 is the xtitle */ void compareQuantities(string filename1, string filename2,string filename3, string filename4,string filename5,string filename6, string var1, string var2, int nbins, float min, float max, string cut=""){ if (var2 == "") var2 = var1; gStyle->SetOptStat(110); //gStyle->SetOptStat("n"); gROOT->SetStyle("Plain"); gPad->SetLeftMargin(0.11); gPad->SetRightMargin(0.03); TFile *inputFile1 = new TFile(filename1.c_str()); TFile *inputFile2 = new TFile(filename2.c_str()); TFile *inputFile3 = new TFile(filename3.c_str()); TFile *inputFile4 = new TFile(filename4.c_str()); TFile *inputFile5 = new TFile(filename5.c_str()); TFile *inputFile6 = new TFile(filename6.c_str()); TTree *jetTree1 = (TTree *) inputFile1->Get("demo/tree"); TTree *jetTree2 = (TTree *) inputFile2->Get("demo/tree"); TTree *jetTree3 = (TTree *) inputFile3->Get("demo/tree"); TTree *jetTree4 = (TTree *) inputFile4->Get("demo/tree"); TTree *jetTree5 = (TTree *) inputFile5->Get("demo/tree"); TTree *jetTree6 = (TTree *) inputFile6->Get("demo/tree"); TH1F *Phantom = new TH1F("Phantom", "", nbins, min, max); TH1F *Phantom_bkg = new TH1F("Phantom_bkg", "", nbins, min, max); TH1F *LL = new TH1F("LL", "LL", nbins, min, max); TH1F *LT = new TH1F("LT", "LT", nbins, min, max); TH1F *TT = new TH1F("TT", "TT", nbins, min, max); TH1F *TOT = new TH1F("TOT", "TOT", nbins, min, max); jetTree1->Draw(Form("%s>>Phantom",var1.c_str()), cut.c_str(), "goff"); jetTree2->Draw(Form("%s>>LL",var1.c_str()), cut.c_str(), "goff"); jetTree3->Draw(Form("%s>>LT",var1.c_str()), cut.c_str(), "goff"); jetTree4->Draw(Form("%s>>TT",var1.c_str()), cut.c_str(), "goff"); jetTree5->Draw(Form("%s>>TOT",var1.c_str()), cut.c_str(), "goff"); jetTree6->Draw(Form("%s>>Phantom_bkg",var1.c_str()), cut.c_str(), "goff"); Phantom->SetLineWidth(2); Phantom_bkg->SetLineWidth(2); LL->SetLineWidth(2); LT->SetLineWidth(2); TT->SetLineWidth(2); TOT->SetLineWidth(2); Phantom->SetLineStyle(1); Phantom_bkg->SetLineStyle(8); LL->SetLineStyle(1); LT->SetLineStyle(3); TT->SetLineStyle(8); TOT->SetLineStyle(1); Phantom->SetLineColor(kBlue); Phantom_bkg->SetLineColor(38); LL->SetLineColor(kRed); LT->SetLineColor(6); TT->SetLineColor(kGreen); TOT->SetLineColor(kBlack); Phantom->GetYaxis()->SetTitle("Fraction of Events"); Phantom->GetYaxis()->SetTitleOffset(1.3); Phantom->GetXaxis()->SetTitle(var2.c_str()); Phantom->Scale(1/Phantom->Integral()); Phantom_bkg->Scale(1/Phantom_bkg->Integral()); LL->Scale(1/LL->Integral()); LT->Scale(1/LT->Integral()); TT->Scale(1/TT->Integral()); TOT->Scale(1/TOT->Integral()); Phantom->SetMaximum( TMath::Max(Phantom->GetMaximum() * 1.10, TMath::Max(LL->GetMaximum() , TMath::Max(LT->GetMaximum() , TMath::Max(TT->GetMaximum(), TMath::Max(TOT->GetMaximum(),Phantom_bkg->GetMaximum()))))*1.10)); Phantom->Draw(); gPad->Update(); TPaveStats *statsbox1 = (TPaveStats*)Phantom->GetListOfFunctions()->FindObject("stats"); statsbox1->SetX1NDC(0.04); //set new y start position statsbox1->SetX2NDC(0.20); //set new y end position statsbox1->SetY1NDC(0.85); //set new y start position statsbox1->SetY2NDC(0.99); //set new y end position statsbox1->SetTextColor(kBlue); LL->Draw("sames"); gPad->Update(); TPaveStats *statsbox2 = (TPaveStats*)LL->GetListOfFunctions()->FindObject("stats"); statsbox2->SetX1NDC(0.20); //set new y start position statsbox2->SetX2NDC(0.36); //set new y end position statsbox2->SetY1NDC(0.85); //set new y start position statsbox2->SetY2NDC(0.99); //set new y end position statsbox2->SetTextColor(kRed); LT->Draw("sames"); gPad->Update(); TPaveStats *statsbox3 = (TPaveStats*)LT->GetListOfFunctions()->FindObject("stats"); statsbox3->SetX1NDC(0.36); //set new y start position statsbox3->SetX2NDC(0.52); //set new y end position statsbox3->SetY1NDC(0.85); //set new y start position statsbox3->SetY2NDC(0.99); //set new y end position statsbox3->SetTextColor(6); TT->Draw("sames"); gPad->Update(); TPaveStats *statsbox4 = (TPaveStats*)TT->GetListOfFunctions()->FindObject("stats"); statsbox4->SetX1NDC(0.52); //set new y start position statsbox4->SetX2NDC(0.68); //set new y end position statsbox4->SetY1NDC(0.85); //set new y start position statsbox4->SetY2NDC(0.99); //set new y end position statsbox4->SetTextColor(kGreen); TOT->Draw("sames"); gPad->Update(); TPaveStats *statsbox5 = (TPaveStats*)TOT->GetListOfFunctions()->FindObject("stats"); statsbox5->SetX1NDC(0.68); //set new y start position statsbox5->SetX2NDC(0.84); //set new y end position statsbox5->SetY1NDC(0.85); //set new y start position statsbox5->SetY2NDC(0.99); //set new y end position statsbox5->SetTextColor(kBlack); Phantom_bkg->Draw("sames"); gPad->Update(); TPaveStats *statsbox6 = (TPaveStats*)Phantom_bkg->GetListOfFunctions()->FindObject("stats"); statsbox6->SetX1NDC(0.84); //set new y start position statsbox6->SetX2NDC(0.99); //set new y end position statsbox6->SetY1NDC(0.85); //set new y start position statsbox6->SetY2NDC(0.99); //set new y end position statsbox6->SetTextColor(38); }