/* this program plots one branch of different trees on the same histogram var1 is the variable that we want to plot var2 is the xtitle n is the number of input rootfiles format to enter $root -l root[].L CompareAdvanced.C root[]compareQuantities("branch_name","x-axis Title",10,0,200,Cut,2,"abc.root","abc","xyz.root","xyz"); abc.root is the name of root file --->>> abc is the legend of abc.root; similarly others. */ double deltaPhi(double phi1, double phi2) { double deltaphi = fabs(phi1-phi2); if (deltaphi > TMath::PI ) deltaphi = 2 * TMath::PI - deltaphi; if (deltaphi > 2 * TMath::PI ) cout<< "Delta Phi = "<SetOptStat(0); gROOT->ForceStyle(kTRUE); va_list list; va_start(list, n); char** fname=new char*[n]; TFile** tf = new TFile*[n]; TTree** tt = new TTree*[n]; TH1F** th = new TH1F*[n]; TPaveStats** tp = new TPaveStats*[n]; TLegend** leg = new TLegend*[n]; for (int i=0;iGet("demo/tree"); th[i] = new TH1F(Form("th%i",i),"",nbins,min,max); tt[i]->Draw(Form("%s>>th%i",var1.c_str(),i), cut.c_str(), "goff"); th[i]->SetStats(0); th[i]->SetLineWidth(2); th[i]->SetLineStyle(style[i]); th[i]->SetLineColor(color[i]); th[i]->GetYaxis()->SetTitle("Fraction of Events"); th[i]->GetYaxis()->CenterTitle(); th[i]->GetYaxis()->SetTitleOffset(1.4); th[i]->GetXaxis()->SetTitle(var2.c_str()); th[i]->GetXaxis()->SetTitle(var2.c_str()); th[i]->GetXaxis()->CenterTitle(); th[i]->Scale(1/th[i]->Integral()); th[0]->SetMaximum(TMath::Max(th[i]->GetMaximum()*1.1,yMax)); yMax = TMath::Max(th[i]->GetMaximum()*1.1,yMax); if (i==0) th[i]->Draw(); else th[i]->Draw("sames"); leg[i] = new TLegend(a1,0.85,a2,0.99); leg[i]->AddEntry(th[i],va_arg(list, char*),"l"); int entries = th[i]->GetEntries(); char c[20]; sprintf(c,"%d",entries); leg[i]->AddEntry(th[i],TString(c),"l"); leg[i]->Draw("sames"); a1 = a2; a2 = a2+0.16; cout<<"histogram "<