diff --git a/Validation/CaloTowers/test/macros/Makefile b/Validation/CaloTowers/test/macros/Makefile index 512662d43ad07..d9672956d121f 100644 --- a/Validation/CaloTowers/test/macros/Makefile +++ b/Validation/CaloTowers/test/macros/Makefile @@ -7,5 +7,5 @@ singlePi.exe : SinglePi.C $(GCC) RelValMacro.so : RelValMacro.C - $(eval tpypath := $(shell python get.py '$(CMSSW_FWLITE_INCLUDE_PATH)')) + $(eval tpypath := $(shell python3 get.py '$(CMSSW_FWLITE_INCLUDE_PATH)')) g++ -fPIC -shared RelValMacro.C -o RelValMacro.so -I $(tpypath)/include/ -I /cvmfs/cms.cern.ch/slc6_amd64_gcc491/external/python/2.7.6-eccfad/include/python2.7 -L /cvmfs/cms.cern.ch/slc6_amd64_gcc491/external/python/2.7.6-eccfad/lib -lpython2.7 -L $(tpypath)/lib -lboost_python -g `root-config --cflags --glibs` diff --git a/Validation/CaloTowers/test/macros/RelValHarvest.py b/Validation/CaloTowers/test/macros/RelValHarvest.py index 2099399448d39..86d412f71594e 100755 --- a/Validation/CaloTowers/test/macros/RelValHarvest.py +++ b/Validation/CaloTowers/test/macros/RelValHarvest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os, re diff --git a/Validation/CaloTowers/test/macros/RelValHarvest_2018A.py b/Validation/CaloTowers/test/macros/RelValHarvest_2018A.py index 9ce3bef11437f..ae46f7a422d79 100755 --- a/Validation/CaloTowers/test/macros/RelValHarvest_2018A.py +++ b/Validation/CaloTowers/test/macros/RelValHarvest_2018A.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os, re diff --git a/Validation/CaloTowers/test/macros/RelValHarvest_2018B.py b/Validation/CaloTowers/test/macros/RelValHarvest_2018B.py index e6f0b80719ca0..8a657d176e669 100755 --- a/Validation/CaloTowers/test/macros/RelValHarvest_2018B.py +++ b/Validation/CaloTowers/test/macros/RelValHarvest_2018B.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os, re diff --git a/Validation/CaloTowers/test/macros/RelValMacro.C b/Validation/CaloTowers/test/macros/RelValMacro.C index 27dbfa6fdd375..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 python 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/CaloTowers/test/macros/RelValMacro.py b/Validation/CaloTowers/test/macros/RelValMacro.py index d8f14f0f108f7..58c6a8aa9610c 100755 --- a/Validation/CaloTowers/test/macros/RelValMacro.py +++ b/Validation/CaloTowers/test/macros/RelValMacro.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #RelValMacro.py import sys diff --git a/Validation/EcalClusters/test/macro/InstructionsForScripts b/Validation/EcalClusters/test/macro/InstructionsForScripts index f8eb98f467772..eeb5320a46eee 100644 --- a/Validation/EcalClusters/test/macro/InstructionsForScripts +++ b/Validation/EcalClusters/test/macro/InstructionsForScripts @@ -34,13 +34,13 @@ e.g. how to plot performace vs. ET: > root -l FitEt.C > out.et > grep Result out.et > output -> python plotMeanVsET.py +> python3 plotMeanVsET.py ( Which takes file 'output' as an input and produces plot_MeanVsET.C ) > root -l plot_MeanVsET.C or -> python plotEffSigmaVsET.py +> python3 plotEffSigmaVsET.py > root -l plot_EffSigmaVsET.C //------------------------------------- diff --git a/Validation/Geometry/test/MaterialBudget.py b/Validation/Geometry/test/MaterialBudget.py index 3528a2da4b7a0..56cdbbf9939af 100644 --- a/Validation/Geometry/test/MaterialBudget.py +++ b/Validation/Geometry/test/MaterialBudget.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Pure trick to start ROOT in batch mode, pass this only option to it # and the rest of the command line options to this code. diff --git a/Validation/Geometry/test/dddvsdb/sortCompositeMaterials.py b/Validation/Geometry/test/dddvsdb/sortCompositeMaterials.py index 27fef1ad1cd5f..2b220da16078c 100755 --- a/Validation/Geometry/test/dddvsdb/sortCompositeMaterials.py +++ b/Validation/Geometry/test/dddvsdb/sortCompositeMaterials.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys import xml.etree.ElementTree as ET diff --git a/Validation/Geometry/test/runMaterialDumpAnalyser.sh b/Validation/Geometry/test/runMaterialDumpAnalyser.sh index 38e71a988b612..156ceee326c62 100755 --- a/Validation/Geometry/test/runMaterialDumpAnalyser.sh +++ b/Validation/Geometry/test/runMaterialDumpAnalyser.sh @@ -128,7 +128,7 @@ fi for t in BeamPipe Tracker PixBar PixFwdMinus PixFwdPlus TIB TOB TIDB TIDF TEC TkStrct InnerServices; do if [ ! -e matbdg_${t}.root ]; then - python runP_Tracker.py geom=${geometry} label=$t >& /dev/null & + python3 runP_Tracker.py geom=${geometry} label=$t >& /dev/null & fi done @@ -137,7 +137,7 @@ waitPendingJobs # Always run the comparison at this stage, since you are guaranteed that all the ingredients are there for t in BeamPipe Tracker PixBar PixFwdMinus PixFwdPlus TIB TOB TIDB TIDF TEC TkStrct InnerServices; do - python MaterialBudget.py -s -d ${t} + python3 MaterialBudget.py -s -d ${t} if [ $? -ne 0 ]; then echo "Error while producing simulation material for ${t}, aborting" exit 1 diff --git a/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseI.sh b/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseI.sh index ff2897c8e51fc..401b945210175 100755 --- a/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseI.sh +++ b/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseI.sh @@ -134,7 +134,7 @@ fi for t in BeamPipe Tracker PixBar PixFwdMinus PixFwdPlus TIB TOB TIDB TIDF TEC TkStrct InnerServices; do if [ ! -e matbdg_${t}.root ]; then - python runP_Tracker.py geom=${geometry} label=$t >& /dev/null & + python3 runP_Tracker.py geom=${geometry} label=$t >& /dev/null & fi done @@ -143,7 +143,7 @@ waitPendingJobs # Always run the comparison at this stage, since you are guaranteed that all the ingredients are there for t in TrackerSum Pixel Strip InnerTracker BeamPipe Tracker PixBar PixFwdMinus PixFwdPlus TIB TOB TIDB TIDF TEC TkStrct InnerServices; do - python MaterialBudget.py -s -d ${t} + python3 MaterialBudget.py -s -d ${t} if [ $? -ne 0 ]; then echo "Error while producing simulation material for ${t}, aborting" exit 1 diff --git a/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseII.sh b/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseII.sh index 5310ec722df6e..71a18afa7f2f2 100755 --- a/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseII.sh +++ b/Validation/Geometry/test/runMaterialDumpAnalyser_PhaseII.sh @@ -135,7 +135,7 @@ fi for t in BeamPipe Tracker Phase2PixelBarrel Phase2OTBarrel Phase2PixelEndcap Phase2OTForward; do if [ ! -e matbdg_${t}.root ]; then - python runP_Tracker.py geom=${geometry} label=$t >& /dev/null & + python3 runP_Tracker.py geom=${geometry} label=$t >& /dev/null & fi done @@ -144,7 +144,7 @@ waitPendingJobs # Always run the comparison at this stage, since you are guaranteed that all the ingredients are there for t in BeamPipe Tracker TrackerSumPhaseII Phase2PixelBarrel Phase2OTBarrel Phase2PixelEndcap Phase2OTForward; do - python MaterialBudget.py -s -d ${t} + python3 MaterialBudget.py -s -d ${t} if [ $? -ne 0 ]; then echo "Error while producing simulation material for ${t}, aborting" exit 1 diff --git a/Validation/Geometry/test/runP_Tracker.py b/Validation/Geometry/test/runP_Tracker.py index ddb375343ed84..48d531fc4ce9b 100644 --- a/Validation/Geometry/test/runP_Tracker.py +++ b/Validation/Geometry/test/runP_Tracker.py @@ -1,6 +1,6 @@ # In order to produce everything that you need in one go, use the command: # -# for t in {'BeamPipe','Tracker','PixBar','PixFwdMinus','PixFwdPlus','TIB','TOB','TIDB','TIDF','TEC','TkStrct','InnerServices'}; do python runP_Tracker.py geom=XYZ label=$t >& /dev/null &; done +# for t in {'BeamPipe','Tracker','PixBar','PixFwdMinus','PixFwdPlus','TIB','TOB','TIDB','TIDF','TEC','TkStrct','InnerServices'}; do python3 runP_Tracker.py geom=XYZ label=$t >& /dev/null &; done from __future__ import print_function import FWCore.ParameterSet.Config as cms @@ -21,7 +21,7 @@ The default component to be monitored is the Tracker. If other components need to be studied, they must be supplied, one at a time, - at the command line, e.g.: python runP_Tracker.py + at the command line, e.g.: python3 runP_Tracker.py label="XYZ" """ diff --git a/Validation/MuonGEMHits/test/Compare.py b/Validation/MuonGEMHits/test/Compare.py index 4913361e0676a..5d05ec1e69a64 100755 --- a/Validation/MuonGEMHits/test/Compare.py +++ b/Validation/MuonGEMHits/test/Compare.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Copied from GEMCode/GEMValidation diff --git a/Validation/MuonGEMHits/test/MakePlot.py b/Validation/MuonGEMHits/test/MakePlot.py index 73785eb33932c..d4b45741e6f95 100755 --- a/Validation/MuonGEMHits/test/MakePlot.py +++ b/Validation/MuonGEMHits/test/MakePlot.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Copied from GEMCode/GEMValidation diff --git a/Validation/MuonGEMHits/test/phiView.py b/Validation/MuonGEMHits/test/phiView.py index 1fbd821d1e1e1..cbb8cb4b77628 100755 --- a/Validation/MuonGEMHits/test/phiView.py +++ b/Validation/MuonGEMHits/test/phiView.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Copied from GEMCode/GEMValidation diff --git a/Validation/Performance/scripts/cmsScimarkParser.py b/Validation/Performance/scripts/cmsScimarkParser.py index c85194f24d640..68ffa1e365842 100755 --- a/Validation/Performance/scripts/cmsScimarkParser.py +++ b/Validation/Performance/scripts/cmsScimarkParser.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 #Script cloned from cmsTiming_parser.py from __future__ import print_function diff --git a/Validation/Performance/scripts/cmsScimarkStop.py b/Validation/Performance/scripts/cmsScimarkStop.py index f70ea1c658fc2..243229ed32f45 100755 --- a/Validation/Performance/scripts/cmsScimarkStop.py +++ b/Validation/Performance/scripts/cmsScimarkStop.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 #Script to #1-check for cmsScimarkLaunch (infinite loop) scripts #2-kill them diff --git a/Validation/Performance/scripts/cmsSimplememchecker_parser.py b/Validation/Performance/scripts/cmsSimplememchecker_parser.py index 9a0203b631ae6..aad34a5153eb0 100755 --- a/Validation/Performance/scripts/cmsSimplememchecker_parser.py +++ b/Validation/Performance/scripts/cmsSimplememchecker_parser.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function diff --git a/Validation/Performance/scripts/cmsTiming_parser.py b/Validation/Performance/scripts/cmsTiming_parser.py index 0f5ceacf2c3fc..f5103790bb56e 100755 --- a/Validation/Performance/scripts/cmsTiming_parser.py +++ b/Validation/Performance/scripts/cmsTiming_parser.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function from builtins import range diff --git a/Validation/RecoB/scripts/cuy.py b/Validation/RecoB/scripts/cuy.py index 856872a9f688e..8de1976c55d2c 100755 --- a/Validation/RecoB/scripts/cuy.py +++ b/Validation/RecoB/scripts/cuy.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #____________________________________________________________ # # cuy diff --git a/Validation/RecoB/scripts/plotFactory.py b/Validation/RecoB/scripts/plotFactory.py index 26ef54dd094ae..72f3d51005af9 100755 --- a/Validation/RecoB/scripts/plotFactory.py +++ b/Validation/RecoB/scripts/plotFactory.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ####### diff --git a/Validation/RecoEgamma/test/OvalFile.Pt1000 b/Validation/RecoEgamma/test/OvalFile.Pt1000 index 06c6f26f64607..bed33c1ac8a70 100644 --- a/Validation/RecoEgamma/test/OvalFile.Pt1000 +++ b/Validation/RecoEgamma/test/OvalFile.Pt1000 @@ -1022,7 +1022,7 @@ Process uncleaned superclusters - + diff --git a/Validation/RecoEgamma/test/electronValidation.csh b/Validation/RecoEgamma/test/electronValidation.csh index e06368bd294a3..0c5d1a86922c8 100755 --- a/Validation/RecoEgamma/test/electronValidation.csh +++ b/Validation/RecoEgamma/test/electronValidation.csh @@ -31,7 +31,7 @@ # # VAL_HISTOS : name of the file describing the histograms to extract and generate. # VAL_ANALYZER : name of the analyzer used. -# VAL_CONFIGURATION : name of the cmsRun python configuration used. +# VAL_CONFIGURATION : name of the cmsRun python3 configuration used. # # DD_SAMPLE : short chosen name for the current dataset ; used in web pages # and used to build the subdirectory where the web pages will be diff --git a/Validation/RecoEgamma/test/electronValidationCheck_Env.py b/Validation/RecoEgamma/test/electronValidationCheck_Env.py index 35ceea649ee4e..46b50f1dce084 100644 --- a/Validation/RecoEgamma/test/electronValidationCheck_Env.py +++ b/Validation/RecoEgamma/test/electronValidationCheck_Env.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # -*-coding: utf-8 -*- from __future__ import print_function diff --git a/Validation/RecoEgamma/test/electronWget.py b/Validation/RecoEgamma/test/electronWget.py index b22682ee9b3a1..288338307fab8 100755 --- a/Validation/RecoEgamma/test/electronWget.py +++ b/Validation/RecoEgamma/test/electronWget.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os, sys if len(sys.argv) > 1: diff --git a/Validation/RecoEgamma/test/makeWebpage.py b/Validation/RecoEgamma/test/makeWebpage.py index 47d7527edf6a6..5a7729c8bca35 100755 --- a/Validation/RecoEgamma/test/makeWebpage.py +++ b/Validation/RecoEgamma/test/makeWebpage.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ## This script writes an index.html page ## displaying all plots contained in the diff --git a/Validation/RecoMuon/test/README b/Validation/RecoMuon/test/README index 3e304edbc3099..4d8a074a7b840 100644 --- a/Validation/RecoMuon/test/README +++ b/Validation/RecoMuon/test/README @@ -5,13 +5,13 @@ Muon Summary Validation script New Muon Validation: from CMSSW_10_1_0_pre1 * set the input data in: new_userparams.py -* then run: python new_muonReleaseSummary.py +* then run: python3 new_muonReleaseSummary.py ------------------------------- Old Muon Validation: up to CMSSW_10_1_0_pre1 * set the input data in: userparams.py -* then run: python muonReleaseSummary.py +* then run: python3 muonReleaseSummary.py diff --git a/Validation/RecoMuon/test/genericMuonReleaseSummary.py b/Validation/RecoMuon/test/genericMuonReleaseSummary.py index 905656187b368..7dc183c0b1851 100644 --- a/Validation/RecoMuon/test/genericMuonReleaseSummary.py +++ b/Validation/RecoMuon/test/genericMuonReleaseSummary.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import os diff --git a/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C b/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C index 3fe3057db8fe9..6c515b057c442 100644 --- a/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/IsoValHistoPublisher.C @@ -6,29 +6,26 @@ // 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 python ==================== + //==== 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; @@ -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 36cdbd17850e4..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 python ==================== - + //==== 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 392bb18f56453..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 python ==================== - + //==== 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 1e14cc19e186b..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 python ==================== - + //==== 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 2fac61fc73bbe..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; + //==== To be replaced from python3 ==================== -void TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFile="REF_FILE") { - - cout << ">> Starting TrackValHistoPublisher(" - << newFile << "," << refFile << ")..." << endl; - - //==== To be replaced from python ==================== - const char* dataType = "DATATYPE"; const char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION"); const char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION"); - // ==== Initial settings and loads //gROOT->ProcessLine(".x HistoCompare_Tracks.C"); //gROOT ->Reset(); - gROOT ->SetBatch(); - gErrorIgnoreLevel = kWarning; // Get rid of the info messages + 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 0a1fdc66c3856..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") { +void new_TrackValHistoPublisher(const char* newFile = "NEW_FILE", const char* refFile = "REF_FILE") { + cout << ">> Starting new_TrackValHistoPublisher(" << newFile << "," << refFile << ")..." << endl; - cout << ">> Starting new_TrackValHistoPublisher(" - << newFile << "," << refFile << ")..." << endl; + //==== To be replaced from python3 ==================== - //==== To be replaced from python ==================== - const char* dataType = "DATATYPE"; const char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION"); const char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION"); - // ==== Initial settings and loads - gROOT ->SetBatch(); - gErrorIgnoreLevel = kWarning; // Get rid of the info messages + 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; } } - diff --git a/Validation/RecoMuon/test/muonReleaseSummary.py b/Validation/RecoMuon/test/muonReleaseSummary.py index a2459b6080df5..0adb4139d6037 100644 --- a/Validation/RecoMuon/test/muonReleaseSummary.py +++ b/Validation/RecoMuon/test/muonReleaseSummary.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import os diff --git a/Validation/RecoMuon/test/muonReleaseValidation.py b/Validation/RecoMuon/test/muonReleaseValidation.py index a994084a9bb04..f5046d5415ea6 100755 --- a/Validation/RecoMuon/test/muonReleaseValidation.py +++ b/Validation/RecoMuon/test/muonReleaseValidation.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import os diff --git a/Validation/RecoMuon/test/muonReleaseValidationFastSim.py b/Validation/RecoMuon/test/muonReleaseValidationFastSim.py index e75e56930d22b..d5dbf59b173c2 100755 --- a/Validation/RecoMuon/test/muonReleaseValidationFastSim.py +++ b/Validation/RecoMuon/test/muonReleaseValidationFastSim.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import os @@ -157,7 +157,7 @@ def do_validation(samples, GlobalTag, trackquality, trackalgorithm): if(os.path.isfile(newdir+'/val.'+sample+'.rootytootie' )!=True): #search the primary dataset - cmd='python $DBSCMD_HOME/dbsCommandLine.py "find dataset where dataset like *' + cmd='python3 $DBSCMD_HOME/dbsCommandLine.py "find dataset where dataset like *' #search for correct EventContent (and site) if (FastSimUse=="True"): cmd+=sample+'/'+NewRelease+'-'+GlobalTagUse+'*GEN-SIM-DIGI-RECO* AND site like *cern* "' @@ -176,7 +176,7 @@ def do_validation(samples, GlobalTag, trackquality, trackalgorithm): if(dataset!="" or DBS==False): print('dataset found ', dataset[:-1]) #Find and format the list of files - cmd2='python $DBSCMD_HOME/dbsCommandLine.py "find file where dataset like '+ dataset[:-1] +'"|grep ' + sample + cmd2='python3 $DBSCMD_HOME/dbsCommandLine.py "find file where dataset like '+ dataset[:-1] +'"|grep ' + sample thisFile=0 for thisFilename in os.popen(cmd2).readlines(): @@ -202,13 +202,13 @@ def do_validation(samples, GlobalTag, trackquality, trackalgorithm): if (FastSimUse=="True"): cmd3=cmd else: - cmd3='python $DBSCMD_HOME/dbsCommandLine.py "find dataset.parent where dataset like '+ dataset[:-1] +'"|grep ' + sample + cmd3='python3 $DBSCMD_HOME/dbsCommandLine.py "find dataset.parent where dataset like '+ dataset[:-1] +'"|grep ' + sample parentdataset=os.popen(cmd3).readline() print('Parent DataSet: ', parentdataset, '\n') #Check if a dataset is found if parentdataset!="": - cmd4='python $DBSCMD_HOME/dbsCommandLine.py "find file where dataset like '+ parentdataset[:-1] +'"|grep ' + sample + cmd4='python3 $DBSCMD_HOME/dbsCommandLine.py "find file where dataset like '+ parentdataset[:-1] +'"|grep ' + sample filenames+='secFiles.extend( [\n' first=True for line in os.popen(cmd4).readlines(): diff --git a/Validation/RecoMuon/test/new_muonReleaseSummary.py b/Validation/RecoMuon/test/new_muonReleaseSummary.py index 2564b853bc84e..4bbca2e230fe4 100644 --- a/Validation/RecoMuon/test/new_muonReleaseSummary.py +++ b/Validation/RecoMuon/test/new_muonReleaseSummary.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import os diff --git a/Validation/RecoMuon/test/new_userparams.py b/Validation/RecoMuon/test/new_userparams.py index 2b37fdd45041f..c489fa1fafd70 100644 --- a/Validation/RecoMuon/test/new_userparams.py +++ b/Validation/RecoMuon/test/new_userparams.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import os import shutil diff --git a/Validation/RecoMuon/test/userparams.py b/Validation/RecoMuon/test/userparams.py index d0ba82c0db54e..e614e27c12aff 100644 --- a/Validation/RecoMuon/test/userparams.py +++ b/Validation/RecoMuon/test/userparams.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import os import shutil diff --git a/Validation/RecoParticleFlow/Makefile b/Validation/RecoParticleFlow/Makefile index be9f3e878a40e..32accc7c01cac 100644 --- a/Validation/RecoParticleFlow/Makefile +++ b/Validation/RecoParticleFlow/Makefile @@ -6,7 +6,7 @@ conf: cd ${TMPDIR} && ${RELVALCMD} conf reco 0 dumpconf: - cd ${TMPDIR}/conf && python -c 'import step3; print step3.process.dumpPython()' > step3_dump.py + cd ${TMPDIR}/conf && python3 -c 'import step3; print step3.process.dumpPython()' > step3_dump.py cp ${TMPDIR}/conf/step3.py test/crab/ cp ${TMPDIR}/conf/step3_dump.py test/crab/ @@ -15,9 +15,9 @@ QCD: QCD_reco QCD_dqm QCD_reco: cd ${TMPDIR} && ${RELVALCMD} QCD reco 0 -#Need to expand the CMSSW python configuration +#Need to expand the CMSSW python3 configuration QCD_dumpconf: - cd ${TMPDIR}/QCD && python -c 'import step3_RAW2DIGI_L1Reco_RECO_RECOSIM_EI_PAT as step3; print step3.process.dumpPython()' > step3_dump.py + cd ${TMPDIR}/QCD && python3 -c 'import step3_RAW2DIGI_L1Reco_RECO_RECOSIM_EI_PAT as step3; print step3.process.dumpPython()' > step3_dump.py cp ${TMPDIR}/QCD/step3_dump.py crab/ QCDPU_reco: diff --git a/Validation/RecoParticleFlow/README.md b/Validation/RecoParticleFlow/README.md index dd13b13509cfc..7e879e02403a1 100644 --- a/Validation/RecoParticleFlow/README.md +++ b/Validation/RecoParticleFlow/README.md @@ -34,7 +34,7 @@ Create input file lists under test/tmp/das_cache (You can modify which datasets are being used in the end of datasets.py script) ~~~ -cd test; python datasets.py; cd .. +cd test; python3 datasets.py; cd .. ~~~ Proceed to RECO step, about 30 minutes @@ -123,7 +123,7 @@ be included in the DQM step, so delete files you don't want to study. Note that the default era, condition, and samples are now set to 2021. Change CONDITIONS and ERA in test/run_relval.sh when trying other era, before trying the above commands. Also check (and if necessary, update) input samples and conf.Site.storageSite specified in $CMSSW_BASE/src/Validation/RecoParticleFlow/crab/multicrab.py (default storage site is T2_US_Caltech, but change it to your favorite site you have access to. use crab checkwrite --site= to check your permission). -Take note that the CMSSW python configuration for running the RECO sequence is dumped into `crab/step3_dump.py`. +Take note that the CMSSW python3 configuration for running the RECO sequence is dumped into `crab/step3_dump.py`. # Running DQM steps from existing MINIAOD samples diff --git a/Validation/RecoParticleFlow/test/compare.py b/Validation/RecoParticleFlow/test/compare.py index e2830d9e3e276..6d394038a5615 100644 --- a/Validation/RecoParticleFlow/test/compare.py +++ b/Validation/RecoParticleFlow/test/compare.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import os import ROOT diff --git a/Validation/RecoParticleFlow/test/datasets.py b/Validation/RecoParticleFlow/test/datasets.py index b6012e09f8e2b..f500cb0ce6bec 100644 --- a/Validation/RecoParticleFlow/test/datasets.py +++ b/Validation/RecoParticleFlow/test/datasets.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function #Hack to get ROOT to ignore command line arguments that we want @@ -113,7 +113,7 @@ def cache_das_filenames(self): nfiles = 0 with open(self.get_das_cache_filename(), "w") as fi: - for line in ret.split("\n"): + for line in ret.decode().split("\n"): if line.endswith(".root"): fi.write(self.global_file_prefix + line + "\n") nfiles += 1 diff --git a/Validation/RecoParticleFlow/test/offsetStack.py b/Validation/RecoParticleFlow/test/offsetStack.py index 57e822ba5d02b..8894e57de2363 100644 --- a/Validation/RecoParticleFlow/test/offsetStack.py +++ b/Validation/RecoParticleFlow/test/offsetStack.py @@ -1,5 +1,5 @@ #chad harrington 2019 -#execute as python test/offsetStack.py -f HS_old:tmp/HS_old/DQMTotal.root HS:tmp/HS/DQMTotal.root -o . +#execute as python3 test/offsetStack.py -f HS_old:tmp/HS_old/DQMTotal.root HS:tmp/HS/DQMTotal.root -o . import argparse import ROOT diff --git a/Validation/RecoTau/Tools/GetRecoTauVFromDQM_MC_cff.py b/Validation/RecoTau/Tools/GetRecoTauVFromDQM_MC_cff.py index 3e0a044e2d327..9e65453b8c8b6 100644 --- a/Validation/RecoTau/Tools/GetRecoTauVFromDQM_MC_cff.py +++ b/Validation/RecoTau/Tools/GetRecoTauVFromDQM_MC_cff.py @@ -4,7 +4,7 @@ import ROOT if len(sys.argv) < 4: - print("Error. Expected at least 3 arguments\n\nUsage: python GetRecoTauVFromDQM_MC_cff.py InputFile OutputFile EventType") + print("Error. Expected at least 3 arguments\n\nUsage: python3 GetRecoTauVFromDQM_MC_cff.py InputFile OutputFile EventType") sys.exit() diff --git a/Validation/RecoTau/Tools/MergeFilesAndCalculateEfficiencies_cfg.py b/Validation/RecoTau/Tools/MergeFilesAndCalculateEfficiencies_cfg.py index 0338fc3415ab4..e2ad83494eea4 100644 --- a/Validation/RecoTau/Tools/MergeFilesAndCalculateEfficiencies_cfg.py +++ b/Validation/RecoTau/Tools/MergeFilesAndCalculateEfficiencies_cfg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ MergeFilesAndCalculateEfficiencies.py diff --git a/Validation/RecoTau/Tools/MultipleCompare.py b/Validation/RecoTau/Tools/MultipleCompare.py index 25912db77d95e..cc5b1ed0124b3 100644 --- a/Validation/RecoTau/Tools/MultipleCompare.py +++ b/Validation/RecoTau/Tools/MultipleCompare.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function from builtins import range @@ -47,7 +47,7 @@ def LoadCommandlineOptions(argv): parser.add_option('--minYaxis',metavar='number',type=float, dest="minYaxis", default=0, help="Sets the minimum range on Y axis in the main pad") parser.add_option('--rebin', dest="rebin", type=int, default=-1, help="Sets the rebinning scale") parser.add_option('--branding','-b',metavar='branding', type=str,help='Define a branding to label the plots (in the top right corner)',dest='branding',default = None) - #parser.add_option('--search,-s',metavar='searchStrings', type=str,help='Sets the label to put in the plots for ref file',dest='testLabel',default = None) No idea on how to tell python to use all the strings before a new option, thus moving this from option to argument (but may be empty) + #parser.add_option('--search,-s',metavar='searchStrings', type=str,help='Sets the label to put in the plots for ref file',dest='testLabel',default = None) No idea on how to tell python3 to use all the strings before a new option, thus moving this from option to argument (but may be empty) (options,toPlot) = parser.parse_args() if options.help: diff --git a/Validation/RecoTau/Tools/RefreshWebPage.py b/Validation/RecoTau/Tools/RefreshWebPage.py index 23c3b675badd9..b4f0e1bef50f2 100644 --- a/Validation/RecoTau/Tools/RefreshWebPage.py +++ b/Validation/RecoTau/Tools/RefreshWebPage.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function import os diff --git a/Validation/RecoTau/Tools/SteerMultipleCompare.py b/Validation/RecoTau/Tools/SteerMultipleCompare.py index 4e6550fb344fe..1a48a782ad222 100644 --- a/Validation/RecoTau/Tools/SteerMultipleCompare.py +++ b/Validation/RecoTau/Tools/SteerMultipleCompare.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import sys diff --git a/Validation/RecoTau/Tools/makeLayoutFileForGui.py b/Validation/RecoTau/Tools/makeLayoutFileForGui.py index bcf03b875526c..697884d11f4e7 100644 --- a/Validation/RecoTau/Tools/makeLayoutFileForGui.py +++ b/Validation/RecoTau/Tools/makeLayoutFileForGui.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ###################################################################################################################################################### # SHIFT LAYOUTS ###################################################################################################################################################### diff --git a/Validation/RecoTau/python/ValidationOptions_cff.py b/Validation/RecoTau/python/ValidationOptions_cff.py index cdb4da0be92e6..022273e4469cb 100644 --- a/Validation/RecoTau/python/ValidationOptions_cff.py +++ b/Validation/RecoTau/python/ValidationOptions_cff.py @@ -155,7 +155,7 @@ def checkOptionsForBadInput(): sys.exit() def calledBycmsRun(): - ''' Returns true of this python file is being called via cmsRun ''' + ''' Returns true of this python3 file is being called via cmsRun ''' if sys.argv[0].find('cmsRun') == -1: return False else: diff --git a/Validation/RecoTau/python/compare.py b/Validation/RecoTau/python/compare.py index 71a9b85070ba7..f1b74f571a0ea 100644 --- a/Validation/RecoTau/python/compare.py +++ b/Validation/RecoTau/python/compare.py @@ -17,7 +17,7 @@ argc = len(argvs) if argc != 2: - print('Please specify the runtype : python tauPOGplot.py ') + print('Please specify the runtype : python3 tauPOGplot.py ') sys.exit(0) runtype = argvs[1] diff --git a/Validation/RecoTau/python/runTauDisplay.py b/Validation/RecoTau/python/runTauDisplay.py index cd81c28924bb7..1349b05498965 100644 --- a/Validation/RecoTau/python/runTauDisplay.py +++ b/Validation/RecoTau/python/runTauDisplay.py @@ -35,7 +35,7 @@ argc = len(argvs) if argc != 2: - print('Please specify the runtype : python runTauDisplay.py ') + print('Please specify the runtype : python3 runTauDisplay.py ') sys.exit(0) runtype = argvs[1] diff --git a/Validation/RecoTau/test/CreateDataRegistry.py b/Validation/RecoTau/test/CreateDataRegistry.py index b0eaedfdd3175..7dd3e3c49e14c 100755 --- a/Validation/RecoTau/test/CreateDataRegistry.py +++ b/Validation/RecoTau/test/CreateDataRegistry.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import FWCore.ParameterSet.Config as cms import Validation.RecoTau.DBSApi_cff as mydbs diff --git a/Validation/RecoTau/test/LXBatchValidation.py b/Validation/RecoTau/test/LXBatchValidation.py index fc66f7b6864ee..f0d9e92cbc94a 100755 --- a/Validation/RecoTau/test/LXBatchValidation.py +++ b/Validation/RecoTau/test/LXBatchValidation.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Script to submit Tau Validation jobs to lxbatch # Author: Evan Friis evan.klose.friis@cern.ch @@ -17,7 +17,7 @@ sys.exit() if options.nJobs == 0: - print("Must specify nJobs > 0. Run 'python LXBatchValidation.py help' for options") + print("Must specify nJobs > 0. Run 'python3 LXBatchValidation.py help' for options") sys.exit() if options.maxEvents == -1 and options.nJobs > 1: diff --git a/Validation/RecoTau/test/UtilityCommands.csh b/Validation/RecoTau/test/UtilityCommands.csh index 97af326f94139..5887779d8abd1 100644 --- a/Validation/RecoTau/test/UtilityCommands.csh +++ b/Validation/RecoTau/test/UtilityCommands.csh @@ -13,10 +13,10 @@ alias MergeBatchJob 'cmsRun ${VALTOOLS}/MergeFilesAndCalculateEfficiencies_cfg.p alias MergeGridJob 'cmsRun ${VALTOOLS}/MergeFilesAndCalculateEfficiencies_cfg.py' alias Compare 'cmsRun ${VALTOOLS}/Compare_cfg.py' alias Summarize 'cmsRun ${VALTOOLS}/SummaryPlots_cfg.py' -alias PerformanceCurves 'python ${VALTOOLS}/PlotPerformanceCurves.py' -alias MultipleCompare 'python ${VALTOOLS}/MultipleCompare.py' -alias BuildWebpage 'python ${VALTOOLS}/BuildWebpage.py' -alias SubmitResults 'python ${PFVALTOOLS}/submit.py' +alias PerformanceCurves 'python3 ${VALTOOLS}/PlotPerformanceCurves.py' +alias MultipleCompare 'python3 ${VALTOOLS}/MultipleCompare.py' +alias BuildWebpage 'python3 ${VALTOOLS}/BuildWebpage.py' +alias SubmitResults 'python3 ${PFVALTOOLS}/submit.py' alias getZTTRecoFiles 'dbs search --query="find dataset where release = CMSSW_3_1_0_pre10 and primds = RelValZTT and tier like *RECO* and dataset not like *FastSim*" --createCFF=tempZTTRecoFiles' alias removeLogs 'rm -r $VALTEST/LSFJOB_[0-9]*' diff --git a/Validation/RecoTau/test/UtilityCommands.sh b/Validation/RecoTau/test/UtilityCommands.sh index fb9b2e4caf39a..300bd55084286 100644 --- a/Validation/RecoTau/test/UtilityCommands.sh +++ b/Validation/RecoTau/test/UtilityCommands.sh @@ -13,10 +13,10 @@ alias MergeBatchJob='cmsRun ${VALTOOLS}/MergeFilesAndCalculateEfficiencies_cfg.p alias MergeGridJob='cmsRun ${VALTOOLS}/MergeFilesAndCalculateEfficiencies_cfg.py' alias Compare='cmsRun ${VALTOOLS}/Compare_cfg.py' alias Summarize='cmsRun ${VALTOOLS}/SummaryPlots_cfg.py' -alias MultipleCompare='python ${VALTOOLS}/MultipleCompare.py' -alias PerformanceCurves='python ${VALTOOLS}/PlotPerformanceCurves.py' -alias BuildWebpage='python ${VALTOOLS}/RefreshWebPage.py' -alias SubmitResults='python ${PFVALTOOLS}/submit.py' +alias MultipleCompare='python3 ${VALTOOLS}/MultipleCompare.py' +alias PerformanceCurves='python3 ${VALTOOLS}/PlotPerformanceCurves.py' +alias BuildWebpage='python3 ${VALTOOLS}/RefreshWebPage.py' +alias SubmitResults='python3 ${PFVALTOOLS}/submit.py' alias getZTTRecoFiles='dbs search --query="find dataset where release = CMSSW_3_1_0_pre10 and primds = RelValZTT and tier like *RECO* and dataset not like *FastSim*" --createCFF=tempZTTRecoFiles' alias removeLogs='rm -r $VALTEST/LSFJOB_[0-9]*' diff --git a/Validation/RecoTrack/test/fakeAnalysis/analysis.py b/Validation/RecoTrack/test/fakeAnalysis/analysis.py index 9fba01be7d8cb..67a4a227cf7bf 100644 --- a/Validation/RecoTrack/test/fakeAnalysis/analysis.py +++ b/Validation/RecoTrack/test/fakeAnalysis/analysis.py @@ -825,7 +825,7 @@ def ClassifyEventFakes(ntuple_file, nEvents = 100, return_fakes = False, real_cr Returns a dictionary of class items, with class index as a key and number of fakes in the class as the value. ''' i = 0 - results = {class_item: 0 for class_item in classes} # This line has issues with the python version, worked with Python 2.17.12. Comment something to compile with older version + results = {class_item: 0 for class_item in classes} # This line has issues with the python3 version, worked with Python 2.17.12. Comment something to compile with older version fake_list = [] for event in ntuple_file: fakes = FindFakes(event) diff --git a/Validation/RecoVertex/README.md b/Validation/RecoVertex/README.md index 98afa2fdb597e..0eaba4d33ea4a 100644 --- a/Validation/RecoVertex/README.md +++ b/Validation/RecoVertex/README.md @@ -4,10 +4,10 @@ INTRODUCTION This small README file is here to guide you in the process of running the Vertex Validation, slimmed version, on RelVal samples, in case you want to perform test on tracking and vertexing. The idea here is not -to give you pre-cooked python configuration files, but to teach you +to give you pre-cooked python3 configuration files, but to teach you how you could use the most common tool available in CMS to perform the same. We will mainly use cmsDriver and its powerful option to create -the python cfg that we will run, and das_client to explore and find +the python3 cfg that we will run, and das_client to explore and find suitable samples to run upon. At the end of this page there is the description of other standalone analyzers, configurations and Root macros. Let start with order. PREREQUISITES @@ -64,7 +64,7 @@ RUN RECO AND VERTEX VALIDATION ============================== Inn order to run the vertex validation starting from RAW file, you -need to create a proper python cfg. As said, instead of preparing a +need to create a proper python3 cfg. As said, instead of preparing a pre-cooked one, we think its more useful to give you the cmsDriver command that will dynamically prepare it for you. To obtain such a cfg file, issue the following command: @@ -73,7 +73,7 @@ file, issue the following command: cmsDriver.py step3 --conditions auto:run2_mc -n 100 --eventcontent DQM -s RAW2DIGI,RECO,VALIDATION:vertexValidationStandalone --datatier DQMIO --filein filelist:gen_sim_digi_raw_files.txt --fileout step3_VertexValidation.root --customise SLHCUpgradeSimulations/Configuration/postLS1Customs.customisePostLS1 --magField 38T_PostLS1 ``` -This will create the python configuration file **and will +This will create the python3 configuration file **and will automatically run cmsRun on it. If instead you want to just produce the configuration, e.g. for inspection and further customization, you can add the option: diff --git a/Validation/RecoVertex/test/V0PerformanceValidation.py b/Validation/RecoVertex/test/V0PerformanceValidation.py index b9b1e04527c69..abe7e4e1e7aaa 100644 --- a/Validation/RecoVertex/test/V0PerformanceValidation.py +++ b/Validation/RecoVertex/test/V0PerformanceValidation.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import os diff --git a/Validation/RecoVertex/test/vertexCompare.py b/Validation/RecoVertex/test/vertexCompare.py index f60d1212b88e9..8a21ae11fb766 100755 --- a/Validation/RecoVertex/test/vertexCompare.py +++ b/Validation/RecoVertex/test/vertexCompare.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # This is an example of plotting the standard vertex validation # plots from an explicit set of DQM root files. diff --git a/Validation/RecoVertex/test/vertexPerformanceValidation.py b/Validation/RecoVertex/test/vertexPerformanceValidation.py index 9f6a8d06b3ef9..4b79c756419cc 100755 --- a/Validation/RecoVertex/test/vertexPerformanceValidation.py +++ b/Validation/RecoVertex/test/vertexPerformanceValidation.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from Validation.RecoTrack.plotting.validation import Sample, Validation import Validation.RecoTrack.plotting.validation as validation diff --git a/Validation/Tools/python/GenObject.py b/Validation/Tools/python/GenObject.py index 6aeb53b468316..5adc5273aa2b8 100755 --- a/Validation/Tools/python/GenObject.py +++ b/Validation/Tools/python/GenObject.py @@ -1504,7 +1504,7 @@ def printTuple (chain): @staticmethod def _convertStringToParameters (string): - """Convert comma-separated string into a python list of + """Convert comma-separated string into a python3 list of parameters. Currently only understands strings, floats, and integers.""" retval = []