void jets() { char* newFile="DQM_CM3_newTune.root"; // char* newFile="DQM_CM3.root"; char* refFile="DQM_CM1.root"; run("calo",newFile,refFile); run("pf",newFile,refFile); } void run(TString type="calo",char* newFile="DQM_new_iterativetracking.root",char* refFile="DQM_old_iterativetracking.root") { gROOT ->Reset(); gROOT ->SetBatch(); //========= settings ==================== gROOT->SetStyle("Plain"); gStyle->SetPadGridX(kTRUE); gStyle->SetPadGridY(kTRUE); gStyle->SetPadRightMargin(0.07); gStyle->SetPadLeftMargin(0.13); //gStyle->SetTitleXSize(0.07); //gStyle->SetTitleXOffset(0.6); //tyle->SetTitleYSize(0.3); //gStyle->SetLabelSize(0.6) //gStyle->SetTextSize(0.5); char* refLabel("reference histogram"); char* newLabel("new histogram"); delete gROOT->GetListOfFiles()->FindObject(refFile); delete gROOT->GetListOfFiles()->FindObject(newFile); TText* te = new TText(); TFile * sfile = new TFile(newFile); TDirectory * sdir=gDirectory; TFile * rfile = new TFile(refFile); TDirectory * rdir=gDirectory; if(sfile->GetDirectory("DQMData/Run 1/JetMET")) sfile->cd("DQMData/Run 1/JetMET/Run summary/RecoJetsV"); else if(sfile->GetDirectory("DQMData/JetMET/RecoJetsV"))sfile->cd("DQMData/JetMET/RecoJetsV"); sdir=gDirectory; TList *sl= sdir->GetListOfKeys(); if(rfile->GetDirectory("DQMData/Run 1/JetMET")) rfile->cd("DQMData/Run 1/JetMET/Run summary/RecoJetsV"); else if(rfile->GetDirectory("DQMData/JetMET/RecoJetsV"))rfile->cd("DQMData/JetMET/RecoJetsV"); rdir=gDirectory; TList *rl= rdir->GetListOfKeys(); TString collname1; TString collname2; if (type=="calo") { collname1="CaloJetTask_ak5CaloJets"; collname2="CaloJetTask_ak5CaloJets"; } else if (type=="pf") { collname1="PFJetTask_ak5PFJets"; collname2="PFJetTask_ak5PFJets"; } else { cout << "invalid type of jet (choose calo or pf)" << endl; return; } TCanvas *canvas; TProfile *sh1,*rh1; TProfile *sh2,*rh2; TProfile *sh3,*rh3; TProfile *sh4,*rh4; rdir->GetObject(collname1+"/pTScaleB_d",rh1); sdir->GetObject(collname2+"/pTScaleB_d",sh1); rdir->GetObject(collname1+"/pTScaleE_d",rh2); sdir->GetObject(collname2+"/pTScaleE_d",sh2); rdir->GetObject(collname1+"/pTScaleF_d",rh3); sdir->GetObject(collname2+"/pTScaleF_d",sh3); rdir->GetObject(collname1+"/pTScale_60_120_d",rh4); sdir->GetObject(collname2+"/pTScale_60_120_d",sh4); rh1->GetXaxis()->SetTitle("p_{T}"); rh1->GetYaxis()->SetTitle("p_{T}(raw)/p_{T}(gen), Barrel"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rh1->GetYaxis()->SetRangeUser(0.,1.5); sh1->GetYaxis()->SetRangeUser(0.,1.5); rh1->Rebin(2); sh1->Rebin(2); rh2->GetXaxis()->SetTitle("p_{T}"); rh2->GetYaxis()->SetTitle("p_{T}(raw)/p_{T}(gen), Endcap"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rh2->GetYaxis()->SetRangeUser(0.,1.5); sh2->GetYaxis()->SetRangeUser(0.,1.5); rh2->Rebin(2); sh2->Rebin(2); rh3->GetXaxis()->SetTitle("p_{T}"); rh3->GetYaxis()->SetTitle("p_{T}(raw)/p_{T}(gen), Forward"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rh3->GetYaxis()->SetRangeUser(0.,1.5); sh3->GetYaxis()->SetRangeUser(0.,1.5); rh3->Rebin(2); sh3->Rebin(2); rh4->GetXaxis()->SetTitle("#eta"); rh4->GetYaxis()->SetTitle("p_{T}(raw)/p_{T}(gen) vs #eta"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); rh4->GetYaxis()->SetRangeUser(0.,1.5); sh4->GetYaxis()->SetRangeUser(0.,1.5); rh4->Rebin(2); sh4->Rebin(2); canvas = new TCanvas("Jets","Jets",1000,1400); TH1F * r[4]={rh1,rh2,rh3,rh4}; TH1F * s[4]={sh1,sh2,sh3,sh4}; plotBuilding(canvas,s, r,4, te,"UU",-1, 1, false, 0); //0xC); canvas->cd(); l = new TLegend(0.10,0.14,0.90,0.19); l->SetTextSize(0.016); l->SetLineColor(1); l->SetLineWidth(1); l->SetLineStyle(1); l->SetFillColor(0); l->SetBorderSize(3); l->AddEntry(rh1,refLabel,"LPF"); l->AddEntry(sh1,newLabel,"LPF"); l->Draw(); TString namepdf = type; namepdf += ".pdf"; canvas->Print(namepdf); delete l; delete canvas; } void plotBuilding(TCanvas *canvas, TH1F **s, TH1F **r, int n,TText* te, char * option, double startingY, double startingX = .1,bool fit = false, unsigned int logx=0){ canvas->Divide(2,(n+1)/2); //this should work also for odd n for(int i=0; iSetMarkerStyle(20); r[i]->SetMarkerStyle(21); s[i]->SetMarkerColor(2); r[i]->SetMarkerColor(4); s[i]->SetMarkerSize(0.7); r[i]->SetMarkerSize(0.7); s[i]->SetLineColor(1); r[i]->SetLineColor(1); s[i]->SetLineWidth(1); r[i]->SetLineWidth(1); TPad *pad=canvas->cd(i+1); setStats(s[i],r[i], -1, 0, false); if((logx>>i)&1)pad->SetLogx(); r[i]->Draw(); s[i]->Draw("sames"); } } void setStats(TH1* s,TH1* r, double startingY, double startingX = .1,bool fit){ if (startingY<0){ s->SetStats(0); r->SetStats(0); } else { //gStyle->SetOptStat(1001); s->SetStats(1); r->SetStats(1); if (fit){ s->Fit("gaus"); TF1* f1 = (TF1*) s->GetListOfFunctions()->FindObject("gaus"); f1->SetLineColor(2); f1->SetLineWidth(1); } s->Draw(); gPad->Update(); TPaveStats* st1 = (TPaveStats*) s->GetListOfFunctions()->FindObject("stats"); if (fit) {st1->SetOptFit(0010); st1->SetOptStat(1001);} st1->SetX1NDC(startingX); st1->SetX2NDC(startingX+0.30); st1->SetY1NDC(startingY+0.20); st1->SetY2NDC(startingY+0.35); st1->SetTextColor(2); if (fit) { r->Fit("gaus"); TF1* f2 = (TF1*) r->GetListOfFunctions()->FindObject("gaus"); f2->SetLineColor(4); f2->SetLineWidth(1); } r->Draw(); gPad->Update(); TPaveStats* st2 = (TPaveStats*) r->GetListOfFunctions()->FindObject("stats"); if (fit) {st2->SetOptFit(0010); st2->SetOptStat(1001);} st2->SetX1NDC(startingX); st2->SetX2NDC(startingX+0.30); st2->SetY1NDC(startingY); st2->SetY2NDC(startingY+0.15); st2->SetTextColor(4); } }