From bdb163d22bf92fbc5f982ce32cb486bf19ffece8 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 5 Aug 2024 18:10:13 +0200 Subject: [PATCH 1/2] Modifyy the macro to accommodate some requirement for obtaining calibration constants of HCAL --- Calibration/HcalCalibAlgos/macros/CalibMain.C | 8 +++++--- .../macros/CalibPlotProperties.C | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Calibration/HcalCalibAlgos/macros/CalibMain.C b/Calibration/HcalCalibAlgos/macros/CalibMain.C index d479a301ac3cd..2cb8862ba5878 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibMain.C +++ b/Calibration/HcalCalibAlgos/macros/CalibMain.C @@ -30,7 +30,7 @@ // // Other parameters for CalibSplit: // -// +// // // //////////////////////////////////////////////////////////////////////////////// @@ -371,8 +371,10 @@ int main(Int_t argc, Char_t* argv[]) { // CalibSplit double pmin = (argc > 10) ? std::atof(argv[10]) : 40.0; double pmax = (argc > 11) ? std::atof(argv[11]) : 60.0; - bool debug = (argc > 12) ? (std::atoi(argv[12]) > 0) : false; - CalibSplit c1(infile, dirname, histfile, pmin, pmax, debug); + int runMin = (argc > 12) ? std::atoi(argv[12]) : -1; + int runMax = (argc > 13) ? std::atoi(argv[13]) : -1; + bool debug = (argc > 14) ? (std::atoi(argv[14]) > 0) : false; + CalibSplit c1(infile, dirname, histfile, pmin, pmax, runMin, runMax, debug); c1.Loop(nmax); } return 0; diff --git a/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C b/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C index 9eb328b8a7ed8..7f0d67a779a17 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C +++ b/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C @@ -22,7 +22,7 @@ // pLow and pHigh and save the canvases // // .L CalibPlotProperties.C+g -// CalibSplit c1(fname, dirname, outFileName, pmin, pmax, debug); +// CalibSplit c1(fname, dirname, outFileName, pmin, pmax, runMin, runMax, debug); // c1.Loop(nentries); // // This will split the tree and keep for tacks with momenta between @@ -138,6 +138,8 @@ // outFileName (std::string)= name of the file containing saved tree // pmin (double) = minimum track momentum (40.0) // pmax (double) = maximum track momentum (60.0) +// runMin (int) = minimum run number (-1) | if -1, no check on +// runMax (int) = maximum run number (-1) | run number not done // debug (bool) = debug flag (false) ////////////////////////////////////////////////////////////////////////////// #include @@ -1812,6 +1814,8 @@ public: const std::string &outFileName, double pmin = 40.0, double pmax = 60.0, + int runMin = -1, + int runMax = -1, bool debug = false); virtual ~CalibSplit(); virtual Int_t Cut(Long64_t entry); @@ -1827,23 +1831,27 @@ public: private: const std::string fname_, dirnm_, outFileName_; const double pmin_, pmax_; + const int runMin_, runMax_; const bool debug_; + bool checkRun_; TFile *outputFile_; TDirectoryFile *outputDir_; TTree *outputTree_; }; -CalibSplit::CalibSplit( - const char *fname, const std::string &dirnm, const std::string &outFileName, double pmin, double pmax, bool debug) +CalibSplit::CalibSplit(const char *fname, const std::string &dirnm, const std::string &outFileName, double pmin, double pmax, int runMin, int runMax, bool debug) : fname_(fname), dirnm_(dirnm), outFileName_(outFileName), pmin_(pmin), pmax_(pmax), + runMin_(runMin), + runMax_(runMax), debug_(debug), outputFile_(nullptr), outputDir_(nullptr), outputTree_(nullptr) { + checkRun_ = ((runMin_ < 0) || (runMax_ < 0)) ? false : true; char treeName[400]; sprintf(treeName, "%s/CalibTree", dirnm.c_str()); TChain *chain = new TChain(treeName); @@ -2075,6 +2083,10 @@ void CalibSplit::Loop(Long64_t nentries) { std::cout << "Entry " << jentry << " Run " << t_Run << " Event " << t_Event << std::endl; ++kount; bool select = ((t_p >= pmin_) && (t_p < pmax_)); + if (select && checkRun_) { + if ((t_Run < runMin_) || (t_Run > runMax_)) + select = false; + } if (!select) { ++reject; if (debug_) From 5091d02512c26fdf61917aba5f0a89a6900cc584 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 5 Aug 2024 18:25:08 +0200 Subject: [PATCH 2/2] Code check --- .../HcalCalibAlgos/macros/CalibPlotProperties.C | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C b/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C index 7f0d67a779a17..ef6fed45046ff 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C +++ b/Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C @@ -1814,8 +1814,8 @@ public: const std::string &outFileName, double pmin = 40.0, double pmax = 60.0, - int runMin = -1, - int runMax = -1, + int runMin = -1, + int runMax = -1, bool debug = false); virtual ~CalibSplit(); virtual Int_t Cut(Long64_t entry); @@ -1839,7 +1839,14 @@ private: TTree *outputTree_; }; -CalibSplit::CalibSplit(const char *fname, const std::string &dirnm, const std::string &outFileName, double pmin, double pmax, int runMin, int runMax, bool debug) +CalibSplit::CalibSplit(const char *fname, + const std::string &dirnm, + const std::string &outFileName, + double pmin, + double pmax, + int runMin, + int runMax, + bool debug) : fname_(fname), dirnm_(dirnm), outFileName_(outFileName), @@ -2085,7 +2092,7 @@ void CalibSplit::Loop(Long64_t nentries) { bool select = ((t_p >= pmin_) && (t_p < pmax_)); if (select && checkRun_) { if ((t_Run < runMin_) || (t_Run > runMax_)) - select = false; + select = false; } if (!select) { ++reject;