From 262635305191171c3bf2ebaa3703cd02c4cc7154 Mon Sep 17 00:00:00 2001 From: Hannah Date: Mon, 28 Oct 2024 23:34:43 +0100 Subject: [PATCH] Modification to move ZDC trigger spacing to TP channel parameters conditions. --- .../HcalTPGAlgos/interface/HcaluLUTTPGCoder.h | 1 - .../HcalTPGAlgos/src/HcaluLUTTPGCoder.cc | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h b/CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h index 3026bf3f176b2..d974bcf54a60d 100644 --- a/CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h +++ b/CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h @@ -32,7 +32,6 @@ class HcalDbService; class HcaluLUTTPGCoder : public HcalTPGCoder { public: static const float lsb_; - static const float zdc_lsb_; HcaluLUTTPGCoder(); HcaluLUTTPGCoder(const HcalTopology* topo, const HcalTimeSlew* delay); diff --git a/CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc b/CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc index 985c6598853cf..dc6a562d01cbb 100644 --- a/CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc +++ b/CalibCalorimetry/HcalTPGAlgos/src/HcaluLUTTPGCoder.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include "CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h" #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h" #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h" @@ -29,7 +30,6 @@ #include "CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h" const float HcaluLUTTPGCoder::lsb_ = 1. / 16; -const float HcaluLUTTPGCoder::zdc_lsb_ = 50.; const int HcaluLUTTPGCoder::QIE8_LUT_BITMASK; const int HcaluLUTTPGCoder::QIE10_LUT_BITMASK; @@ -595,10 +595,21 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) { const HcalLutMetadatum* meta = metadata->getValues(cell); auto tpParam = conditions.getHcalTPChannelParameter(cell, false); - int weight = tpParam->getauxi1(); + const int weight = tpParam->getauxi1(); + int factorGeVPerCount = tpParam->getauxi2(); + if (factorGeVPerCount == 0) { + edm::LogWarning("HcaluLUTTPGCoder") + << "WARNING: ZDC trigger spacing factor, taken from auxi2 field of HCALTPChannelParameters for the cell " + "with (zside, section, channel) = (" + << cell.zside() << " , " << cell.section() << " , " << cell.channel() + << ") is set to the " + "default value of 0, which is an incompatible value for a spacing factor. Setting the value to 50 and " + "continuing."; + factorGeVPerCount = 50; + } - int lutId = getLUTId(cell); - int lutId_ootpu = lutId + sizeZDC_; + const int lutId = getLUTId(cell); + const int lutId_ootpu = lutId + sizeZDC_; Lut& lut = inputLUT_[lutId]; Lut& lut_ootpu = inputLUT_[lutId_ootpu]; float ped = 0; @@ -656,9 +667,9 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) { lut[adc] = 0; lut_ootpu[adc] = 0; } else { - lut[adc] = std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / zdc_lsb_)), MASK); - lut_ootpu[adc] = - std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib * weight / (zdc_lsb_ * 256))), MASK); + auto lut_term = (adc2fC(adc) - ped) * gain * rcalib / factorGeVPerCount; + lut[adc] = std::clamp(int(lut_term), 0, MASK); + lut_ootpu[adc] = std::clamp(int(lut_term * weight / 256), 0, MASK); } } }