Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-09 03:15:14

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   uint32_t compressed_value(0);
0027   vfeCompression_.compressSingle(ctc.sumHwPt, code, compressed_value);
0028 
0029   tc.setHwPt(compressed_value);
0030   calibration_.calibrateInGeV(tc);
0031 }
0032 
0033 void HGCalConcentratorCoarsenerImpl::coarsen(const std::vector<l1t::HGCalTriggerCell>& trigCellVecInput,
0034                                              std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput) {
0035   coarseTCs_.clear();
0036 
0037   // first pass, fill the coarse trigger cell information
0038   for (const l1t::HGCalTriggerCell& tc : trigCellVecInput) {
0039     int thickness = triggerTools_.thicknessIndex(tc.detId());
0040 
0041     if (fixedDataSizePerHGCROC_ && thickness == kHighDensityThickness_) {
0042       trigCellVecOutput.push_back(tc);
0043       continue;
0044     }
0045 
0046     uint32_t ctcid = coarseTCmapping_.getCoarseTriggerCellId(tc.detId());
0047     updateCoarseTriggerCellMaps(tc, ctcid);
0048   }
0049 
0050   for (const auto& ctc : coarseTCs_) {
0051     l1t::HGCalTriggerCell triggerCell;
0052 
0053     uint32_t representativeId = coarseTCmapping_.getRepresentativeDetId(ctc.second.maxId);
0054     triggerCell.setDetId(representativeId);
0055 
0056     GlobalPoint point = coarseTCmapping_.getCoarseTriggerCellPosition(ctc.first);
0057     math::PtEtaPhiMLorentzVector initial_p4(ctc.second.sumPt, point.eta(), point.phi(), 0);
0058 
0059     triggerCell.setP4(initial_p4);
0060     assignCoarseTriggerCellEnergy(triggerCell, ctc.second);
0061 
0062     math::PtEtaPhiMLorentzVector p4(triggerCell.pt(), point.eta(), point.phi(), 0);
0063     triggerCell.setPosition(point);
0064     triggerCell.setP4(p4);
0065     trigCellVecOutput.push_back(triggerCell);
0066   }
0067 }