Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:31

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 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 
0009 l1ct::EGInputSelectorEmuConfig::EGInputSelectorEmuConfig(const edm::ParameterSet &pset)
0010     : idMask(pset.getParameter<uint32_t>("emIDMask")),
0011       nHADCALO_IN(pset.getParameter<uint32_t>("nHADCALO_IN")),
0012       nEMCALO_OUT(pset.getParameter<uint32_t>("nEMCALO_OUT")),
0013       debug(pset.getUntrackedParameter<uint32_t>("debug")) {}
0014 
0015 edm::ParameterSetDescription l1ct::EGInputSelectorEmuConfig::getParameterSetDescription() {
0016   edm::ParameterSetDescription description;
0017   description.add<unsigned int>("emIDMask", 30);
0018   description.add<unsigned int>("nHADCALO_IN");
0019   description.add<unsigned int>("nEMCALO_OUT");
0020   description.addUntracked<uint32_t>("debug", 0);
0021   return description;
0022 }
0023 #endif
0024 
0025 void EGInputSelectorEmulator::toFirmware(const PFInputRegion &in, HadCaloObj hadcalo[/*nCALO*/]) const {
0026   l1ct::toFirmware(in.hadcalo, cfg.nHADCALO_IN, hadcalo);
0027 }
0028 
0029 void EGInputSelectorEmulator::toFirmware(const std::vector<EmCaloObjEmu> &emcalo_sel, EmCaloObj emcalo[]) const {
0030   l1ct::toFirmware(emcalo_sel, cfg.nEMCALO_OUT, emcalo);
0031 }
0032 
0033 void EGInputSelectorEmulator::select_eginput(const l1ct::HadCaloObjEmu &in,
0034                                              l1ct::EmCaloObjEmu &out,
0035                                              bool &valid_out) const {
0036   out.src = in.src;
0037   out.hwPt = in.hwEmPt;
0038   out.hwEta = in.hwEta;
0039   out.hwPhi = in.hwPhi;
0040   out.hwPtErr = 0;
0041   // shift to get rid of PFEM ID bit (more usable final EG quality)
0042   out.hwEmID = (in.hwEmID >> 1);
0043 
0044   out.hwSrrTot = in.hwSrrTot;
0045   out.hwMeanZ = in.hwMeanZ;
0046   out.hwHoe = in.hwHoe;
0047   valid_out = (in.hwEmID & cfg.idMask) != 0;
0048 }
0049 
0050 void EGInputSelectorEmulator::select_eginputs(const std::vector<HadCaloObjEmu> &hadcalo_in,
0051                                               std::vector<EmCaloObjEmu> &emcalo_sel) const {
0052   for (int ic = 0, nc = hadcalo_in.size(); ic < nc; ++ic) {
0053     if (emcalo_sel.size() == cfg.nEMCALO_OUT)
0054       break;
0055     bool valid = false;
0056     EmCaloObjEmu out;
0057     select_eginput(hadcalo_in[ic], out, valid);
0058     if (valid) {
0059       emcalo_sel.push_back(out);
0060     }
0061   }
0062 }
0063 
0064 void EGInputSelectorEmulator::select_or_clear(const HadCaloObjEmu &hadcalo_in, EmCaloObjEmu &emcalo_out) const {
0065   bool valid = false;
0066   select_eginput(hadcalo_in, emcalo_out, valid);
0067   if (!valid)
0068     emcalo_out.clear();
0069 }
0070 
0071 void EGInputSelectorEmulator::select_or_clear(const std::vector<HadCaloObjEmu> &hadcalo_in,
0072                                               std::vector<EmCaloObjEmu> &emcalo_out) const {
0073   emcalo_out.resize(hadcalo_in.size());
0074   for (int ic = 0, nc = hadcalo_in.size(); ic < nc; ++ic) {
0075     select_or_clear(hadcalo_in[ic], emcalo_out[ic]);
0076   }
0077 }