Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-20 01:53:35

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/gcteminput_ref.h"
0002 
0003 #ifdef CMSSW_GIT_HASH
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 
0007 // TODO: Currently this only works in CMSSW
0008 l1ct::GctEmClusterDecoderEmulator::GctEmClusterDecoderEmulator(const edm::ParameterSet &iConfig)
0009     : corrector_(iConfig.getParameter<std::string>("gctEmCorrector"), -1),
0010       resol_(iConfig.getParameter<edm::ParameterSet>("gctEmResol")) {}
0011 
0012 edm::ParameterSetDescription l1ct::GctEmClusterDecoderEmulator::getParameterSetDescription() {
0013   edm::ParameterSetDescription description;
0014   description.add<std::string>("gctEmCorrector");
0015   edm::ParameterSetDescription gctEmResolPSD;
0016   gctEmResolPSD.add<std::vector<double>>("etaBins");
0017   gctEmResolPSD.add<std::vector<double>>("offset");
0018   gctEmResolPSD.add<std::vector<double>>("scale");
0019   gctEmResolPSD.add<std::string>("kind");
0020   description.add<edm::ParameterSetDescription>("gctEmResol", gctEmResolPSD);
0021   return description;
0022 }
0023 #endif
0024 
0025 l1ct::EmCaloObjEmu l1ct::GctEmClusterDecoderEmulator::decode(const l1ct::PFRegionEmu &sector,
0026                                                              const ap_uint<64> &in) const {
0027   constexpr float ETA_RANGE_ONE_SIDE = 1.4841;  // barrel goes from (-1.4841, +1.4841)
0028   constexpr float ETA_LSB = 2 * ETA_RANGE_ONE_SIDE / 170.;
0029   constexpr float PHI_LSB = 2 * M_PI / 360.;
0030 
0031   // need to add emid
0032   l1ct::EmCaloObjEmu calo;
0033   calo.clear();
0034   calo.hwPt = pt(in) * l1ct::pt_t(0.5);  // the LSB for GCT objects
0035   // We add half a crystal both in eta and phi to avoid a bias
0036   calo.hwEta = l1ct::Scales::makeGlbEta(eta(in) * ETA_LSB + ETA_LSB / 2.);  // at this point eta is abs(globalEta)
0037   calo.hwPhi = l1ct::Scales::makePhi(phi(in) * PHI_LSB + (PHI_LSB / 2));    // This is already in the local frame
0038 
0039   if (corrector_.valid()) {
0040     float newpt =
0041         corrector_.correctedPt(calo.floatPt(), calo.floatPt(), calo.floatEta());  // NOTE: this is still abs(globalEta)
0042     calo.hwPt = l1ct::Scales::makePtFromFloat(newpt);
0043   }
0044 
0045   // Note: at this point still
0046   calo.hwPtErr =
0047       l1ct::Scales::makePtFromFloat(resol_(calo.floatPt(), calo.floatEta()));  // NOTE: this is still abs(globalEta)
0048 
0049   // hwQual definition:
0050   // bit 0: standaloneWP: is_iso && is_ss
0051   // bit 1: looseL1TkMatchWP: is_looseTkiso && is_looseTkss
0052   // bit 2: photonWP:
0053   calo.hwEmID = (passes_iso(in) && passes_ss(in)) | ((passes_looseTkiso(in) && passes_looseTkss(in)) << 1) |
0054                 ((passes_looseTkiso(in) && passes_looseTkss(in)) << 2);
0055 
0056   // convert eta to local
0057   if (sector.hwEtaCenter < 0) {
0058     calo.hwEta = -calo.hwEta - sector.hwEtaCenter;
0059   } else {
0060     calo.hwEta = calo.hwEta - sector.hwEtaCenter;
0061   }
0062 
0063   return calo;
0064 }