Skip to content

Commit

Permalink
Merge pull request #34116 from bsunanda/Run3-alca187
Browse files Browse the repository at this point in the history
Run3-alca187 Update calibration macros in view of discrepancy in the procedure
  • Loading branch information
cmsbuild committed Jun 18, 2021
2 parents eb08629 + 3d3085d commit 76899b5
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 60 deletions.
38 changes: 28 additions & 10 deletions Calibration/HcalCalibAlgos/macros/CalibCorr.C
Expand Up @@ -103,6 +103,24 @@ unsigned int truncateId(unsigned int detId, int truncateFlag, bool debug = false
return id;
}

unsigned int repackId(const std::string& det, int eta, int depth) {
int subdet = (det == "HE") ? 2 : 1;
int zside = (eta >= 0) ? 1 : -1;
int ieta = (eta >= 0) ? eta : -eta;
unsigned int id =
(subdet << 25) | (0x1000000) | ((depth & 0xF) << 20) | ((zside > 0) ? (0x80000 | (ieta << 10)) : (ieta << 10));
return id;
}

unsigned int repackId(int eta, int depth) {
int zside = (eta >= 0) ? 1 : -1;
int ieta = (eta >= 0) ? eta : -eta;
int subdet = ((ieta > 16) || ((ieta == 16) && (depth > 3))) ? 2 : 1;
unsigned int id =
(subdet << 25) | (0x1000000) | ((depth & 0xF) << 20) | ((zside > 0) ? (0x80000 | (ieta << 10)) : (ieta << 10));
return id;
}

double puFactor(int type, int ieta, double pmom, double eHcal, double ediff, bool debug = false) {
double fac(1.0);
if (debug)
Expand Down Expand Up @@ -328,14 +346,14 @@ std::vector<std::string> splitString(const std::string& fLine) {

class CalibCorrFactor {
public:
CalibCorrFactor(const char* infile, int useScale, double scale, bool etamax, bool debug);
CalibCorrFactor(const char* infile, int useScale, double scale, bool etamax, bool marina, bool debug);
~CalibCorrFactor() {}

bool doCorr() const { return (corrE_ || (useScale_ != 0)); }
double getCorr(unsigned int id);

private:
bool readCorrFactor(const char* fName);
bool readCorrFactor(const char* fName, bool marina);
double getFactor(const int& ieta);

const int useScale_;
Expand Down Expand Up @@ -391,22 +409,22 @@ private:
std::vector<int> phis_;
};

CalibCorrFactor::CalibCorrFactor(const char* infile, int useScale, double scale, bool etamax, bool debug)
CalibCorrFactor::CalibCorrFactor(const char* infile, int useScale, double scale, bool etamax, bool marina, bool debug)
: useScale_(useScale), scale_(scale), etaMax_(etamax), debug_(debug), etamp_(0), etamn_(0) {
for (int i = 0; i < depMax_; ++i) {
cfacmp_[i] = 1.0;
cfacmn_[i] = 1.0;
}
if (std::string(infile) != "") {
corrE_ = readCorrFactor(infile);
corrE_ = readCorrFactor(infile, marina);
std::cout << "Reads " << cfactors_.size() << " correction factors from " << infile << " with flag " << corrE_
<< std::endl
<< "Flag for scale " << useScale_ << " with scale " << scale_ << " and flag for etaMax " << etaMax_
<< std::endl;
<< "Flag for scale " << useScale_ << " with scale " << scale_ << "; flag for etaMax " << etaMax_
<< " and flag for Format " << marina << std::endl;
} else {
corrE_ = false;
std::cout << "No correction factors provided; Flag for scale " << useScale_ << " with scale " << scale_
<< " and flag for etaMax " << etaMax_ << std::endl;
<< "; flag for etaMax " << etaMax_ << " and flag for Format " << marina << std::endl;
}
}

Expand All @@ -433,7 +451,7 @@ double CalibCorrFactor::getCorr(unsigned int id) {
return cfac;
}

bool CalibCorrFactor::readCorrFactor(const char* fname) {
bool CalibCorrFactor::readCorrFactor(const char* fname, bool marina) {
bool ok(false);
if (std::string(fname) != "") {
std::ifstream fInput(fname);
Expand All @@ -451,8 +469,8 @@ bool CalibCorrFactor::readCorrFactor(const char* fname) {
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 ieta = (marina) ? std::atoi(items[0].c_str()) : std::atoi(items[1].c_str());
int depth = (marina) ? std::atoi(items[1].c_str()) : std::atoi(items[2].c_str());
float corrf = std::atof(items[3].c_str());
double scale = getFactor(std::abs(ieta));
cfactors_[std::pair<int, int>(ieta, depth)] = scale * corrf;
Expand Down

0 comments on commit 76899b5

Please sign in to comment.