Skip to content

Commit

Permalink
Merge pull request #45044 from bsunanda/Run3-alca247Z
Browse files Browse the repository at this point in the history
Run3-alca247Z Add a new defintion of truncated DetID and a new scaling script for HCAL IsoTrack  calibration
  • Loading branch information
cmsbuild authored May 28, 2024
2 parents 5d0c0d5 + f1b31a2 commit 1b89ee1
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
65 changes: 65 additions & 0 deletions Calibration/HcalCalibAlgos/macros/CalibCorr.C
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
// void CalibCorrScale(infile, oufile, scale)
// Scales all contents of correction factors by "scale" from "infile"
// to "outfile"
// void CalibCorrScale2(infile, oufile, scaleB, scaleT, scaleE)
// Scales all contents of correction factors in the barrel, transition and
// endcap regions by "scaleB", "scaleT", "scaleE" from "infile" and writes
// them to "outfile"
//////////////////////////////////////////////////////////////////////////////
#ifndef CalibrationHcalCalibAlgosCalibCorr_h
#define CalibrationHcalCalibAlgosCalibCorr_h
Expand Down Expand Up @@ -144,6 +148,13 @@ unsigned int truncateId(unsigned int detId, int truncateFlag, bool debug = false
//Ignore depth index for depth > 1 in HB and HE
if (depth > 1)
depth = 2;
} else if (truncate0 == 6) {
//Ignore depth index for depth > 2 in HB and HE and
// depthe 1, 2 are considered as depth 1
if (depth <= 2)
depth = 1;
else
depth = 2;
}
id = (subdet << 25) | (0x1000000) | ((depth & 0xF) << 20) | ((zside > 0) ? (0x80000 | (ieta << 10)) : (ieta << 10));
if (debug) {
Expand Down Expand Up @@ -1353,4 +1364,58 @@ void CalibCorrScale(const char* infile, const char* outfile, double scale) {
myfile.close();
}
}

void CalibCorrScale2(const char* infile, const char* outfile, double scaleB, double scaleT, double scaleE) {
int ietasL[3] = {0, 13, 17};
int ietasH[3] = {14, 18, 29};
double scale[3] = {scaleB, scaleT, scaleE};
std::ofstream myfile;
myfile.open(outfile);
if (!myfile.is_open()) {
std::cout << "** ERROR: Can't open '" << outfile << std::endl;
} else {
if (std::string(infile) != "") {
std::ifstream fInput(infile);
if (!fInput.good()) {
std::cout << "Cannot open file " << infile << std::endl;
} else {
char buffer[1024];
unsigned int all(0), good(0), comment(0);
while (fInput.getline(buffer, 1024)) {
++all;
if (buffer[0] == '#') {
myfile << buffer << std::endl;
++comment;
continue; //ignore comment
}
std::vector<std::string> items = splitString(std::string(buffer));
if (items.size() != 5) {
std::cout << "Ignore line: " << buffer << std::endl;
} else {
++good;
int ieta = std::atoi(items[1].c_str());
int depth = std::atoi(items[2].c_str());
int jp(-1);
for (int j = 0; j < 3; ++j) {
if (std::abs(ieta) > ietasL[j] && std::abs(ieta) <= ietasH[j]) {
if (jp < 0)
jp = j;
}
}
if (jp < 0)
jp = 2;
float corrf = scale[jp] * std::atof(items[3].c_str());
float dcorr = scale[jp] * std::atof(items[4].c_str());
myfile << std::setw(10) << items[0] << std::setw(10) << std::dec << ieta << std::setw(10) << depth
<< std::setw(10) << corrf << " " << std::setw(10) << dcorr << std::endl;
}
}
fInput.close();
std::cout << "Reads total of " << all << ", " << comment << " and " << good << " good records from " << infile
<< " and copied to " << outfile << std::endl;
}
}
myfile.close();
}
}
#endif
3 changes: 2 additions & 1 deletion Calibration/HcalCalibAlgos/macros/CalibMonitor.C
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
// depths in HE with values > 1 as depth 2; (4)
// all depths in HB with values > 1 as depth 2;
// (5) all depths in HB and HE with values > 1
// as depth 2.
// as depth 2; (6) for depth = 1 and 2, depth =
// 1, else depth = 2.
// The digit *d* is used if zside is to be
// ignored (1) or not (0)
// (Default 0)
Expand Down
5 changes: 3 additions & 2 deletions Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
// all depths as depth 1 (2), all depths in HE
// with values > 1 as depth 2 (3), all depths in
// HB with values > 1 as depth 2 (4), all depths
// in HB and HE with values > 1 as depth 2 (5)
// (Default 0)
// in HB and HE with values > 1 as depth 2 (5),
// for depth = 1 and 2, depth = 1, else depth
// = 2 (6). (Default 0)
// useGen (bool) = true/false to use generator level momentum
// or reconstruction level momentum (def false)
// scale (double) = energy scale if correction factor to be used
Expand Down
3 changes: 2 additions & 1 deletion Calibration/HcalCalibAlgos/macros/CalibTree.C
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
// depths in HE with values > 1 as depth 2; (4)
// all depths in HB with values > 1 as depth 2;
// (5) all depths in HB and HE with values > 1
// as depth 2.
// as depth 2; (6) for depth = 1 and 2, depth =
// 1, else depth = 2.
// The digit *d* is used if zside is to be
// ignored (1) or not (0)
// (Default 0)
Expand Down

0 comments on commit 1b89ee1

Please sign in to comment.