Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
void setOverrideDBweightsAndFilterHE(bool overrideDBweightsAndFilterHE) {
overrideDBweightsAndFilterHE_ = overrideDBweightsAndFilterHE;
}
void setNpedWidthsForZS(float nPedWidthsForZS) { nPedWidthsForZS_ = nPedWidthsForZS; }
void setOverrideDBnPedWidthsForZS(bool overrideDBnPedWidthsForZS) {
overrideDBnPedWidthsForZS_ = overrideDBnPedWidthsForZS;
}
void lookupMSB(const HBHEDataFrame& df, std::vector<bool>& msb) const;
void lookupMSB(const QIE10DataFrame& df, std::vector<std::bitset<2>>& msb) const;
void lookupMSB(const QIE11DataFrame& df, std::vector<std::bitset<2>>& msb) const;
Expand Down Expand Up @@ -141,6 +145,8 @@ class HcaluLUTTPGCoder : public HcalTPGCoder {
std::unique_ptr<HcalPulseContainmentManager> pulseCorr_;
bool overrideDBweightsAndFilterHB_ = false;
bool overrideDBweightsAndFilterHE_ = false;
float nPedWidthsForZS_ = 0.0;
bool overrideDBnPedWidthsForZS_ = false;
};

#endif
40 changes: 31 additions & 9 deletions CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
bool is2018OrLater = topo_->triggerMode() >= HcalTopologyMode::TriggerMode_2018 or
topo_->triggerMode() == HcalTopologyMode::TriggerMode_2018legacy;

// The number of pedestal widths for ZS is packed into the third byte
// of the 32 bit auxi1 variable from HcalTPParameters
// Assume a fixed-point SF of 1 / 16 to convert to final number of widths
float nPedWidthsForZSfromDB = ((aux1 & 0xFF0000u) >> 16) / 16.0;

// If overriding with corresponding param in python or the extracted value from third byte of HcalTPParameters auxi1 is 0,
// use the param from python. Otherwise, take the value as extracted from DB
float nPedWidthsForZSfinal =
(overrideDBnPedWidthsForZS_ or nPedWidthsForZSfromDB == 0) ? nPedWidthsForZS_ : nPedWidthsForZSfromDB;

for (const auto& id : metadata->getAllChannels()) {
if (id.det() == DetId::Hcal and topo_->valid(id)) {
HcalDetId cell(id);
Expand All @@ -479,9 +489,16 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
int lutId = getLUTId(cell);
Lut& lut = inputLUT_[lutId];
float ped = 0;
float pedwidth = 0;
float gain = 0;
uint32_t status = 0;

const HcalCalibrationWidths& calibrationWidths = conditions.getHcalCalibrationWidths(cell);
for (auto capId : {0, 1, 2, 3}) {
pedwidth += calibrationWidths.effpedestal(capId);
}
pedwidth /= 4.0;

if (LUTGenerationMode_) {
const HcalCalibrations& calibrations = conditions.getHcalCalibrations(cell);
for (auto capId : {0, 1, 2, 3}) {
Expand Down Expand Up @@ -574,17 +591,22 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
}
}
if (allLinear_)
lut[adc] = (LutElement)std::min(
std::max(0,
int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection * containmentCorrection /
linearLSB / cosh_ieta(cell.ietaAbs(), cell.depth(), HcalEndcap))),
MASK);
lut[adc] =
adc2fC(adc) - (ped + nPedWidthsForZSfinal * pedwidth) <= 0
? 0
: (LutElement)std::min(std::max(0,
int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection *
containmentCorrection / linearLSB /
cosh_ieta(cell.ietaAbs(), cell.depth(), HcalEndcap))),
MASK);
else
lut[adc] =
(LutElement)std::min(std::max(0,
int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection *
containmentCorrection / nominalgain_ / granularity)),
MASK);
adc2fC(adc) - (ped + nPedWidthsForZSfinal * pedwidth) <= 0
? 0
: (LutElement)std::min(std::max(0,
int((adc2fC(adc) - ped) * gain * rcalib * nonlinearityCorrection *
containmentCorrection / nominalgain_ / granularity)),
MASK);

unsigned int linearizedADC =
lut[adc]; // used for bits 12, 13, 14, 15 for Group 0 LUT for LLP time and depth bits that rely on linearized energies
Expand Down
7 changes: 7 additions & 0 deletions CalibCalorimetry/HcalTPGEventSetup/src/HcalTPGCoderULUT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class HcalTPGCoderULUT : public edm::ESProducer {
double containPhaseNSHB_, containPhaseNSHE_;
bool applyFixPCC_;
bool overrideDBweightsAndFilterHB_, overrideDBweightsAndFilterHE_;
double nPedWidthsForZS_;
bool overrideDBnPedWidthsForZS_;
double linearLSB_QIE8_, linearLSB_QIE11Overlap_, linearLSB_QIE11_;
int maskBit_;
bool overrideFGHF_;
Expand Down Expand Up @@ -93,6 +95,8 @@ HcalTPGCoderULUT::HcalTPGCoderULUT(const edm::ParameterSet& iConfig) {
containPhaseNSHE_ = iConfig.getParameter<double>("containPhaseNSHE");
overrideDBweightsAndFilterHB_ = iConfig.getParameter<bool>("overrideDBweightsAndFilterHB");
overrideDBweightsAndFilterHE_ = iConfig.getParameter<bool>("overrideDBweightsAndFilterHE");
nPedWidthsForZS_ = iConfig.getParameter<double>("nPedWidthsForZS");
overrideDBnPedWidthsForZS_ = iConfig.getParameter<bool>("overrideDBnPedWidthsForZS");
applyFixPCC_ = iConfig.getParameter<bool>("applyFixPCC");

//the following line is needed to tell the framework what
Expand Down Expand Up @@ -135,6 +139,9 @@ void HcalTPGCoderULUT::buildCoder(const HcalTopology* topo,
theCoder->setContainPhaseHB(containPhaseNSHB_);
theCoder->setContainPhaseHE(containPhaseNSHE_);

theCoder->setNpedWidthsForZS(nPedWidthsForZS_);
theCoder->setOverrideDBnPedWidthsForZS(overrideDBnPedWidthsForZS_);

theCoder->setApplyFixPCC(applyFixPCC_);

if (read_Ascii_ || read_XML_) {
Expand Down
2 changes: 2 additions & 0 deletions SimCalorimetry/HcalTrigPrimProducers/python/hcaltpdigi_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
applyFixPCC = PCCUpdate.applyFixPCC,
overrideDBweightsAndFilterHB = cms.bool(False),
overrideDBweightsAndFilterHE = cms.bool(False),
nPedWidthsForZS = cms.double(0.0),
overrideDBnPedWidthsForZS = cms.bool(False),
tpScales = tpScales,
MaskBit = cms.int32(0x8000),
overrideFGHF = cms.bool(False),
Expand Down