Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:53:55

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/egamma/pfeginput_ref.h"
0002 
0003 using namespace l1ct;
0004 
0005 #ifdef CMSSW_GIT_HASH
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 
0008 l1ct::EGInputSelectorEmuConfig::EGInputSelectorEmuConfig(const edm::ParameterSet &pset)
0009     : idMask(pset.getParameter<uint32_t>("emIDMask")),
0010       nHADCALO_IN(pset.getParameter<uint32_t>("nHADCALO_IN")),
0011       nEMCALO_OUT(pset.getParameter<uint32_t>("nEMCALO_OUT")),
0012       debug(pset.getUntrackedParameter<uint32_t>("debug", 0)) {}
0013 
0014 #endif
0015 
0016 void EGInputSelectorEmulator::toFirmware(const PFInputRegion &in, HadCaloObj hadcalo[/*nCALO*/]) const {
0017   l1ct::toFirmware(in.hadcalo, cfg.nHADCALO_IN, hadcalo);
0018 }
0019 
0020 void EGInputSelectorEmulator::toFirmware(const std::vector<EmCaloObjEmu> &emcalo_sel, EmCaloObj emcalo[]) const {
0021   l1ct::toFirmware(emcalo_sel, cfg.nEMCALO_OUT, emcalo);
0022 }
0023 
0024 void EGInputSelectorEmulator::select_eginput(const l1ct::HadCaloObjEmu &in,
0025                                              l1ct::EmCaloObjEmu &out,
0026                                              bool &valid_out) const {
0027   out.src = in.src;
0028   out.hwPt = in.hwEmPt;
0029   out.hwEta = in.hwEta;
0030   out.hwPhi = in.hwPhi;
0031   out.hwPtErr = 0;
0032   // shift to get rid of PFEM ID bit (more usable final EG quality)
0033   out.hwEmID = (in.hwEmID >> 1);
0034   valid_out = (in.hwEmID & cfg.idMask) != 0;
0035 }
0036 
0037 void EGInputSelectorEmulator::select_eginputs(const std::vector<HadCaloObjEmu> &hadcalo_in,
0038                                               std::vector<EmCaloObjEmu> &emcalo_sel) const {
0039   for (int ic = 0, nc = hadcalo_in.size(); ic < nc; ++ic) {
0040     if (emcalo_sel.size() == cfg.nEMCALO_OUT)
0041       break;
0042     bool valid = false;
0043     EmCaloObjEmu out;
0044     select_eginput(hadcalo_in[ic], out, valid);
0045     if (valid) {
0046       emcalo_sel.push_back(out);
0047     }
0048   }
0049 }
0050 
0051 void EGInputSelectorEmulator::select_or_clear(const HadCaloObjEmu &hadcalo_in, EmCaloObjEmu &emcalo_out) const {
0052   bool valid = false;
0053   select_eginput(hadcalo_in, emcalo_out, valid);
0054   if (!valid)
0055     emcalo_out.clear();
0056 }
0057 
0058 void EGInputSelectorEmulator::select_or_clear(const std::vector<HadCaloObjEmu> &hadcalo_in,
0059                                               std::vector<EmCaloObjEmu> &emcalo_out) const {
0060   emcalo_out.resize(hadcalo_in.size());
0061   for (int ic = 0, nc = hadcalo_in.size(); ic < nc; ++ic) {
0062     select_or_clear(hadcalo_in[ic], emcalo_out[ic]);
0063   }
0064 }