Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h"
0002 
0003 #include <cmath>
0004 #include <cstdio>
0005 #include <algorithm>
0006 
0007 #ifdef CMSSW_GIT_HASH
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 
0011 l1ct::RegionizerEmulator::RegionizerEmulator(const edm::ParameterSet& iConfig)
0012     : useAlsoVtxCoords_(iConfig.getParameter<bool>("useAlsoVtxCoords")),
0013       debug_(iConfig.getUntrackedParameter<bool>("debug")) {}
0014 
0015 edm::ParameterSetDescription l1ct::RegionizerEmulator::getParameterSetDescription() {
0016   edm::ParameterSetDescription description;
0017   description.add<bool>("useAlsoVtxCoords", true);
0018   description.addUntracked<bool>("debug", false);
0019   return description;
0020 }
0021 #endif
0022 
0023 l1ct::RegionizerEmulator::~RegionizerEmulator() {}
0024 
0025 void l1ct::RegionizerEmulator::run(const RegionizerDecodedInputs& in, std::vector<PFInputRegion>& out) {
0026   for (const auto& sec : in.track) {
0027     for (const auto& tk : sec) {
0028       if (tk.hwPt == 0)
0029         continue;
0030       float fglbEta = sec.region.floatGlbEtaOf(tk), fglbPhi = sec.region.floatGlbPhiOf(tk);
0031       glbeta_t glbEta = sec.region.hwGlbEtaOf(tk);
0032       glbphi_t glbPhi = sec.region.hwGlbPhiOf(tk);
0033       glbeta_t glbEtaV = sec.region.hwGlbEta(tk.hwVtxEta());
0034       glbphi_t glbPhiV = sec.region.hwGlbPhi(tk.hwVtxPhi());
0035       for (auto& r : out) {
0036         if (r.region.containsHw(glbEta, glbPhi) || (useAlsoVtxCoords_ && r.region.containsHw(glbEtaV, glbPhiV))) {
0037           r.track.push_back(tk);
0038           r.track.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(fglbEta));
0039           r.track.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(fglbPhi));
0040         }
0041       }
0042     }
0043   }
0044 
0045   for (const auto& sec : in.hadcalo) {
0046     for (const auto& c : sec) {
0047       if (c.hwPt == 0)
0048         continue;
0049       float fglbEta = sec.region.floatGlbEtaOf(c), fglbPhi = sec.region.floatGlbPhiOf(c);
0050       glbeta_t glbEta = sec.region.hwGlbEtaOf(c);
0051       glbphi_t glbPhi = sec.region.hwGlbPhiOf(c);
0052       for (auto& r : out) {
0053         if (r.region.containsHw(glbEta, glbPhi)) {
0054           r.hadcalo.push_back(c);
0055           r.hadcalo.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(fglbEta));
0056           r.hadcalo.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(fglbPhi));
0057         }
0058       }
0059     }
0060   }
0061 
0062   for (const auto& sec : in.emcalo) {
0063     for (const auto& c : sec) {
0064       if (c.hwPt == 0)
0065         continue;
0066       float fglbEta = sec.region.floatGlbEtaOf(c), fglbPhi = sec.region.floatGlbPhiOf(c);
0067       glbeta_t glbEta = sec.region.hwGlbEtaOf(c);
0068       glbphi_t glbPhi = sec.region.hwGlbPhiOf(c);
0069       for (auto& r : out) {
0070         if (r.region.containsHw(glbEta, glbPhi)) {
0071           r.emcalo.push_back(c);
0072           r.emcalo.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(fglbEta));
0073           r.emcalo.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(fglbPhi));
0074         }
0075       }
0076     }
0077   }
0078 
0079   for (const auto& mu : in.muon.obj) {
0080     if (mu.hwPt == 0)
0081       continue;
0082     float glbEta = mu.floatEta(), glbPhi = mu.floatPhi();
0083     for (auto& r : out) {
0084       if (r.region.containsHw(mu.hwEta, mu.hwPhi)) {
0085         r.muon.push_back(mu);
0086         r.muon.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(glbEta));
0087         r.muon.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(glbPhi));
0088       }
0089     }
0090   }
0091 
0092   for (auto& r : out) {
0093     std::sort(r.track.begin(), r.track.end(), [](const l1ct::TkObjEmu& a, const l1ct::TkObjEmu& b) {
0094       return a.hwPt > b.hwPt;
0095     });
0096     std::sort(r.hadcalo.begin(), r.hadcalo.end(), [](const l1ct::HadCaloObjEmu& a, const l1ct::HadCaloObjEmu& b) {
0097       return a.hwPt > b.hwPt;
0098     });
0099     std::sort(r.emcalo.begin(), r.emcalo.end(), [](const l1ct::EmCaloObjEmu& a, const l1ct::EmCaloObjEmu& b) {
0100       return a.hwPt > b.hwPt;
0101     });
0102     std::sort(
0103         r.muon.begin(), r.muon.end(), [](const l1ct::MuObjEmu& a, const l1ct::MuObjEmu& b) { return a.hwPt > b.hwPt; });
0104   }
0105 }