File indexing completed on 2025-09-12 10:10:00
0001 #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h"
0002 #include <cstdint>
0003
0004 HGCalVFESummationImpl::HGCalVFESummationImpl(const edm::ParameterSet& conf)
0005 : lsb_silicon_fC_(conf.getParameter<double>("siliconCellLSB_fC")),
0006 lsb_scintillator_MIP_(conf.getParameter<double>("scintillatorCellLSB_MIP")) {
0007 thresholds_silicon_ =
0008 conf.getParameter<edm::ParameterSet>("noiseSilicon").getParameter<std::vector<double>>("values");
0009 threshold_scintillator_ = conf.getParameter<edm::ParameterSet>("noiseScintillator").getParameter<double>("noise_MIP");
0010 const auto threshold = conf.getParameter<double>("noiseThreshold");
0011 std::transform(
0012 thresholds_silicon_.begin(), thresholds_silicon_.end(), thresholds_silicon_.begin(), [threshold](auto noise) {
0013 return noise * threshold;
0014 });
0015 threshold_scintillator_ *= threshold;
0016 }
0017
0018 void HGCalVFESummationImpl::checkSizeValidity() const {
0019 unsigned nThickness = triggerTools_.nSiWaferTypes();
0020 if (thresholds_silicon_.size() != nThickness) {
0021 throw cms::Exception("Configuration") << thresholds_silicon_.size() << " silicon thresholds are given instead of "
0022 << nThickness << " (the number of sensor thicknesses)";
0023 }
0024 }
0025
0026 void HGCalVFESummationImpl::triggerCellSums(const std::vector<std::pair<DetId, uint32_t>>& input_dataframes,
0027 std::unordered_map<uint32_t, uint32_t>& triggercells) {
0028 if (input_dataframes.empty())
0029 return;
0030
0031 for (const auto& [cellid, value] : input_dataframes) {
0032
0033 uint32_t value_zero_suppressed = value;
0034 if (triggerTools_.isSilicon(cellid)) {
0035 int thickness = triggerTools_.thicknessIndex(cellid);
0036 double threshold = thresholds_silicon_.at(thickness);
0037 value_zero_suppressed = (value * lsb_silicon_fC_ > threshold ? value : 0);
0038 } else if (triggerTools_.isScintillator(cellid)) {
0039 value_zero_suppressed = (value * lsb_scintillator_MIP_ > threshold_scintillator_ ? value : 0);
0040 }
0041 if (value_zero_suppressed == 0)
0042 continue;
0043
0044
0045 uint32_t tcid = triggerTools_.getTriggerGeometry()->getTriggerCellFromCell(cellid);
0046 triggercells.emplace(tcid, 0);
0047
0048
0049 triggercells[tcid] += value_zero_suppressed;
0050 }
0051 }