diff --git a/SimCalorimetry/HcalTrigPrimAlgos/interface/HcalTriggerPrimitiveAlgo.h b/SimCalorimetry/HcalTrigPrimAlgos/interface/HcalTriggerPrimitiveAlgo.h index b050a2f32a899..150be73086fc0 100644 --- a/SimCalorimetry/HcalTrigPrimAlgos/interface/HcalTriggerPrimitiveAlgo.h +++ b/SimCalorimetry/HcalTrigPrimAlgos/interface/HcalTriggerPrimitiveAlgo.h @@ -80,7 +80,7 @@ class HcalTriggerPrimitiveAlgo { HcalTrigPrimDigiCollection& result); void setPeakFinderAlgorithm(int algo); void setWeightsQIE11(const edm::ParameterSet& weightsQIE11); - void setWeightQIE11(int aieta, double weight); + void setWeightQIE11(int aieta, int weight); void setNCTScaleShift(int); void setRCTScaleShift(int); @@ -136,7 +136,7 @@ class HcalTriggerPrimitiveAlgo { double theThreshold; bool peakfind_; std::vector weights_; - std::array, 29> weightsQIE11_; + std::array, 29> weightsQIE11_; int latency_; uint32_t FG_threshold_; std::vector FG_HF_thresholds_; diff --git a/SimCalorimetry/HcalTrigPrimAlgos/src/HcalTriggerPrimitiveAlgo.cc b/SimCalorimetry/HcalTrigPrimAlgos/src/HcalTriggerPrimitiveAlgo.cc index 9cd27fbeeef93..e7b0e60f775c1 100644 --- a/SimCalorimetry/HcalTrigPrimAlgos/src/HcalTriggerPrimitiveAlgo.cc +++ b/SimCalorimetry/HcalTrigPrimAlgos/src/HcalTriggerPrimitiveAlgo.cc @@ -439,38 +439,76 @@ void HcalTriggerPrimitiveAlgo::analyzeQIE11(IntegerCaloSamples& samples, for (unsigned int ibin = 0; ibin < dgSamples - shrink; ++ibin) { int algosumvalue = 0; bool check_sat = false; - for (unsigned int i = 0; i < filterSamples; i++) { + //TP energy calculation for PFA2 + if (weightsQIE11_[theIeta][0] == 255) { + for (unsigned int i = 0; i < filterSamples; i++) { + //add up value * scale factor + // In addition, divide by two in the 10 degree phi segmentation region + // to mimic 5 degree segmentation for the trigger + unsigned int sample = samples[ibin + i]; + + if (fix_saturation_ && (sample_saturation.size() > ibin + i)) + check_sat = (check_sat | sample_saturation[ibin + i] | (sample > QIE11_MAX_LINEARIZATION_ET)); + + if (sample > QIE11_MAX_LINEARIZATION_ET) + sample = QIE11_MAX_LINEARIZATION_ET; + + // Usually use a segmentation factor of 1.0 but for ieta >= 21 use 2 + int segmentationFactor = 1; + if (ids.size() == 2) { + segmentationFactor = 2; + } + + algosumvalue += int(sample / segmentationFactor); + } + if (algosumvalue < 0) + sum[ibin] = 0; // low-side + //high-side + //else if (algosumvalue>QIE11_LINEARIZATION_ET) sum[ibin]=QIE11_LINEARIZATION_ET; + else + sum[ibin] = algosumvalue; //assign value to sum[] + + if (check_sat) + force_saturation[ibin] = true; + //TP energy calculation for PFA1' and PFA1 + } else { //add up value * scale factor // In addition, divide by two in the 10 degree phi segmentation region // to mimic 5 degree segmentation for the trigger - unsigned int sample = samples[ibin + i]; + int sampleTS = samples[ibin + 1]; + int sampleTSminus1 = samples[ibin]; - if (fix_saturation_ && (sample_saturation.size() > ibin + i)) - check_sat = (check_sat | sample_saturation[ibin + i] | (sample > QIE11_MAX_LINEARIZATION_ET)); + if (fix_saturation_ && (sample_saturation.size() > ibin + 1)) + check_sat = (sample_saturation[ibin + 1] | (sampleTS >= QIE11_MAX_LINEARIZATION_ET) | sample_saturation[ibin] | + (sampleTSminus1 >= QIE11_MAX_LINEARIZATION_ET)); - if (sample > QIE11_MAX_LINEARIZATION_ET) - sample = QIE11_MAX_LINEARIZATION_ET; + if (sampleTS > QIE11_MAX_LINEARIZATION_ET) + sampleTS = QIE11_MAX_LINEARIZATION_ET; - // Usually use a segmentation factor of 1.0 but for ieta >= 21 use 0.5 - double segmentationFactor = 1.0; + if (sampleTSminus1 > QIE11_MAX_LINEARIZATION_ET) + sampleTSminus1 = QIE11_MAX_LINEARIZATION_ET; + + // Usually use a segmentation factor of 1.0 but for ieta >= 21 use 2 + int segmentationFactor = 1; if (ids.size() == 2) { - segmentationFactor = 0.5; + segmentationFactor = 2; } // Based on the |ieta| of the sample, retrieve the correct region weight - double theWeight = weightsQIE11_[theIeta][i]; + int theWeight = weightsQIE11_[theIeta][0]; - algosumvalue += int(sample * segmentationFactor * theWeight); - } - if (algosumvalue < 0) - sum[ibin] = 0; // low-side - //high-side - //else if (algosumvalue>QIE11_LINEARIZATION_ET) sum[ibin]=QIE11_LINEARIZATION_ET; - else - sum[ibin] = algosumvalue; //assign value to sum[] + algosumvalue = ((sampleTS << 8) - (sampleTSminus1 * theWeight)) / 256 / segmentationFactor; + + if (algosumvalue < 0) + sum[ibin] = 0; // low-side + //high-side + //else if (algosumvalue>QIE11_LINEARIZATION_ET) sum[ibin]=QIE11_LINEARIZATION_ET; + else + sum[ibin] = algosumvalue; //assign value to sum[] - if (check_sat) - force_saturation[ibin] = true; + if (check_sat) + force_saturation[ibin] = true; + } } std::vector finegrain(tpSamples, false); @@ -490,13 +528,13 @@ void HcalTriggerPrimitiveAlgo::analyzeQIE11(IntegerCaloSamples& samples, } //Only run the peak-finder when the PFA2 FIR filter is running, which corresponds to weights = 1 - if (weightsQIE11_[theIeta][0] == 1) { + if (weightsQIE11_[theIeta][0] == 255) { bool isPeak = (sum[idx] > sum[idx - 1] && sum[idx] >= sum[idx + 1] && sum[idx] > theThreshold); if (isPeak) { output[ibin] = std::min(sum[idx], QIE11_MAX_LINEARIZATION_ET); if (fix_saturation_ && force_saturation[idx] && ids.size() == 2) - output[ibin] = QIE11_MAX_LINEARIZATION_ET * 0.5; + output[ibin] = QIE11_MAX_LINEARIZATION_ET / 2; else if (fix_saturation_ && force_saturation[idx]) output[ibin] = QIE11_MAX_LINEARIZATION_ET; @@ -508,7 +546,7 @@ void HcalTriggerPrimitiveAlgo::analyzeQIE11(IntegerCaloSamples& samples, output[ibin] = std::min(sum[idx], QIE11_MAX_LINEARIZATION_ET); if (fix_saturation_ && force_saturation[idx] && ids.size() == 2) - output[ibin] = QIE11_MAX_LINEARIZATION_ET * 0.5; + output[ibin] = QIE11_MAX_LINEARIZATION_ET / 2; else if (fix_saturation_ && force_saturation[idx]) output[ibin] = QIE11_MAX_LINEARIZATION_ET; } @@ -957,15 +995,15 @@ void HcalTriggerPrimitiveAlgo::setWeightsQIE11(const edm::ParameterSet& weightsQ std::vector ietaStrs = weightsQIE11.getParameterNames(); for (auto& ietaStr : ietaStrs) { // Strip off "ieta" part of key and just use integer value in map - auto const& v = weightsQIE11.getParameter>(ietaStr); + auto const& v = weightsQIE11.getParameter>(ietaStr); weightsQIE11_[std::stoi(ietaStr.substr(4))] = {{v[0], v[1]}}; } } -void HcalTriggerPrimitiveAlgo::setWeightQIE11(int aieta, double weight) { +void HcalTriggerPrimitiveAlgo::setWeightQIE11(int aieta, int weight) { // Simple map of |ieta| in HBHE to weight // Only one weight for SOI-1 TS - weightsQIE11_[aieta] = {{weight, 1.0}}; + weightsQIE11_[aieta] = {{weight, 255}}; } void HcalTriggerPrimitiveAlgo::setPeakFinderAlgorithm(int algo) { diff --git a/SimCalorimetry/HcalTrigPrimProducers/plugins/HcalTrigPrimDigiProducer.cc b/SimCalorimetry/HcalTrigPrimProducers/plugins/HcalTrigPrimDigiProducer.cc index 4abb171cfecd3..7a6f069385816 100644 --- a/SimCalorimetry/HcalTrigPrimProducers/plugins/HcalTrigPrimDigiProducer.cc +++ b/SimCalorimetry/HcalTrigPrimProducers/plugins/HcalTrigPrimDigiProducer.cc @@ -175,7 +175,7 @@ void HcalTrigPrimDigiProducer::beginRun(const edm::Run& run, const edm::EventSet int aieta = abs(hcalTTDetId.ieta()); // Filter weight represented in fixed point 8 bit - int fixedPointWeight = -1.0; + int fixedPointWeight = -1; // The absence of TT channels in the HcalTPChannelParameters // is intepreted as to not use the new filter @@ -190,22 +190,22 @@ void HcalTrigPrimDigiProducer::beginRun(const edm::Run& run, const edm::EventSet // Size of filter is already known when using DB weights // Weight from DB represented as 8-bit integer if (!overrideDBweightsAndFilterHB_) { - if (fixedPointWeight != -1.0) { + if (fixedPointWeight != -1) { theAlgo_.setNumFilterPresamplesHBQIE11(1); - theAlgo_.setWeightQIE11(aieta, -static_cast(fixedPointWeight) / 256.0); + theAlgo_.setWeightQIE11(aieta, fixedPointWeight); } else { theAlgo_.setNumFilterPresamplesHBQIE11(0); - theAlgo_.setWeightQIE11(aieta, 1.0); + theAlgo_.setWeightQIE11(aieta, 255); } } } else if (aieta < lastHERing) { if (!overrideDBweightsAndFilterHE_) { - if (fixedPointWeight != -1.0) { + if (fixedPointWeight != -1) { theAlgo_.setNumFilterPresamplesHEQIE11(1); - theAlgo_.setWeightQIE11(aieta, -static_cast(fixedPointWeight) / 256.0); + theAlgo_.setWeightQIE11(aieta, fixedPointWeight); } else { theAlgo_.setNumFilterPresamplesHEQIE11(0); - theAlgo_.setWeightQIE11(aieta, 1.0); + theAlgo_.setWeightQIE11(aieta, 255); } } } diff --git a/SimCalorimetry/HcalTrigPrimProducers/python/hcaltpdigi_cfi.py b/SimCalorimetry/HcalTrigPrimProducers/python/hcaltpdigi_cfi.py index b261766aa6651..9bdb9c10fe2f6 100644 --- a/SimCalorimetry/HcalTrigPrimProducers/python/hcaltpdigi_cfi.py +++ b/SimCalorimetry/HcalTrigPrimProducers/python/hcaltpdigi_cfi.py @@ -18,34 +18,34 @@ peakFilter = cms.bool(True), weights = cms.vdouble(1.0, 1.0), ##hardware algo weightsQIE11 = cms.PSet( - ieta1 = cms.vdouble(1.0, 1.0), - ieta2 = cms.vdouble(1.0, 1.0), - ieta3 = cms.vdouble(1.0, 1.0), - ieta4 = cms.vdouble(1.0, 1.0), - ieta5 = cms.vdouble(1.0, 1.0), - ieta6 = cms.vdouble(1.0, 1.0), - ieta7 = cms.vdouble(1.0, 1.0), - ieta8 = cms.vdouble(1.0, 1.0), - ieta9 = cms.vdouble(1.0, 1.0), - ieta10 = cms.vdouble(1.0, 1.0), - ieta11 = cms.vdouble(1.0, 1.0), - ieta12 = cms.vdouble(1.0, 1.0), - ieta13 = cms.vdouble(1.0, 1.0), - ieta14 = cms.vdouble(1.0, 1.0), - ieta15 = cms.vdouble(1.0, 1.0), - ieta16 = cms.vdouble(1.0, 1.0), - ieta17 = cms.vdouble(1.0, 1.0), - ieta18 = cms.vdouble(1.0, 1.0), - ieta19 = cms.vdouble(1.0, 1.0), - ieta20 = cms.vdouble(1.0, 1.0), - ieta21 = cms.vdouble(1.0, 1.0), - ieta22 = cms.vdouble(1.0, 1.0), - ieta23 = cms.vdouble(1.0, 1.0), - ieta24 = cms.vdouble(1.0, 1.0), - ieta25 = cms.vdouble(1.0, 1.0), - ieta26 = cms.vdouble(1.0, 1.0), - ieta27 = cms.vdouble(1.0, 1.0), - ieta28 = cms.vdouble(1.0, 1.0) + ieta1 = cms.vint32(255, 255), + ieta2 = cms.vint32(255, 255), + ieta3 = cms.vint32(255, 255), + ieta4 = cms.vint32(255, 255), + ieta5 = cms.vint32(255, 255), + ieta6 = cms.vint32(255, 255), + ieta7 = cms.vint32(255, 255), + ieta8 = cms.vint32(255, 255), + ieta9 = cms.vint32(255, 255), + ieta10 = cms.vint32(255, 255), + ieta11 = cms.vint32(255, 255), + ieta12 = cms.vint32(255, 255), + ieta13 = cms.vint32(255, 255), + ieta14 = cms.vint32(255, 255), + ieta15 = cms.vint32(255, 255), + ieta16 = cms.vint32(255, 255), + ieta17 = cms.vint32(255, 255), + ieta18 = cms.vint32(255, 255), + ieta19 = cms.vint32(255, 255), + ieta20 = cms.vint32(255, 255), + ieta21 = cms.vint32(255, 255), + ieta22 = cms.vint32(255, 255), + ieta23 = cms.vint32(255, 255), + ieta24 = cms.vint32(255, 255), + ieta25 = cms.vint32(255, 255), + ieta26 = cms.vint32(255, 255), + ieta27 = cms.vint32(255, 255), + ieta28 = cms.vint32(255, 255) ), latency = cms.int32(1),