From eb7792445fdee995743c161039101588c54c5b86 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 9 Jul 2021 13:38:26 +0200 Subject: [PATCH] Code format --- .../CaloTowers/test/macros/RelValMacro.C | 1659 +++++++++-------- .../test/macro/IsoValHistoPublisher.C | 215 ++- .../test/macro/RecoMuonValHistoPublisher.C | 442 +++-- .../test/macro/RecoValHistoPublisher.C | 249 ++- .../test/macro/SeedValHistoPublisher.C | 148 +- .../test/macro/TrackValHistoPublisher.C | 603 +++--- .../test/macro/new_TrackValHistoPublisher.C | 1145 +++++++----- 7 files changed, 2467 insertions(+), 1994 deletions(-) diff --git a/Validation/CaloTowers/test/macros/RelValMacro.C b/Validation/CaloTowers/test/macros/RelValMacro.C index ffccc71337d9b..bec48e04b3b32 100644 --- a/Validation/CaloTowers/test/macros/RelValMacro.C +++ b/Validation/CaloTowers/test/macros/RelValMacro.C @@ -28,870 +28,913 @@ #include #include -template -void prn(T1 s1, T2 s2) -{ - std::cout << "\t>> " << s1 << ": " << s2 << std::endl; +template +void prn(T1 s1, T2 s2) { + std::cout << "\t>> " << s1 << ": " << s2 << std::endl; } void RelValMacro(std::string seriesOfTubes); -void ProcessRelVal(TFile *ref_file, TFile *val_file, std::string ref_vers, std::string val_vers, std::string histName, std::string outLabel, int nRebin, double xAxisMin, double xAxisMax, double yAxisMin, double yAxisMax, - std::string dimSwitch, std::string statSwitch, std::string chi2Switch, std::string logSwitch, std::string ratioFlag, int refCol, int valCol, std::string xAxisTitle, std::string normFlag, std::string histName2 = ""); -template +void ProcessRelVal(TFile* ref_file, + TFile* val_file, + std::string ref_vers, + std::string val_vers, + std::string histName, + std::string outLabel, + int nRebin, + double xAxisMin, + double xAxisMax, + double yAxisMin, + double yAxisMax, + std::string dimSwitch, + std::string statSwitch, + std::string chi2Switch, + std::string logSwitch, + std::string ratioFlag, + int refCol, + int valCol, + std::string xAxisTitle, + std::string normFlag, + std::string histName2 = ""); +template void setObjProps(T obj); -class DirectoryFinder -{ +class DirectoryFinder { private: - std::map ptdMap; - TDirectory* findDirectory( TDirectory *target, std::string& s, int dig = 2); + std::map ptdMap; + TDirectory* findDirectory(TDirectory* target, std::string& s, int dig = 2); + public: - TDirectory* operator()(TDirectory *target, std::string& s); + TDirectory* operator()(TDirectory* target, std::string& s); } dfRef, dfVal; +void RelValMacro(std::string seriesOfTubes) { + //Split the string passed from the python3 driver + std::stringstream ss(seriesOfTubes); + std::string item; + std::vector props; + while (getline(ss, item, '|')) { + props.push_back(item); + } + std::string ref_vers = props[0]; + std::string val_vers = props[1]; + std::string rfname = props[2]; + std::string vfname = props[3]; + std::string histName = props[4]; + std::string ofileName = props[5]; + int nRebin = std::stoi(props[6]); + double xAxisMin = std::stod(props[7]); + double xAxisMax = std::stod(props[8]); + double yAxisMin = std::stod(props[9]); + double yAxisMax = std::stod(props[10]); + std::string dimFlag = props[11]; + std::string statFlag = props[12]; + std::string chi2Flag = props[13]; + std::string logFlag = props[14]; + std::string ratioFlag = props[15]; + int refCol = std::stoi(props[16]); + int valCol = std::stoi(props[17]); + std::string xAxisTitle = props[18]; + std::string histName2 = props[19]; + std::string normFlag = props[20]; + + if (strcmp(histName.c_str(), "HcalDigiTask/HcalDigiTask_signal_amplitude_HE") == 0) { + std::cout << "==================" << std::endl; + std::cout << xAxisMin << " " << xAxisMax << std::endl; + } + //Warning!!! This rootlogon hacks the root color pallate. This should probably be rewritten. + setColors(); + + TFile* Ref_File = new TFile(rfname.c_str()); + TFile* Val_File = new TFile(vfname.c_str()); + + if (Ref_File && Val_File) { + if (histName2 == "none") + histName2 = ""; + + //Make plot + ProcessRelVal(Ref_File, + Val_File, + ref_vers, + val_vers, + histName, + ofileName, + nRebin, + xAxisMin, + xAxisMax, + yAxisMin, + yAxisMax, + dimFlag, + statFlag, + chi2Flag, + logFlag, + ratioFlag, + refCol, + valCol, + xAxisTitle, + histName2, + normFlag); + } else { + if (!Ref_File) + std::cout << "Input root file \"" << rfname << "\" not found!!!" << std::endl; + if (!Val_File) + std::cout << "Input root file \"" << vfname << "\" not found!!!" << std::endl; + } + + // ProcessSubDetCT(Ref_File, Val_File, RelValStream, CT_nHist1, CT_nHist2, CT_nProf, CT_nHistTot, ref_vers, val_vers, harvest); + + return; +} -void RelValMacro(std::string seriesOfTubes) -{ - //Split the string passed from the python3 driver - std::stringstream ss(seriesOfTubes); - std::string item; - std::vector props; - while (getline(ss, item, '|')) { - props.push_back(item); +void ProcessRelVal(TFile* ref_file, + TFile* val_file, + std::string ref_vers, + std::string val_vers, + std::string histName, + std::string outLabel, + int nRebin, + double xAxisMin, + double xAxisMax, + double yAxisMin, + double yAxisMax, + std::string dimSwitch, + std::string statSwitch, + std::string chi2Switch, + std::string logSwitch, + std::string ratioFlag, + int refCol, + int valCol, + std::string xAxisTitle, + std::string histName2, + std::string normFlag) { + std::string NormHist = "HcalRecHitTask/N_HB"; + + //split directory off histName + int slashLoc = histName.rfind("/"); + std::string histDir = histName.substr(0, slashLoc); + if (slashLoc < histName.size() - 1) + histName = histName.substr(slashLoc + 1, histName.size()); + + int slashLocN = NormHist.rfind("/"); + std::string histDirN = NormHist.substr(0, slashLocN); + if (slashLocN < NormHist.size() - 1) + NormHist = NormHist.substr(slashLocN + 1, NormHist.size()); + + std::cout << "Processing \"" << histDir << "/" << histName << "\"" << std::endl; + + //Get objects from TFiles + TDirectory* refTD = dfRef(ref_file, histDir); + TObject* refObj = 0; + + TDirectory* refTDN = dfRef(ref_file, histDirN); + TObject* refObjN = 0; + + if (refTD) { + refObj = refTD->Get(histName.c_str()); + if (refObj) + refObj = refObj->Clone(); + } else { + std::cout << "Cannot find directory \"" << histDir << "\" in file \"" << ref_file->GetName() << "\"" << std::endl; + return; + } + if (!refObj) { + std::cout << "Cannot find histogram \"" << histDir << "/" << histName << "\" in file \"" << ref_file->GetName() + << "\"" << std::endl; + return; + } + + if (refTDN) { + refObjN = refTDN->Get(NormHist.c_str()); + if (refObjN) + refObjN = refObjN->Clone(); + } else { + std::cout << "Cannot find directory \"" << histDirN << "\" in file \"" << ref_file->GetName() << "\"" << std::endl; + } + if (!refObjN) { + std::cout << "Cannot find histogram \"" << histDirN << "/" << NormHist << "\" in file \"" << ref_file->GetName() + << "\"" << std::endl; + } + + TDirectory* valTD = dfVal(val_file, histDir); + TObject* valObj = 0; + TDirectory* valTDN = dfVal(val_file, histDirN); + TObject* valObjN = 0; + if (valTD) { + valObj = valTD->Get(histName.c_str()); + if (valObj) + valObj = valObj->Clone(); + } else { + std::cout << "Cannot find directory \"" << histDir << "\" in file \"" << val_file->GetName() << "\"" << std::endl; + return; + } + if (!valObj) { + std::cout << "Cannot find histogram \"" << histDir << "/" << histName << "\" in file \"" << val_file->GetName() + << "\"" << std::endl; + return; + } + + if (valTDN) { + valObjN = valTDN->Get(NormHist.c_str()); + if (valObjN) + valObjN = valObjN->Clone(); + } else { + std::cout << "Cannot find directory \"" << histDirN << "\" in file \"" << val_file->GetName() << "\"" << std::endl; + } + if (!valObjN) { + std::cout << "Cannot find histogram \"" << histDirN << "/" << NormHist << "\" in file \"" << val_file->GetName() + << "\"" << std::endl; + } + + //Try to continue processing even if N_HB is missing + //We only care if the ratio flag is set + //If we can't find any way to normalize the plots, unset the ratioflag + if (std::stoi(ratioFlag) == 1) { + if (!refTDN && !valTDN) { + std::cout << "Cannot find directory \"" << histDirN << "\" in either file \"" << std::endl; + ratioFlag = "0"; } - std::string ref_vers = props[0]; - std::string val_vers = props[1]; - std::string rfname = props[2]; - std::string vfname = props[3]; - std::string histName = props[4]; - std::string ofileName = props[5]; - int nRebin = std::stoi(props[6]); - double xAxisMin = std::stod(props[7]); - double xAxisMax = std::stod(props[8]); - double yAxisMin = std::stod(props[9]); - double yAxisMax = std::stod(props[10]); - std::string dimFlag = props[11]; - std::string statFlag = props[12]; - std::string chi2Flag = props[13]; - std::string logFlag = props[14]; - std::string ratioFlag = props[15]; - int refCol = std::stoi(props[16]); - int valCol = std::stoi(props[17]); - std::string xAxisTitle = props[18]; - std::string histName2 = props[19]; - std::string normFlag = props[20]; - - if(strcmp(histName.c_str(),"HcalDigiTask/HcalDigiTask_signal_amplitude_HE") == 0) { - - std::cout<<"=================="<Clone(); + std::cout << "Using histogram \"" << NormHist << "from file \"" << ref_file->GetName() << std::endl; + } else if (!refObjN) { + refObjN = valObjN->Clone(); + std::cout << "Using histogram \"" << NormHist << "from file \"" << val_file->GetName() << std::endl; } - //Warning!!! This rootlogon hacks the root color pallate. This should probably be rewritten. - setColors(); - - TFile* Ref_File = new TFile(rfname.c_str()); - TFile* Val_File = new TFile(vfname.c_str()); - - - if(Ref_File && Val_File) - { - - if(histName2 == "none") histName2 = ""; - - //Make plot - ProcessRelVal(Ref_File, Val_File, ref_vers, val_vers, histName, ofileName, nRebin, xAxisMin, xAxisMax, yAxisMin, yAxisMax, dimFlag, statFlag, chi2Flag, logFlag, ratioFlag, refCol, valCol, xAxisTitle, histName2, normFlag); - } - else - { - if(!Ref_File) std::cout << "Input root file \"" << rfname << "\" not found!!!" << std::endl; - if(!Val_File) std::cout << "Input root file \"" << vfname << "\" not found!!!" << std::endl; - } - - -// ProcessSubDetCT(Ref_File, Val_File, RelValStream, CT_nHist1, CT_nHist2, CT_nProf, CT_nHistTot, ref_vers, val_vers, harvest); + } // Make sure we can normalize ratio plots - return; -} + std::cout << "Loaded \"" << histDir << "/" << histName << "\"" << std::endl; -void ProcessRelVal(TFile *ref_file, TFile *val_file, std::string ref_vers, std::string val_vers, std::string histName, std::string outLabel, int nRebin, double xAxisMin, double xAxisMax, double yAxisMin, double yAxisMax, - std::string dimSwitch, std::string statSwitch, std::string chi2Switch, std::string logSwitch, std::string ratioFlag, int refCol, int valCol, std::string xAxisTitle, std::string histName2, std::string normFlag) -{ - std::string NormHist = "HcalRecHitTask/N_HB"; + //Format canvas + TCanvas* myc = 0; + if (dimSwitch.compare("PRwide") == 0) { + gStyle->SetPadLeftMargin(0.06); + gStyle->SetPadRightMargin(0.03); + myc = new TCanvas("myc", "", 1200, 600); + } else + myc = new TCanvas("myc", "", 800, 600); + // gStyle->SetOptStat(0); + myc->SetGrid(); - //split directory off histName - int slashLoc = histName.rfind("/"); - std::string histDir = histName.substr(0, slashLoc); - if(slashLoc < histName.size() - 1) histName = histName.substr(slashLoc + 1, histName.size()); + TPad *pad1, *pad2; - int slashLocN = NormHist.rfind("/"); - std::string histDirN = NormHist.substr(0, slashLocN); - if(slashLocN < NormHist.size() - 1) NormHist = NormHist.substr(slashLocN + 1, NormHist.size()); + // Ratio Flag - std::cout << "Processing \"" << histDir << "/" << histName << "\"" << std::endl; + float nRef = 1, nVal = 1; - //Get objects from TFiles - TDirectory *refTD = dfRef(ref_file, histDir); - TObject *refObj = 0; - - TDirectory *refTDN = dfRef(ref_file, histDirN); - TObject *refObjN = 0; - - if(refTD) - { - refObj = refTD->Get(histName.c_str()); - if(refObj) refObj = refObj->Clone(); - } - else - { - std::cout << "Cannot find directory \"" << histDir << "\" in file \"" << ref_file->GetName() << "\"" << std::endl; - return; - } - if(!refObj) - { - std::cout << "Cannot find histogram \"" << histDir << "/" << histName << "\" in file \"" << ref_file->GetName() << "\"" << std::endl; - return; - } + std::cout << "Ratio Flag: " << std::stoi(ratioFlag) << std::endl; + + if (std::stoi(ratioFlag) == 1) { + std::cout << "Histogram will include ratio" << std::endl; + + TH1* refN_HB = (TH1*)refObjN; + TH1* valN_HB = (TH1*)valObjN; + + nRef = refN_HB->Integral(); + nVal = valN_HB->Integral(); - if(refTDN) - { - refObjN = refTDN->Get(NormHist.c_str()); - if(refObjN) refObjN = refObjN->Clone(); + // Divide canvas into two pads + // myc->Divide(1,2,0,0); + pad1 = new TPad("pad1", "pad1", 0.0, 0.3, 1.0, 1.0, 0); + pad1->SetBottomMargin(1); // Upper and lower plots are joined (0) or separate (1) + pad1->SetGridx(); // Vertical grid + pad1->SetFillColor(kCyan - 10); //spandey + pad2 = new TPad("pad2", "pad2", 0.0, 0.03, 1.0, 0.3, 0); //spandey updated pad size + pad2->SetTopMargin(0); + pad2->SetBottomMargin(0.2); + pad2->SetGridx(); // vertical grid + pad2->SetGridy(); // horizontal grid + pad2->SetFillColor(kCyan - 10); //spandey + + pad1->Draw(); + pad2->Draw(); + + // float pad2width = pad2->GetWw(); + // float pad2height = pad2->GetWh() * pad2->GetAbsHNCD(); + // float x2pixels = 10; + // float y2pixels = 10; + // float x2size = x2pixels / pad2width; + // float y2size = y2pixels / pad2height; + + //Format pads + // myc->cd(1); + // pad1->cd(); + if (logSwitch.compare("Log") == 0 && dimSwitch.compare("2D") == 0) { + pad1->SetLogy(0); + pad1->SetLogz(1); + } else if (logSwitch.compare("Log") == 0) { + pad1->SetLogy(1); } - else - { - std::cout << "Cannot find directory \"" << histDirN << "\" in file \"" << ref_file->GetName() << "\"" << std::endl; + // pad2->cd(); + pad2->SetGridy(); + + // pad1->cd(); + } + + std::string xTitleCheck = xAxisTitle; + xTitleCheck = xTitleCheck.substr(1, 7); + + if (dimSwitch.compare("1D") == 0) { + //Get histograms from objects + TH1* ref_hist1 = (TH1*)refObj; + TH1* val_hist1 = (TH1*)valObj; + + // change what is embedded in DQM histos + setObjProps(ref_hist1); + setObjProps(val_hist1); + + //Rebin histograms -- has to be done first + if (nRebin != 1) { + ref_hist1->Rebin(nRebin); + val_hist1->Rebin(nRebin); } - if(!refObjN) - { - std::cout << "Cannot find histogram \"" << histDirN << "/" << NormHist << "\" in file \"" << ref_file->GetName() << "\"" << std::endl; + + TH1* ratio_hist1; + + // Ratio Flag + if (std::stoi(ratioFlag) == 1) { + //Let's normalize the val plot to have the same number of events as the ref plot + //But only if normFlag isn't tripped + if (normFlag.compare("Norm") == 0) + val_hist1->Scale(nRef / nVal); + + //Create Copies (Clones) to use in Ratio Plot + TH1* ref_hist1_clone = (TH1*)ref_hist1->Clone("ref_hist1_clone"); + TH1* val_hist1_clone = (TH1*)val_hist1->Clone("val_hist1_clone"); + + //Prepare clones for correct uncertainties + ref_hist1_clone->Sumw2(); + val_hist1_clone->Sumw2(); + + // Normalize (scale = n_ref/n_val) + //float n_ref = ref_hist1_clone->Integral(); + //float n_val = val_hist1_clone->Integral(); + //float scale = n_ref/n_val; + //val_hist1_clone->Scale(scale); + + //Create ratio histogram (val - ref)/ref + ratio_hist1 = (TH1*)val_hist1_clone; + ratio_hist1->Sumw2(); + ratio_hist1->Add(ref_hist1_clone, -1.); + ratio_hist1->Divide(ref_hist1_clone); + + // //Format Ratio Plot + // float pad2width = pad2->GetWw(); + // float pad2height = pad2->GetWh() * pad2->GetAbsHNDC(); + // float x2pixels = 100; + // float y2pixels = 15; + // float x2size = x2pixels / pad2width; + // float y2size = y2pixels / pad2height; + // + // TAxis* x2axis = ratio_hist1->GetXaxis(); + // TAxis* y2axis = ratio_hist1->GetYaxis(); + // + // x2axis->SetTitleOffset(2); + // x2axis->SetTitleSize(0.15); + // x2axis->SetLabelSize(x2size); + // + // y2axis->SetTitleOffset(0.3); + // y2axis->SetTitleSize(0.12); + // y2axis->SetRangeUser(0,2.5); + // y2axis->SetLabelSize(y2size); + + // Sanitizing axis inputs + //Min/Max Convetion: Default AxisMin = 0. Default AxisMax = -1. + //xAxis + if (xAxisMin == 0) + xAxisMin = ref_hist1->GetXaxis()->GetXmin(); + if (xAxisMax < 0) + xAxisMax = ref_hist1->GetXaxis()->GetXmax(); + + //Sanitize xAxis inputs + if (xAxisMin < ref_hist1->GetXaxis()->GetXmin()) + xAxisMin = ref_hist1->GetXaxis()->GetXmin(); + if (xAxisMax > ref_hist1->GetXaxis()->GetXmax()) + xAxisMax = ref_hist1->GetXaxis()->GetXmax(); + + ratio_hist1->SetTitle(""); + ratio_hist1->SetLineStyle(1); + ratio_hist1->SetMarkerStyle(1); + ratio_hist1->SetMarkerSize(0.02); + + //Format Ratio Plot + //lets get schwifty + float pad2width = pad2->GetWw(); + float pad2height = pad2->GetWh() * pad2->GetAbsHNDC(); + float x2pixels = 100; + float y2pixels = 15; + float x2size = x2pixels / pad2width; + float y2size = y2pixels / pad2height; + + TAxis* x2axis = ratio_hist1->GetXaxis(); + TAxis* y2axis = ratio_hist1->GetYaxis(); + + x2axis->SetTitleOffset(1.0); // Important for seeing x-axis title! + x2axis->SetTitleSize(0.1); //spandey + x2axis->SetLabelSize(x2size * 0.64); + x2axis->SetRangeUser(xAxisMin, xAxisMax); + + y2axis->SetTitle("(val - ref)/ref"); + y2axis->SetTitleOffset(0.3); + y2axis->SetTitleSize(0.12); + // y2axis->SetRangeUser(0,2.5); + y2axis->SetLabelSize(y2size); + y2axis->SetNdivisions(4); + + ratio_hist1->SetStats(kFALSE); } - TDirectory *valTD = dfVal(val_file, histDir); - TObject *valObj = 0; - TDirectory *valTDN = dfVal(val_file, histDirN); - TObject *valObjN = 0; - if(valTD) - { - valObj = valTD->Get(histName.c_str()); - if(valObj) valObj = valObj->Clone(); + //Set the colors, styles, titles, stat boxes and format axes for the histograms + ref_hist1->SetStats(kTRUE); + val_hist1->SetStats(kTRUE); + + if (statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) { + ref_hist1->SetStats(kFALSE); + val_hist1->SetStats(kFALSE); } - else - { - std::cout << "Cannot find directory \"" << histDir << "\" in file \"" << val_file->GetName() << "\"" << std::endl; - return; + + //Min/Max Convetion: Default AxisMin = 0. Default AxisMax = -1. + //xAxis + if (xAxisMin == 0) + xAxisMin = ref_hist1->GetXaxis()->GetXmin(); + if (xAxisMax < 0) + xAxisMax = ref_hist1->GetXaxis()->GetXmax(); + + //Sanitize xAxis inputs + if (xAxisMin < ref_hist1->GetXaxis()->GetXmin()) + xAxisMin = ref_hist1->GetXaxis()->GetXmin(); + if (xAxisMax > ref_hist1->GetXaxis()->GetXmax()) + xAxisMax = ref_hist1->GetXaxis()->GetXmax(); + + if (xAxisMax > 0 || xAxisMin != 0) { + ref_hist1->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); + val_hist1->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); } - if(!valObj) - { - std::cout << "Cannot find histogram \"" << histDir << "/" << histName << "\" in file \"" << val_file->GetName() << "\"" << std::endl; - return; + //yAxis + if (yAxisMin != 0) + ref_hist1->SetMinimum(yAxisMin); + if (yAxisMax > 0) + ref_hist1->SetMaximum(yAxisMax); + else if (ref_hist1->GetMaximum() < val_hist1->GetMaximum() && val_hist1->GetMaximum() > 0) { + if (logSwitch.compare("Log") == 0) + ref_hist1->SetMaximum(2 * val_hist1->GetMaximum()); + else + ref_hist1->SetMaximum(1.05 * val_hist1->GetMaximum()); } - if(valTDN) - { - valObjN = valTDN->Get(NormHist.c_str()); - if(valObjN) valObjN = valObjN->Clone(); + //Title + // if (xTitleCheck != "NoTitle") ref_hist1->GetXaxis()->SetTitle(xAxisTitle.c_str()); + ref_hist1->GetXaxis()->SetTitle(""); + if (xTitleCheck != "NoTitle" && std::stoi(ratioFlag) == 1) + ratio_hist1->GetXaxis()->SetTitle(xAxisTitle.c_str()); + if (xTitleCheck != "NoTitle" && std::stoi(ratioFlag) != 1) + ref_hist1->GetXaxis()->SetTitle(xAxisTitle.c_str()); + + //Different histo colors and styles + ref_hist1->SetTitle(""); + ref_hist1->SetLineColor(refCol); + ref_hist1->SetLineStyle(1); + ref_hist1->SetMarkerSize(0.02); + + val_hist1->SetTitle(""); + val_hist1->SetLineColor(valCol); + val_hist1->SetLineStyle(2); + val_hist1->SetMarkerSize(0.02); + if (statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) { + ref_hist1->SetLineWidth(2); + val_hist1->SetLineWidth(2); } - else - { - std::cout << "Cannot find directory \"" << histDirN << "\" in file \"" << val_file->GetName() << "\"" << std::endl; + + //Legend + TLegend* leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); + leg->SetBorderSize(2); + leg->SetFillStyle(1001); + leg->AddEntry(ref_hist1, ("CMSSW_" + ref_vers).c_str(), "l"); + leg->AddEntry(val_hist1, ("CMSSW_" + val_vers).c_str(), "l"); + + //It's time to draw (#yolo)! + if (chi2Switch.compare("Chi2") == 0) { + // Title Time + + //Draw and save histograms + if (std::stoi(ratioFlag) == 1) { + pad1->cd(); + } + ref_hist1->SetFillColor(40); //42 Originally, now 40 which is light brown + ref_hist1->Draw("hist"); + val_hist1->SetLineStyle(1); + if (statSwitch.compare("Statrv") == 0) + val_hist1->Draw("sames e0"); + else + val_hist1->Draw("same e0"); + + // Ratio Flag + if (std::stoi(ratioFlag) == 1) { + //Draw ratio + pad2->cd(); + //pad1->cd(); + ratio_hist1->Draw(); + pad1->cd(); + //pad2->cd(); + } + + //Get p-value from chi2 test + const float NCHI2MIN = 0.01; + + float pval; + char tempbuff[30]; + + pval = ref_hist1->Chi2Test(val_hist1); + + sprintf(tempbuff, "Chi2 p-value: %6.3E", pval); + + TPaveText* ptchi2 = new TPaveText(0.05, 0.92, 0.35, 0.99, "NDC"); + + if (pval > NCHI2MIN) + ptchi2->SetFillColor(kGreen); + else + ptchi2->SetFillColor(kRed); + + ptchi2->SetTextSize(0.03); + ptchi2->AddText(tempbuff); + ptchi2->Draw(); + } else { + // Title Time + + //Draw and save histograms + if (std::stoi(ratioFlag) == 1) { + pad1->cd(); + } + ref_hist1->Draw("hist"); + if (statSwitch.compare("Statrv") == 0) + val_hist1->Draw("hist sames"); + else + val_hist1->Draw("hist same"); + + // Ratio Flag + if (std::stoi(ratioFlag) == 1) { + //Draw ratio + pad2->cd(); + ratio_hist1->Draw(); + pad1->cd(); + } } - if(!valObjN) - { - std::cout << "Cannot find histogram \"" << histDirN << "/" << NormHist << "\" in file \"" << val_file->GetName() << "\"" << std::endl; + + //Stat Box where required + if (statSwitch.compare("Stat") == 0 || statSwitch.compare("Statrv") == 0) { + TPaveStats* ptstats_r = new TPaveStats(0.85, 0.86, 0.98, 0.98, "brNDC"); + ptstats_r->SetTextColor(refCol); + ref_hist1->GetListOfFunctions()->Add(ptstats_r); + ptstats_r->SetParent(ref_hist1->GetListOfFunctions()); + TPaveStats* ptstats_v = new TPaveStats(0.85, 0.74, 0.98, 0.86, "brNDC"); + ptstats_v->SetTextColor(valCol); + val_hist1->GetListOfFunctions()->Add(ptstats_v); + ptstats_v->SetParent(val_hist1->GetListOfFunctions()); + + ptstats_r->Draw(); + ptstats_v->Draw(); } - //Try to continue processing even if N_HB is missing - //We only care if the ratio flag is set - //If we can't find any way to normalize the plots, unset the ratioflag - if(std::stoi(ratioFlag) == 1){ - if(!refTDN && !valTDN) - { - std::cout << "Cannot find directory \"" << histDirN << "\" in either file \"" << std::endl; - ratioFlag = "0"; - } - - if(!refObjN && !valObjN) - { - std::cout << "Cannot find histogram \"" << histDirN << "/" << NormHist << "\" in either file \"" << std::endl; - ratioFlag = "0"; - } - else if(!valObjN) - { - valObjN = refObjN->Clone(); - std::cout << "Using histogram \"" << NormHist << "from file \"" << ref_file->GetName() << std::endl; - } - else if(!refObjN) - { - refObjN = valObjN->Clone(); - std::cout << "Using histogram \"" << NormHist << "from file \"" << val_file->GetName() << std::endl; - } - }// Make sure we can normalize ratio plots - - std::cout << "Loaded \"" << histDir << "/" << histName << "\"" << std::endl; - - //Format canvas - TCanvas *myc = 0; - if (dimSwitch.compare("PRwide") == 0) { - gStyle->SetPadLeftMargin(0.06); - gStyle->SetPadRightMargin(0.03); - myc = new TCanvas("myc", "", 1200, 600); - } else myc = new TCanvas("myc", "", 800, 600); -// gStyle->SetOptStat(0); - myc->SetGrid(); - - TPad *pad1, *pad2; - -// Ratio Flag - - float nRef =1, nVal = 1; - - std::cout << "Ratio Flag: " << std::stoi(ratioFlag) << std::endl; - - if(std::stoi(ratioFlag) == 1) { - - std::cout << "Histogram will include ratio" << std::endl; - - TH1* refN_HB = (TH1*)refObjN; - TH1* valN_HB = (TH1*)valObjN; - - nRef = refN_HB->Integral(); - nVal = valN_HB->Integral(); - - // Divide canvas into two pads - // myc->Divide(1,2,0,0); - pad1 = new TPad("pad1","pad1", 0.0, 0.3, 1.0, 1.0, 0); - pad1->SetBottomMargin(1); // Upper and lower plots are joined (0) or separate (1) - pad1->SetGridx(); // Vertical grid - pad1->SetFillColor(kCyan-10); //spandey - pad2 = new TPad("pad2","pad2", 0.0, 0.03, 1.0, 0.3, 0); //spandey updated pad size - pad2->SetTopMargin(0); - pad2->SetBottomMargin(0.2); - pad2->SetGridx(); // vertical grid - pad2->SetGridy(); // horizontal grid - pad2->SetFillColor(kCyan-10); //spandey - - pad1->Draw(); - pad2->Draw(); - - // float pad2width = pad2->GetWw(); - // float pad2height = pad2->GetWh() * pad2->GetAbsHNCD(); - // float x2pixels = 10; - // float y2pixels = 10; - // float x2size = x2pixels / pad2width; - // float y2size = y2pixels / pad2height; - - //Format pads - // myc->cd(1); - // pad1->cd(); - if(logSwitch.compare("Log") == 0 && dimSwitch.compare("2D") == 0) - { - pad1->SetLogy(0); - pad1->SetLogz(1); - } - else if(logSwitch.compare("Log") == 0) - { - pad1->SetLogy(1); - } -// pad2->cd(); - pad2->SetGridy(); - -// pad1->cd(); - + leg->Draw(); + + myc->SaveAs(outLabel.c_str()); + } + //Profiles not associated with histograms + else if (dimSwitch.compare("PR") == 0 || dimSwitch.compare("PRwide") == 0) { + //Get profiles from objects + TProfile* ref_prof = (TProfile*)refObj; + TProfile* val_prof = (TProfile*)valObj; + + // HACK to change what is embedded in DQM histos + setObjProps(ref_prof); + setObjProps(val_prof); + + //Legend + TLegend* leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); + leg->SetBorderSize(2); + leg->SetFillStyle(1001); + + //Ordinary profiles + if (dimSwitch.compare("PR") == 0) { + ref_prof->SetTitle(""); + ref_prof->SetErrorOption(""); + + val_prof->SetTitle(""); + val_prof->SetErrorOption(""); + + ref_prof->GetXaxis()->SetTitle(xAxisTitle.c_str()); + + if (statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) { + ref_prof->SetStats(kFALSE); + val_prof->SetStats(kFALSE); + } + + ref_prof->SetLineColor(41); + ref_prof->SetLineStyle(1); + ref_prof->SetLineWidth(1); + ref_prof->SetMarkerColor(41); + ref_prof->SetMarkerStyle(21); + ref_prof->SetMarkerSize(0.8); + + val_prof->SetLineColor(43); + val_prof->SetLineStyle(1); + val_prof->SetLineWidth(1); + val_prof->SetMarkerColor(43); + val_prof->SetMarkerStyle(22); + val_prof->SetMarkerSize(1.0); + + if (ref_prof->GetMaximum() < val_prof->GetMaximum() && val_prof->GetMaximum() > 0) { + if (logSwitch.compare("Log") == 0) + ref_prof->SetMaximum(2 * val_prof->GetMaximum()); + else + ref_prof->SetMaximum(1.05 * val_prof->GetMaximum()); + } + + ref_prof->Draw("hist pl"); + val_prof->Draw("hist pl same"); + + leg->AddEntry(ref_prof, ("CMSSW_" + ref_vers).c_str(), "pl"); + leg->AddEntry(val_prof, ("CMSSW_" + val_vers).c_str(), "pl"); + } //Wide profiles + else if (dimSwitch.compare("PRwide") == 0) { + char temp[128]; + sprintf(temp, "%s_px_v", ref_prof->GetName()); + TH1* ref_fp = ref_prof->ProjectionX(); + TH1* val_fp = val_prof->ProjectionX(temp); + + ref_fp->SetTitle(""); + val_fp->SetTitle(""); + + ref_fp->GetXaxis()->SetTitle(xAxisTitle.c_str()); + + if (statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) { + ref_fp->SetStats(kFALSE); + val_fp->SetStats(kFALSE); + } + + int nbins = ref_fp->GetNbinsX(); + for (int j = 1; j < nbins; j++) { + ref_fp->SetBinError(j, 0.); + val_fp->SetBinError(j, 0.); + } + ref_fp->SetLineWidth(0); + ref_fp->SetLineColor(0); // 5 yellow + ref_fp->SetLineStyle(1); + ref_fp->SetMarkerColor(2); + ref_fp->SetMarkerStyle(20); + ref_fp->SetMarkerSize(0.5); + + val_fp->SetLineWidth(0); + val_fp->SetLineColor(0); // 45 blue + val_fp->SetLineStyle(2); + val_fp->SetMarkerColor(4); + val_fp->SetMarkerStyle(22); + val_fp->SetMarkerSize(0.5); + + if (ref_fp->GetMaximum() < val_fp->GetMaximum() && val_fp->GetMaximum() > 0) { + if (logSwitch.compare("Log") == 0) + ref_fp->SetMaximum(2 * val_fp->GetMaximum()); + else + ref_fp->SetMaximum(1.05 * val_fp->GetMaximum()); + } + + ref_fp->Draw("p9"); + val_fp->Draw("p9same"); + + leg->AddEntry(ref_fp, ("CMSSW_" + ref_vers).c_str(), "lp"); + leg->AddEntry(val_fp, ("CMSSW_" + val_vers).c_str(), "lp"); } - - - std::string xTitleCheck = xAxisTitle; - xTitleCheck = xTitleCheck.substr(1, 7); - - if (dimSwitch.compare("1D") == 0) - { - //Get histograms from objects - TH1* ref_hist1 = (TH1*)refObj; - TH1* val_hist1 = (TH1*)valObj; - - // change what is embedded in DQM histos - setObjProps(ref_hist1); - setObjProps(val_hist1); - - //Rebin histograms -- has to be done first - if (nRebin != 1) { - ref_hist1->Rebin(nRebin); - val_hist1->Rebin(nRebin); - } - - TH1* ratio_hist1; - - // Ratio Flag - if(std::stoi(ratioFlag) == 1){ - //Let's normalize the val plot to have the same number of events as the ref plot - //But only if normFlag isn't tripped - if(normFlag.compare("Norm") == 0) - val_hist1->Scale(nRef/nVal); - - //Create Copies (Clones) to use in Ratio Plot - TH1* ref_hist1_clone = (TH1*)ref_hist1->Clone("ref_hist1_clone"); - TH1* val_hist1_clone = (TH1*)val_hist1->Clone("val_hist1_clone"); - - //Prepare clones for correct uncertainties - ref_hist1_clone->Sumw2(); - val_hist1_clone->Sumw2(); - - // Normalize (scale = n_ref/n_val) - //float n_ref = ref_hist1_clone->Integral(); - //float n_val = val_hist1_clone->Integral(); - //float scale = n_ref/n_val; - //val_hist1_clone->Scale(scale); - - //Create ratio histogram (val - ref)/ref - ratio_hist1 = (TH1*)val_hist1_clone; - ratio_hist1->Sumw2(); - ratio_hist1->Add(ref_hist1_clone,-1.); - ratio_hist1->Divide(ref_hist1_clone); - -// //Format Ratio Plot -// float pad2width = pad2->GetWw(); -// float pad2height = pad2->GetWh() * pad2->GetAbsHNDC(); -// float x2pixels = 100; -// float y2pixels = 15; -// float x2size = x2pixels / pad2width; -// float y2size = y2pixels / pad2height; -// -// TAxis* x2axis = ratio_hist1->GetXaxis(); -// TAxis* y2axis = ratio_hist1->GetYaxis(); -// -// x2axis->SetTitleOffset(2); -// x2axis->SetTitleSize(0.15); -// x2axis->SetLabelSize(x2size); -// -// y2axis->SetTitleOffset(0.3); -// y2axis->SetTitleSize(0.12); -// y2axis->SetRangeUser(0,2.5); -// y2axis->SetLabelSize(y2size); - -// Sanitizing axis inputs - //Min/Max Convetion: Default AxisMin = 0. Default AxisMax = -1. - //xAxis - if (xAxisMin == 0) xAxisMin = ref_hist1->GetXaxis()->GetXmin(); - if (xAxisMax < 0) xAxisMax = ref_hist1->GetXaxis()->GetXmax(); - - //Sanitize xAxis inputs - if (xAxisMin < ref_hist1->GetXaxis()->GetXmin()) xAxisMin = ref_hist1->GetXaxis()->GetXmin(); - if (xAxisMax > ref_hist1->GetXaxis()->GetXmax()) xAxisMax = ref_hist1->GetXaxis()->GetXmax(); - - ratio_hist1->SetTitle(""); - ratio_hist1->SetLineStyle(1); - ratio_hist1->SetMarkerStyle(1); - ratio_hist1->SetMarkerSize(0.02); - - //Format Ratio Plot - //lets get schwifty - float pad2width = pad2->GetWw(); - float pad2height = pad2->GetWh() * pad2->GetAbsHNDC() ; - float x2pixels = 100; - float y2pixels = 15; - float x2size = x2pixels / pad2width; - float y2size = y2pixels / pad2height; - - TAxis* x2axis = ratio_hist1->GetXaxis(); - TAxis* y2axis = ratio_hist1->GetYaxis(); - - - x2axis->SetTitleOffset(1.0); // Important for seeing x-axis title! - x2axis->SetTitleSize(0.1); //spandey - x2axis->SetLabelSize(x2size*0.64); - x2axis->SetRangeUser(xAxisMin, xAxisMax); - - y2axis->SetTitle("(val - ref)/ref"); - y2axis->SetTitleOffset(0.3); - y2axis->SetTitleSize(0.12); - // y2axis->SetRangeUser(0,2.5); - y2axis->SetLabelSize(y2size); - y2axis->SetNdivisions(4); - - ratio_hist1->SetStats(kFALSE); - - } - - //Set the colors, styles, titles, stat boxes and format axes for the histograms - ref_hist1->SetStats(kTRUE); - val_hist1->SetStats(kTRUE); - - if (statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) { - ref_hist1->SetStats(kFALSE); - val_hist1->SetStats(kFALSE); - } - - - //Min/Max Convetion: Default AxisMin = 0. Default AxisMax = -1. - //xAxis - if (xAxisMin == 0) xAxisMin = ref_hist1->GetXaxis()->GetXmin(); - if (xAxisMax < 0) xAxisMax = ref_hist1->GetXaxis()->GetXmax(); - - //Sanitize xAxis inputs - if (xAxisMin < ref_hist1->GetXaxis()->GetXmin()) xAxisMin = ref_hist1->GetXaxis()->GetXmin(); - if (xAxisMax > ref_hist1->GetXaxis()->GetXmax()) xAxisMax = ref_hist1->GetXaxis()->GetXmax(); - - if (xAxisMax > 0 || xAxisMin != 0) { - ref_hist1->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); - val_hist1->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); - - } - //yAxis - if (yAxisMin != 0) ref_hist1->SetMinimum(yAxisMin); - if (yAxisMax > 0) ref_hist1->SetMaximum(yAxisMax); - else if (ref_hist1->GetMaximum() < val_hist1->GetMaximum() && - val_hist1->GetMaximum() > 0) { - if (logSwitch.compare("Log") == 0) ref_hist1->SetMaximum(2 * val_hist1->GetMaximum()); - else ref_hist1->SetMaximum(1.05 * val_hist1->GetMaximum()); - } - - //Title -// if (xTitleCheck != "NoTitle") ref_hist1->GetXaxis()->SetTitle(xAxisTitle.c_str()); - ref_hist1->GetXaxis()->SetTitle(""); - if (xTitleCheck != "NoTitle" && std::stoi(ratioFlag) == 1) ratio_hist1->GetXaxis()->SetTitle(xAxisTitle.c_str()); - if (xTitleCheck != "NoTitle" && std::stoi(ratioFlag) != 1) ref_hist1->GetXaxis()->SetTitle(xAxisTitle.c_str()); - - //Different histo colors and styles - ref_hist1->SetTitle(""); - ref_hist1->SetLineColor(refCol); - ref_hist1->SetLineStyle(1); - ref_hist1->SetMarkerSize(0.02); - - val_hist1->SetTitle(""); - val_hist1->SetLineColor(valCol); - val_hist1->SetLineStyle(2); - val_hist1->SetMarkerSize(0.02); - if(statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) - { - ref_hist1->SetLineWidth(2); - val_hist1->SetLineWidth(2); - } - - //Legend - TLegend *leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); - leg->SetBorderSize(2); - leg->SetFillStyle(1001); - leg->AddEntry(ref_hist1, ("CMSSW_" + ref_vers).c_str(), "l"); - leg->AddEntry(val_hist1, ("CMSSW_" + val_vers).c_str(), "l"); - - //It's time to draw (#yolo)! - if (chi2Switch.compare("Chi2") == 0) { - - // Title Time - - //Draw and save histograms - if(std::stoi(ratioFlag) == 1){ - pad1->cd(); - } - ref_hist1->SetFillColor(40);//42 Originally, now 40 which is light brown - ref_hist1->Draw("hist"); - val_hist1->SetLineStyle(1); - if (statSwitch.compare("Statrv") == 0) val_hist1->Draw("sames e0"); - else val_hist1->Draw("same e0"); - - // Ratio Flag - if(std::stoi(ratioFlag) == 1){ - //Draw ratio - pad2->cd(); - //pad1->cd(); - ratio_hist1->Draw(); - pad1->cd(); - //pad2->cd(); - } - - //Get p-value from chi2 test - const float NCHI2MIN = 0.01; - - float pval; - char tempbuff[30]; - - pval = ref_hist1->Chi2Test(val_hist1); - - sprintf(tempbuff, "Chi2 p-value: %6.3E", pval); - - TPaveText* ptchi2 = new TPaveText(0.05, 0.92, 0.35, 0.99, "NDC"); - - if (pval > NCHI2MIN) ptchi2->SetFillColor(kGreen); - else ptchi2->SetFillColor(kRed); - - ptchi2->SetTextSize(0.03); - ptchi2->AddText(tempbuff); - ptchi2->Draw(); - } else { - - // Title Time - - - //Draw and save histograms - if(std::stoi(ratioFlag) == 1){ - pad1->cd(); - } - ref_hist1->Draw("hist"); - if (statSwitch.compare("Statrv") == 0) val_hist1->Draw("hist sames"); - else val_hist1->Draw("hist same"); - - - // Ratio Flag - if(std::stoi(ratioFlag) == 1){ - //Draw ratio - pad2->cd(); - ratio_hist1->Draw(); - pad1->cd(); - } - } - - //Stat Box where required - if (statSwitch.compare("Stat") == 0 || statSwitch.compare("Statrv") == 0) { - TPaveStats* ptstats_r = new TPaveStats(0.85, 0.86, 0.98, 0.98, "brNDC"); - ptstats_r->SetTextColor(refCol); - ref_hist1->GetListOfFunctions()->Add(ptstats_r); - ptstats_r->SetParent(ref_hist1->GetListOfFunctions()); - TPaveStats* ptstats_v = new TPaveStats(0.85, 0.74, 0.98, 0.86, "brNDC"); - ptstats_v->SetTextColor(valCol); - val_hist1->GetListOfFunctions()->Add(ptstats_v); - ptstats_v->SetParent(val_hist1->GetListOfFunctions()); - - ptstats_r->Draw(); - ptstats_v->Draw(); - } - - leg->Draw(); - - myc->SaveAs(outLabel.c_str()); + + leg->Draw(""); + + myc->SaveAs(outLabel.c_str()); + } //Timing Histograms (special: read two lines at once) + else if (dimSwitch.compare("TM") == 0) { + //split directory off histName + int slashLoc2 = histName2.rfind("/"); + std::string histDir2 = histName2.substr(0, slashLoc2); + if (slashLoc2 < histName2.size() - 1) + histName2 = histName2.substr(slashLoc2 + 1, histName2.size()); + + //Get objects from TFiles + TDirectory* refTD2 = dfRef(ref_file, histDir2); + TObject* refObj2 = refTD->Get(histName2.c_str())->Clone(); + TDirectory* valTD2 = dfVal(val_file, histDir2); + TObject* valObj2 = valTD->Get(histName2.c_str())->Clone(); + + TH2* ref_hist2 = (TH2*)refObj; + TProfile* ref_prof = (TProfile*)refObj2; + + ref_hist2->SetMarkerStyle(21); + ref_prof->SetMarkerStyle(21); + ref_hist2->SetMarkerSize(0.02); + ref_prof->SetMarkerSize(0.02); + + TH2* val_hist2 = (TH2F*)valObj; + TProfile* val_prof = (TProfile*)valObj2; + + val_hist2->SetMarkerStyle(21); + val_prof->SetMarkerStyle(21); + val_hist2->SetMarkerSize(0.02); + val_prof->SetMarkerSize(0.02); + + // HACK to change what is embedded in DQM histos + setObjProps(ref_hist2); + setObjProps(val_hist2); + + //Min/Max Convention: Default AxisMin = 0. Default AxisMax = -1. + //xAxis + if (xAxisMin == 0) + xAxisMin = ref_hist2->GetXaxis()->GetXmin(); + if (xAxisMax < 0) + xAxisMax = ref_hist2->GetXaxis()->GetXmax(); + + if (xAxisMax > 0 || xAxisMin != 0) { + ref_hist2->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); + val_hist2->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); } - //Profiles not associated with histograms - else if (dimSwitch.compare("PR") == 0 || dimSwitch.compare("PRwide") == 0) - { - //Get profiles from objects - TProfile* ref_prof = (TProfile*)refObj; - TProfile* val_prof = (TProfile*)valObj; - - // HACK to change what is embedded in DQM histos - setObjProps(ref_prof); - setObjProps(val_prof); - - //Legend - TLegend* leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); - leg->SetBorderSize(2); - leg->SetFillStyle(1001); - - //Ordinary profiles - if(dimSwitch.compare("PR") == 0) - { - ref_prof->SetTitle(""); - ref_prof->SetErrorOption(""); - - val_prof->SetTitle(""); - val_prof->SetErrorOption(""); - - ref_prof->GetXaxis()->SetTitle(xAxisTitle.c_str()); - - if (statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) { - ref_prof->SetStats(kFALSE); - val_prof->SetStats(kFALSE); - } - - ref_prof->SetLineColor(41); - ref_prof->SetLineStyle(1); - ref_prof->SetLineWidth(1); - ref_prof->SetMarkerColor(41); - ref_prof->SetMarkerStyle(21); - ref_prof->SetMarkerSize(0.8); - - val_prof->SetLineColor(43); - val_prof->SetLineStyle(1); - val_prof->SetLineWidth(1); - val_prof->SetMarkerColor(43); - val_prof->SetMarkerStyle(22); - val_prof->SetMarkerSize(1.0); - - if (ref_prof->GetMaximum() < val_prof->GetMaximum() && - val_prof->GetMaximum() > 0) { - if (logSwitch.compare("Log") == 0) ref_prof->SetMaximum(2 * val_prof->GetMaximum()); - else ref_prof->SetMaximum(1.05 * val_prof->GetMaximum()); - } - - ref_prof->Draw("hist pl"); - val_prof->Draw("hist pl same"); - - leg->AddEntry(ref_prof, ("CMSSW_" + ref_vers).c_str(), "pl"); - leg->AddEntry(val_prof, ("CMSSW_" + val_vers).c_str(), "pl"); - }//Wide profiles - else if(dimSwitch.compare("PRwide") == 0) - { - char temp[128]; - sprintf(temp, "%s_px_v", ref_prof->GetName()); - TH1* ref_fp = ref_prof->ProjectionX(); - TH1* val_fp = val_prof->ProjectionX(temp); - - ref_fp->SetTitle(""); - val_fp->SetTitle(""); - - ref_fp->GetXaxis()->SetTitle(xAxisTitle.c_str()); - - if(statSwitch.compare("Stat") != 0 && statSwitch.compare("Statrv") != 0) - { - ref_fp->SetStats(kFALSE); - val_fp->SetStats(kFALSE); - } - - int nbins = ref_fp->GetNbinsX(); - for (int j = 1; j < nbins; j++) { - ref_fp->SetBinError(j, 0.); - val_fp->SetBinError(j, 0.); - } - ref_fp->SetLineWidth(0); - ref_fp->SetLineColor(0); // 5 yellow - ref_fp->SetLineStyle(1); - ref_fp->SetMarkerColor(2); - ref_fp->SetMarkerStyle(20); - ref_fp->SetMarkerSize(0.5); - - val_fp->SetLineWidth(0); - val_fp->SetLineColor(0); // 45 blue - val_fp->SetLineStyle(2); - val_fp->SetMarkerColor(4); - val_fp->SetMarkerStyle(22); - val_fp->SetMarkerSize(0.5); - - if (ref_fp->GetMaximum() < val_fp->GetMaximum() && - val_fp->GetMaximum() > 0) { - if (logSwitch.compare("Log") == 0) ref_fp->SetMaximum(2 * val_fp->GetMaximum()); - else ref_fp->SetMaximum(1.05 * val_fp->GetMaximum()); - } - - ref_fp->Draw("p9"); - val_fp->Draw("p9same"); - - leg->AddEntry(ref_fp, ("CMSSW_" + ref_vers).c_str(), "lp"); - leg->AddEntry(val_fp, ("CMSSW_" + val_vers).c_str(), "lp"); - - } - - leg->Draw(""); - - myc->SaveAs(outLabel.c_str()); - }//Timing Histograms (special: read two lines at once) - else if (dimSwitch.compare("TM") == 0) - { - //split directory off histName - int slashLoc2 = histName2.rfind("/"); - std::string histDir2 = histName2.substr(0, slashLoc2); - if(slashLoc2 < histName2.size() - 1) histName2 = histName2.substr(slashLoc2 + 1, histName2.size()); - - //Get objects from TFiles - TDirectory *refTD2 = dfRef(ref_file, histDir2); - TObject *refObj2 = refTD->Get(histName2.c_str())->Clone(); - TDirectory *valTD2 = dfVal(val_file, histDir2); - TObject *valObj2 = valTD->Get(histName2.c_str())->Clone(); - - TH2* ref_hist2 = (TH2*)refObj; - TProfile* ref_prof = (TProfile*)refObj2; - - ref_hist2->SetMarkerStyle(21); - ref_prof ->SetMarkerStyle(21); - ref_hist2->SetMarkerSize(0.02); - ref_prof ->SetMarkerSize(0.02); - - TH2* val_hist2 = (TH2F*)valObj; - TProfile* val_prof = (TProfile*)valObj2; - - val_hist2->SetMarkerStyle(21); - val_prof ->SetMarkerStyle(21); - val_hist2->SetMarkerSize(0.02); - val_prof ->SetMarkerSize(0.02); - - // HACK to change what is embedded in DQM histos - setObjProps(ref_hist2); - setObjProps(val_hist2); - - //Min/Max Convention: Default AxisMin = 0. Default AxisMax = -1. - //xAxis - if (xAxisMin == 0) xAxisMin = ref_hist2->GetXaxis()->GetXmin(); - if (xAxisMax < 0) xAxisMax = ref_hist2->GetXaxis()->GetXmax(); - - if (xAxisMax > 0 || xAxisMin != 0) { - ref_hist2->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); - val_hist2->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); - } - //yAxis - if (yAxisMin != 0) ref_hist2->SetMinimum(yAxisMin); - if (yAxisMax > 0) ref_hist2->SetMaximum(yAxisMax); - else if (ref_hist2->GetMaximum() < val_hist2->GetMaximum() && - val_hist2->GetMaximum() > 0) { - if (logSwitch == "Log") ref_hist2->SetMaximum(2 * val_hist2->GetMaximum()); - else ref_hist2->SetMaximum(1.05 * val_hist2->GetMaximum()); - } - - //AF - if (yAxisMax > 0 || yAxisMin != 0) { - ref_hist2->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); - val_hist2->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); - } - - //Legend - TLegend* leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); - leg->SetBorderSize(2); - leg->SetFillStyle(1001); - - ref_hist2->GetXaxis()->SetTitle(xAxisTitle.c_str()); - ref_hist2->SetStats(kFALSE); - - ref_hist2->SetTitle(""); - val_hist2->SetTitle(""); - - ref_hist2->SetMarkerColor(refCol); // rose - ref_hist2->Draw(); - ref_prof->SetLineColor(41); - ref_prof->Draw("same"); - - val_hist2->SetMarkerColor(valCol); - val_hist2->Draw("same"); - val_prof->SetLineColor(45); - val_prof->Draw("same"); - - leg->AddEntry(ref_prof, ("CMSSW_" + ref_vers).c_str(), "pl"); - leg->AddEntry(val_prof, ("CMSSW_" + val_vers).c_str(), "pl"); - - leg->Draw(""); - - myc->SaveAs(outLabel.c_str()); - - if(refObj2) delete refObj2; - if(valObj2) delete valObj2; + //yAxis + if (yAxisMin != 0) + ref_hist2->SetMinimum(yAxisMin); + if (yAxisMax > 0) + ref_hist2->SetMaximum(yAxisMax); + else if (ref_hist2->GetMaximum() < val_hist2->GetMaximum() && val_hist2->GetMaximum() > 0) { + if (logSwitch == "Log") + ref_hist2->SetMaximum(2 * val_hist2->GetMaximum()); + else + ref_hist2->SetMaximum(1.05 * val_hist2->GetMaximum()); } - else if(dimSwitch.compare("2D") == 0) - { - - myc->SetGrid(0, 0); - - //Get histograms from objects - TH2* ref_hist2D = (TH2*)refObj; - TH2* val_hist2D = (TH2*)valObj; - - ref_hist2D->SetStats(kFALSE); - val_hist2D->SetStats(kFALSE); - - // HACK to change what is embedded in DQM histos - setObjProps(ref_hist2D); - setObjProps(val_hist2D); - - ref_hist2D->SetTitle(""); - val_hist2D->SetTitle(""); - - // special zoom on HB/HE depth1 - //if (n2D == 1) { - // ref_hist2D->GetXaxis()->SetRangeUser(-29., 28.); - // val_hist2D->GetXaxis()->SetRangeUser(-29., 28.); - //} - - //Min/Max Convetion: Default AxisMin = 0. Default AxisMax = -1. - //xAxis - if (xAxisMax > 0 || xAxisMin != 0) { - ref_hist2D->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); - val_hist2D->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); - } - //yAxis - if (yAxisMax > 0 || yAxisMin != 0) { - ref_hist2D->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); - val_hist2D->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); - } - //Set bin minimum to 0 - ref_hist2D->SetMinimum(0.0); - val_hist2D->SetMinimum(0.0); - - TLegend *leg1 = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); - leg1->SetBorderSize(2); - leg1->SetFillStyle(1001); - leg1->AddEntry(ref_hist2D, ("CMSSW_" + ref_vers).c_str(), "l"); - - if (xTitleCheck != "NoTitle") ref_hist2D->GetXaxis()->SetTitle(xAxisTitle.c_str()); - ref_hist2D->Draw("colz"); - leg1->Draw(); - myc->SaveAs(("ref_" + outLabel).c_str()); - - TLegend *leg2 = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); - leg2->SetBorderSize(2); - leg2->SetFillStyle(1001); - leg2->AddEntry(val_hist2D, ("CMSSW_" + val_vers).c_str(), "l"); - - if (xTitleCheck != "NoTitle") val_hist2D->GetXaxis()->SetTitle(xAxisTitle.c_str()); - val_hist2D->Draw("colz"); - leg2->Draw(); - myc->SaveAs(("val_" + outLabel).c_str()); + + //AF + if (yAxisMax > 0 || yAxisMin != 0) { + ref_hist2->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); + val_hist2->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); } - if(myc) delete myc; - if(refObj) delete refObj; - if(valObj) delete valObj; + //Legend + TLegend* leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); + leg->SetBorderSize(2); + leg->SetFillStyle(1001); - return; -} + ref_hist2->GetXaxis()->SetTitle(xAxisTitle.c_str()); + ref_hist2->SetStats(kFALSE); -TDirectory* DirectoryFinder::operator()(TDirectory *target, std::string& s) -{ - if(ptdMap.find(s) == ptdMap.end()) return (ptdMap[s] = findDirectory(target, s)); - else return ptdMap[s]; -} + ref_hist2->SetTitle(""); + val_hist2->SetTitle(""); + + ref_hist2->SetMarkerColor(refCol); // rose + ref_hist2->Draw(); + ref_prof->SetLineColor(41); + ref_prof->Draw("same"); -TDirectory* DirectoryFinder::findDirectory( TDirectory *target, std::string& s, int dig) -{ - TDirectory *retval = 0; + val_hist2->SetMarkerColor(valCol); + val_hist2->Draw("same"); + val_prof->SetLineColor(45); + val_prof->Draw("same"); - // loop over all keys in this directory - TIter nextkey(target->GetListOfKeys()); - TKey *key, *oldkey=0; - while((key = (TKey*)nextkey())) - { + leg->AddEntry(ref_prof, ("CMSSW_" + ref_vers).c_str(), "pl"); + leg->AddEntry(val_prof, ("CMSSW_" + val_vers).c_str(), "pl"); - //std::cout << "Found " << key->ReadObj()->GetName() << std::endl; + leg->Draw(""); - //keep only the highest cycle number for each key - if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue; + myc->SaveAs(outLabel.c_str()); - // read object from file -// target->cd(); - TObject *obj = key->ReadObj(); -// obj->Print(); + if (refObj2) + delete refObj2; + if (valObj2) + delete valObj2; + } else if (dimSwitch.compare("2D") == 0) { + myc->SetGrid(0, 0); - if(obj->IsA()->InheritsFrom(TDirectory::Class())) - { - // it's a subdirectory - //std::cout << "Found subdirectory " << obj->GetName() << std::endl; + //Get histograms from objects + TH2* ref_hist2D = (TH2*)refObj; + TH2* val_hist2D = (TH2*)valObj; - if(strcmp(s.c_str(), obj->GetName()) == 0) return (TDirectory*)obj; + ref_hist2D->SetStats(kFALSE); + val_hist2D->SetStats(kFALSE); - if((retval = findDirectory((TDirectory*)obj, s, dig-1))) break; + // HACK to change what is embedded in DQM histos + setObjProps(ref_hist2D); + setObjProps(val_hist2D); - } else if(dig < 1){ - break; - } + ref_hist2D->SetTitle(""); + val_hist2D->SetTitle(""); + // special zoom on HB/HE depth1 + //if (n2D == 1) { + // ref_hist2D->GetXaxis()->SetRangeUser(-29., 28.); + // val_hist2D->GetXaxis()->SetRangeUser(-29., 28.); + //} + + //Min/Max Convetion: Default AxisMin = 0. Default AxisMax = -1. + //xAxis + if (xAxisMax > 0 || xAxisMin != 0) { + ref_hist2D->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); + val_hist2D->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax); + } + //yAxis + if (yAxisMax > 0 || yAxisMin != 0) { + ref_hist2D->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); + val_hist2D->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax); } + //Set bin minimum to 0 + ref_hist2D->SetMinimum(0.0); + val_hist2D->SetMinimum(0.0); + + TLegend* leg1 = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); + leg1->SetBorderSize(2); + leg1->SetFillStyle(1001); + leg1->AddEntry(ref_hist2D, ("CMSSW_" + ref_vers).c_str(), "l"); + + if (xTitleCheck != "NoTitle") + ref_hist2D->GetXaxis()->SetTitle(xAxisTitle.c_str()); + ref_hist2D->Draw("colz"); + leg1->Draw(); + myc->SaveAs(("ref_" + outLabel).c_str()); + + TLegend* leg2 = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC"); + leg2->SetBorderSize(2); + leg2->SetFillStyle(1001); + leg2->AddEntry(val_hist2D, ("CMSSW_" + val_vers).c_str(), "l"); + + if (xTitleCheck != "NoTitle") + val_hist2D->GetXaxis()->SetTitle(xAxisTitle.c_str()); + val_hist2D->Draw("colz"); + leg2->Draw(); + myc->SaveAs(("val_" + outLabel).c_str()); + } + + if (myc) + delete myc; + if (refObj) + delete refObj; + if (valObj) + delete valObj; + + return; +} - return retval; +TDirectory* DirectoryFinder::operator()(TDirectory* target, std::string& s) { + if (ptdMap.find(s) == ptdMap.end()) + return (ptdMap[s] = findDirectory(target, s)); + else + return ptdMap[s]; } -template -void setObjProps(T obj) -{ - obj->GetXaxis()->SetLabelSize(0.04); - obj->GetYaxis()->SetLabelSize(0.04); - obj->GetXaxis()->SetTitleSize(0.045); +TDirectory* DirectoryFinder::findDirectory(TDirectory* target, std::string& s, int dig) { + TDirectory* retval = 0; + + // loop over all keys in this directory + TIter nextkey(target->GetListOfKeys()); + TKey *key, *oldkey = 0; + while ((key = (TKey*)nextkey())) { + //std::cout << "Found " << key->ReadObj()->GetName() << std::endl; + + //keep only the highest cycle number for each key + if (oldkey && !strcmp(oldkey->GetName(), key->GetName())) + continue; + + // read object from file + // target->cd(); + TObject* obj = key->ReadObj(); + // obj->Print(); - obj->GetXaxis()->SetTickLength(-0.015); - obj->GetYaxis()->SetTickLength(-0.015); + if (obj->IsA()->InheritsFrom(TDirectory::Class())) { + // it's a subdirectory + //std::cout << "Found subdirectory " << obj->GetName() << std::endl; - obj->GetXaxis()->SetLabelOffset(0.02); - obj->GetYaxis()->SetLabelOffset(0.02); - - obj->GetXaxis()->SetTitleOffset(1.3); + if (strcmp(s.c_str(), obj->GetName()) == 0) + return (TDirectory*)obj; + + if ((retval = findDirectory((TDirectory*)obj, s, dig - 1))) + break; + + } else if (dig < 1) { + break; + } + } + + return retval; } +template +void setObjProps(T obj) { + obj->GetXaxis()->SetLabelSize(0.04); + obj->GetYaxis()->SetLabelSize(0.04); + obj->GetXaxis()->SetTitleSize(0.045); -BOOST_PYTHON_MODULE(RelValMacro) -{ - using namespace boost::python; - def("RelValMacro", RelValMacro); + obj->GetXaxis()->SetTickLength(-0.015); + obj->GetYaxis()->SetTickLength(-0.015); + + obj->GetXaxis()->SetLabelOffset(0.02); + obj->GetYaxis()->SetLabelOffset(0.02); + + obj->GetXaxis()->SetTitleOffset(1.3); } +BOOST_PYTHON_MODULE(RelValMacro) { + using namespace boost::python; + def("RelValMacro", RelValMacro); +} diff --git a/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C b/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C index d4f97f5042be7..6c515b057c442 100644 --- a/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C @@ -6,7 +6,7 @@ // Uncomment the following line for some extra debug information // #define DEBUG -void IsoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { +void IsoValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { cout << ">> Starting IsoValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python3 ==================== @@ -14,21 +14,18 @@ void IsoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="RE 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 + gROOT->SetBatch(); + gErrorIgnoreLevel = kWarning; // Get rid of the info messages SetGlobalStyle(); - - - // ==== Some cleaning... is this needed? + + // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); - delete gROOT->GetListOfFiles()->FindObject(newFile); - + 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; @@ -41,10 +38,9 @@ void IsoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="RE cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* sdir = gDirectory; + 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); @@ -54,122 +50,156 @@ void IsoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="RE cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* rdir = gDirectory; + TDirectory* rdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; - - - + //==== Iterate now over histograms and collections cout << ">> Iterating over histograms and collections..." << endl; - TIter iter_r( rl ); - TIter iter_s( sl ); + TIter iter_r(rl); + TIter iter_s(sl); TKey* rKey = 0; TKey* sKey = 0; TString rcollname; TString scollname; - while ( (rKey = (TKey*)iter_r()) ) { + 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; + if (!sKey) + continue; scollname = sKey->GetName(); - if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { + 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; + 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 logy [] = {false, false, false, false }; - bool doKolmo [] = {true, true, true, true }; - Double_t norm [] = {0.,0.,0.,0.}; + newDir += myName; + gSystem->mkdir(newDir, kTRUE); + + bool logy[] = {false, false, false, false}; + bool doKolmo[] = {true, true, true, true}; + Double_t norm[] = {0., 0., 0., 0.}; //===== Tracker, ECAL Deposits - const char* plots1 [] = {"sumPt", "emEt", "sumPt_cd", "emEt_cd"}; + const char* plots1[] = {"sumPt", "emEt", "sumPt_cd", "emEt_cd"}; Plot4Histograms(newDir + "/muonIso1", - rdir, sdir, - rcollname, scollname, - "IsoHistos1", "Tracker, ECAL Deposits", - refLabel, newLabel, - plots1, 0, - logy, doKolmo, norm); - + rdir, + sdir, + rcollname, + scollname, + "IsoHistos1", + "Tracker, ECAL Deposits", + refLabel, + newLabel, + plots1, + 0, + logy, + doKolmo, + norm); + //===== HCAL and HO Isolation Distributions - const char* plots2 [] = {"hadEt", "hoEt", "hadEt_cd", "hoEt_cd"}; + const char* plots2[] = {"hadEt", "hoEt", "hadEt_cd", "hoEt_cd"}; Plot4Histograms(newDir + "/muonIso2", - rdir, sdir, - rcollname, scollname, - "IsoHistos2", "HCAL, HO Deposits", - refLabel, newLabel, - plots2, 0, - logy, doKolmo,norm); - + rdir, + sdir, + rcollname, + scollname, + "IsoHistos2", + "HCAL, HO Deposits", + refLabel, + newLabel, + plots2, + 0, + logy, + doKolmo, + norm); + //===== N_Tracks, N_Jets around #mu - const char* plots3 [] = {"nTracks", "nJets", "nTracks_cd", "nJets_cd"}; + const char* plots3[] = {"nTracks", "nJets", "nTracks_cd", "nJets_cd"}; Plot4Histograms(newDir + "/muonIso3", - rdir, sdir, - rcollname, scollname, - "IsoHistos3", "Number of tracks, jets around #mu", - refLabel, newLabel, - plots3, 0, - logy, doKolmo,norm); - - + rdir, + sdir, + rcollname, + scollname, + "IsoHistos3", + "Number of tracks, jets around #mu", + refLabel, + newLabel, + plots3, + 0, + logy, + doKolmo, + norm); + //===== avg Pt, weighted Et around #mu - const char* plots4 [] = {"avgPt", "weightedEt", "avgPt_cd", "weightedEt_cd"}; + const char* plots4[] = {"avgPt", "weightedEt", "avgPt_cd", "weightedEt_cd"}; Plot4Histograms(newDir + "/muonIso4", - rdir, sdir, - rcollname, scollname, - "IsoHistos4", "Average p_{T}, weighted E_{T} aroun #mu", - refLabel, newLabel, - plots4, 0, - logy, doKolmo,norm); - - + rdir, + sdir, + rcollname, + scollname, + "IsoHistos4", + "Average p_{T}, weighted E_{T} aroun #mu", + refLabel, + newLabel, + plots4, + 0, + logy, + doKolmo, + norm); + //===== Tracker and CAL deposits vs muon pT - const char* plots5 [] = {"muonPt_sumPt", "muonPt_emEt", "muonPt_hadEt", "muonPt_hoEt"}; - Double_t norm2 [] = {-999.,-999.,-999.,-999.}; + const char* plots5[] = {"muonPt_sumPt", "muonPt_emEt", "muonPt_hadEt", "muonPt_hoEt"}; + Double_t norm2[] = {-999., -999., -999., -999.}; Plot4Histograms(newDir + "/muonIso5", - rdir, sdir, - rcollname, scollname, - "IsoHistos5", "Trk, CAL Isolations vs. #mu p_{T}", - refLabel, newLabel, - plots5, 0, - logy, doKolmo,norm2); - + rdir, + sdir, + rcollname, + scollname, + "IsoHistos5", + "Trk, CAL Isolations vs. #mu p_{T}", + refLabel, + newLabel, + plots5, + 0, + logy, + doKolmo, + norm2); + //===== NTracks, NJets, avgPt, weightedEt vs Muon pT - const char* plots6 [] = {"muonPt_nTracks", "muonPt_nJets", "muonPt_avgPt", "muonPt_weightedEt"}; + const char* plots6[] = {"muonPt_nTracks", "muonPt_nJets", "muonPt_avgPt", "muonPt_weightedEt"}; Plot4Histograms(newDir + "/muonIso6", - rdir, sdir, - rcollname, scollname, - "IsoHistos6", "Other stuff vs #mu p_{T}", - refLabel, newLabel, - plots6, 0, - logy, doKolmo,norm2); - - + rdir, + sdir, + rcollname, + scollname, + "IsoHistos6", + "Other stuff vs #mu p_{T}", + refLabel, + newLabel, + plots6, + 0, + logy, + doKolmo, + norm2); + //// Merge pdf histograms together into larger files, and name them based on the collection names - TString mergefile = "merged_iso.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+"/muonIso1.pdf " - +newDir+"/muonIso2.pdf " - +newDir+"/muonIso3.pdf " - +newDir+"/muonIso4.pdf " - +newDir+"/muonIso5.pdf " - +newDir+"/muonIso6.pdf "; + TString mergefile = "merged_iso.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 + + "/muonIso1.pdf " + newDir + "/muonIso2.pdf " + newDir + "/muonIso3.pdf " + newDir + + "/muonIso4.pdf " + newDir + "/muonIso5.pdf " + newDir + "/muonIso6.pdf "; cout << ">> Merging partial pdfs to " << mergefile << "..." << endl; #ifdef DEBUG cout << "DEBUG: ...with command \"" << gscommand << "\"" << endl; @@ -179,11 +209,10 @@ void IsoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="RE gSystem->Rename(mergefile, destfile); cout << ">> Deleting partial pdf files" << endl; - gSystem->Exec("rm -rf "+newDir+"/*.pdf"); + gSystem->Exec("rm -rf " + newDir + "/*.pdf"); 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); diff --git a/Validation/RecoMuon/test/macro/RecoMuonValHistoPublisher.C b/Validation/RecoMuon/test/macro/RecoMuonValHistoPublisher.C index 7d52a4270e66d..610f0cdd590db 100644 --- a/Validation/RecoMuon/test/macro/RecoMuonValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/RecoMuonValHistoPublisher.C @@ -7,32 +7,27 @@ // Uncomment the following line to get more debuggin output // #define DEBUG -void RecoMuonValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { +void RecoMuonValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { cout << ">> Starting RecoMuonValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python3 ==================== - + 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 - + gROOT->SetBatch(); + gErrorIgnoreLevel = kWarning; // Get rid of the info messages SetGlobalStyle(); - - // ==== Some cleaning... is this needed? + // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); - delete gROOT->GetListOfFiles()->FindObject(newFile); - - + 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; @@ -45,10 +40,10 @@ void RecoMuonValHistoPublisher(const char* newFile="NEW_FILE",const char* refFil cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* sdir = gDirectory; + 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"); @@ -57,95 +52,118 @@ void RecoMuonValHistoPublisher(const char* newFile="NEW_FILE",const char* refFil cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* rdir = gDirectory; + 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.; + 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 ); + TIter iter_r(rl); + TIter iter_s(sl); TKey* rKey = 0; TKey* sKey = 0; TString rcollname; TString scollname; - while ( (rKey = (TKey*)iter_r()) ) { + 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; + if (!sKey) + continue; scollname = sKey->GetName(); - if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { + 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; + 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); + 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 + 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}; - - //===== reco muon distributions: GLB + 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})"}; + 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", - rdir, sdir, - rcollname, scollname, - "RecHistosGlb", "Distributions for GlobalMuons (GLB)", - refLabel, newLabel, - plots1, plotst1, - logy, doKolmo, norm,resol,minx,maxx); - - + 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 + 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", - rdir, sdir, - rcollname, scollname, - "RecEffHistosGlb", "Distributions for GlobalMuons (GLB), efficiencies and fractions", - refLabel, newLabel, - plots2, plotst2, - logy, doKolmo,norm2,resol,minx1,maxx1); - + 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); @@ -175,141 +193,187 @@ void RecoMuonValHistoPublisher(const char* newFile="NEW_FILE",const char* refFil 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})"}; + 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", - rdir, sdir, - rcollname, scollname, - "RecHistosSta", "Distributions for StandAloneMuons (STA)", - refLabel, newLabel, - plots5, plotst5, - logy, doKolmo, norm,resol, minx,maxx); - - - + 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"}; + 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", - rdir, sdir, - rcollname, scollname, - "RecEffHistosSta", "Distributions for StandAloneMuons (STA), efficiencies and fractions", - refLabel, newLabel, - plots6, plotst6, - logy, doKolmo, norm2,resol,minx1,maxx1); - - + 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 + //===== 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})"}; + 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", - rdir, sdir, - rcollname, scollname, - "RecHistosTrk", "Distributions for TrackerMuons (TRK)", - refLabel, newLabel, - plots7, plotst7, - logy, doKolmo, norm,resol,minx,maxx); - + 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"}; + //==== 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", - rdir, sdir, - rcollname, scollname, - "RecEffHistosTrk", "Distributions for TrackerMuons (TRK), efficiencies and fractions", - refLabel, newLabel, - plots8, plotst8, - logy, doKolmo, norm2,resol,minx1,maxx1); + 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})"}; + 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", - rdir, sdir, - rcollname, scollname, - "RecHistosTgt", "Distributions for Tight Muons", - refLabel, newLabel, - plots9, plotst9, - logy, doKolmo, norm,resol,minx,maxx); - + 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"}; + //==== 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", - rdir, sdir, - rcollname, scollname, - "RecEffHistosTgt", "Distributions for Tight Muons, efficiencies and fractions", - refLabel, newLabel, - plots10, plotst10, - logy, doKolmo, norm2,resol,minx1,maxx1); - - - + 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 "; + 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 @@ -319,16 +383,16 @@ void RecoMuonValHistoPublisher(const char* newFile="NEW_FILE",const char* refFil cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl; gSystem->Rename(mergefile, destfile); cout << " ... Done" << endl; - + cout << ">> Deleting partial pdf files" << endl; - gSystem->Exec("rm -r "+newDir+"/*.pdf"); - + gSystem->Exec("rm -r " + newDir + "/*.pdf"); + } // 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; diff --git a/Validation/RecoMuon/test/macro/RecoValHistoPublisher.C b/Validation/RecoMuon/test/macro/RecoValHistoPublisher.C index ccb0db2c0b4ab..ed2d3806b6f3a 100644 --- a/Validation/RecoMuon/test/macro/RecoValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/RecoValHistoPublisher.C @@ -6,32 +6,27 @@ // Uncomment the following line for some extra debug information // #define DEBUG -void RecoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { +void RecoValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { cout << ">> Starting RecoValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python3 ==================== - + 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 + gROOT->SetBatch(); + gErrorIgnoreLevel = kWarning; // Get rid of the info messages - SetGlobalStyle(); - - // ==== Some cleaning... is this needed? + // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); - delete gROOT->GetListOfFiles()->FindObject(newFile); + 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; @@ -43,10 +38,10 @@ void RecoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* sdir = gDirectory; + 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, "MuonRecoAnalyzer"); @@ -55,15 +50,14 @@ void RecoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* rdir = gDirectory; + TDirectory* rdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; - // Get the number of events for the normalization: TH1F *sevt, *revt; - sdir->GetObject("RecoMuonV/RecoMuon_MuonAssoc_Glb/NMuon",sevt); - rdir->GetObject("RecoMuonV/RecoMuon_MuonAssoc_Glb/NMuon",revt); + sdir->GetObject("RecoMuonV/RecoMuon_MuonAssoc_Glb/NMuon", sevt); + rdir->GetObject("RecoMuonV/RecoMuon_MuonAssoc_Glb/NMuon", revt); /* if (sevt && revt) { if (revt->GetEntries()>0) @@ -79,123 +73,174 @@ void RecoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R cout << "WARNING: Missing normalization histos!" << endl; } */ - Float_t maxPT; + Float_t maxPT; TString File = newFile; - if(File.Contains("SingleMuPt10")) {maxPT = 70.;} - else if (File.Contains("SingleMuPt100")) {maxPT = 400.;} - else if (File.Contains("SingleMuPt1000") ||File.Contains("WpM")||File.Contains("ZpMM") ) maxPT=1400.; else maxPT = 300.; + if (File.Contains("SingleMuPt10")) { + maxPT = 70.; + } else if (File.Contains("SingleMuPt100")) { + maxPT = 400.; + } else if (File.Contains("SingleMuPt1000") || File.Contains("WpM") || File.Contains("ZpMM")) + maxPT = 1400.; + else + maxPT = 300.; //==== Iterate now over histograms and collections cout << ">> Iterating over histograms and collections..." << endl; - TIter iter_r( rl ); - TIter iter_s( sl ); + TIter iter_r(rl); + TIter iter_s(sl); TKey* rKey = 0; TKey* sKey = 0; TString rcollname; TString scollname; - while ( (rKey = (TKey*)iter_r()) ) { + 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; + if (!sKey) + continue; scollname = sKey->GetName(); - if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { + 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; + 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); - + 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, 5., -1E100, -1E100, -1E100 }; - Double_t maxx [] = {-1E100, -1E100,maxPT, -1E100, -1E100, -1E100 }; - Double_t snorm [] = {0.,0.,0.,0.,0.,0.}; + bool* resol = &resolx; + bool logy[] = {false, false, false, false}; + bool doKolmo[] = {true, true, true, true}; + Double_t minx[] = {-1E100, -1E100, 5., -1E100, -1E100, -1E100}; + Double_t maxx[] = {-1E100, -1E100, maxPT, -1E100, -1E100, -1E100}; + Double_t snorm[] = {0., 0., 0., 0., 0., 0.}; //===== reco muon distributions: GLB_GLB - const char* plots1 [] = {"GlbMuon_Glb_eta", "GlbMuon_Glb_phi", "GlbMuon_Glb_pt", "GlbMuon_Glb_chi2OverDf"}; - const char* plotst1 [] = {"GlobalMuon(GLB) #eta", "GlobalMuon(GLB) #phi", "GlobalMuon(GLB) pT", "GlobalMuon(GLB) #chi^{2}/ndf"}; + const char* plots1[] = {"GlbMuon_Glb_eta", "GlbMuon_Glb_phi", "GlbMuon_Glb_pt", "GlbMuon_Glb_chi2OverDf"}; + const char* plotst1[] = { + "GlobalMuon(GLB) #eta", "GlobalMuon(GLB) #phi", "GlobalMuon(GLB) pT", "GlobalMuon(GLB) #chi^{2}/ndf"}; Plot4Histograms(newDir + "/muonReco1", - rdir, sdir, - rcollname, scollname, - "RecoHistos1", "Distributions for GlobalMuons (GLB)", - refLabel, newLabel, - plots1, plotst1, - logy, doKolmo, snorm,resol, minx,maxx); - - + rdir, + sdir, + rcollname, + scollname, + "RecoHistos1", + "Distributions for GlobalMuons (GLB)", + refLabel, + newLabel, + plots1, + plotst1, + logy, + doKolmo, + snorm, + resol, + minx, + maxx); + //===== reco muon distributions: GLB_STA - const char* plots2 [] = {"GlbMuon_Sta_eta", "GlbMuon_Sta_phi", "GlbMuon_Sta_pt", "GlbMuon_Sta_chi2OverDf"}; - const char* plotst2 [] = {"GlobalMuon(STA) #eta", "GlobalMuon(STA) #phi", "GlobalMuon(STA) p_T", "GlobalMuon(STA) #chi^{2}/ndf"}; - Double_t minx1 [] = {-1E100,-1E100, 5., -1E100, -1E100 }; - Double_t maxx1 [] = {-1E100, -1E100,maxPT, -1E100, -1E100 }; + const char* plots2[] = {"GlbMuon_Sta_eta", "GlbMuon_Sta_phi", "GlbMuon_Sta_pt", "GlbMuon_Sta_chi2OverDf"}; + const char* plotst2[] = { + "GlobalMuon(STA) #eta", "GlobalMuon(STA) #phi", "GlobalMuon(STA) p_T", "GlobalMuon(STA) #chi^{2}/ndf"}; + Double_t minx1[] = {-1E100, -1E100, 5., -1E100, -1E100}; + Double_t maxx1[] = {-1E100, -1E100, maxPT, -1E100, -1E100}; Plot4Histograms(newDir + "/muonReco2", - rdir, sdir, - rcollname, scollname, - "RecoHistos2", "Distributions for GlobalMuons (STA)", - refLabel, newLabel, - plots2, plotst2, - logy, doKolmo, snorm,resol, minx1,maxx1); - - + rdir, + sdir, + rcollname, + scollname, + "RecoHistos2", + "Distributions for GlobalMuons (STA)", + refLabel, + newLabel, + plots2, + plotst2, + logy, + doKolmo, + snorm, + resol, + minx1, + maxx1); + //===== reco muon distributions: GLB_TK - const char* plots3 [] = {"GlbMuon_Tk_eta", "GlbMuon_Tk_phi", "GlbMuon_Tk_pt", "GlbMuon_Tk_chi2OverDf"}; - const char* plotst3 [] = {"GlobalMuon(TK) #eta", "GlobalMuon(TK) #phi", "GlobalMuon(TK) pT", "GlobalMuon(TK) #chi^{2}/ndf"}; + const char* plots3[] = {"GlbMuon_Tk_eta", "GlbMuon_Tk_phi", "GlbMuon_Tk_pt", "GlbMuon_Tk_chi2OverDf"}; + const char* plotst3[] = { + "GlobalMuon(TK) #eta", "GlobalMuon(TK) #phi", "GlobalMuon(TK) pT", "GlobalMuon(TK) #chi^{2}/ndf"}; Plot4Histograms(newDir + "/muonReco3", - rdir, sdir, - rcollname, scollname, - "RecoHistos3", "Distributions for GlobalMuons (TK)", - refLabel, newLabel, - plots3, plotst3, - logy, doKolmo, snorm,resol,minx1,maxx1); - - + rdir, + sdir, + rcollname, + scollname, + "RecoHistos3", + "Distributions for GlobalMuons (TK)", + refLabel, + newLabel, + plots3, + plotst3, + logy, + doKolmo, + snorm, + resol, + minx1, + maxx1); + //===== reco muon distributions: STA - const char* plots4 [] = {"StaMuon_eta", "StaMuon_phi", "StaMuon_pt", "StaMuon_chi2OverDf"}; - const char* plotst4 [] = {"StaMuon #eta", "StaMuon #phi", "StaMuon p_T", "StaMuon #chi^{2}/ndf"}; + const char* plots4[] = {"StaMuon_eta", "StaMuon_phi", "StaMuon_pt", "StaMuon_chi2OverDf"}; + const char* plotst4[] = {"StaMuon #eta", "StaMuon #phi", "StaMuon p_T", "StaMuon #chi^{2}/ndf"}; Plot4Histograms(newDir + "/muonReco4", - rdir, sdir, - rcollname, scollname, - "RecoHistos4", "Distributions for StandAlone Muons", - refLabel, newLabel, - plots4, plotst4, - logy, doKolmo, snorm,resol,minx1,maxx1); - - + rdir, + sdir, + rcollname, + scollname, + "RecoHistos4", + "Distributions for StandAlone Muons", + refLabel, + newLabel, + plots4, + plotst4, + logy, + doKolmo, + snorm, + resol, + minx1, + maxx1); + //===== reco muon distributions: Tracker Muons - const char* plots5 [] = {"TkMuon_eta", "TkMuon_phi", "TkMuon_pt", "TkMuon_chi2OverDf"}; - const char* plotst5 [] = {"TkMuon #eta", "TkMuon #phi", "TkMuon p_T", "TkMuon #chi^{2}/ndf"}; + const char* plots5[] = {"TkMuon_eta", "TkMuon_phi", "TkMuon_pt", "TkMuon_chi2OverDf"}; + const char* plotst5[] = {"TkMuon #eta", "TkMuon #phi", "TkMuon p_T", "TkMuon #chi^{2}/ndf"}; Plot4Histograms(newDir + "/muonReco5", - rdir, sdir, - rcollname, scollname, - "RecoHistos5", "Distributions for Tracker Muons", - refLabel, newLabel, - plots5, plotst5, - logy, doKolmo, snorm,resol,minx1,maxx1); - - + rdir, + sdir, + rcollname, + scollname, + "RecoHistos5", + "Distributions for Tracker Muons", + refLabel, + newLabel, + plots5, + plotst5, + logy, + doKolmo, + snorm, + resol, + minx1, + maxx1); + //// Merge pdf histograms together into larger files, and name them based on the collection names - TString mergefile = "merged_reco.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+"/muonReco1.pdf " - +newDir+"/muonReco2.pdf " - +newDir+"/muonReco3.pdf " - +newDir+"/muonReco4.pdf " - +newDir+"/muonReco5.pdf "; + TString mergefile = "merged_reco.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 + + "/muonReco1.pdf " + newDir + "/muonReco2.pdf " + newDir + "/muonReco3.pdf " + newDir + + "/muonReco4.pdf " + newDir + "/muonReco5.pdf "; cout << ">> Merging partial pdfs to " << mergefile << "..." << endl; #ifdef DEBUG @@ -204,17 +249,17 @@ void RecoValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R gSystem->Exec(gscommand); cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl; gSystem->Rename(mergefile, destfile); - + cout << ">> Deleting partial pdf files" << endl; - gSystem->Exec("rm -r "+newDir+"/*.pdf"); + gSystem->Exec("rm -r " + newDir + "/*.pdf"); 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; diff --git a/Validation/RecoMuon/test/macro/SeedValHistoPublisher.C b/Validation/RecoMuon/test/macro/SeedValHistoPublisher.C index b64fe93a3e41f..acfd0a6366395 100644 --- a/Validation/RecoMuon/test/macro/SeedValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/SeedValHistoPublisher.C @@ -3,39 +3,33 @@ #include "TMath.h" #include "macro/PlotHelpers.C" - //Uncomment the following line to get some more output //#define DEBUG 1 -void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { +void SeedValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { cout << ">> Starting SeedValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python3 ==================== - + 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 + gROOT->SetBatch(); + gErrorIgnoreLevel = kWarning; // Get rid of the info messages - SetGlobalStyle(); - - // ==== Some cleaning... is this needed? + // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); - delete gROOT->GetListOfFiles()->FindObject(newFile); - - + 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, "Seeds"); @@ -44,10 +38,10 @@ void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* sdir = gDirectory; + 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, "Seeds"); @@ -56,20 +50,15 @@ void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* rdir = gDirectory; + TDirectory* rdir = gDirectory; for (unsigned int i = 0; i < sl->GetEntries(); i++) cout << " + " << sl->At(i)->GetName() << endl; - - - - - //==== Get the number of events for the normalization: cout << ">> Find out number of events for normalization..." << endl; TH1F *sevt, *revt; - sdir->GetObject("RecoMuonV/RecoMuon_TrackAssoc/Muons/NMuon",sevt); - rdir->GetObject("RecoMuonV/RecoMuon_TrackAssoc/Muons/NMuon",revt); + sdir->GetObject("RecoMuonV/RecoMuon_TrackAssoc/Muons/NMuon", sevt); + rdir->GetObject("RecoMuonV/RecoMuon_TrackAssoc/Muons/NMuon", revt); /* if (sevt && revt) { if (revt->GetEntries()>0) @@ -84,39 +73,39 @@ void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R //==== Iterate now over histograms and collections cout << ">> Iterating over histograms and collections..." << endl; - TIter iter_r( rl ); - TIter iter_s( sl ); + TIter iter_r(rl); + TIter iter_s(sl); TKey* rKey = 0; TKey* sKey = 0; TString rcollname; TString scollname; - while ( (rKey = (TKey*)iter_r()) ) { + 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; + if (!sKey) + continue; scollname = sKey->GetName(); - if ( (rcollname != scollname) && (rcollname+"FS" != scollname) && (rcollname != scollname+"FS") ) { + 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; + 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); + newDir += myName; + gSystem->mkdir(newDir, kTRUE); - - bool logy [] = {false, true, false, true }; - bool doKolmo [] = {true, true, true, true }; - Double_t norm [] = {0.,0.,0.,0.,0.,0.}; + bool logy[] = {false, true, false, true}; + bool doKolmo[] = {true, true, true, true}; + Double_t norm[] = {0., 0., 0., 0., 0., 0.}; /* const char* plots [] = {"", "", "", ""}; const char* plotsl[] = {"", "", "", ""}; @@ -130,23 +119,29 @@ void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R */ //===== muon seeds plots, first page: - const char* plots1 [] = {"seedEta_", "seedEtaErr_", "seedPhi_", "seedPhiErr_"}; + const char* plots1[] = {"seedEta_", "seedEtaErr_", "seedPhi_", "seedPhiErr_"}; const char* plotsl1[] = {"seed #eta", "seed #eta error", "seed #phi", "seed #phi error"}; Plot4Histograms(newDir + "/muonSeed1", - rdir, sdir, - rcollname, scollname, - "Seeds1", "Seeds eta and phi", - refLabel, newLabel, - plots1, plotsl1, - logy, doKolmo, norm); - + rdir, + sdir, + rcollname, + scollname, + "Seeds1", + "Seeds eta and phi", + refLabel, + newLabel, + plots1, + plotsl1, + logy, + doKolmo, + norm); // ====== muon seeds plots, second page: // NOTE: Originally in one page, now split in two pages // const char* plots2 [] = {"seedPt_", "seedPtErrOverPt_", "seedPz_", "seedPzErrOverPz_"}; // const char* plotsl2[] = {"seed P_{T}", "seed P_{T} Err/P_{T}", "seed P_{Z}", "seed P_{Z} Err/P_{Z}"}; // Plot4Histograms(newDir + "/muonSeed2", - // rdir, sdir, + // rdir, sdir, // rcollname, scollname, // "Seeds2", "Seeds momenta", // refLabel, newLabel, @@ -156,35 +151,44 @@ void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R // const char* plots3 [] = {"NumberOfRecHitsPerSeed_", "seedPErrOverP_", "", ""}; // const char* plotsl3[] = {"Nr RecHits per seed", "seed P Err/P", "", ""}; // Plot4Histograms(newDir + "/muonSeed3", - // rdir, sdir, + // rdir, sdir, // rcollname, scollname, // "Seeds3", "Seeds hits and momentum", // refLabel, newLabel, // plots3, plotsl3, // logy, doKolmo); - - bool logy2 [] = {false, true, false, true, false, true}; - bool doKolmo2[] = {true, true, true, true, true, true}; - const char* plots2 [] = {"seedPt_", "seedPtErrOverPt_", "seedPz_", "seedPzErrOverPz_", - "NumberOfRecHitsPerSeed_", "seedPErrOverP_"}; - const char* plotsl2 [] = {"seed P_{T}", "seed P_{T} Err/P_{T}", "seed P_{Z}", "seed P_{Z} Err/P_{Z}", - "Nr RecHits per seed", "seed P Err/P"}; + + bool logy2[] = {false, true, false, true, false, true}; + bool doKolmo2[] = {true, true, true, true, true, true}; + const char* plots2[] = { + "seedPt_", "seedPtErrOverPt_", "seedPz_", "seedPzErrOverPz_", "NumberOfRecHitsPerSeed_", "seedPErrOverP_"}; + const char* plotsl2[] = {"seed P_{T}", + "seed P_{T} Err/P_{T}", + "seed P_{Z}", + "seed P_{Z} Err/P_{Z}", + "Nr RecHits per seed", + "seed P Err/P"}; Plot6Histograms(newDir + "/muonSeed2", - rdir, sdir, - rcollname, scollname, - "Seeds2", "Seeds momenta and hits", - refLabel, newLabel, - plots2, plotsl2, - logy2, doKolmo2, norm); - - + rdir, + sdir, + rcollname, + scollname, + "Seeds2", + "Seeds momenta and hits", + refLabel, + newLabel, + plots2, + plotsl2, + logy2, + doKolmo2, + norm); + //// Merge pdf histograms together into larger files, and name them based on the collection names - TString mergefile = "merged_seed.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 + "/muonSeed1.pdf " - + newDir + "/muonSeed2.pdf "; - // + newDir + "/muonSeed3.pdf "; + TString mergefile = "merged_seed.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 + + "/muonSeed1.pdf " + newDir + "/muonSeed2.pdf "; + // + newDir + "/muonSeed3.pdf "; cout << ">> Merging partial pdfs to " << mergefile << "..." << endl; #ifdef DEBUG cout << "DEBUG: ...with command \"" << gscommand << "\"" << endl; @@ -192,13 +196,13 @@ void SeedValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="R gSystem->Exec(gscommand); cout << ">> Moving " << mergefile << " to " << destfile << "..." << endl; gSystem->Rename(mergefile, destfile); - + cout << ">> Deleting partial pdf files" << endl; - gSystem->Exec("rm -r "+newDir+"/*.pdf"); + gSystem->Exec("rm -r " + newDir + "/*.pdf"); 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); diff --git a/Validation/RecoMuon/test/macro/TrackValHistoPublisher.C b/Validation/RecoMuon/test/macro/TrackValHistoPublisher.C index ee5905a8f10e6..3d6a1554b9a7a 100644 --- a/Validation/RecoMuon/test/macro/TrackValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/TrackValHistoPublisher.C @@ -3,113 +3,101 @@ #include "TMath.h" #include "macro/PlotHelpers.C" - //Uncomment the following line to get some more output //#define DEBUG 1 TList* GetListOfBranches(const char* dataType, TFile* file) { if (TString(dataType) == "HLT") { - if(file->cd("DQMData/Run 1/HLT")) + if (file->cd("DQMData/Run 1/HLT")) file->cd("DQMData/Run 1/HLT/Run summary/Muon/MultiTrack"); - else + else file->cd("DQMData/HLT/Muon/MultiTrack"); - } - else if (TString(dataType) == "RECO") { - if(file->cd("DQMData/Run 1/RecoMuonV")) + } else if (TString(dataType) == "RECO") { + if (file->cd("DQMData/Run 1/RecoMuonV")) file->cd("DQMData/Run 1/RecoMuonV/Run summary/MultiTrack"); - else if(file->cd("DQMData/Run 1/Muons/Run summary/RecoMuonV")) + else if (file->cd("DQMData/Run 1/Muons/Run summary/RecoMuonV")) file->cd("DQMData/Run 1/Muons/Run summary/RecoMuonV/MultiTrack"); - else + else file->cd("DQMData/RecoMuonV/MultiTrack"); - } - else { + } else { cout << "ERROR: Data type " << dataType << " not allowed: only RECO and HLT are considered" << endl; return 0; } - TDirectory * dir=gDirectory; + TDirectory* dir = gDirectory; TList* sl = GetListOfDirectories(dir); - + if (sl->GetSize() == 0) { cout << "ERROR: No DQM muon reco histos found in NEW file " << endl; delete sl; return 0; } - + return sl; } - - -void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { - - cout << ">> Starting TrackValHistoPublisher(" - << newFile << "," << refFile << ")..." << endl; +void TrackValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { + cout << ">> Starting TrackValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python3 ==================== - + 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 + 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.; + 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 ctf = 1; bool resol = false; - // ==== Some cleaning... is this needed? + // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); - delete gROOT->GetListOfFiles()->FindObject(newFile); - - + 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); + 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; + 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); + 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; + 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; @@ -117,11 +105,11 @@ void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile=" bool hasOnlyMuonAssociatorInSig = true; bool hasOnlyTrackAssociatorInRef = true; bool hasOnlyTrackAssociatorInSig = true; - TIter iter_r0( rl ); - TIter iter_s0( sl ); + 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")) ) { @@ -149,19 +137,17 @@ void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile=" 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 ); + TIter iter_r(rl); + TIter iter_s(sl); TString scollname; TString rcollname; - - TKey *myNext2=0; - while ( (rKey = (TKey*)iter_r()) ) { + + TKey* myNext2 = 0; + while ((rKey = (TKey*)iter_r())) { TString myName = rKey->GetName(); #ifdef DEBUG cout << "DEBUG: Checking key " << myName << endl; @@ -185,299 +171,381 @@ void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile=" if (myNext2) { sKey = myNext2; myNext2 = 0; - } - else { + } else { sKey = (TKey*)iter_s(); } - if (!sKey) continue; + 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; + 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; - } + if (myName2 != myName) { + myNext2 = (TKey*)iter_s(); + TKey* myTemp = sKey; + sKey = myNext2; + myName2 = sKey->GetName(); + myNext2 = myTemp; + } } - - scollname=myName2; + + 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") ) - ) { + 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") ) { + } 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("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("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; + 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(); - } + 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; + // 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 }; + 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* 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 }; + bool logy0[] = {false, false, false, false}; Plot4Histograms(newDir + "/building", - 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 "<> Merging partial pdfs to " << mergefile << "..." << endl; #ifdef DEBUG cout << "DEBUG: ...with command \"" << gscommand << "\"" << endl; @@ -487,10 +555,10 @@ void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile=" gSystem->Rename(mergefile, destfile); cout << ">> Deleting partial pdf files" << endl; - gSystem->Exec("rm -rf "+newDir+"/*.pdf"); + gSystem->Exec("rm -rf " + newDir + "/*.pdf"); 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); @@ -500,4 +568,3 @@ void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile=" cerr << "DEBUG: Exiting!" << endl; #endif } - diff --git a/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C b/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C index eb962001ee024..b83286b26e457 100644 --- a/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C @@ -9,34 +9,39 @@ bool DEBUG = false; TList* GetListOfBranches(const char* dataType, TFile* file) { if (TString(dataType) == "HLT") { file->cd("DQMData/Run 1/HLT/Run summary/Muon/MuonTrack"); - } - else if (TString(dataType) == "RECO") { + } else if (TString(dataType) == "RECO") { file->cd("DQMData/Run 1/Muons/Run summary/RecoMuonV/MuonTrack"); - } - else { + } else { cout << "ERROR: Data type " << dataType << " not allowed: only RECO and HLT are considered" << endl; cerr << "ERROR: Data type " << dataType << " not allowed: only RECO and HLT are considered" << endl; return 0; } - TDirectory * dir=gDirectory; + TDirectory* dir = gDirectory; TList* sl = GetListOfDirectories(dir); - + if (sl->GetSize() == 0) { cout << "ERROR: No DQM muon reco histos found in NEW file " << endl; cerr << "ERROR: No DQM muon reco histos found in NEW file " << endl; delete sl; return 0; } - + return sl; } -void plotOptReset(bool logx[6], bool logy[6], bool doKolmo[6], Double_t norm[6], - Double_t minx[6], Double_t maxx[6], Double_t miny[6], Double_t maxy[6], const char* drawopt[6], - TString plots[6], TString titles[6]) { - - for(int i=0; i<6; ++i) { +void plotOptReset(bool logx[6], + bool logy[6], + bool doKolmo[6], + Double_t norm[6], + Double_t minx[6], + Double_t maxx[6], + Double_t miny[6], + Double_t maxy[6], + const char* drawopt[6], + TString plots[6], + TString titles[6]) { + for (int i = 0; i < 6; ++i) { logx[i] = false; logy[i] = false; doKolmo[i] = true; @@ -46,37 +51,34 @@ void plotOptReset(bool logx[6], bool logy[6], bool doKolmo[6], Double_t norm[6], miny[i] = 0; maxy[i] = 0; drawopt[i] = ""; - plots[i] = ""; - titles[i] = ""; + plots[i] = ""; + titles[i] = ""; } } -void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { - - cout << ">> Starting new_TrackValHistoPublisher(" - << newFile << "," << refFile << ")..." << endl; +void new_TrackValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { + cout << ">> Starting new_TrackValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; //==== To be replaced from python3 ==================== - + 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 + gROOT->SetBatch(); + gErrorIgnoreLevel = kWarning; // Get rid of the info messages SetGlobalStyle(); - // ==== Some cleaning... is this needed? + // ==== Some cleaning... is this needed? delete gROOT->GetListOfFiles()->FindObject(refFile); - delete gROOT->GetListOfFiles()->FindObject(newFile); - + 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); + TFile* sfile = new TFile(newFile); TList* sl = GetListOfBranches(dataType, sfile); if (!sl) { @@ -84,15 +86,15 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* sdir = gDirectory; + 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); + TFile* rfile = new TFile(refFile); TList* rl = GetListOfBranches(dataType, rfile); if (!rl) { @@ -100,7 +102,7 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi cerr << "ERROR: Could not find keys!!!" << endl; return; } - TDirectory* rdir = gDirectory; + TDirectory* rdir = gDirectory; if (DEBUG) { for (unsigned int i = 0; i < rl->GetEntries(); i++) @@ -110,31 +112,32 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi //==== 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 + 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 plots[6] = {"", "", "", "", "", ""}; + TString titles[6] = {"", "", "", "", "", ""}; TString rcollname; TString scollname; - TIter iter_r( rl ); - TIter iter_s( sl ); + 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; + if (Ref_CMSSW_Release.Contains("CMSSW_9") || Ref_CMSSW_Release.Contains("CMSSW_10_0")) + NEWcollNames = true; - while ( (rKey = (TKey*)iter_r()) ) { + while ((rKey = (TKey*)iter_r())) { TString myName = rKey->GetName(); rcollname = myName; if (DEBUG) { @@ -144,386 +147,553 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi 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"; + 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: "<mkdir(newDir,kTRUE); - + 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]=1.09; - maxy[2]=1.09; - maxy[3]=1.09; - + 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] = 1.09; + maxy[2] = 1.09; + maxy[3] = 1.09; + 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); - + 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]= 1.09; - maxy[2]= 0.; - maxy[3]= 0.; + 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] = 1.09; + 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); - + 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.; + 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); - + 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" ; + 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.; + miny[0] = -0.0001; + miny[1] = 0.; - maxy[0]= 1.09; - maxy[1]= 0.; + maxy[0] = 1.09; + maxy[1] = 0.; norm[1] = -1; 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); - + 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]= 0.; - norm[1]= 0.; - 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")) + //===== 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] = 0.; + norm[1] = 0.; + 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 "; + 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 "; - + 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; + 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"); + gSystem->Exec("rm -rf " + newDir + "/*.pdf"); cout << " ... Done" << endl; - - } // end of "while loop" + + } // end of "while loop" /////////////////////////////////////////////////////////////////////////////// // comparison plots of Muon and Track associators on the probeTracks @@ -548,10 +718,12 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi } 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; + 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"; @@ -560,7 +732,8 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi // 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 (New_CMSSW_Release.Contains("CMSSW_9") || New_CMSSW_Release.Contains("CMSSW_10_0")) + NEWprobeTrksNames = true; if (NEWprobeTrksNames) { rcollname = "NEWprobeTrks_TkAsso"; scollname = "NEWprobeTrks"; @@ -570,106 +743,154 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi 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.; + 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); + 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.; - + 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); - + 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" ; - + 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.; + + miny[0] = -0.0001; + miny[1] = 0.; + + maxy[0] = 1.09; + maxy[1] = 0.; norm[1] = -1; - + 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 "; - + 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; + 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"); + 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; } } -