Skip to content

Commit e87276d

Browse files
authored
Merge pull request cms-sw#33999 from bsunanda/Run3-alca186
Run3-alca186 Update the calibration scripts for HCAL
2 parents 2558ac5 + 1c1102d commit e87276d

File tree

4 files changed

+63
-22
lines changed

4 files changed

+63
-22
lines changed

Calibration/HcalCalibAlgos/macros/CalibCorr.C

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ double puFactor(int type, int ieta, double pmom, double eHcal, double ediff, boo
178178
if (debug)
179179
std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " << icor << ":" << CONST_COR_COEF[icor] << ":"
180180
<< LINEAR_COR_COEF[icor] << ":" << SQUARE_COR_COEF[icor] << " Fac " << fac;
181-
} else { // 21pu
181+
} else if (type == 6) { // 21pu (old)
182182
const double CONST_COR_COEF[6] = {0.98913, 0.982008, 0.974011, 0.496234, 0.368110, 0.294053};
183183
const double LINEAR_COR_COEF[6] = {-0.0491388, -0.124058, -0.249718, -0.0667390, -0.0770766, -0.0580492};
184184
const double SQUARE_COR_COEF[6] = {0, 0, 0.0368657, 0.00656337, 0.00724508, 0.00568967};
@@ -195,6 +195,40 @@ double puFactor(int type, int ieta, double pmom, double eHcal, double ediff, boo
195195
if (debug)
196196
std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " << icor << ":" << CONST_COR_COEF[icor] << ":"
197197
<< LINEAR_COR_COEF[icor] << ":" << SQUARE_COR_COEF[icor] << " Fac " << fac;
198+
} else if (type == 99) { // dlphin
199+
const double CONST_COR_COEF[6] = {0.98312, 0.978532, 0.972211, 0.756004, 0.638075, 0.547192};
200+
const double LINEAR_COR_COEF[6] = {-0.0472436, -0.186206, -0.247339, -0.166062, -0.159781, -0.118747};
201+
const double SQUARE_COR_COEF[6] = {0, 0, 0.0356827, 0.0202461, 0.01785078, 0.0123003};
202+
const int PU_IETA_1 = 7;
203+
const int PU_IETA_2 = 16;
204+
const int PU_IETA_3 = 25;
205+
const int PU_IETA_4 = 26;
206+
const int PU_IETA_5 = 27;
207+
unsigned icor = (unsigned(jeta >= PU_IETA_1) + unsigned(jeta >= PU_IETA_2) + unsigned(jeta >= PU_IETA_3) +
208+
unsigned(jeta >= PU_IETA_4) + unsigned(jeta >= PU_IETA_5));
209+
double deltaCut = (icor > 2) ? 1.0 : DELTA_CUT;
210+
if (d2p > deltaCut)
211+
fac = (CONST_COR_COEF[icor] + LINEAR_COR_COEF[icor] * d2p + SQUARE_COR_COEF[icor] * d2p * d2p);
212+
if (debug)
213+
std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " << icor << ":" << CONST_COR_COEF[icor] << ":"
214+
<< LINEAR_COR_COEF[icor] << ":" << SQUARE_COR_COEF[icor] << " Fac " << fac;
215+
} else { // 21pu (June, 2021)
216+
const double CONST_COR_COEF[6] = {0.989727, 0.981923, 0.97571, 0.562475, 0.467947, 0.411831};
217+
const double LINEAR_COR_COEF[6] = {-0.0469558, -0.125805, -0.251383, -0.0668994, -0.0964236, -0.0947158};
218+
const double SQUARE_COR_COEF[6] = {0, 0, 0.0399785, 0.00610104, 0.00952528, 0.0100645};
219+
const int PU_IETA_1 = 7;
220+
const int PU_IETA_2 = 16;
221+
const int PU_IETA_3 = 25;
222+
const int PU_IETA_4 = 26;
223+
const int PU_IETA_5 = 27;
224+
unsigned icor = (unsigned(jeta >= PU_IETA_1) + unsigned(jeta >= PU_IETA_2) + unsigned(jeta >= PU_IETA_3) +
225+
unsigned(jeta >= PU_IETA_4) + unsigned(jeta >= PU_IETA_5));
226+
double deltaCut = (icor > 2) ? 1.0 : DELTA_CUT;
227+
if (d2p > deltaCut)
228+
fac = (CONST_COR_COEF[icor] + LINEAR_COR_COEF[icor] * d2p + SQUARE_COR_COEF[icor] * d2p * d2p);
229+
if (debug)
230+
std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " << icor << ":" << CONST_COR_COEF[icor] << ":"
231+
<< LINEAR_COR_COEF[icor] << ":" << SQUARE_COR_COEF[icor] << " Fac " << fac;
198232
}
199233
}
200234
if (fac < 0 || fac > 1)
@@ -307,9 +341,10 @@ private:
307341
const int useScale_;
308342
const double scale_;
309343
const bool etaMax_, debug_;
344+
static const int depMax_ = 10;
310345
bool corrE_;
311346
int etamp_, etamn_;
312-
double cfacmp_, cfacmn_;
347+
double cfacmp_[depMax_], cfacmn_[depMax_];
313348
std::map<std::pair<int, int>, double> cfactors_;
314349
};
315350

@@ -357,7 +392,11 @@ private:
357392
};
358393

359394
CalibCorrFactor::CalibCorrFactor(const char* infile, int useScale, double scale, bool etamax, bool debug)
360-
: useScale_(useScale), scale_(scale), etaMax_(etamax), debug_(debug), etamp_(0), etamn_(0), cfacmp_(1), cfacmn_(1) {
395+
: useScale_(useScale), scale_(scale), etaMax_(etamax), debug_(debug), etamp_(0), etamn_(0) {
396+
for (int i = 0; i < depMax_; ++i) {
397+
cfacmp_[i] = 1.0;
398+
cfacmn_[i] = 1.0;
399+
}
361400
if (std::string(infile) != "") {
362401
corrE_ = readCorrFactor(infile);
363402
std::cout << "Reads " << cfactors_.size() << " correction factors from " << infile << " with flag " << corrE_
@@ -382,9 +421,9 @@ double CalibCorrFactor::getCorr(unsigned int id) {
382421
cfac = itr->second;
383422
} else if (etaMax_) {
384423
if (zside > 0 && ieta > etamp_)
385-
cfac = cfacmp_;
424+
cfac = (depth < depMax_) ? cfacmp_[depth] : cfacmp_[depMax_ - 1];
386425
if (zside < 0 && ieta > -etamn_)
387-
cfac = cfacmn_;
426+
cfac = (depth < depMax_) ? cfacmn_[depth] : cfacmn_[depMax_ - 1];
388427
}
389428
} else if (useScale_ != 0) {
390429
int subdet, zside, ieta, iphi, depth;
@@ -417,20 +456,21 @@ bool CalibCorrFactor::readCorrFactor(const char* fname) {
417456
float corrf = std::atof(items[3].c_str());
418457
double scale = getFactor(std::abs(ieta));
419458
cfactors_[std::pair<int, int>(ieta, depth)] = scale * corrf;
420-
if (ieta > etamp_ && depth == 1) {
459+
if (ieta > etamp_ && depth == 1)
421460
etamp_ = ieta;
422-
cfacmp_ = scale * corrf;
423-
}
424-
if (ieta < etamn_ && depth == 1) {
461+
if (ieta == etamp_ && depth < depMax_)
462+
cfacmp_[depth] = scale * corrf;
463+
if (ieta < etamn_ && depth == 1)
425464
etamn_ = ieta;
426-
cfacmn_ = scale * corrf;
427-
}
465+
if (ieta == etamn_ && depth < depMax_)
466+
cfacmn_[depth] = scale * corrf;
428467
}
429468
}
430469
fInput.close();
431470
std::cout << "Reads total of " << all << " and " << good << " good records"
432-
<< " Max eta (z>0) " << etamp_ << ":" << cfacmp_ << " eta (z<0) " << etamn_ << ":" << cfacmn_
433-
<< std::endl;
471+
<< " Max eta (z>0) " << etamp_ << " eta (z<0) " << etamn_ << std::endl;
472+
for (int i = 0; i < depMax_; ++i)
473+
std::cout << "[" << i << "] C+ " << cfacmp_[i] << " C- " << cfacmn_[i] << std::endl;
434474
if (good > 0)
435475
ok = true;
436476
}

Calibration/HcalCalibAlgos/macros/CalibFitPlots.C

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
//
3737
// For plotting on the same canvas plots with different
3838
// prefixes residing in the same file with approrprate text
39-
// PlotTwoHists(infile, prefix1, text1, prefix2, text2, text0, type, iname,
40-
// lumi, ener, drawStatBox, save);
39+
// PlotTwoHists(infile, prefix1, text1, prefix2, text2, text0, type, iname,
40+
// lumi, ener, drawStatBox, save);
4141
// Defaults: type=0; iname=2; lumi=0; ener=13; drawStatBox=true;
4242
// save=0;
4343
// Note prefixN, textN have the same meaning as prefix and text for set N
@@ -46,8 +46,8 @@
4646
// =1 plots MPV of response vs RBX #
4747
//
4848
// For plotting stored histograms from CalibTree
49-
// PlotFiveHists(infile, text0, prefix0, type, iname, drawStatBox, normalize,
50-
// save, prefix1, text1, prefix2, text2, prefix3, text3,
49+
// PlotFiveHists(infile, text0, prefix0, type, iname, drawStatBox, normalize,
50+
// save, prefix1, text1, prefix2, text2, prefix3, text3,
5151
// prefix4, text4, prefix5, text5);
5252
// Defaults: type=0; iname=0; drawStatBox=true; normalize=false;
5353
// save=0; prefixN=""; textN=""; (for N > 0)
@@ -1222,6 +1222,7 @@ void PlotHistEta(const char* infile,
12221222
int eta = (k > numb2) ? (k - numb2) : (k - numb2 - 1);
12231223
sprintf(name, "%s%s%d%d", prefix.c_str(), name0.c_str(), iene, k);
12241224
TH1D* hist1 = (TH1D*)file->FindObjectAny(name);
1225+
std::cout << name << " at " << hist1 << std::endl;
12251226
if (hist1 != nullptr) {
12261227
TH1D* hist = (TH1D*)(hist1->Clone());
12271228
double ymin(0.90);
@@ -1928,8 +1929,8 @@ void PlotHistCorrFactor(char* infile,
19281929
gStyle->SetOptStat(0);
19291930
gStyle->SetOptFit(0);
19301931
}
1931-
int colors[6] = {1, 6, 4, 7, 2, 9};
1932-
int mtype[6] = {20, 21, 22, 23, 24, 33};
1932+
int colors[7] = {1, 6, 4, 7, 2, 9, 3};
1933+
int mtype[7] = {20, 21, 22, 23, 24, 33, 25};
19331934
int nbin = etamax - etamin + 1;
19341935
std::vector<TH1D*> hists;
19351936
std::vector<int> entries;

Calibration/HcalCalibAlgos/macros/CalibMonitor.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ void CalibMonitor::Loop() {
935935
break;
936936
nb = fChain->GetEntry(jentry);
937937
nbytes += nb;
938-
if (jentry % 100000 == 0)
938+
if (jentry % 1000000 == 0)
939939
std::cout << "Entry " << jentry << " Run " << t_Run << " Event " << t_Event << std::endl;
940940
double pmom = (useGen_ && (t_gentrackP > 0)) ? t_gentrackP : t_p;
941941
bool p4060 = ((pmom >= 40.0) && (pmom <= 60.0));
@@ -2623,7 +2623,7 @@ void CalibPlotProperties::Loop() {
26232623
break;
26242624
nb = fChain->GetEntry(jentry);
26252625
nbytes += nb;
2626-
if (jentry % 100000 == 0)
2626+
if (jentry % 1000000 == 0)
26272627
std::cout << "Entry " << jentry << " Run " << t_Run << " Event " << t_Event << std::endl;
26282628
bool select = (std::find(entries_.begin(), entries_.end(), jentry) == entries_.end());
26292629
if (!select) {

Calibration/HcalCalibAlgos/macros/CalibPlotProperties.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ void CalibPlotProperties::Loop(Long64_t nentries) {
778778
break;
779779
nb = fChain->GetEntry(jentry);
780780
nbytes += nb;
781-
if (jentry % 100000 == 0)
781+
if (jentry % 1000000 == 0)
782782
std::cout << "Entry " << jentry << " Run " << t_Run << " Event " << t_Event << std::endl;
783783
bool select = (std::find(entries_.begin(), entries_.end(), jentry) == entries_.end());
784784
if (!select) {

0 commit comments

Comments
 (0)