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 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 }