void RecoMuonValHistoPublisher(char* newFile="NEW_FILE",char* refFile="REF_FILE") { //gROOT->ProcessLine(".x HistoCompare_Tracks.C"); gROOT ->Reset(); gROOT ->SetBatch(); //========= settings ==================== char* dataType = "DATATYPE"; 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("REF_LABEL, REF_RELEASE REFSELECTION"); char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION"); Float_t maxPT=1500.; char* fastSim = "IS_FSIM"; //============================================= delete gROOT->GetListOfFiles()->FindObject(refFile); delete gROOT->GetListOfFiles()->FindObject(newFile); //INPUT FILE IS DEFINED HERE, passed from python wrapper TText* te = new TText(); TFile * sfile = new TFile(newFile); TDirectory * sdir=gDirectory; TFile * rfile = new TFile(refFile); TDirectory * rdir=gDirectory; //check datatype if (dataType == "RECO") { if(sfile->cd("DQMData/Run 1/Muons/Run summary")) {;} else { cout << " Muon Histos for " << dataType << " not found" << endl; return; } } else { cout << " Data type " << dataType << " not allowed: only RECO is considered" << endl; return; } sdir=gDirectory; TIter nextkey( sdir->GetListOfKeys() ); TList *sl = new TList(); TKey *key, *oldkey=0; cout << "- New DQM muon reco collections: " << endl; while ( key = (TKey*)nextkey() ) { TObject *obj = key->ReadObj(); if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) { TString theName = obj->GetName(); if (theName.Contains("RecoMuonV")) { cout << " -> " << theName << endl; sl->Add(obj); } } } if (sl->GetSize()>0) { TString collname2 =sl->At(0)->GetName(); } else { cout << " No DQM muon reco histos found in NEW file " << endl; return; } if (dataType == "RECO") { if(rfile->cd("DQMData/Run 1/Muons/Run summary")) {;} else { cout << " Muon Histos for " << dataType << " not found" << endl; return; } } rdir=gDirectory; TIter nextkeyr( rdir->GetListOfKeys() ); TList *rl = new TList(); TKey *keyr, *oldkeyr=0; cout << "- Ref DQM muon reco collections: " << endl; while ( keyr = (TKey*)nextkeyr() ) { TObject *obj = keyr->ReadObj(); if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) { TString theName = obj->GetName(); if (theName.Contains("RecoMuonV")) { cout << " -> " << theName << endl; rl->Add(obj); } } } if (rl->GetSize()>0) { TString collname1=rl->At(0)->GetName(); } else { cout << " No DQM muon reco histos found in REF file " << endl; return; } TCanvas *canvas; TH1F *sh1,*rh1; TH1F *sh2,*rh2; TH1F *sh3,*rh3; TH1F *sh4,*rh4; TH1F *sh5,*rh5; TH1F *sh6,*rh6; TIter iter_r( rl ); TIter iter_s( sl ); TKey * myKey1, *myKey2; while ( (myKey1 = (TKey*)iter_r()) ) { TString myName = myKey1->GetName(); collname1 = myName; myKey2 = (TKey*)iter_s(); if (!myKey2) continue; collname2 = myKey2->GetName(); if ( (collname1 != collname2) && (collname1+"FS" != collname2) && (collname1 != collname2+"FS") ) { cout << " Different collection names, please check: " << collname1 << " : " << collname2 << endl; continue; } TString newDir("NEW_RELEASE/NEWSELECTION/NEW_LABEL/"); newDir+=myName; gSystem->mkdir(newDir,kTRUE); //rh1 = 0; //sh1 = 0; //===== For each monitored type as defined in muonValidation_cff.py //===== reco muon distributions: GLB rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt",sh1); rh1->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p_{T}/p_{T}"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrP",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrP",sh2); rh2->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p/p"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3); if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3); if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3); rh3->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p_{T}/p_{T} vs #sigma(#eta)"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4); if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4); if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4); rh4->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p_{T}/p_{T} vs #sigma(p_{T})"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecHistosGlb","Distributions for GlobalMuons (GLB)",1000,1050); // Normalize to the same number of "new" events: NormalizeHistograms(rh1,sh1); NormalizeHistograms(rh2,sh2); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoGlb.pdf"); delete l; delete canvas; //==== efficiencies and fractions GLB rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffP",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffP",sh1); //if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("GlobalMuon(GLB) #epsilon vs. p"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffEta",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffEta",sh2); rh2->GetYaxis()->SetTitle("GlobalMuon(GLB) #epsilon vs. #eta"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractP",rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractP",sh3); rh3->GetYaxis()->SetTitle("GlobalMuon(GLB) fraction vs. p"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractEta",rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractEta",sh4); rh4->GetYaxis()->SetTitle("GlobalMuon(GLB) fraction vs. #eta"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecEffHistosGlb","Distributions for GlobalMuons (GLB), efficiencies and fractions",1000,1050); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoGlbEff.pdf"); delete l; delete canvas; //===== reco muon distributions: GLBPF rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T}"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrP",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrP",sh2); rh2->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p/p"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3); if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3); if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3); rh3->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T} vs #sigma(#eta)"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4); if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4); if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4); rh4->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T} vs #sigma(p_{T})"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecHistosGlbPF","Distributions for PFGlobalMuons (GLBPF)",1000,1050); // Normalize to the same number of "new" events: NormalizeHistograms(rh1,sh1); NormalizeHistograms(rh2,sh2); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoGlbPF.pdf"); delete l; delete canvas; //==== efficiencies and fractions GLBPF rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffP",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffP",sh1); //if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #epsilon vs. p"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffEta",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffEta",sh2); rh2->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #epsilon vs. #eta"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractP",rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractP",sh3); rh3->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) fraction vs. p"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractEta",rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractEta",sh4); rh4->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) fraction vs. #eta"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecEffHistosGlbPF","Distributions for PFGlobalMuons (GLBPF), efficiencies and fractions",1000,1050); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoGlbPFEff.pdf"); delete l; delete canvas; //===== reco muon distributions: STA rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p_{T}/p_{T}"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrP",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrP",sh2); rh2->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p/p"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3); if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3); if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3); rh3->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p_{T}/p_{T} vs #sigma(#eta)"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4); if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4); if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4); rh4->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p_{T}/p_{T} vs #sigma(p_{T})"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecHistosSta","Distributions for StandAloneMuons (STA)",1000,1050); // Normalize to the same number of "new" events: NormalizeHistograms(rh1,sh1); NormalizeHistograms(rh2,sh2); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoSta.pdf"); delete l; delete canvas; //==== efficiencies and fractions STA rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffP",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffP",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("StandAloneMuon(STA) #epsilon vs. p"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffEta",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffEta",sh2); rh2->GetYaxis()->SetTitle("StandAloneMuon(STA) #epsilon vs. #eta"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractP",rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractP",sh3); rh3->GetYaxis()->SetTitle("StandAloneMuon(STA) fraction vs. p"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractEta",rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractEta",sh4); rh4->GetYaxis()->SetTitle("StandAloneMuon(STA) fraction vs. #eta"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecEffHistosSta","Distributions for StandAloneMuons (STA), efficiencies and fractions",1000,1050); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoStaEff.pdf"); delete l; delete canvas; //===== reco muon distributions: TRK rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p_{T}/p_{T}"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrP",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrP",sh2); rh2->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p/p"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3); if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3); if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3); rh3->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p_{T}/p_{T} vs #sigma(#eta)"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4); if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4); if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4); rh4->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p_{T}/p_{T} vs #sigma(p_{T})"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecHistosTrk","Distributions for TrackerMuons (TRK)",1000,1050); // Normalize to the same number of "new" events: NormalizeHistograms(rh1,sh1); NormalizeHistograms(rh2,sh2); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoTrk.pdf"); delete l; delete canvas; //==== efficiencies and fractions TRK rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffP",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffP",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("TrackerMuon(TRK) #epsilon vs. p"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffEta",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffEta",sh2); rh2->GetYaxis()->SetTitle("TrackerMuon(TRK) #epsilon vs. #eta"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractP",rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractP",sh3); rh3->GetYaxis()->SetTitle("TrackerMuon(TRK) fraction vs. p"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractEta",rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractEta",sh4); rh4->GetYaxis()->SetTitle("TrackerMuon(TRK) fraction vs. #eta"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecEffHistosTrk","Distributions for TrackerMuons (TRK), efficiencies and fractions",1000,1050); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoTrkEff.pdf"); delete l; delete canvas; // //===== reco muon distributions: Tight Muons // rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("Tight Muon #Delta p_{T}/p_{T}"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrP",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrP",sh2); rh2->GetYaxis()->SetTitle("Tight Muon #Delta p/p"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3); if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3); if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3); rh3->GetYaxis()->SetTitle("Tight Muon #Delta p_{T}/p_{T} vs #sigma(#eta)"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4); if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4); if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4); rh4->GetYaxis()->SetTitle("Tigh Muon) #Delta p_{T}/p_{T} vs #sigma(p_{T})"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecHistosTgt","Distributions for Tight Muons",1000,1050); // Normalize to the same number of "new" events: NormalizeHistograms(rh1,sh1); NormalizeHistograms(rh2,sh2); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoTgt.pdf"); delete l; delete canvas; //==== efficiencies and fractions Tight Muons rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffP",rh1); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffP",sh1); // if(! rh1 && sh1) continue; rh1->GetYaxis()->SetTitle("Tight Muon #epsilon vs. p"); rh1->GetYaxis()->SetTitleSize(0.05); rh1->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffEta",rh2); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffEta",sh2); rh2->GetYaxis()->SetTitle("Tight Muon #epsilon vs. #eta"); rh2->GetYaxis()->SetTitleSize(0.05); rh2->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractP",rh3); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractP",sh3); rh3->GetYaxis()->SetTitle("Tight Muon fraction vs. p"); rh3->GetYaxis()->SetTitleSize(0.05); rh3->GetYaxis()->SetTitleOffset(1.2); rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractEta",rh4); sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractEta",sh4); rh4->GetYaxis()->SetTitle("Tight Muon fraction vs. #eta"); rh4->GetYaxis()->SetTitleSize(0.05); rh4->GetYaxis()->SetTitleOffset(1.2); canvas = new TCanvas("RecEffHistosTgt","Distributions for Tight Muons, efficiencies and fractions",1000,1050); plot4histos(canvas, sh1,rh1,sh2,rh2, sh3,rh3,sh4,rh4, te,"UU",-1); canvas->cd(); l = new TLegend(0.20,0.48,0.90,0.53); 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(); canvas->Print(newDir+"/muonRecoTgtEff.pdf"); delete l; delete canvas; // // Merge pdf histograms together into larger files, and name them based on the collection names // gSystem->Exec("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf " +newDir+"/muonRecoGlb.pdf " +newDir+"/muonRecoGlbEff.pdf " +newDir+"/muonRecoGlbPF.pdf " +newDir+"/muonRecoGlbPFEff.pdf " +newDir+"/muonRecoSta.pdf " +newDir+"/muonRecoStaEff.pdf " +newDir+"/muonRecoTrk.pdf " +newDir+"/muonRecoTrkEff.pdf " +newDir+"/muonRecoTgt.pdf " +newDir+"/muonRecoTgtEff.pdf "); gSystem->Exec("mv merged.pdf "+newDir+"/../"+myName+".pdf"); gSystem->Exec("rm -r "+newDir); } // end of "while loop" }
void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { cout << ">> Starting new_TrackValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python ==================== const char* dataType = "DATATYPE"; const char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION"); const char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION"); // ==== Initial settings and loads gROOT ->SetBatch(); gErrorIgnoreLevel = kWarning; // Get rid of the info messages SetGlobalStyle(); // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); delete gROOT->GetListOfFiles()->FindObject(newFile); // ==== Opening files, moving to the right branch and getting the list of sub-branches cout << ">> Opening files, moving to the right branch and getting the list of sub-branches..." << endl; cout << ">> Finding new DQM file ..." << endl; TFile * sfile = new TFile(newFile); TList* sl = GetListOfBranches(dataType, sfile); if (!sl) { cout << "ERROR: Could not find keys!!!" << endl; cerr << "ERROR: Could not find keys!!!" << endl; return; } TDirectory* sdir = gDirectory; if (DEBUG) { for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; } cout << ">> Finding reference DQM file ..." << endl; TFile * rfile = new TFile(refFile); TList* rl = GetListOfBranches(dataType, rfile); if (!rl) { cout << "ERROR: Could not find keys!!!" << endl; cerr << "ERROR: Could not find keys!!!" << endl; return; } TDirectory* rdir = gDirectory; if (DEBUG) { for (unsigned int i = 0; i < rl->GetEntries(); i++) cout << " + " << rl->At(i)->GetName() << endl; } //==== Iterate now over histograms and collections cout << ">> Iterating over histograms and collections..." << endl; bool logy[6] = {false, false, false, false, false, false }; bool logx[6] = {false, false, false, false, false, false }; bool doKolmo[6] = {true, true, true, true, true, true }; Double_t norm[6] = {-1.,-1.,-1.,-1.,-1.,-1.}; // initial default: do not normalize Double_t minx[6] = {0, 0, 0, 0, 0, 0}; Double_t maxx[6] = {0, 0, 0, 0, 0, 0}; Double_t miny[6] = {0, 0, 0, 0, 0, 0}; Double_t maxy[6] = {0, 0, 0, 0, 0, 0}; const char* drawopt[6] = {"", "", "", "", "", ""}; TString plots[6] = {"", "", "", "", "", ""}; TString titles[6] = {"", "", "", "", "", ""}; TString rcollname; TString scollname; TIter iter_r( rl ); TIter iter_s( sl ); TString newDirBase("NEW_RELEASE/NEWSELECTION/NEW_LABEL/"); TKey* rKey = 0; // before CMSSW_10_1_0_pre1 a few collection names were different bool NEWcollNames = false; TString Ref_CMSSW_Release("REF_RELEASE"); if (Ref_CMSSW_Release.Contains("CMSSW_9") || Ref_CMSSW_Release.Contains("CMSSW_10_0")) NEWcollNames=true; while ( (rKey = (TKey*)iter_r()) ) { TString myName = rKey->GetName(); rcollname = myName; if (DEBUG) { cout << " Checking collection: " << myName << endl; cerr << " Checking collection: " << myName << endl; } TString myName2 = myName; if (NEWcollNames) { if (myName=="NEWprobeTrks") myName2="probeTrks"; else if (myName=="NEWprobeTrks_TkAsso") myName2="probeTrks_TkAsso"; else if (myName=="NEWseedsOfSTAmuons") myName2="seedsOfSTAmuons"; else if (myName=="NEWseedsOfDisplacedSTAmuons") myName2="seedsOfDisplacedSTAmuons"; else if (myName=="NEWcutsRecoTrkMuons") myName2="cutsRecoTrkMuons"; else if (myName=="NEWextractGemMuons") myName2="extractGemMuons"; else if (myName=="NEWextractMe0Muons") myName2="extractMe0Muons"; } scollname = myName2; if (DEBUG) { cout << " Comparing " << rcollname << " and " << scollname << endl; cerr << " Comparing " << rcollname << " and " << scollname << endl; } // ==== Now let's go for the plotting... TString newDir = newDirBase+myName2; cout<<"creating directory: "<<newDir<<endl; gSystem->mkdir(newDir,kTRUE); // efficiency and fake rate Vs eta and phi plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_eta" ; titles[0]="Efficiency vs #eta"; plots[1]="fakerate_vs_eta" ; titles[1]="Fake rate vs #eta" ; plots[2]="effic_vs_phi" ; titles[2]="Efficiency vs #phi" ; plots[3]="fakerate_vs_phi" ; titles[3]="Fake rate vs #phi" ; miny[0]=-0.0001; miny[1]=-0.0001; miny[2]=-0.0001; miny[3]=-0.0001; maxy[0]=1.09; maxy[1]=0.; maxy[2]=1.09; maxy[3]=0.; Plot4Histograms(newDir + "/eff_eta_phi", rdir, sdir, rcollname, scollname, "eff_eta_phi", "Efficiency vs eta and Vs phi", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // efficiency and fake rate Vs pt plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_pt" ; titles[0]="Efficiency vs pt"; plots[1]="fakerate_vs_pt" ; titles[1]="Fake rate vs pt" ; plots[2]="num_simul_pT" ; titles[2]="N of simulated tracks vs pt" ; plots[3]="num_reco_pT" ; titles[3]="N of reco track vs pt" ; logx[0]=true; logx[1]=true; logx[2]=true; logx[3]=true; drawopt[0]=""; drawopt[1]=""; drawopt[2]="hist"; drawopt[3]="hist"; norm[0]= -1.; norm[1]= -1.; norm[2]= 2.; norm[3]= 2.; miny[0]= -0.0001; miny[1]= -0.0001; miny[2]= 0.; miny[3]= 0.; maxy[0]= 1.09; maxy[1]= 0.; maxy[2]= 0.; maxy[3]= 0.; Plot4Histograms(newDir + "/eff_pt", rdir, sdir, rcollname, scollname, "eff_pt", "Efficiency vs pt and sim,reco distributions", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // efficiency and fake rate vs Number of Hits; Hit multiplicity per track; Ave.N.hits vs eta plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_hit" ; titles[0]="Efficiency vs Number of hits"; plots[1]="fakerate_vs_hit" ; titles[1]="Fake rate vs Number of hits" ; plots[2]="nhits" ; titles[2]="number of hits per track" ; plots[3]="nhits_vs_eta_prof" ; titles[3]="mean number of Hits vs eta" ; drawopt[0]=""; drawopt[1]=""; drawopt[2]="hist"; drawopt[3]=""; norm[0]= -1.; norm[1]= -1.; norm[2]= 0.; norm[3]= -1.; miny[0]= -0.0001; miny[1]= -0.0001; miny[2]= 0.; miny[3]= 0.; maxy[0]= 1.09; maxy[1]= 0.; maxy[2]= 0.; maxy[3]= 0.; Plot4Histograms(newDir + "/eff_hits", rdir, sdir, rcollname, scollname, "eff_hits", "Efficiency vs Number of hits and hit multiplicity per track", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // efficiency and fake rate vs PU plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_pu" ; titles[0]="Efficiency vs n.PU interactions"; plots[1]="fakerate_vs_pu" ; titles[1]="Fake rate vs n.PU interactions" ; //maxx[0]= 100.; //maxx[1]= 100.; miny[0]= -0.0001; miny[1]= 0.; maxy[0]= 1.09; maxy[1]= 0.; Plot4Histograms(newDir + "/eff_pu", rdir, sdir, rcollname, scollname, "eff_pu", "Efficiency vs n.PU interactions", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // skip other plots for seeds if (!scollname.Contains("seeds")) { //===== normalized chi2, chi2 probability, ave. norm. chi2 vs eta; ave. pt bias vs eta plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="chi2" ; titles[0]="Track #chi^{2}"; plots[1]="chi2prob" ; titles[1]="Probability of track #chi^{2}"; plots[2]="chi2_vs_eta_prof" ; titles[2]="Mean normalized #chi^{2} vs #eta" ; drawopt[0]="hist"; drawopt[1]="hist"; drawopt[2]=""; norm[0]= -1.; norm[1]= 2.; norm[2]= -1.; logy[0]=true; logy[1]=false; logy[2]=false; Plot4Histograms(newDir + "/chi2", rdir, sdir, rcollname, scollname, "chi2", "chi2 distributions", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); //===== pull distributions plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="ptpull" ; titles[0]="p_{T} Pull"; plots[1]="qoverppull" ; titles[1]="q/p Pull" ; plots[2]="phipull" ; titles[2]="#phi Pull" ; plots[3]="thetapull" ; titles[3]="#theta Pull" ; plots[4]="dxypull" ; titles[4]="dxy Pull" ; plots[5]="dzpull" ; titles[5]="dz Pull" ; logy[0]=true; logy[1]=true; logy[2]=true; logy[3]=true; logy[4]=true; logy[5]=true; drawopt[0]="hist"; drawopt[1]="hist"; drawopt[2]="hist"; drawopt[3]="hist"; drawopt[4]="hist"; drawopt[5]="hist"; norm[0]= 2.; norm[1]= 2.; norm[2]= 2.; norm[3]= 2.; norm[4]= 2.; norm[5]= 2.; Plot6Histograms(newDir + "/pulls", rdir, sdir, rcollname, scollname, "pulls", "pull distributions", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); //===== residual distributions (projected on Y-axis from the 2D histos with residuals vs eta) plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="ptres_vs_eta" ; titles[0]="p_{T} Relative Residual"; plots[1]="etares_vs_eta" ; titles[1]="#eta Residual" ; plots[2]="phires_vs_eta" ; titles[2]="#phi Residual" ; plots[3]="thetaCotres_vs_eta" ; titles[3]="cot(#theta) Residual" ; plots[4]="dxyres_vs_eta" ; titles[4]="dxy Residual" ; plots[5]="dzres_vs_eta" ; titles[5]="dz Residual" ; logy[0]=true; logy[1]=true; logy[2]=true; logy[3]=true; logy[4]=true; logy[5]=true; drawopt[0]="hist"; drawopt[1]="hist"; drawopt[2]="hist"; drawopt[3]="hist"; drawopt[4]="hist"; drawopt[5]="hist"; norm[0]= 2.; norm[1]= 2.; norm[2]= 2.; norm[3]= 2.; norm[4]= 2.; norm[5]= 2.; Plot6Histograms(newDir + "/residuals", rdir, sdir, rcollname, scollname, "residuals", "residual distributions", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); //===== resolutions vs eta; pt relative bias vs eta plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="phires_vs_eta_Sigma" ; titles[0]="width #phi Residual vs #eta"; plots[1]="thetaCotres_vs_eta_Sigma" ; titles[1]="width cot(#theta) Residual vs #eta" ; plots[2]="dxyres_vs_eta_Sigma" ; titles[2]="width dxy Residual vs #eta" ; plots[3]="dzres_vs_eta_Sigma" ; titles[3]="width dz Residual vs #eta" ; plots[4]="ptres_vs_eta_Sigma" ; titles[4]="width p_{T} Relative Residual vs #eta" ; plots[5]="ptres_vs_eta_Mean" ; titles[5]="mean p_{T} Relative Residual vs #eta" ; logy[0]=true; logy[1]=true; logy[2]=true; logy[3]=true; logy[4]=true; logy[5]=false; Plot6Histograms(newDir + "/resol_eta", rdir, sdir, rcollname, scollname, "resol_eta", "resolutions vs eta", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); //===== resolutions vs pt; pt relative bias vs eta plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="phires_vs_pt_Sigma" ; titles[0]="width #phi Residual vs p_{T}"; plots[1]="thetaCotres_vs_pt_Sigma" ; titles[1]="width cot(#theta) Residual vs p_{T}" ; plots[2]="dxyres_vs_pt_Sigma" ; titles[2]="width dxy Residual vs p_{T}" ; plots[3]="dzres_vs_pt_Sigma" ; titles[3]="width dz Residual vs p_{T}" ; plots[4]="ptres_vs_pt_Sigma" ; titles[4]="width p_{T} Relative Residual vs p_{T}" ; plots[5]="ptres_vs_pt_Mean" ; titles[5]="mean p_{T} Relative Residual vs p_{T}" ; logx[0]=true; logx[1]=true; logx[2]=true; logx[3]=true; logx[4]=true; logx[5]=true; logy[0]=true; logy[1]=true; logy[2]=true; logy[3]=true; logy[4]=true; logy[5]=false; Plot6Histograms(newDir + "/resol_pt", rdir, sdir, rcollname, scollname, "resol_pt", "resolutions vs pt", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // ================= charge misid rate vs eta, pt, n.hits, PU plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="chargeMisId_vs_eta" ; titles[0]="Charge MisId rate vs #eta"; plots[1]="chargeMisId_vs_pt" ; titles[1]="Charge MisID rate vs p_{T}" ; plots[2]="chargeMisId_vs_hit" ; titles[2]="Charge MisID rate vs number of RecHits" ; plots[3]="chargeMisId_vs_pu" ; titles[3]="Charge MisID rate vs n.PU interactions" ; logx[0]=false; logx[1]=true; logx[2]=false; logx[3]=false; //maxx[0]= 0.; //maxx[1]= 0.; //maxx[2]= 0.; //maxx[3]= 100.; miny[0]= -0.0001; miny[1]= 0.; miny[2]= -0.0001; miny[3]= 0.; maxy[0]= 0.; maxy[1]= 0.; maxy[2]= 0.; maxy[3]= 0.; Plot4Histograms(newDir + "/chargeMisId", rdir, sdir, rcollname, scollname, "chargeMisId", "charge misId rate vs eta, pt, nhits, PU", refLabel, newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); } // if (!scollname.Contains("seeds")) //// Merge pdf files together and rename the merged pdf after the collection name TString mergefile = "merged_plots.pdf"; // File name where partial pdfs will be merged TString destfile = newDir + "/../" + myName + ".pdf"; // Destination file name TString gscommand = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + mergefile + " " + newDir + "/eff_eta_phi.pdf " + newDir + "/eff_pt.pdf " + newDir + "/eff_hits.pdf " + newDir + "/eff_pu.pdf " + newDir + "/chi2.pdf " + newDir + "/pulls.pdf " + newDir + "/residuals.pdf " + newDir + "/resol_eta.pdf " + newDir + "/resol_pt.pdf " + newDir + "/chargeMisId.pdf "; if (scollname.Contains("seeds")) gscommand = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + mergefile + " " + newDir + "/eff_eta_phi.pdf " + newDir + "/eff_pt.pdf " + newDir + "/eff_hits.pdf " + newDir + "/eff_pu.pdf "; cout << ">> Merging partial pdfs to " << mergefile << "..." << endl; if (DEBUG) cout << " ...with command \"" << gscommand << "\"" << endl; gSystem->Exec(gscommand); cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl; gSystem->Rename(mergefile, destfile); cout << ">> Deleting partial pdf files" << endl; gSystem->Exec("rm -rf "+newDir+"/*.pdf"); cout << " ... Done" << endl; } // end of "while loop" /////////////////////////////////////////////////////////////////////////////// // comparison plots of Muon and Track associators on the probeTracks TString dir_MABH_vs_TABH = newDirBase + "probeTrks_MABH_vs_TABH"; gSystem->mkdir(dir_MABH_vs_TABH, kTRUE); // in case of HLT or HeavyIons skip the following TString new_Sample_Name("NEW_LABEL"); if (TString(dataType) == "HLT" || new_Sample_Name.Contains("_HI")) { cout << ">> Removing the relval files from ROOT before closing..." << endl; gROOT->GetListOfFiles()->Remove(sfile); gROOT->GetListOfFiles()->Remove(rfile); if (DEBUG) { cout << " Exiting!" << endl; cerr << " Exiting!" << endl; } return; } if (DEBUG) { cout << " Comparing MuonAssociatorByHits with quickTrackAssociatorByHits on probeTracks (for the new release)" << endl; cerr << " Comparing MuonAssociatorByHits with quickTrackAssociatorByHits on probeTracks (for the new release)" << endl; } sfile->cd("DQMData/Run 1/Muons/Run summary/RecoMuonV/MuonTrack"); sdir = gDirectory; rcollname = "probeTrks_TkAsso"; scollname = "probeTrks"; // for releases before CMSSW_10_1_0_pre1 and New Muon Validation TString New_CMSSW_Release("NEW_RELEASE"); bool NEWprobeTrksNames = false; if (New_CMSSW_Release.Contains("CMSSW_9") || New_CMSSW_Release.Contains("CMSSW_10_0")) NEWprobeTrksNames=true; if (NEWprobeTrksNames) { rcollname = "NEWprobeTrks_TkAsso"; scollname = "NEWprobeTrks"; } const char* _refLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION quickTrackAssociatorByHits"); const char* _newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION MuonAssociatorByHits"); // efficiency and fake rate Vs eta and phi plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_eta" ; titles[0]="Efficiency vs #eta"; plots[1]="fakerate_vs_eta" ; titles[1]="Fake rate vs #eta" ; plots[2]="effic_vs_pt" ; titles[2]="Efficiency vs pt" ; plots[3]="fakerate_vs_pt" ; titles[3]="Fake rate vs pt" ; logx[0]=false; logx[1]=false; logx[2]=true; logx[3]=true; miny[0]=-0.0001; miny[1]=-0.0001; miny[2]=-0.0001; miny[3]=-0.0001; maxy[0]=1.09; maxy[1]=0.; maxy[2]=1.09; maxy[3]=0.; Plot4Histograms(dir_MABH_vs_TABH + "/eff_pt_eta", sdir, sdir, rcollname, scollname, "eff_pt_eta_MABHvsTABH", "Efficiency vs eta and pt - Muon vs Track Associator", _refLabel, _newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // efficiency and fake rate Vs N.hits and phi plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_hit" ; titles[0]="Efficiency vs Number of hits"; plots[1]="fakerate_vs_hit" ; titles[1]="Fake rate vs Number of hits" ; plots[2]="effic_vs_phi" ; titles[2]="Efficiency vs #phi" ; plots[3]="fakerate_vs_phi" ; titles[3]="Fake rate vs #phi" ; miny[0]=-0.0001; miny[1]=-0.0001; miny[2]=-0.0001; miny[3]=-0.0001; maxy[0]=1.09; maxy[1]=0.; maxy[2]=1.09; maxy[3]=0.; Plot4Histograms(dir_MABH_vs_TABH + "/eff_phi_hits", sdir, sdir, rcollname, scollname, "eff_phi_hits_MABHvsTABH", "Efficiency vs phi and N. hits - Muon vs Track Associator", _refLabel, _newLabel, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); // efficiency and fake rate Vs PU plotOptReset(logx,logy,doKolmo,norm,minx,maxx,miny,maxy,drawopt,plots,titles); plots[0]="effic_vs_pu" ; titles[0]="Efficiency vs n.PU interactions"; plots[1]="fakerate_vs_pu" ; titles[1]="Fake rate vs n.PU interactions" ; //maxx[0]= 100.; //maxx[1]= 100.; miny[0]= -0.0001; miny[1]= 0.; maxy[0]= 1.09; maxy[1]= 0.; PlotNHistograms(dir_MABH_vs_TABH + "/eff_pu", sdir, sdir, rcollname, scollname, "eff_pu_MABHvsTABH", "Efficiency vs N.PU interactions - Muon vs Track Associator", _refLabel, _newLabel, 4, plots, titles, drawopt, logy, logx, doKolmo, norm, minx, maxx, miny, maxy); //// Merge pdf files together and rename the merged pdf after the TString _destfile = newDirBase + "probeTrks_MABH_vs_TABH" + ".pdf"; // Destination file name TString _gscommand = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + _destfile + " " + dir_MABH_vs_TABH + "/eff_pt_eta.pdf " + dir_MABH_vs_TABH + "/eff_phi_hits.pdf " + dir_MABH_vs_TABH + "/eff_pu.pdf "; cout << ">> Merging partial pdfs to " << _destfile << "..." << endl; if (DEBUG) cout << " ...with command \"" << _gscommand << "\"" << endl; gSystem->Exec(_gscommand); cout << ">> Deleting partial pdf files" << endl; gSystem->Exec("rm -rf "+ dir_MABH_vs_TABH +"/eff_*.pdf"); cout << " ... Done" << endl; cout << ">> Removing the relval files from ROOT before closing..." << endl; gROOT->GetListOfFiles()->Remove(sfile); gROOT->GetListOfFiles()->Remove(rfile); if (DEBUG) { cout << " Exiting!" << endl; cerr << " Exiting!" << endl; } }
void RecoMuonValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { cout << ">> Starting RecoMuonValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python ==================== const char* dataType = "DATATYPE"; const char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION"); const char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION"); const char* fastSim = "IS_FSIM"; // ==== Initial settings and loads //gROOT->ProcessLine(".x HistoCompare_Tracks.C"); //gROOT ->Reset(); gROOT ->SetBatch(); gErrorIgnoreLevel = kWarning; // Get rid of the info messages SetGlobalStyle(); // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); delete gROOT->GetListOfFiles()->FindObject(newFile); // ==== Opening files, moving to the right branch and getting the list of sub-branches cout << ">> Openning file, moving to the right branch and getting sub-branches..." << endl; cout << ">> Finding sources..." << endl; TFile* sfile = new TFile(newFile); TList* sl = getListOfBranches(dataType, sfile, "RecoMuonV"); if (!sl) { cout << "ERROR: Could not find keys!!!" << endl; cerr << "ERROR: Could not find keys!!!" << endl; return; } TDirectory* sdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; cout << ">> Finding references..." << endl; TFile* rfile = new TFile(refFile); TList* rl = getListOfBranches(dataType, rfile, "RecoMuonV"); if (!rl) { cout << "ERROR: Could not find keys!!!" << endl; cerr << "ERROR: Could not find keys!!!" << endl; return; } TDirectory* rdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; Float_t maxPT; TString File = newFile; if (File.Contains("SingleMuPt1000") ||File.Contains("WpM")||File.Contains("ZpMM") ) maxPT=1400.; else if(File.Contains("SingleMuPt10")) {maxPT = 70.;} else if (File.Contains("SingleMuPt100")) {maxPT = 400.;} else maxPT = 400.; TIter iter_r( rl ); TIter iter_s( sl ); TKey* rKey = 0; TKey* sKey = 0; TString rcollname; TString scollname; while ( (rKey = (TKey*)iter_r()) ) { TString myName = rKey->GetName(); #ifdef DEBUG cout << "DEBUG: Checking key " << myName << endl; #endif rcollname = myName; sKey = (TKey*)iter_s(); if (!sKey) continue; scollname = sKey->GetName(); if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { cerr << "ERROR: Different collection names, please check: " << rcollname << " : " << scollname << endl; cout << "ERROR: Different collection names, please check: " << rcollname << " : " << scollname << endl; continue; } // ==== Now let's go for the plotting... cout << ">> Comparing plots in " << myName << "..." << endl; cerr << ">> Comparing plots in " << myName << "..." << endl; TString newDir("NEW_RELEASE/NEWSELECTION/NEW_LABEL/"); newDir+=myName; gSystem->mkdir(newDir,kTRUE); bool resolx = false; bool *resol = &resolx; bool logy [] = {false, false, false, false }; bool doKolmo [] = {true, true, true, true }; Double_t minx [] = {-1E100, -1E100, -1E100, 5., -1E100, -1E100 }; Double_t maxx [] = {-1E100, -1E100,-1E100, maxPT, -1E100, -1E100 }; Double_t norm [] = {0.,0.,-999.,-999.,0.,0.}; //Normalize to first histogram //===== reco muon distributions: GLB //TString baseh = Form("RecoMuon_MuonAssoc_Glb%s/",fastSim); const char* plots1[] = {"RecoMuon_MuonAssoc_Glb/ErrPt", "RecoMuon_MuonAssoc_Glb/ErrP", "RecoMuon_MuonAssoc_Glb/ErrPt_vs_Eta_Sigma", "RecoMuon_MuonAssoc_Glb/ErrPt_vs_Pt_Sigma"}; const char* plotst1[] = {"GlobalMuon(GLB) #Delta p_{T}/p_{T}", "GlobalMuon(GLB) #Delta p/p", "GlobalMuon(GLB) #Delta p_{T}/p_{T} vs #sigma(#eta)", "GlobalMuon(GLB) #Delta p_{T}/p_{T} vs #sigma(p_{T})"}; Plot4Histograms(newDir + "/muonRecoGlb.pdf", rdir, sdir, rcollname, scollname, "RecHistosGlb", "Distributions for GlobalMuons (GLB)", refLabel, newLabel, plots1, plotst1, logy, doKolmo, norm,resol,minx,maxx); //==== efficiencies and fractions GLB const char* plots2 [] = {"RecoMuon_MuonAssoc_Glb/EffP", "RecoMuon_MuonAssoc_Glb/EffEta", "RecoMuon_MuonAssoc_Glb/FractP", "RecoMuon_MuonAssoc_Glb/FractEta"}; const char* plotst2[] = {"GlobalMuon(GLB) #epsilon vs. p", "GlobalMuon(GLB) #epsilon vs. #eta", "GlobalMuon(GLB) fraction vs. p", "GlobalMuon(GLB) fraction vs. #eta"}; Double_t minx1 [] = {5., -1E100, 5., -1E100, -1E100, -1E100 }; Double_t maxx1 [] = {maxPT, -1E100,maxPT, -1E100, -1E100, -1E100 }; Double_t norm2 [] = {-999.,-999.,-999.,-999.,-999.,-999.}; //Normalize to first histogram Plot4Histograms(newDir + "/muonRecoGlbEff.pdf", rdir, sdir, rcollname, scollname, "RecEffHistosGlb", "Distributions for GlobalMuons (GLB), efficiencies and fractions", refLabel, newLabel, plots2, plotst2, logy, doKolmo,norm2,resol,minx1,maxx1); /* //===== reco muon distributions: GLBPF baseh = Form("RecoMuon_MuonAssoc_GlbPF%s/",fastSim); const char* plots3[] = {(baseh + "ErrPt").Data(), (baseh + "ErrP").Data(), (baseh + "ErrPt_vs_Eta_Sigma").Data(), (baseh + "ErrPt_vs_Pt_Sigma").Data()}; const char* plotst3[] = {"PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T}", "PFGlobalMuon(GLBPF) #Delta p/p", "PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T} vs #sigma(#eta)", "PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T} vs #sigma(p_{T})"}; Plot4Histograms(newDir + "/muonRecoGlbPF.pdf", rdir, sdir, rcollname, scollname, "RecHistosGlbPF", "Distributions for PFGlobalMuons (GLBPF)", refLabel, newLabel, plots3, plotst3, logy, doKolmo, norm); //==== efficiencies and fractions GLBPF const char* plots4 [] = {(baseh + "EffP").Data(), (baseh + "EffEta").Data(), (baseh + "FractP").Data(), (baseh + "FractEta").Data()}; const char* plotst4[] = {"PFGlobalMuon(GLBPF) #epsilon vs. p", "PFGlobalMuon(GLBPF) #epsilon vs. #eta", "PFGlobalMuon(GLBPF) fraction vs. p", "PFGlobalMuon(GLBPF) fraction vs. #eta"}; Plot4Histograms(newDir + "/muonRecoGlbPFEff.pdf", rdir, sdir, rcollname, scollname, "RecEffHistosGlbPF", "Distributions for PFGlobalMuons (GLBPF), efficiencies and fractions", refLabel, newLabel, plots4, plotst4, logy, doKolmo, norm); */ //===== reco muon distributions: STA //baseh = Form("RecoMuon_MuonAssoc_Sta%s/",fastSim); const char* plots5 [] = {"RecoMuon_MuonAssoc_Sta/ErrPt", "RecoMuon_MuonAssoc_Sta/ErrP", "RecoMuon_MuonAssoc_Sta/ErrPt_vs_Eta_Sigma", "RecoMuon_MuonAssoc_Sta/ErrPt_vs_Pt_Sigma"}; const char* plotst5[] = {"StandAloneMuon(STA) #Delta p_{T}/p_{T}", "StandAloneMuon(STA) #Delta p/p", "StandAloneMuon(STA) #Delta p_{T}/p_{T} vs #sigma(#eta)", "StandAloneMuon(STA) #Delta p_{T}/p_{T} vs #sigma(p_{T})"}; Plot4Histograms(newDir + "/muonRecoSta.pdf", rdir, sdir, rcollname, scollname, "RecHistosSta", "Distributions for StandAloneMuons (STA)", refLabel, newLabel, plots5, plotst5, logy, doKolmo, norm,resol, minx,maxx); //==== efficiencies and fractions STA const char* plots6 [] = {"RecoMuon_MuonAssoc_Sta/EffP", "RecoMuon_MuonAssoc_Sta/EffEta", "RecoMuon_MuonAssoc_Sta/FractP", "RecoMuon_MuonAssoc_Sta/FractEta"}; const char* plotst6[] = {"StandAloneMuon(STA) #epsilon vs. p", "StandAloneMuon(STA) #epsilon vs. #eta", "StandAloneMuon(STA) fraction vs. p", "StandAloneMuon(STA) fraction vs. #eta"}; Plot4Histograms(newDir + "/muonRecoStaEff.pdf", rdir, sdir, rcollname, scollname, "RecEffHistosSta", "Distributions for StandAloneMuons (STA), efficiencies and fractions", refLabel, newLabel, plots6, plotst6, logy, doKolmo, norm2,resol,minx1,maxx1); //===== reco muon distributions: TRK //baseh = Form("RecoMuon_MuonAssoc_Trk%s/",fastSim); const char* plots7 [] = {"RecoMuon_MuonAssoc_Trk/ErrPt", "RecoMuon_MuonAssoc_Trk/ErrP", "RecoMuon_MuonAssoc_Trk/ErrPt_vs_Eta_Sigma", "RecoMuon_MuonAssoc_Trk/ErrPt_vs_Pt_Sigma"}; const char* plotst7[] = {"TrackerMuon(TRK) #Delta p_{T}/p_{T}", "TrackerMuon(TRK) #Delta p/p", "TrackerMuon(TRK) #Delta p_{T}/p_{T} vs #sigma(#eta)", "TrackerMuon(TRK) #Delta p_{T}/p_{T} vs #sigma(p_{T})"}; Plot4Histograms(newDir + "/muonRecoTrk.pdf", rdir, sdir, rcollname, scollname, "RecHistosTrk", "Distributions for TrackerMuons (TRK)", refLabel, newLabel, plots7, plotst7, logy, doKolmo, norm,resol,minx,maxx); //==== efficiencies and fractions TRK const char* plots8 [] = {"RecoMuon_MuonAssoc_Trk/EffP", "RecoMuon_MuonAssoc_Trk/EffEta", "RecoMuon_MuonAssoc_Trk/FractP", "RecoMuon_MuonAssoc_Trk/FractEta"}; const char* plotst8[] = {"TrackerMuon(TRK) #epsilon vs. p", "TrackerMuon(TRK) #epsilon vs. #eta", "TrackerMuon(TRK) fraction vs. p", "TrackerMuon(TRK) fraction vs. #eta"}; Plot4Histograms(newDir + "/muonRecoTrkEff.pdf", rdir, sdir, rcollname, scollname, "RecEffHistosTrk", "Distributions for TrackerMuons (TRK), efficiencies and fractions", refLabel, newLabel, plots8, plotst8, logy, doKolmo, norm2,resol,minx1,maxx1); // //===== reco muon distributions: Tight Muons // //baseh = Form("RecoMuon_MuonAssoc_Tgt%s/",fastSim); const char* plots9 [] = {"RecoMuon_MuonAssoc_Tgt/ErrPt", "RecoMuon_MuonAssoc_Tgt/ErrP", "RecoMuon_MuonAssoc_Tgt/ErrPt_vs_Eta_Sigma", "RecoMuon_MuonAssoc_Tgt/ErrPt_vs_Pt_Sigma"}; const char* plotst9[] = {"Tight Muon #Delta p_{T}/p_{T}", "Tight Muon #Delta p/p", "Tight Muon #Delta p_{T}/p_{T} vs #sigma(#eta)", "Tight Muon #Delta p_{T}/p_{T} vs #sigma(p_{T})"}; Plot4Histograms(newDir + "/muonRecoTgt.pdf", rdir, sdir, rcollname, scollname, "RecHistosTgt", "Distributions for Tight Muons", refLabel, newLabel, plots9, plotst9, logy, doKolmo, norm,resol,minx,maxx); //==== efficiencies and fractions Tight Muons const char* plots10 [] = {"RecoMuon_MuonAssoc_Tgt/EffP", "RecoMuon_MuonAssoc_Tgt/EffEta", "RecoMuon_MuonAssoc_Tgt/FractP", "RecoMuon_MuonAssoc_Tgt/FractEta"}; const char* plotst10[] = {"Tight Muon #epsilon vs. p", "Tight Muon #epsilon vs. #eta", "Tight Muon fraction vs. p", "Tight Muon fraction vs. #eta"}; Plot4Histograms(newDir + "/muonRecoTgtEff.pdf", rdir, sdir, rcollname, scollname, "RecEffHistosTgt", "Distributions for Tight Muons, efficiencies and fractions", refLabel, newLabel, plots10, plotst10, logy, doKolmo, norm2,resol,minx1,maxx1); // // Merge pdf histograms together into larger files, and name them based on the collection names // TString mergefile = "merged_recomuonval.pdf"; // File name where partial pdfs will be merged TString destfile = newDir + "/../" + myName + ".pdf"; // Destination file name TString gscommand = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="+ mergefile + " " +newDir+"/muonRecoGlb.pdf " +newDir+"/muonRecoGlbEff.pdf " // +newDir+"/muonRecoGlbPF.pdf " // +newDir+"/muonRecoGlbPFEff.pdf " +newDir+"/muonRecoSta.pdf " +newDir+"/muonRecoStaEff.pdf " +newDir+"/muonRecoTrk.pdf " +newDir+"/muonRecoTrkEff.pdf " +newDir+"/muonRecoTgt.pdf " +newDir+"/muonRecoTgtEff.pdf "; cout << ">> Merging partial pdfs to " << mergefile << "..." << endl; #ifdef DEBUG cout << "DEBUG: ...with command \"" << gscommand << "\"" << endl; #endif gSystem->Exec(gscommand); cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl; gSystem->Rename(mergefile, destfile); cout << " ... Done" << endl; cout << ">> Deleting partial pdf files" << endl; gSystem->Exec("rm -r "+newDir); } // end of "while loop" cout << ">> Removing the relval files from ROOT before closing..." << endl; gROOT->GetListOfFiles()->Remove(sfile); gROOT->GetListOfFiles()->Remove(rfile); #ifdef DEBUG cout << "DEBUG: Exiting!" << endl; cerr << "DEBUG: Exiting!" << endl; #endif }
void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { cout << ">> Starting TrackValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python ==================== const char* dataType = "DATATYPE"; const char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION"); const char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION"); // ==== Initial settings and loads //gROOT->ProcessLine(".x HistoCompare_Tracks.C"); //gROOT ->Reset(); gROOT ->SetBatch(); gErrorIgnoreLevel = kWarning; // Get rid of the info messages SetGlobalStyle(); Float_t maxPT; TString File = newFile; if (File.Contains("SingleMuPt1000") ||File.Contains("WpM")||File.Contains("ZpMM") ) maxPT=1400.; else if (File.Contains("SingleMuPt100")) {maxPT = 400.;} else if(File.Contains("SingleMuPt10")) {maxPT = 70.;} else maxPT = 400.; bool ctf=1; bool resol = false; // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); delete gROOT->GetListOfFiles()->FindObject(newFile); // ==== Opening files, moving to the right branch and getting the list of sub-branches cout << ">> Openning file, moving to the right branch and getting sub-branches..." << endl; cout << ">> Finding sources..." << endl; TFile * sfile = new TFile(newFile); TList* sl = GetListOfBranches(dataType, sfile); if (!sl) { cout << "ERROR: Could not find keys!!!" << endl; cerr << "ERROR: Could not find keys!!!" << endl; return; } TDirectory* sdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; cout << ">> Finding references..." << endl; TFile * rfile = new TFile(refFile); TList* rl = GetListOfBranches(dataType, rfile); if (!rl) { cout << "ERROR: Could not find keys!!!" << endl; cerr << "ERROR: Could not find keys!!!" << endl; return; } TDirectory* rdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; //==== Find if the collection has muon associator or track associator cout << ">> Find if the collection has muon associator or track associator..." << endl; bool hasOnlyMuonAssociatorInRef = true; bool hasOnlyMuonAssociatorInSig = true; bool hasOnlyTrackAssociatorInRef = true; bool hasOnlyTrackAssociatorInSig = true; TIter iter_r0( rl ); TIter iter_s0( sl ); TKey* rKey = 0; TKey* sKey = 0; /*while ( (rKey = (TKey*)iter_r0()) ) { TString myName = rKey->GetName(); if ( !(myName.Contains("TkAsso")) && !(myName.Contains("MuonAssociation")) ) { hasOnlyMuonAssociatorInRef = false; } if ( !(myName.Contains("TkAsso")) && (myName.Contains("MuonAssociation")) ) { hasOnlyTrackAssociatorInRef = false; } } while ( (sKey = (TKey*)iter_s0()) ) { TString myName = sKey->GetName(); if ( !(myName.Contains("TkAsso")) && !(myName.Contains("MuonAssociation")) ) { hasOnlyMuonAssociatorInSig = false; } if ( !(myName.Contains("TkAsso")) && (myName.Contains("MuonAssociation")) ) { hasOnlyTrackAssociatorInSig = false; } } */ bool considerOnlyMuonAssociator = hasOnlyMuonAssociatorInRef || hasOnlyMuonAssociatorInSig; cout << " + Has Only Muon Associator (reference): " << hasOnlyMuonAssociatorInRef << endl; cout << " + Has Only Muon Associator (signal): " << hasOnlyMuonAssociatorInSig << endl; cout << " + Has Only Track Associator (reference): " << hasOnlyTrackAssociatorInRef << endl; cout << " + Has Only Track Associator (signal): " << hasOnlyTrackAssociatorInSig << endl; cout << " + Consider only Muon Associator: " << considerOnlyMuonAssociator << endl; //==== Iterate now over histograms and collections cout << ">> Iterating over histograms and collections..." << endl; TIter iter_r( rl ); TIter iter_s( sl ); TString scollname; TString rcollname; TKey *myNext2=0; while ( (rKey = (TKey*)iter_r()) ) { TString myName = rKey->GetName(); #ifdef DEBUG cout << "DEBUG: Checking key " << myName << endl; #endif /* if (!(myName.Contains("TkAsso")) && considerOnlyMuonAssociator && hasOnlyTrackAssociatorInRef) { if (myName.Contains("TrackAssociation")) myName.ReplaceAll("TrackAssociation","MuonAssociation"); else myName.ReplaceAll("Association","MuonAssociation"); } while (considerOnlyMuonAssociator && !(myName.Contains("TkAsso")) && !(myName.Contains("MuonAssociation")) ) { rKey = (TKey*)iter_r(); myName = rKey->GetName(); }*/ rcollname = myName; // ==> extractedGlobalMuons are in a different position wrt globalMuons: if (myNext2) { sKey = myNext2; myNext2 = 0; } else { sKey = (TKey*)iter_s(); } if (!sKey) continue; TString myName2 = sKey->GetName(); /* this was thought for when there are different names */ if (myName2 != myName) { myNext2 = (TKey*)iter_s(); TKey* myTemp = sKey; sKey = myNext2; myName2 = sKey->GetName(); myNext2 = myTemp; if(myName2 != myName) {myNext2 = (TKey*)iter_s(); TKey* myTemp = sKey; sKey = myNext2; myName2 = sKey->GetName(); myNext2 = myTemp; } } scollname=myName2; #ifdef DEBUG cout << "DEBUG: Comparing " << rcollname << " and " << scollname << endl; #endif if ( (myName == myName2) || (myName+"FS" == myName2) || (myName == myName2+"FS" ) || (myName.Contains("extractedGlobalMuons") && myName2.Contains("globalMuons") ) || (myName.Contains("globalMuons") && myName2.Contains("extractedGlobalMuons") ) ) { rcollname = rKey->GetName(); scollname = sKey->GetName(); } else if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { bool goodAsWell = false; if (rcollname.BeginsWith("StandAloneMuons_UpdAtVtx") && scollname.BeginsWith("StandAloneMuons_UpdAtVtx")) { if (rcollname.Contains("MuonAssociation")==scollname.Contains("MuonAssociation")){} goodAsWell = true; } if (rcollname.BeginsWith("hltL2Muons_UpdAtVtx") && scollname.BeginsWith("hltL2Muons_UpdAtVtx")) { if (rcollname.Contains("MuonAssociation")==scollname.Contains("MuonAssociation")){} goodAsWell = true; } if (rcollname.BeginsWith("hltL3Tk") && scollname.BeginsWith("hltL3Tk")) { if (rcollname.Contains("MuonAssociation")==scollname.Contains("MuonAssociation")){} goodAsWell = true; } // TString isGood = (goodAsWell? "good": "NOT good"); // cout << " -- The two collections: " << rcollname << " : " << scollname << " -> " << isGood << endl; if (! goodAsWell) { if (rcollname.Contains("SET") && !scollname.Contains("SET")) { while (rcollname.Contains("SET")) { if ((rKey = (TKey*)iter_r())) rcollname = rKey->GetName(); } } else if (scollname.Contains("SET") && !rcollname.Contains("SET")) { while (scollname.Contains("SET")) { if ((sKey = (TKey*)iter_s())) scollname = sKey->GetName(); } } if (rcollname.Contains("dyt") && !scollname.Contains("dyt")) { while (rcollname.Contains("dyt")) { if ((rKey = (TKey*)iter_r())) rcollname = rKey->GetName(); } } else if (scollname.Contains("dyt") && !rcollname.Contains("dyt")) { while (scollname.Contains("dyt")) { if ((sKey = (TKey*)iter_s())) scollname = sKey->GetName(); } } if (rcollname.Contains("refitted") && !scollname.Contains("refitted")) { while (rcollname.Contains("refitted")) { if ((rKey = (TKey*)iter_r())) rcollname = rKey->GetName(); } } else if (scollname.Contains("refitted") && !rcollname.Contains("refitted")) { while (scollname.Contains("refitted")) { if ((sKey = (TKey*)iter_s())) scollname = sKey->GetName(); } } if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { cout << " Different collection names, please check: " << rcollname << " : " << scollname << endl; continue; } else { // cout << " The NEW collections: " << rcollname << " : " << scollname << endl; myName = rKey->GetName(); } } } // ==== Now let's go for the plotting... // cout << ">> Comparing plots in " << myName << "..." << endl; //cerr << ">> Comparing plots in " << myName << "..." << endl; TString newDir("NEW_RELEASE/NEWSELECTION/NEW_LABEL/"); newDir+=myName; gSystem->mkdir(newDir,kTRUE); bool logyfalse [] = {false, false, false, false, false, false }; bool doKolmo [] = {true, true, true, true, true, true }; Double_t norm [] = {-999.,-999.,-999.,-999.,-999.,-999.}; Double_t minx [] = {-1E100, -1E100, 5., 5., -1E100, -1E100 }; Double_t maxx [] = {-1E100, -1E100, maxPT, maxPT, -1E100, -1E100 }; Double_t miny [] = {0.5, -1E100, 0, -1E100, 0.5, -1E100 }; Double_t maxy [] = {1.0125, -1E100, 1.025, -1E100, 1.0125, -1E100 }; ////////////////////////////////////// /////////// CTF ////////////////////// ////////////////////////////////////// if (ctf) { //===== building const char* plots0[] = {"effic", "fakerate", "efficPt", "fakeratePt"}; const char* plotsl0[] = {"efficiency vs #eta", "fakerate vs #eta", "efficiency vs Pt", "fakerate vs Pt"}; bool logy0 [] = {false, false, false, false }; Plot4Histograms(newDir + "/building.pdf", rdir, sdir, rcollname, scollname, "Seeds", "Efficiency Vs Pt and Vs #eta", refLabel, newLabel, plots0, plotsl0, logy0, doKolmo, norm,0,minx,maxx,miny,maxy); cout<<"HICE EL HISTO "<<endl; const char* plots1[] = { "effic_vs_hit", "fakerate_vs_hit","effic_vs_phi","fakerate_vs_phi"}; const char* plotsl1[] = { "efficiency vs hits", "fakerate vs hits","efficiency vs #phi","fakerate vs #phi"}; bool logy [] = {false, false, false, false }; Plot4Histograms(newDir + "/building2.pdf", rdir, sdir, rcollname, scollname, "Seeds2", "Efficiency vs hits and #phi", refLabel, newLabel, plots1, plotsl1, logy, doKolmo, norm, 0,minx,maxx,miny,maxy); cout<<"HICE EL HISTO "<<endl; // ====== hits and pt const char* plots2 [] = { "hits_eta", "hits", "num_simul_pT","num_reco_pT"}; const char* plotsl2 [] = { "nhits vs eta", "number of hits per track", "Number of Pt Simulated","Pt of Reco tracks"}; Double_t norm2 [] = {0.,0.,0.,0.,0.,0.}; // Double_t minx2 [] = {-1E100, -1E100, 0, 0, -1E100, -1E100 }; // Double_t maxx2 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t miny2 [] = {0.5, -1E100, 0., -1E100, 0.5, -1E100 }; // Double_t maxy2 [] = {1.0125, -1E100, -1E100, -1E100, -1E100, -1E100 }; Plot4Histograms(newDir + "/hitsAndPt.pdf", rdir, sdir, rcollname, scollname, "hits", "Pt", refLabel, newLabel, plots2, plotsl2, logyfalse, doKolmo, norm2,0,minx,maxx); //===== tuning bool logy3 [] = {false, true, false, true }; bool doKolmo3 [] = {true, true, true, true }; const char* plots3 [] = {"chi2","chi2_prob","chi2mean", "ptres_vs_eta_Mean"}; Plot4Histograms(newDir + "/tuning.pdf", rdir, sdir, rcollname, scollname, "IsoHistos2", "HCAL, HO Deposits", refLabel, newLabel, plots3, 0, logy3, doKolmo3,norm2,0); //===== pulls const char* plots4 [] = {"pullPt", "pullQoverp", "pullPhi", "pullTheta", "pullDxy","pullDz"}; const char* plotsl4 [] = {"Pt Pull", "Q/P Pull", "#Phi Pull", "#theta Pull", "Dxy Pull","Dz Pull"}; // Double_t minx4 [] = {-10, -10, -10, -10, -10, -10 }; // Double_t maxx4 [] = {10,10,10, 10, 10, 10 }; // Double_t miny4 [] = {0., -1E100, 0., -1E100, 0, -1E100 }; // Double_t maxy4 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; Plot6Histograms(newDir + "/Pulls.pdf", rdir, sdir, rcollname, scollname, "Pullsdis", "Pull Distributions", refLabel, newLabel, plots4, plotsl4, logyfalse, doKolmo, norm2,0); //===== residuals const char* plots5 [] = {"ptres_vs_eta", "etares_vs_eta", "phires_vs_eta", "cotThetares_vs_eta", "dxyres_vs_eta","dzres_vs_eta"}; const char* plotsl5 [] = {"p_{t} resolution", "#eta resolution", "#Phi resolution", "cot(#theta) resolution", "Dxy resolution","Dz resolution"}; // Double_t minx5 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t maxx5 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t miny5 [] = {0., -1E100, 0., -1E100, 0, -1E100 }; // Double_t maxy5 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; resol= true; Plot6Histograms(newDir + "/residuals.pdf", rdir, sdir, rcollname, scollname, "residualdis", "residuals vs Pt", refLabel, newLabel, plots5, plotsl5, logyfalse, doKolmo, norm2,&resol); //===== resolutions vs eta const char* plots6 [] = {"phires_vs_eta_Sigma", "cotThetares_vs_eta_Sigma", "dxyres_vs_eta_Sigma", "dzres_vs_eta_Sigma", "ptres_vs_eta_Sigma"}; const char* plotsl6 [] = {"#sigma(#delta #phi) [rad]", "#sigma(#delta cot(#theta))", "#sigma(#delta d_{0}) [cm]", "#sigma(#delta z_{0}) [cm]", "#sigma(#delta p_{t}/p_{t})"}; // Double_t minx6 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t maxx6 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t miny6 [] = {0., -1E100, 0., -1E100, 0, -1E100 }; // Double_t maxy6 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; Plot5Histograms(newDir + "/residualsEta.pdf", rdir, sdir, rcollname, scollname, "residualsdisEta", "residuals vs Eta", refLabel, newLabel, plots6, plotsl6, logyfalse, doKolmo, norm,0); // //===== mean values vs eta const char* plots7 [] = {"phires_vs_eta_Mean", "cotThetares_vs_eta_Mean", "dxyres_vs_eta_Mean", "dzres_vs_eta_Mean", "ptres_vs_eta_Mean"}; const char* plotsl7 [] = {"#delta #phi [rad]", "#delta cot(#theta)", "#delta d_{0} [cm]", "#delta z_{0} [cm]", "#delta p_{t}/p_{t}"}; // Double_t minx7 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t maxx7 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; // Double_t miny7 [] = {0., -1E100, 0., -1E100, 0, -1E100 }; // Double_t maxy7 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; Plot5Histograms(newDir + "/meanvaluesEta.pdf", rdir, sdir, rcollname, scollname, "meanvaluesEtadis", "mean values vs eta", refLabel, newLabel, plots7, plotsl7, logyfalse, doKolmo,norm,0); // //===== resolutions vs pt // const char* plots8 [] = {"phires_vs_pt_Sigma", "cotThetares_vs_pt_Sigma", "dxyres_vs_pt_Sigma", "dzres_vs_pt_Sigma", "ptres_vs_pt_Sigma","ptres_vs_pt_Sigma"}; const char* plotsl8 [] = {"#sigma(#delta #phi) [rad]", "#sigma(#delta cot(#theta))", "#sigma(#delta d_{0}) [cm]", "#sigma(#delta z_{0}) [cm]", "#sigma(#delta p_{t}/p_{t})"}; Double_t minx8 [] = {5., 5., 5., 5., 5., 5.}; Double_t maxx8 [] = {maxPT,maxPT,maxPT,maxPT,maxPT,maxPT}; // Double_t miny8 [] = {0., -1E100, 0., -1E100, 0, -1E100 }; // Double_t maxy8 [] = {-1E100, -1E100, -1E100, -1E100, -1E100, -1E100 }; Plot5Histograms(newDir + "/resolutionsPt.pdf", rdir, sdir, rcollname, scollname, "resolutionsPtdis", "resolution vs pt", refLabel, newLabel, plots8, plotsl8, logyfalse, doKolmo, norm,0,minx8,maxx8); } // end of "if CTF" //// Merge pdf histograms together into larger files, and name them based on the collection names TString mergefile = "merged_tracks.pdf"; // File name where partial pdfs will be merged TString destfile = newDir + "/../" + myName + ".pdf"; // Destination file name TString gscommand = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + mergefile + " " + newDir + "/building.pdf " + newDir + "/building2.pdf " + newDir + "/hitsAndPt.pdf " + newDir + "/tuning.pdf " + newDir + "/Pulls.pdf " + newDir + "/residuals.pdf " + newDir + "/residualsEta.pdf " + newDir + "/meanvaluesEta.pdf " + newDir + "/resolutionsPt.pdf "; cout << ">> Merging partial pdfs to " << mergefile << "..." << endl; #ifdef DEBUG cout << "DEBUG: ...with command \"" << gscommand << "\"" << endl; #endif gSystem->Exec(gscommand); cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl; gSystem->Rename(mergefile, destfile); cout << ">> Deleting partial pdf files" << endl; gSystem->Exec("rm -rf "+newDir); cout << " ... Done" << endl; } // end of "while loop" cout << ">> Removing the relval files from ROOT before closing..." << endl; gROOT->GetListOfFiles()->Remove(sfile); gROOT->GetListOfFiles()->Remove(rfile); #ifdef DEBUG cout << "DEBUG: Exiting!" << endl; cerr << "DEBUG: Exiting!" << endl; #endif }