File indexing completed on 2022-06-10 01:53:58
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 l1ct::RegionizerEmulator::RegionizerEmulator(const edm::ParameterSet& iConfig)
0010 : useAlsoVtxCoords_(iConfig.getParameter<bool>("useAlsoVtxCoords")),
0011 debug_(iConfig.getUntrackedParameter<bool>("debug", false)) {}
0012 #endif
0013
0014 l1ct::RegionizerEmulator::~RegionizerEmulator() {}
0015
0016 void l1ct::RegionizerEmulator::run(const RegionizerDecodedInputs& in, std::vector<PFInputRegion>& out) {
0017 for (const auto& sec : in.track) {
0018 for (const auto& tk : sec) {
0019 if (tk.hwPt == 0)
0020 continue;
0021 float fglbEta = sec.region.floatGlbEtaOf(tk), fglbPhi = sec.region.floatGlbPhiOf(tk);
0022 glbeta_t glbEta = sec.region.hwGlbEtaOf(tk);
0023 glbphi_t glbPhi = sec.region.hwGlbPhiOf(tk);
0024 glbeta_t glbEtaV = sec.region.hwGlbEta(tk.hwVtxEta());
0025 glbphi_t glbPhiV = sec.region.hwGlbPhi(tk.hwVtxPhi());
0026 for (auto& r : out) {
0027 if (r.region.containsHw(glbEta, glbPhi) || (useAlsoVtxCoords_ && r.region.containsHw(glbEtaV, glbPhiV))) {
0028 r.track.push_back(tk);
0029 r.track.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(fglbEta));
0030 r.track.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(fglbPhi));
0031 }
0032 }
0033 }
0034 }
0035
0036 for (const auto& sec : in.hadcalo) {
0037 for (const auto& c : sec) {
0038 if (c.hwPt == 0)
0039 continue;
0040 float fglbEta = sec.region.floatGlbEtaOf(c), fglbPhi = sec.region.floatGlbPhiOf(c);
0041 glbeta_t glbEta = sec.region.hwGlbEtaOf(c);
0042 glbphi_t glbPhi = sec.region.hwGlbPhiOf(c);
0043 for (auto& r : out) {
0044 if (r.region.containsHw(glbEta, glbPhi)) {
0045 r.hadcalo.push_back(c);
0046 r.hadcalo.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(fglbEta));
0047 r.hadcalo.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(fglbPhi));
0048 }
0049 }
0050 }
0051 }
0052
0053 for (const auto& sec : in.emcalo) {
0054 for (const auto& c : sec) {
0055 if (c.hwPt == 0)
0056 continue;
0057 float fglbEta = sec.region.floatGlbEtaOf(c), fglbPhi = sec.region.floatGlbPhiOf(c);
0058 glbeta_t glbEta = sec.region.hwGlbEtaOf(c);
0059 glbphi_t glbPhi = sec.region.hwGlbPhiOf(c);
0060 for (auto& r : out) {
0061 if (r.region.containsHw(glbEta, glbPhi)) {
0062 r.emcalo.push_back(c);
0063 r.emcalo.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(fglbEta));
0064 r.emcalo.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(fglbPhi));
0065 }
0066 }
0067 }
0068 }
0069
0070 for (const auto& mu : in.muon.obj) {
0071 if (mu.hwPt == 0)
0072 continue;
0073 float glbEta = mu.floatEta(), glbPhi = mu.floatPhi();
0074 for (auto& r : out) {
0075 if (r.region.containsHw(mu.hwEta, mu.hwPhi)) {
0076 r.muon.push_back(mu);
0077 r.muon.back().hwEta = l1ct::Scales::makeEta(r.region.localEta(glbEta));
0078 r.muon.back().hwPhi = l1ct::Scales::makePhi(r.region.localPhi(glbPhi));
0079 }
0080 }
0081 }
0082
0083 for (auto& r : out) {
0084 std::sort(r.track.begin(), r.track.end(), [](const l1ct::TkObjEmu& a, const l1ct::TkObjEmu& b) {
0085 return a.hwPt > b.hwPt;
0086 });
0087 std::sort(r.hadcalo.begin(), r.hadcalo.end(), [](const l1ct::HadCaloObjEmu& a, const l1ct::HadCaloObjEmu& b) {
0088 return a.hwPt > b.hwPt;
0089 });
0090 std::sort(r.emcalo.begin(), r.emcalo.end(), [](const l1ct::EmCaloObjEmu& a, const l1ct::EmCaloObjEmu& b) {
0091 return a.hwPt > b.hwPt;
0092 });
0093 std::sort(
0094 r.muon.begin(), r.muon.end(), [](const l1ct::MuObjEmu& a, const l1ct::MuObjEmu& b) { return a.hwPt > b.hwPt; });
0095 }
0096 }