Skip to content

Commit

Permalink
Merge pull request #45641 from bsunanda/Run3-alca248A
Browse files Browse the repository at this point in the history
Run3-alca248A Modify the macro to accommodate some requirements for obtaining calibration constants of HCAL
  • Loading branch information
cmsbuild authored Aug 6, 2024
2 parents 10ceefa + 5091d02 commit be1c0ac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Calibration/HcalCalibAlgos/macros/CalibMain.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//
// Other parameters for CalibSplit:
// <InputFile> <HistogramFile> <Flag> <DirectoryName> <Prefix> <PUcorr>
// <Truncate> <Nmax> <pmin> <pmax> <debug>
// <Truncate> <Nmax> <pmin> <pmax> <runMin> <runMax> <debug>
//
//
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 22 additions & 3 deletions Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <TROOT.h>
Expand Down Expand Up @@ -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);
Expand All @@ -1827,23 +1831,34 @@ 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);
Expand Down Expand Up @@ -2075,6 +2090,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_)
Expand Down

0 comments on commit be1c0ac

Please sign in to comment.