Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:42

0001 #include "L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorCoarsenerImpl.h"
0002 
0003 HGCalConcentratorCoarsenerImpl::HGCalConcentratorCoarsenerImpl(const edm::ParameterSet& conf)
0004     : fixedDataSizePerHGCROC_(conf.getParameter<bool>("fixedDataSizePerHGCROC")),
0005       coarseTCmapping_(conf.getParameter<std::vector<unsigned>>("ctcSize")),
0006       calibration_(conf.getParameterSet("superTCCalibration")),
0007       vfeCompression_(conf.getParameterSet("coarseTCCompression")) {}
0008 
0009 void HGCalConcentratorCoarsenerImpl::updateCoarseTriggerCellMaps(const l1t::HGCalTriggerCell& tc, uint32_t ctcid) {
0010   auto& ctc = coarseTCs_[ctcid];
0011 
0012   ctc.sumPt += tc.pt();
0013   ctc.sumHwPt += tc.hwPt();
0014   ctc.sumMipPt += tc.mipPt();
0015 
0016   if (tc.mipPt() > ctc.maxMipPt) {
0017     ctc.maxId = tc.detId();
0018     ctc.maxMipPt = tc.mipPt();
0019   }
0020 }
0021 
0022 void HGCalConcentratorCoarsenerImpl::assignCoarseTriggerCellEnergy(l1t::HGCalTriggerCell& tc,
0023                                                                    const CoarseTC& ctc) const {
0024   //Compress and recalibrate CTC energy
0025   uint32_t code(0);
0026   uint64_t compressed_value(0);
0027   vfeCompression_.compressSingle(ctc.sumHwPt, code, compressed_value);
0028 
0029   if (compressed_value > std::numeric_limits<int>::max())
0030     edm::LogWarning("CompressedValueDowncasting") << "Compressed value cannot fit into 32-bit word. Downcasting.";
0031 
0032   tc.setHwPt(static_cast<int>(compressed_value));
0033   calibration_.calibrateInGeV(tc);
0034 }
0035 
0036 void HGCalConcentratorCoarsenerImpl::coarsen(const std::vector<l1t::HGCalTriggerCell>& trigCellVecInput,
0037                                              std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput) {
0038   coarseTCs_.clear();
0039 
0040   // first pass, fill the coarse trigger cell information
0041   for (const l1t::HGCalTriggerCell& tc : trigCellVecInput) {
0042     int thickness = triggerTools_.thicknessIndex(tc.detId());
0043 
0044     if (fixedDataSizePerHGCROC_ && thickness == kHighDensityThickness_) {
0045       trigCellVecOutput.push_back(tc);
0046       continue;
0047     }
0048 
0049     uint32_t ctcid = coarseTCmapping_.getCoarseTriggerCellId(tc.detId());
0050     updateCoarseTriggerCellMaps(tc, ctcid);
0051   }
0052 
0053   for (const auto& ctc : coarseTCs_) {
0054     l1t::HGCalTriggerCell triggerCell;
0055 
0056     uint32_t representativeId = coarseTCmapping_.getRepresentativeDetId(ctc.second.maxId);
0057     triggerCell.setDetId(representativeId);
0058 
0059     GlobalPoint point = coarseTCmapping_.getCoarseTriggerCellPosition(ctc.first);
0060     math::PtEtaPhiMLorentzVector initial_p4(ctc.second.sumPt, point.eta(), point.phi(), 0);
0061 
0062     triggerCell.setP4(initial_p4);
0063     assignCoarseTriggerCellEnergy(triggerCell, ctc.second);
0064 
0065     math::PtEtaPhiMLorentzVector p4(triggerCell.pt(), point.eta(), point.phi(), 0);
0066     triggerCell.setPosition(point);
0067     triggerCell.setP4(p4);
0068     trigCellVecOutput.push_back(triggerCell);
0069   }
0070 }