Skip to content

Commit d54f536

Browse files
authored
Merge pull request #46544 from hjbossi/PRfor_14_1_X_HCALLUTScaling
[14_1_X] Backport of modifications to make ZDC trigger spacing configurable with TP channel parameters.
2 parents 6e2aeb3 + 38697ae commit d54f536

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class HcalDbService;
3232
class HcaluLUTTPGCoder : public HcalTPGCoder {
3333
public:
3434
static const float lsb_;
35-
static const float zdc_lsb_;
3635

3736
HcaluLUTTPGCoder();
3837
HcaluLUTTPGCoder(const HcalTopology* topo, const HcalTimeSlew* delay);

CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <fstream>
33
#include <cmath>
44
#include <string>
5+
#include <algorithm>
56
#include "CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h"
67
#include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
78
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
@@ -29,7 +30,6 @@
2930
#include "CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h"
3031

3132
const float HcaluLUTTPGCoder::lsb_ = 1. / 16;
32-
const float HcaluLUTTPGCoder::zdc_lsb_ = 50.;
3333

3434
const int HcaluLUTTPGCoder::QIE8_LUT_BITMASK;
3535
const int HcaluLUTTPGCoder::QIE10_LUT_BITMASK;
@@ -275,10 +275,10 @@ void HcaluLUTTPGCoder::update(const char* filename, bool appendMSB) {
275275
} else
276276
inputLUT_[lutId][adc] = lutFromFile[i][adc];
277277
} // for adc
278-
} // for depth
279-
} // for iphi
280-
} // for ieta
281-
} // for nCol
278+
} // for depth
279+
} // for iphi
280+
} // for ieta
281+
} // for nCol
282282
}
283283

284284
void HcaluLUTTPGCoder::updateXML(const char* filename) {
@@ -595,10 +595,21 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
595595
const HcalLutMetadatum* meta = metadata->getValues(cell);
596596

597597
auto tpParam = conditions.getHcalTPChannelParameter(cell, false);
598-
int weight = tpParam->getauxi1();
598+
const int weight = tpParam->getauxi1();
599+
int factorGeVPerCount = tpParam->getauxi2();
600+
if (factorGeVPerCount == 0) {
601+
edm::LogWarning("HcaluLUTTPGCoder")
602+
<< "WARNING: ZDC trigger spacing factor, taken from auxi2 field of HCALTPChannelParameters for the cell "
603+
"with (zside, section, channel) = ("
604+
<< cell.zside() << " , " << cell.section() << " , " << cell.channel()
605+
<< ") is set to the "
606+
"default value of 0, which is an incompatible value for a spacing factor. Setting the value to 50 and "
607+
"continuing.";
608+
factorGeVPerCount = 50;
609+
}
599610

600-
int lutId = getLUTId(cell);
601-
int lutId_ootpu = lutId + sizeZDC_;
611+
const int lutId = getLUTId(cell);
612+
const int lutId_ootpu = lutId + sizeZDC_;
602613
Lut& lut = inputLUT_[lutId];
603614
Lut& lut_ootpu = inputLUT_[lutId_ootpu];
604615
float ped = 0;
@@ -656,9 +667,9 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
656667
lut[adc] = 0;
657668
lut_ootpu[adc] = 0;
658669
} else {
659-
lut[adc] = std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / zdc_lsb_)), MASK);
660-
lut_ootpu[adc] =
661-
std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib * weight / (zdc_lsb_ * 256))), MASK);
670+
auto lut_term = (adc2fC(adc) - ped) * gain * rcalib / factorGeVPerCount;
671+
lut[adc] = std::clamp(int(lut_term), 0, MASK);
672+
lut_ootpu[adc] = std::clamp(int(lut_term * weight / 256), 0, MASK);
662673
}
663674
}
664675
}

0 commit comments

Comments
 (0)