File indexing completed on 2023-03-17 11:12:18
0001 #ifndef __L1Trigger_L1THGCal_HGCalConcentratorSuperTriggerCellImpl_h__
0002 #define __L1Trigger_L1THGCal_HGCalConcentratorSuperTriggerCellImpl_h__
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"
0006 #include "L1Trigger/L1THGCal/interface/HGCalCoarseTriggerCellMapping.h"
0007 #include "L1Trigger/L1THGCal/interface/HGCalVFECompressionImpl.h"
0008 #include "L1Trigger/L1THGCal/interface/HGCalTriggerCellCalibration.h"
0009
0010 #include <array>
0011 #include <vector>
0012
0013 class HGCalConcentratorSuperTriggerCellImpl {
0014 public:
0015 HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf);
0016
0017 void select(const std::vector<l1t::HGCalTriggerCell>& trigCellVecInput,
0018 std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput);
0019 void setGeometry(const HGCalTriggerGeometryBase* const geom) {
0020 triggerTools_.setGeometry(geom);
0021 coarseTCmapping_.setGeometry(geom);
0022 superTCmapping_.setGeometry(geom);
0023 calibrationEE_.setGeometry(geom);
0024 calibrationHEsi_.setGeometry(geom);
0025 calibrationHEsc_.setGeometry(geom);
0026 calibrationNose_.setGeometry(geom);
0027 }
0028
0029 private:
0030 enum EnergyDivisionType {
0031 superTriggerCell,
0032 oneBitFraction,
0033 equalShare,
0034 };
0035
0036 EnergyDivisionType energyDivisionType_;
0037 static constexpr int kHighDensityThickness_ = 0;
0038 static constexpr int kOddNumberMask_ = 1;
0039
0040 HGCalTriggerTools triggerTools_;
0041 bool fixedDataSizePerHGCROC_;
0042 std::vector<unsigned> coarsenTriggerCells_;
0043 HGCalCoarseTriggerCellMapping coarseTCmapping_;
0044 HGCalCoarseTriggerCellMapping superTCmapping_;
0045
0046
0047 double oneBitFractionThreshold_;
0048 double oneBitFractionLowValue_;
0049 double oneBitFractionHighValue_;
0050
0051
0052 static constexpr int kTriggerCellsForDivision_ = 4;
0053
0054 HGCalTriggerCellCalibration calibrationEE_;
0055 HGCalTriggerCellCalibration calibrationHEsi_;
0056 HGCalTriggerCellCalibration calibrationHEsc_;
0057 HGCalTriggerCellCalibration calibrationNose_;
0058 HGCalVFECompressionImpl vfeCompression_;
0059
0060 class SuperTriggerCell {
0061 private:
0062 float sumPt_, sumMipPt_, maxMipPt_, fracsum_;
0063 int sumHwPt_;
0064 uint32_t maxId_, stcId_;
0065 std::map<uint32_t, float> tc_pts_;
0066
0067 public:
0068 SuperTriggerCell() : sumPt_(0), sumMipPt_(0), maxMipPt_(0), fracsum_(0), sumHwPt_(0), maxId_(0), stcId_(0){};
0069
0070 void add(const l1t::HGCalTriggerCell& c, uint32_t stcId) {
0071 sumPt_ += c.pt();
0072 sumMipPt_ += c.mipPt();
0073 sumHwPt_ += c.hwPt();
0074 if (maxId_ == 0 || c.mipPt() > maxMipPt_) {
0075 maxMipPt_ = c.mipPt();
0076 maxId_ = c.detId();
0077 }
0078
0079 if (stcId_ == 0) {
0080 stcId_ = stcId;
0081 }
0082 tc_pts_[c.detId()] = c.mipPt();
0083 }
0084 void addToFractionSum(float frac) {
0085 fracsum_ += frac;
0086 if (fracsum_ > 1) {
0087 throw cms::Exception("HGCalConcentratorSuperTriggerCellError")
0088 << "Sum of Trigger Cell fractions should not be greater than 1";
0089 }
0090 }
0091 uint32_t getMaxId() const { return maxId_; }
0092 uint32_t getSTCId() const { return stcId_; }
0093 float getSumMipPt() const { return sumMipPt_; }
0094 int getSumHwPt() const { return sumHwPt_; }
0095 float getSumPt() const { return sumPt_; }
0096 float getFractionSum() const { return fracsum_; }
0097 float getTCpt(uint32_t tcid) const {
0098 const auto pt = tc_pts_.find(tcid);
0099 return (pt == tc_pts_.end() ? 0 : pt->second);
0100 }
0101 int size() const { return tc_pts_.size(); }
0102 };
0103 void createAllTriggerCells(std::unordered_map<unsigned, SuperTriggerCell>& STCs,
0104 std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput) const;
0105 void assignSuperTriggerCellEnergyAndPosition(l1t::HGCalTriggerCell& c, const SuperTriggerCell& stc) const;
0106 float getTriggerCellOneBitFraction(float tcPt, float sumPt) const;
0107 uint32_t getCompressedSTCEnergy(const SuperTriggerCell& stc) const;
0108 };
0109
0110 #endif