From c321c3b83e6bb50d944a74e459314de1fef24f95 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 28 Sep 2023 10:38:06 +0200 Subject: [PATCH 1/8] Add enum for binary word encoding type and method for direct access to GT HW object --- .../L1TCorrelator/interface/TkElectron.h | 7 +++++++ DataFormats/L1TCorrelator/interface/TkEm.h | 18 +++++++++++++++++- DataFormats/L1TCorrelator/src/TkEm.cc | 3 ++- DataFormats/L1TCorrelator/src/classes_def.xml | 6 ++++-- .../plugins/L1TCorrelatorLayer1Producer.cc | 4 ++-- .../plugins/L1TCtL2EgProducer.cc | 4 ++-- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/DataFormats/L1TCorrelator/interface/TkElectron.h b/DataFormats/L1TCorrelator/interface/TkElectron.h index c5b70d79598fb..8d006a65809e4 100644 --- a/DataFormats/L1TCorrelator/interface/TkElectron.h +++ b/DataFormats/L1TCorrelator/interface/TkElectron.h @@ -46,6 +46,13 @@ namespace l1t { void setTrackCurvature(double trackCurvature) { trackCurvature_ = trackCurvature; } void setIdScore(float score) { idScore_ = score; } + l1gt::Electron hwObj() const { + if (encoding() != HWEncoding::GT) { + throw cms::Exception("RuntimeError") << "TkElectron::hwObj : encoding is not in GT format!" << std::endl; + } + return l1gt::Electron::unpack_ap(egBinaryWord()); + } + private: edm::Ptr trkPtr_; float trkzVtx_; diff --git a/DataFormats/L1TCorrelator/interface/TkEm.h b/DataFormats/L1TCorrelator/interface/TkEm.h index d3d9c36a41c7f..d433ba5e6563d 100644 --- a/DataFormats/L1TCorrelator/interface/TkEm.h +++ b/DataFormats/L1TCorrelator/interface/TkEm.h @@ -13,6 +13,9 @@ #include "DataFormats/L1Trigger/interface/EGamma.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h" +#include "FWCore/Utilities/interface/Exception.h" + #include namespace l1t { @@ -28,6 +31,8 @@ namespace l1t { float tkisol = -999., float tkisolPV = -999); + enum class HWEncoding { None, CT, GT }; + // ---------- const member functions --------------------- const edm::Ref& EGRef() const { return egRef_; } @@ -56,10 +61,18 @@ namespace l1t { void setEGRef(const edm::Ref& egRef) { egRef_ = egRef; } template - void setEgBinaryWord(ap_uint word) { + void setEgBinaryWord(ap_uint word, HWEncoding encoding) { egBinaryWord0_ = word; egBinaryWord1_ = (word >> 32); egBinaryWord2_ = (word >> 64); + encoding_ = encoding; + } + + l1gt::Photon hwObj() const { + if (encoding() != HWEncoding::GT) { + throw cms::Exception("RuntimeError") << "TkEm::hwObj : encoding is not in GT format!" << std::endl; + } + return l1gt::Photon::unpack_ap(egBinaryWord()); } template @@ -67,6 +80,8 @@ namespace l1t { return ap_uint(egBinaryWord0_) | (ap_uint(egBinaryWord1_) << 32) | (ap_uint(egBinaryWord2_) << 64); } + HWEncoding encoding() const { return encoding_; } + private: edm::Ref egRef_; float trkIsol_; @@ -78,6 +93,7 @@ namespace l1t { uint32_t egBinaryWord0_; uint32_t egBinaryWord1_; uint32_t egBinaryWord2_; + HWEncoding encoding_; }; } // namespace l1t diff --git a/DataFormats/L1TCorrelator/src/TkEm.cc b/DataFormats/L1TCorrelator/src/TkEm.cc index 276f13c1ec0bf..2d71f3decc8ab 100644 --- a/DataFormats/L1TCorrelator/src/TkEm.cc +++ b/DataFormats/L1TCorrelator/src/TkEm.cc @@ -24,4 +24,5 @@ TkEm::TkEm(const LorentzVector& p4, const edm::Ref& egRef, f puppiIsolPV_(-999), egBinaryWord0_(0), egBinaryWord1_(0), - egBinaryWord2_(0) {} + egBinaryWord2_(0), + encoding_(HWEncoding::None) {} diff --git a/DataFormats/L1TCorrelator/src/classes_def.xml b/DataFormats/L1TCorrelator/src/classes_def.xml index 6b5acaf05cbc1..14db8c66d3d99 100644 --- a/DataFormats/L1TCorrelator/src/classes_def.xml +++ b/DataFormats/L1TCorrelator/src/classes_def.xml @@ -10,7 +10,8 @@ - + + @@ -44,7 +45,8 @@ - + + diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 6d3779404c679..96bba4f6ad745 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -1103,7 +1103,7 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, tkem.setHwQual(egiso.hwQual); tkem.setPFIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso)); tkem.setPFIsolPV(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV)); - tkem.setEgBinaryWord(egiso.pack()); + tkem.setEgBinaryWord(egiso.pack(), l1t::TkEm::HWEncoding::CT); tkems->push_back(tkem); npho_obj.push_back(tkems->size() - 1); } @@ -1131,7 +1131,7 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso)); tkele.setHwQual(egele.hwQual); tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso)); - tkele.setEgBinaryWord(egele.pack()); + tkele.setEgBinaryWord(egele.pack(), l1t::TkElectron::HWEncoding::CT); tkele.setIdScore(egele.idScore); tkeles->push_back(tkele); nele_obj.push_back(tkeles->size() - 1); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 6097408bf20e3..1950ed557a775 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -403,7 +403,7 @@ l1t::TkEm L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoObjEmu &egiso, cons tkem.setPFIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso)); tkem.setPFIsolPV(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV)); tkem.setPuppiIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PuppiIso)); - tkem.setEgBinaryWord(gteg.pack()); + tkem.setEgBinaryWord(gteg.pack(), l1t::TkEm::HWEncoding::GT); return tkem; } @@ -422,7 +422,7 @@ l1t::TkElectron L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoEleObjEmu &eg tkele.setHwQual(gteg.quality); tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso)); tkele.setPuppiIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso)); - tkele.setEgBinaryWord(gteg.pack()); + tkele.setEgBinaryWord(gteg.pack(), l1t::TkElectron::HWEncoding::GT); tkele.setIdScore(egele.idScore); return tkele; } From b13f4c5f0eb85fda7ef49cef78fea34596ab02bf Mon Sep 17 00:00:00 2001 From: Gianluca Date: Fri, 16 Jun 2023 13:53:43 +0200 Subject: [PATCH 2/8] Write ID score to FW object and change initialization of bdt score to match FW --- .../L1TParticleFlow/interface/datatypes.h | 2 ++ .../L1TParticleFlow/interface/egamma.h | 10 +++++-- .../interface/layer1_emulator.h | 4 +-- .../interface/egamma/pftkegalgo_ref.h | 20 ++++++------- .../plugins/L1TCorrelatorLayer1Producer.cc | 2 +- .../plugins/L1TCtL2EgProducer.cc | 4 +-- .../python/l1TkEgAlgoEmulator_cfi.py | 8 ++++-- .../src/egamma/pftkegalgo_ref.cpp | 28 +++++++++---------- 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/DataFormats/L1TParticleFlow/interface/datatypes.h b/DataFormats/L1TParticleFlow/interface/datatypes.h index be802bc540b6e..67655a80a99ba 100644 --- a/DataFormats/L1TParticleFlow/interface/datatypes.h +++ b/DataFormats/L1TParticleFlow/interface/datatypes.h @@ -44,6 +44,7 @@ namespace l1ct { typedef ap_uint<8> meanz_t; // mean - MEANZ_OFFSET(= 320 cm) typedef ap_ufixed<10, 5, AP_TRN, AP_SAT> hoe_t; typedef ap_uint<4> redChi2Bin_t; + typedef ap_fixed<10, 1, AP_RND_CONV, AP_SAT> id_score_t; // ID score to be between -1 (background) and 1 (signal) // FIXME: adjust range 10-11bits -> 1/4 - 1/2TeV is probably more than enough for all reasonable use cases typedef ap_ufixed<11, 9, AP_TRN, AP_SAT> iso_t; @@ -178,6 +179,7 @@ namespace l1ct { inline float floatSrrTot(srrtot_t srrtot) { return srrtot.to_float() / SRRTOT_SCALE; }; inline float floatMeanZ(meanz_t meanz) { return meanz + MEANZ_OFFSET; }; inline float floatHoe(hoe_t hoe) { return hoe.to_float(); }; + inline float floatIDScore(id_score_t score) { return score.to_float(); }; inline pt_t makePt(int pt) { return ap_ufixed<16, 14>(pt) >> 2; } inline dpt_t makeDPt(int dpt) { return ap_fixed<18, 16>(dpt) >> 2; } diff --git a/DataFormats/L1TParticleFlow/interface/egamma.h b/DataFormats/L1TParticleFlow/interface/egamma.h index 457b1700d1021..4a61e317a6a15 100644 --- a/DataFormats/L1TParticleFlow/interface/egamma.h +++ b/DataFormats/L1TParticleFlow/interface/egamma.h @@ -87,6 +87,7 @@ namespace l1ct { z0_t hwZ0; tkdeta_t hwDEta; // relative to the region center, at calo tkdphi_t hwDPhi; // relative to the region center, at calo + id_score_t hwIDScore; bool hwCharge; phi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; } @@ -95,7 +96,7 @@ namespace l1ct { inline bool operator==(const EGIsoEleObj &other) const { return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwQual == other.hwQual && hwIso == other.hwIso && hwDEta == other.hwDEta && hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 && - hwCharge == other.hwCharge; + hwIDScore == other.hwIDScore && hwCharge == other.hwCharge; } inline bool operator>(const EGIsoEleObj &other) const { return hwPt > other.hwPt; } @@ -110,6 +111,7 @@ namespace l1ct { hwDEta = 0; hwDPhi = 0; hwZ0 = 0; + hwIDScore = 0; hwCharge = false; } @@ -119,8 +121,10 @@ namespace l1ct { float floatVtxEta() const { return Scales::floatEta(hwVtxEta()); } float floatVtxPhi() const { return Scales::floatPhi(hwVtxPhi()); } float floatZ0() const { return Scales::floatZ0(hwZ0); } + float floatIDScore() const { return Scales::floatIDScore(hwIDScore); } - static const int BITWIDTH = EGIsoObj::BITWIDTH + tkdeta_t::width + tkdphi_t::width + z0_t::width + 1; + static const int BITWIDTH = + EGIsoObj::BITWIDTH + tkdeta_t::width + tkdphi_t::width + z0_t::width + id_score_t::width + 1; inline ap_uint pack() const { ap_uint ret; unsigned int start = 0; @@ -133,6 +137,7 @@ namespace l1ct { pack_into_bits(ret, start, hwDPhi); pack_into_bits(ret, start, hwZ0); pack_bool_into_bits(ret, start, hwCharge); + pack_into_bits(ret, start, hwIDScore); return ret; } inline static EGIsoEleObj unpack(const ap_uint &src) { @@ -152,6 +157,7 @@ namespace l1ct { unpack_from_bits(src, start, hwDPhi); unpack_from_bits(src, start, hwZ0); unpack_bool_from_bits(src, start, hwCharge); + unpack_from_bits(src, start, hwIDScore); } l1gt::Electron toGT() const { diff --git a/DataFormats/L1TParticleFlow/interface/layer1_emulator.h b/DataFormats/L1TParticleFlow/interface/layer1_emulator.h index fcb415d426017..f3a1b2d90cea5 100644 --- a/DataFormats/L1TParticleFlow/interface/layer1_emulator.h +++ b/DataFormats/L1TParticleFlow/interface/layer1_emulator.h @@ -195,7 +195,6 @@ namespace l1ct { const l1t::PFTrack *srcTrack; // we use an index to the standalone object needed to retrieve a Ref when putting int sta_idx; - float idScore; bool read(std::fstream &from); bool write(std::fstream &to) const; void clear() { @@ -203,7 +202,6 @@ namespace l1ct { srcCluster = nullptr; srcTrack = nullptr; sta_idx = -1; - idScore = -999; clearIsoVars(); } @@ -335,7 +333,7 @@ namespace l1ct { }; struct Event { - enum { VERSION = 12 }; + enum { VERSION = 13 }; uint32_t run, lumi; uint64_t event; RawInputs raw; diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h index 560325e46cb0c..c1a6a690a4d38 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h @@ -62,8 +62,8 @@ namespace l1ct { CompIDParameters(const edm::ParameterSet &); CompIDParameters(double bdtScore_loose_wp, double bdtScore_tight_wp, const std::string &model) : bdtScore_loose_wp(bdtScore_loose_wp), bdtScore_tight_wp(bdtScore_tight_wp), conifer_model(model) {} - const double bdtScore_loose_wp; // XGBOOST score - const double bdtScore_tight_wp; // XGBOOST score + const id_score_t bdtScore_loose_wp; // Conifer score/4 + const id_score_t bdtScore_tight_wp; // Conifer score/4 const std::string conifer_model; }; @@ -169,7 +169,7 @@ namespace l1ct { const std::vector &emcalo, const std::vector &track, std::vector &emCalo2tk, - std::vector &emCaloTkBdtScore) const; + std::vector &emCaloTkBdtScore) const; struct CompositeCandidate { unsigned int cluster_idx; @@ -177,10 +177,10 @@ namespace l1ct { double dpt; // For sorting }; - float compute_composite_score(CompositeCandidate &cand, - const std::vector &emcalo, - const std::vector &track, - const PFTkEGAlgoEmuConfig::CompIDParameters ¶ms) const; + id_score_t compute_composite_score(CompositeCandidate &cand, + const std::vector &emcalo, + const std::vector &track, + const PFTkEGAlgoEmuConfig::CompIDParameters ¶ms) const; //FIXME: still needed float deltaPhi(float phi1, float phi2) const; @@ -194,7 +194,7 @@ namespace l1ct { const std::vector &track, const std::vector &emCalo2emCalo, const std::vector &emCalo2tk, - const std::vector &emCaloTkBdtScore, + const std::vector &emCaloTkBdtScore, std::vector &egstas, std::vector &egobjs, std::vector &egeleobjs) const; @@ -208,7 +208,7 @@ namespace l1ct { const unsigned int hwQual, const pt_t ptCorr, const int tk_idx, - const float bdtScore, + const id_score_t bdtScore, const std::vector &components = {}) const; EGObjEmu &addEGStaToPF(std::vector &egobjs, @@ -227,7 +227,7 @@ namespace l1ct { const TkObjEmu &track, const unsigned int hwQual, const pt_t ptCorr, - const float bdtScore) const; + const id_score_t bdtScore) const; // FIXME: reimplemented from PFAlgoEmulatorBase template diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 96bba4f6ad745..a855ba3b1b2a7 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -1132,7 +1132,7 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, tkele.setHwQual(egele.hwQual); tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso)); tkele.setEgBinaryWord(egele.pack(), l1t::TkElectron::HWEncoding::CT); - tkele.setIdScore(egele.idScore); + tkele.setIdScore(egele.floatIDScore()); tkeles->push_back(tkele); nele_obj.push_back(tkeles->size() - 1); } diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 1950ed557a775..362974b24c1a3 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -352,8 +352,6 @@ void L1TCtL2EgProducer::convertToEmu(const l1t::TkElectron &tkele, emu.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkele.pfIsol() * tkele.pt())); emu.setHwIso(EGIsoEleObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkele.puppiIsol() * tkele.pt())); // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl; - // FIXME: this is temporary while waiting to move the BDT score to the FW object - emu.idScore = tkele.idScore(); boarOut.egelectron.push_back(emu); } @@ -423,7 +421,7 @@ l1t::TkElectron L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoEleObjEmu &eg tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso)); tkele.setPuppiIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso)); tkele.setEgBinaryWord(gteg.pack(), l1t::TkElectron::HWEncoding::GT); - tkele.setIdScore(egele.idScore); + tkele.setIdScore(egele.floatIDScore()); return tkele; } diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py b/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py index 4b267ff987db1..9b68b7fa615a2 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms tkEgAlgoParameters = cms.PSet( + # debug=cms.untracked.uint32(4), nTRACK=cms.uint32(50), # very large numbers for first test nTRACK_EGIN=cms.uint32(50), # very large numbers for first test nEMCALO_EGIN=cms.uint32(50), # very large numbers for first test @@ -53,9 +54,10 @@ doCompositeTkEle=cms.bool(False), nCompCandPerCluster=cms.uint32(3), compositeParametersTkEle=cms.PSet( - # the working points are cuts on BDT output logits log(p/1-p) - loose_wp=cms.double(-0.732422), - tight_wp=cms.double(0.214844), + # NOTE: conifer BDT score is log(p/1-p) + # the working points are cuts on BDT output logits [log(p/1-p)]/4 (range -1 to 1 to match the FW dataformat) + loose_wp=cms.double(-0.181641), + tight_wp=cms.double(0.0527344), model=cms.string("L1Trigger/Phase2L1ParticleFlow/data/compositeID.json") ), ) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp index da9baff109831..ca3038290dc4d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp @@ -181,7 +181,7 @@ void PFTkEGAlgoEmulator::link_emCalo2tk_composite(const PFRegionEmu &r, const std::vector &emcalo, const std::vector &track, std::vector &emCalo2tk, - std::vector &emCaloTkBdtScore) const { + std::vector &emCaloTkBdtScore) const { unsigned int nTrackMax = std::min(track.size(), cfg.nTRACK_EGIN); for (int ic = 0, nc = emcalo.size(); ic < nc; ++ic) { auto &calo = emcalo[ic]; @@ -214,12 +214,12 @@ void PFTkEGAlgoEmulator::link_emCalo2tk_composite(const PFRegionEmu &r, if (nCandPerCluster == 0) continue; - float maxScore = -999; + id_score_t maxScore = -pow(2, l1ct::id_score_t::iwidth - 1); int ibest = -1; for (unsigned int icand = 0; icand < nCandPerCluster; icand++) { auto &cand = candidates[icand]; const std::vector &emcalo_sel = emcalo; - float score = compute_composite_score(cand, emcalo_sel, track, cfg.compIDparams); + id_score_t score = compute_composite_score(cand, emcalo_sel, track, cfg.compIDparams); if ((score > cfg.compIDparams.bdtScore_loose_wp) && (score > maxScore)) { maxScore = score; ibest = icand; @@ -232,10 +232,10 @@ void PFTkEGAlgoEmulator::link_emCalo2tk_composite(const PFRegionEmu &r, } } -float PFTkEGAlgoEmulator::compute_composite_score(CompositeCandidate &cand, - const std::vector &emcalo, - const std::vector &track, - const PFTkEGAlgoEmuConfig::CompIDParameters ¶ms) const { +id_score_t PFTkEGAlgoEmulator::compute_composite_score(CompositeCandidate &cand, + const std::vector &emcalo, + const std::vector &track, + const PFTkEGAlgoEmuConfig::CompIDParameters ¶ms) const { // Get the cluster/track objects that form the composite candidate const auto &calo = emcalo[cand.cluster_idx]; const auto &tk = track[cand.track_idx]; @@ -258,7 +258,7 @@ float PFTkEGAlgoEmulator::compute_composite_score(CompositeCandidate &cand, std::vector inputs = {tkpt, hoe, srrtot, deta, dphi, dpt, meanz, nstubs, chi2rphi, chi2rz, chi2bend}; std::vector bdt_score = composite_bdt_->decision_function(inputs); - return bdt_score[0]; + return bdt_score[0] / 4; } void PFTkEGAlgoEmulator::sel_emCalo(unsigned int nmax_sel, @@ -297,7 +297,7 @@ void PFTkEGAlgoEmulator::run(const PFInputRegion &in, OutputRegion &out) const { link_emCalo2emCalo(emcalo_sel, emCalo2emCalo); std::vector emCalo2tk(emcalo_sel.size(), -1); - std::vector emCaloTkBdtScore(emcalo_sel.size(), -999); + std::vector emCaloTkBdtScore(emcalo_sel.size(), 0); if (cfg.doCompositeTkEle) { link_emCalo2tk_composite(in.region, emcalo_sel, in.track, emCalo2tk, emCaloTkBdtScore); @@ -325,7 +325,7 @@ void PFTkEGAlgoEmulator::eg_algo(const PFRegionEmu ®ion, const std::vector &track, const std::vector &emCalo2emCalo, const std::vector &emCalo2tk, - const std::vector &emCaloTkBdtScore, + const std::vector &emCaloTkBdtScore, std::vector &egstas, std::vector &egobjs, std::vector &egeleobjs) const { @@ -341,7 +341,7 @@ void PFTkEGAlgoEmulator::eg_algo(const PFRegionEmu ®ion, << " phi " << calo.hwPhi << std::endl; int itk = emCalo2tk[ic]; - float bdt = emCaloTkBdtScore[ic]; + const id_score_t &bdt = emCaloTkBdtScore[ic]; // check if brem recovery is on if (!cfg.doBremRecovery || cfg.writeBeforeBremRecovery) { @@ -432,7 +432,7 @@ EGIsoEleObjEmu &PFTkEGAlgoEmulator::addEGIsoEleToPF(std::vector const TkObjEmu &track, const unsigned int hwQual, const pt_t ptCorr, - const float bdtScore) const { + const id_score_t bdtScore) const { EGIsoEleObjEmu egiso; egiso.clear(); egiso.hwPt = ptCorr; @@ -456,7 +456,7 @@ EGIsoEleObjEmu &PFTkEGAlgoEmulator::addEGIsoEleToPF(std::vector egiso.hwCharge = track.hwCharge; egiso.srcCluster = calo.src; egiso.srcTrack = track.src; - egiso.idScore = bdtScore; + egiso.hwIDScore = bdtScore; egobjs.push_back(egiso); if (debug_ > 2) @@ -475,7 +475,7 @@ void PFTkEGAlgoEmulator::addEgObjsToPF(std::vector &egstas, const unsigned int hwQual, const pt_t ptCorr, const int tk_idx, - const float bdtScore, + const id_score_t bdtScore, const std::vector &components) const { int sta_idx = -1; if (writeEgSta()) { From 92deee0ab851c80044271ebaa0f00a7c0993ad7e Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 5 Oct 2023 15:41:31 +0200 Subject: [PATCH 3/8] Remove Ref to Standalone object in favor of generic pointer to L1Candidate and cleanup TkElectron interface --- .../L1TCorrelator/interface/TkElectron.h | 9 +- DataFormats/L1TCorrelator/interface/TkEm.h | 21 +--- DataFormats/L1TCorrelator/src/TkElectron.cc | 10 +- DataFormats/L1TCorrelator/src/TkEm.cc | 10 +- DataFormats/L1TCorrelator/src/classes_def.xml | 13 ++- .../interface/layer1_emulator.h | 20 ++-- .../L1TParticleFlow/src/layer1_emulator.cpp | 4 +- .../plugins/L1TCorrelatorLayer1Producer.cc | 57 +--------- .../plugins/L1TCtL2EgProducer.cc | 106 +++++++----------- .../plugins/L1TEGMultiMerger.cc | 45 ++------ .../src/egamma/pftkegalgo_ref.cpp | 9 +- 11 files changed, 102 insertions(+), 202 deletions(-) diff --git a/DataFormats/L1TCorrelator/interface/TkElectron.h b/DataFormats/L1TCorrelator/interface/TkElectron.h index 8d006a65809e4..29a1df62b023b 100644 --- a/DataFormats/L1TCorrelator/interface/TkElectron.h +++ b/DataFormats/L1TCorrelator/interface/TkElectron.h @@ -7,7 +7,6 @@ // Class : TkEm // -#include "DataFormats/Common/interface/Ref.h" #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/L1Trigger/interface/EGamma.h" @@ -29,21 +28,22 @@ namespace l1t { TkElectron(); TkElectron(const LorentzVector& p4, - const edm::Ref& egRef, + const edm::Ptr& egCaloPtr, const edm::Ptr& trkPtr, float tkisol = -999.); + TkElectron(const LorentzVector& p4, float tkisol = -999.); + // ---------- const member functions --------------------- const edm::Ptr& trkPtr() const { return trkPtr_; } float trkzVtx() const { return trkzVtx_; } - double trackCurvature() const { return trackCurvature_; } float idScore() const { return idScore_; } // ---------- member functions --------------------------- + void setTrkPtr(const edm::Ptr& tkPtr) { trkPtr_ = tkPtr; } void setTrkzVtx(float TrkzVtx) { trkzVtx_ = TrkzVtx; } - void setTrackCurvature(double trackCurvature) { trackCurvature_ = trackCurvature; } void setIdScore(float score) { idScore_ = score; } l1gt::Electron hwObj() const { @@ -56,7 +56,6 @@ namespace l1t { private: edm::Ptr trkPtr_; float trkzVtx_; - double trackCurvature_; float idScore_; }; } // namespace l1t diff --git a/DataFormats/L1TCorrelator/interface/TkEm.h b/DataFormats/L1TCorrelator/interface/TkEm.h index d433ba5e6563d..051a324a8e082 100644 --- a/DataFormats/L1TCorrelator/interface/TkEm.h +++ b/DataFormats/L1TCorrelator/interface/TkEm.h @@ -8,7 +8,7 @@ // #include "DataFormats/L1Trigger/interface/L1Candidate.h" -#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/L1Trigger/interface/EGamma.h" @@ -24,24 +24,15 @@ namespace l1t { public: TkEm(); - TkEm(const LorentzVector& p4, const edm::Ref& egRef, float tkisol = -999.); + TkEm(const LorentzVector& p4, float tkisol = -999., float tkisolPV = -999); - TkEm(const LorentzVector& p4, - const edm::Ref& egRef, - float tkisol = -999., - float tkisolPV = -999); + TkEm(const LorentzVector& p4, const edm::Ptr& egCaloPtr, float tkisol = -999., float tkisolPV = -999); enum class HWEncoding { None, CT, GT }; // ---------- const member functions --------------------- - const edm::Ref& EGRef() const { return egRef_; } - - const double l1RefEta() const { return egRef_->eta(); } - - const double l1RefPhi() const { return egRef_->phi(); } - - const double l1RefEt() const { return egRef_->et(); } + const edm::Ptr& egCaloPtr() const { return egCaloPtr_; } float trkIsol() const { return trkIsol_; } // not constrained to the PV, just track ptSum float trkIsolPV() const { return trkIsolPV_; } // constrained to the PV by DZ @@ -58,7 +49,7 @@ namespace l1t { void setPFIsolPV(float pfIsolPV) { pfIsolPV_ = pfIsolPV; } void setPuppiIsol(float puppiIsol) { puppiIsol_ = puppiIsol; } void setPuppiIsolPV(float puppiIsolPV) { puppiIsolPV_ = puppiIsolPV; } - void setEGRef(const edm::Ref& egRef) { egRef_ = egRef; } + void setEgCaloPtr(const edm::Ptr& egPtr) { egCaloPtr_ = egPtr; } template void setEgBinaryWord(ap_uint word, HWEncoding encoding) { @@ -83,7 +74,7 @@ namespace l1t { HWEncoding encoding() const { return encoding_; } private: - edm::Ref egRef_; + edm::Ptr egCaloPtr_; float trkIsol_; float trkIsolPV_; float pfIsol_; diff --git a/DataFormats/L1TCorrelator/src/TkElectron.cc b/DataFormats/L1TCorrelator/src/TkElectron.cc index d587395584e92..60a1ae72c91d7 100644 --- a/DataFormats/L1TCorrelator/src/TkElectron.cc +++ b/DataFormats/L1TCorrelator/src/TkElectron.cc @@ -11,14 +11,14 @@ using namespace l1t; TkElectron::TkElectron() {} TkElectron::TkElectron(const LorentzVector& p4, - const edm::Ref& egRef, + const edm::Ptr& egCaloPtr, const edm::Ptr& trackPtr, float tkisol) - : TkEm(p4, egRef, tkisol, -999), - trkPtr_(trackPtr) - -{ + : TkEm(p4, egCaloPtr, tkisol, -999), trkPtr_(trackPtr) { if (trkPtr_.isNonnull()) { setTrkzVtx(trkPtr()->POCA().z()); } } + +TkElectron::TkElectron(const LorentzVector& p4, float tkisol) + : TkElectron(p4, edm::Ptr(nullptr, 0), edm::Ptr(nullptr, 0), tkisol) {} diff --git a/DataFormats/L1TCorrelator/src/TkEm.cc b/DataFormats/L1TCorrelator/src/TkEm.cc index 2d71f3decc8ab..adbee94433ed3 100644 --- a/DataFormats/L1TCorrelator/src/TkEm.cc +++ b/DataFormats/L1TCorrelator/src/TkEm.cc @@ -5,17 +5,19 @@ // #include "DataFormats/L1TCorrelator/interface/TkEm.h" +// FIXME: can remove +#include "DataFormats/Common/interface/RefToPtr.h" using namespace l1t; TkEm::TkEm() {} -TkEm::TkEm(const LorentzVector& p4, const edm::Ref& egRef, float tkisol) - : TkEm(p4, egRef, tkisol, -999) {} +TkEm::TkEm(const LorentzVector& p4, float tkisol, float tkisolPV) + : TkEm(p4, edm::Ptr(nullptr, 0), tkisol, tkisolPV) {} -TkEm::TkEm(const LorentzVector& p4, const edm::Ref& egRef, float tkisol, float tkisolPV) +TkEm::TkEm(const LorentzVector& p4, const edm::Ptr& egCaloPtr, float tkisol, float tkisolPV) : L1Candidate(p4), - egRef_(egRef), + egCaloPtr_(egCaloPtr), trkIsol_(tkisol), trkIsolPV_(tkisolPV), pfIsol_(-999), diff --git a/DataFormats/L1TCorrelator/src/classes_def.xml b/DataFormats/L1TCorrelator/src/classes_def.xml index 14db8c66d3d99..2846fcf2ba77a 100644 --- a/DataFormats/L1TCorrelator/src/classes_def.xml +++ b/DataFormats/L1TCorrelator/src/classes_def.xml @@ -11,7 +11,7 @@ - + @@ -24,6 +24,12 @@ + + setEgCaloPtr(edm::refToPtr(onfile.egRef_)); + ]]> + + @@ -45,8 +51,9 @@ - - + + + diff --git a/DataFormats/L1TParticleFlow/interface/layer1_emulator.h b/DataFormats/L1TParticleFlow/interface/layer1_emulator.h index f3a1b2d90cea5..9d10a81442cc3 100644 --- a/DataFormats/L1TParticleFlow/interface/layer1_emulator.h +++ b/DataFormats/L1TParticleFlow/interface/layer1_emulator.h @@ -158,14 +158,16 @@ namespace l1ct { struct EGIsoObjEmu : public EGIsoObj { const l1t::PFCluster *srcCluster; - // we use an index to the standalone object needed to retrieve a Ref when putting - int sta_idx; + + // NOTE: we use an index to the persistable RefPtr when we reshuffle collections + // this way we avoid complex object in the object interface which needs to be used in standalone programs + int src_idx; bool read(std::fstream &from); bool write(std::fstream &to) const; void clear() { EGIsoObj::clear(); srcCluster = nullptr; - sta_idx = -1; + src_idx = -1; clearIsoVars(); } @@ -191,17 +193,19 @@ namespace l1ct { }; struct EGIsoEleObjEmu : public EGIsoEleObj { - const l1t::PFCluster *srcCluster; - const l1t::PFTrack *srcTrack; - // we use an index to the standalone object needed to retrieve a Ref when putting - int sta_idx; + const l1t::PFCluster *srcCluster = nullptr; + const l1t::PFTrack *srcTrack = nullptr; + + // NOTE: we use an index to the persistable RefPtr when we reshuffle collections + // this way we avoid complex object in the object interface which needs to be used in standalone programs + int src_idx; bool read(std::fstream &from); bool write(std::fstream &to) const; void clear() { EGIsoEleObj::clear(); srcCluster = nullptr; srcTrack = nullptr; - sta_idx = -1; + src_idx = -1; clearIsoVars(); } diff --git a/DataFormats/L1TParticleFlow/src/layer1_emulator.cpp b/DataFormats/L1TParticleFlow/src/layer1_emulator.cpp index 3f1284413bbf7..3af2dd4e3eece 100644 --- a/DataFormats/L1TParticleFlow/src/layer1_emulator.cpp +++ b/DataFormats/L1TParticleFlow/src/layer1_emulator.cpp @@ -77,7 +77,7 @@ bool l1ct::PuppiObjEmu::write(std::fstream& to) const { return writeObj(from, *this); } @@ -87,7 +87,7 @@ bool l1ct::EGIsoObjEmu::write(std::fstream& to) const { return writeObj(from, *this); } diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index a855ba3b1b2a7..70facf22c7aa0 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -152,12 +152,9 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { std::unique_ptr> fetchDecodedTracks() const; void putPuppi(edm::Event &iEvent) const; - void putEgStaObjects(edm::Event &iEvent, - const std::string &egLablel, - std::vector>> &egsta_refs); + void putEgStaObjects(edm::Event &iEvent, const std::string &egLablel) const; void putEgObjects(edm::Event &iEvent, const bool writeEgSta, - const std::vector>> &egsta_refs, const std::string &tkEmLabel, const std::string &tkEmPerBoardLabel, const std::string &tkEleLabel, @@ -489,7 +486,7 @@ void L1TCorrelatorLayer1Producer::produce(edm::Event &iEvent, const edm::EventSe // get a global reference to the EGSta before being mixed among differente regions std::vector>> egsta_refs; if (l1tkegalgo_->writeEgSta()) { - putEgStaObjects(iEvent, "L1Eg", egsta_refs); + putEgStaObjects(iEvent, "L1Eg"); } // l1tkegsorter_->setDebug(true); @@ -505,7 +502,7 @@ void L1TCorrelatorLayer1Producer::produce(edm::Event &iEvent, const edm::EventSe putPuppi(iEvent); // save the EG objects - putEgObjects(iEvent, l1tkegalgo_->writeEgSta(), egsta_refs, "L1TkEm", "L1TkEmPerBoard", "L1TkEle", "L1TkElePerBoard"); + putEgObjects(iEvent, l1tkegalgo_->writeEgSta(), "L1TkEm", "L1TkEmPerBoard", "L1TkEle", "L1TkElePerBoard"); // Then go do the multiplicities for (int i = 0; i <= l1muType; ++i) { @@ -1015,22 +1012,13 @@ void L1TCorrelatorLayer1Producer::putPuppi(edm::Event &iEvent) const { iEvent.put(std::move(reg), "PuppiRegional"); } -// NOTE: as a side effect we change the "sta_idx" of TkEle and TkEm objects to an index of the -// vector of refs, for this reason this is not const. We could make this more explicit via arguments -void L1TCorrelatorLayer1Producer::putEgStaObjects(edm::Event &iEvent, - const std::string &egLablel, - std::vector>> &egsta_refs) { +void L1TCorrelatorLayer1Producer::putEgStaObjects(edm::Event &iEvent, const std::string &egLablel) const { auto egs = std::make_unique>(); - edm::RefProd> ref_egs = iEvent.getRefBeforePut>(egLablel); - - edm::Ref>::key_type idx = 0; // FIXME: in case more BXes are introduced shuld probably use egs->key(egs->end(bx)); for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) { const auto ® = event_.pfinputs[ir].region; - std::vector ref_pos(event_.out[ir].egsta.size()); - // EG standalone objects for (unsigned int ieg = 0, neg = event_.out[ir].egsta.size(); ieg < neg; ++ieg) { const auto &p = event_.out[ir].egsta[ieg]; @@ -1040,20 +1028,6 @@ void L1TCorrelatorLayer1Producer::putEgStaObjects(edm::Event &iEvent, reco::Candidate::PolarLorentzVector(p.floatPt(), reg.floatGlbEta(p.hwEta), reg.floatGlbPhi(p.hwPhi), 0.)); eg.setHwQual(p.hwQual); egs->push_back(0, eg); - egsta_refs.push_back(edm::Ref>(ref_egs, idx++)); - ref_pos[ieg] = egsta_refs.size() - 1; - } - - for (auto &egiso : event_.out[ir].egphoton) { - if (egiso.hwPt == 0) - continue; - egiso.sta_idx = ref_pos[egiso.sta_idx]; - } - - for (auto &egele : event_.out[ir].egelectron) { - if (egele.hwPt == 0) - continue; - egele.sta_idx = ref_pos[egele.sta_idx]; } } @@ -1062,7 +1036,6 @@ void L1TCorrelatorLayer1Producer::putEgStaObjects(edm::Event &iEvent, void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, const bool writeEgSta, - const std::vector>> &egsta_refs, const std::string &tkEmLabel, const std::string &tkEmPerBoardLabel, const std::string &tkEleLabel, @@ -1085,19 +1058,10 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, if (egiso.hwPt == 0) continue; - edm::Ref> ref_egsta; - if (writeEgSta) { - ref_egsta = egsta_refs[egiso.sta_idx]; - } else { - auto egptr = egiso.srcCluster->constituentsAndFractions()[0].first; - ref_egsta = - edm::Ref>(egptr.id(), dynamic_cast(egptr.get()), egptr.key()); - } - reco::Candidate::PolarLorentzVector mom(egiso.floatPt(), egiso.floatEta(), egiso.floatPhi(), 0.); l1t::TkEm tkem(reco::Candidate::LorentzVector(mom), - ref_egsta, + egiso.srcCluster->constituentsAndFractions()[0].first, egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso), egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV)); tkem.setHwQual(egiso.hwQual); @@ -1114,19 +1078,10 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, if (egele.hwPt == 0) continue; - edm::Ref> ref_egsta; - if (writeEgSta) { - ref_egsta = egsta_refs[egele.sta_idx]; - } else { - auto egptr = egele.srcCluster->constituentsAndFractions()[0].first; - ref_egsta = - edm::Ref>(egptr.id(), dynamic_cast(egptr.get()), egptr.key()); - } - reco::Candidate::PolarLorentzVector mom(egele.floatPt(), egele.floatEta(), egele.floatPhi(), 0.); l1t::TkElectron tkele(reco::Candidate::LorentzVector(mom), - ref_egsta, + egele.srcCluster->constituentsAndFractions()[0].first, edm::refToPtr(egele.srcTrack->track()), egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso)); tkele.setHwQual(egele.hwQual); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 362974b24c1a3..fa13bd6286137 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -44,16 +44,13 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { void endJob() override; - struct RefRemapper { - typedef TTTrack L1TTTrackType; + typedef TTTrack L1TTTrackType; + typedef std::vector, edm::Ptr>> ConstituentPtrVector; - BXVector>> oldRefs; - std::map>, edm::Ref>> old2newRefMap; - std::vector, edm::Ptr>> origRefAndPtr; - }; - - void convertToEmu(const l1t::TkElectron &tkele, RefRemapper &refRemapper, l1ct::OutputBoard &boarOut) const; - void convertToEmu(const l1t::TkEm &tkele, RefRemapper &refRemapper, l1ct::OutputBoard &boarOut) const; + void convertToEmu(const l1t::TkElectron &tkele, + ConstituentPtrVector &constituentsPtrs, + l1ct::OutputBoard &boarOut) const; + void convertToEmu(const l1t::TkEm &tkele, ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const; void convertToPuppi(const l1t::PFCandidateCollection &l1PFCands, l1ct::PuppiObjs &puppiObjs) const; template @@ -115,24 +112,12 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { template void merge(const PFInstanceInputs &instance, edm::Event &iEvent, - RefRemapper &refRemapper, + ConstituentPtrVector &constituentsPtrs, std::unique_ptr &out) const { edm::Handle handle; for (const auto &tokenAndChannel : instance.tokensAndChannels()) { iEvent.getByToken(tokenAndChannel.first, handle); - populate(out, handle, tokenAndChannel.second, refRemapper); - } - remapRefs(iEvent, out, refRemapper); - } - - template - void remapRefs(edm::Event &iEvent, std::unique_ptr &out, RefRemapper &refRemapper) const {} - - void remapRefs(edm::Event &iEvent, std::unique_ptr> &out, RefRemapper &refRemapper) const { - edm::RefProd> ref_egs = iEvent.getRefBeforePut>(tkEGInstanceLabel_); - edm::Ref>::key_type idx = 0; - for (std::size_t ix = 0; ix < out->size(); ix++) { - refRemapper.old2newRefMap[refRemapper.oldRefs[ix]] = edm::Ref>(ref_egs, idx++); + populate(out, handle, tokenAndChannel.second, constituentsPtrs); } } @@ -140,7 +125,7 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { void populate(std::unique_ptr &out, const edm::Handle &in, const std::vector &links, - RefRemapper &refRemapper) const { + ConstituentPtrVector &constituentsPtrs) const { assert(links.size() == in->nRegions()); for (unsigned int iBoard = 0, nBoard = in->nRegions(); iBoard < nBoard; ++iBoard) { auto region = in->region(iBoard); @@ -149,7 +134,7 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { continue; // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << linkID << std::endl; for (const auto &obj : region) { - convertToEmu(obj, refRemapper, out->at(linkID)); + convertToEmu(obj, constituentsPtrs, out->at(linkID)); } } } @@ -157,36 +142,31 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { void populate(std::unique_ptr> &out, const edm::Handle> &in, const std::vector &links, - RefRemapper &refRemapper) const { - edm::Ref>::key_type idx = 0; + ConstituentPtrVector &constituentsPtrs) const { for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) { for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) { out->push_back(bx, *egee_itr); - // this to ensure that the old ref and the new object have the same - // index in the BXVector collection so that we can still match them no - // matter which BX we will insert next - refRemapper.oldRefs.push_back(bx, edm::Ref>(in, idx++)); } } } template void putEgObjects(edm::Event &iEvent, - const RefRemapper &refRemapper, + const ConstituentPtrVector &constituentsPtrs, const std::string &label, const std::vector emulated) const { auto egobjs = std::make_unique(); for (const auto &emu : emulated) { if (emu.hwPt == 0) continue; - auto obj = convertFromEmu(emu, refRemapper); + auto obj = convertFromEmu(emu, constituentsPtrs); egobjs->push_back(obj); } iEvent.put(std::move(egobjs), label); } - l1t::TkEm convertFromEmu(const l1ct::EGIsoObjEmu &emu, const RefRemapper &refRemapper) const; - l1t::TkElectron convertFromEmu(const l1ct::EGIsoEleObjEmu &emu, const RefRemapper &refRemapper) const; + l1t::TkEm convertFromEmu(const l1ct::EGIsoObjEmu &emu, const ConstituentPtrVector &constituentsPtrs) const; + l1t::TkElectron convertFromEmu(const l1ct::EGIsoEleObjEmu &emu, const ConstituentPtrVector &constituentsPtrs) const; PFInstanceInputs> tkEGInputs_; PFInstanceInputs tkEmInputs_; @@ -283,16 +263,16 @@ std::vector> L1TCtL2EgProducer::encodeLayer1EgObjs(unsigned int nObj } void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &) const { - RefRemapper refmapper; + ConstituentPtrVector constituents; auto outEgs = std::make_unique>(); - merge(tkEGInputs_, iEvent, refmapper, outEgs); + merge(tkEGInputs_, iEvent, constituents, outEgs); iEvent.put(std::move(outEgs), tkEGInstanceLabel_); auto boards = std::make_unique>(l2egsorter.nInputBoards()); - merge(tkEleInputs_, iEvent, refmapper, boards); - merge(tkEmInputs_, iEvent, refmapper, boards); + merge(tkEleInputs_, iEvent, constituents, boards); + merge(tkEmInputs_, iEvent, constituents, boards); if (doInPtrn_) { l1t::demo::EventData inData; @@ -321,8 +301,8 @@ void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev outPtrnWrt_->addEvent(outData); } - putEgObjects(iEvent, refmapper, tkEmInstanceLabel_, out_photons_emu); - putEgObjects(iEvent, refmapper, tkEleInstanceLabel_, out_eles_emu); + putEgObjects(iEvent, constituents, tkEmInstanceLabel_, out_photons_emu); + putEgObjects(iEvent, constituents, tkEleInstanceLabel_, out_eles_emu); } void L1TCtL2EgProducer::endJob() { @@ -334,47 +314,40 @@ void L1TCtL2EgProducer::endJob() { } void L1TCtL2EgProducer::convertToEmu(const l1t::TkElectron &tkele, - RefRemapper &refRemapper, + ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const { EGIsoEleObjEmu emu; emu.initFromBits(tkele.egBinaryWord()); emu.srcCluster = nullptr; emu.srcTrack = nullptr; - auto refEg = tkele.EGRef(); - const auto newref = refRemapper.old2newRefMap.find(refEg); - if (newref != refRemapper.old2newRefMap.end()) { - refEg = newref->second; - } - refRemapper.origRefAndPtr.push_back(std::make_pair(refEg, tkele.trkPtr())); - emu.sta_idx = refRemapper.origRefAndPtr.size() - 1; + + // FIXME: this is hugly + constituentsPtrs.push_back(std::make_pair(tkele.egCaloPtr(), tkele.trkPtr())); + emu.src_idx = constituentsPtrs.size() - 1; + // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso emu.setHwIso(EGIsoEleObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkele.trkIsol() * tkele.pt())); emu.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkele.pfIsol() * tkele.pt())); emu.setHwIso(EGIsoEleObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkele.puppiIsol() * tkele.pt())); - // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl; + // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.src_idx << std::endl; boarOut.egelectron.push_back(emu); } void L1TCtL2EgProducer::convertToEmu(const l1t::TkEm &tkem, - RefRemapper &refRemapper, + ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const { EGIsoObjEmu emu; emu.initFromBits(tkem.egBinaryWord()); emu.srcCluster = nullptr; - auto refEg = tkem.EGRef(); - const auto newref = refRemapper.old2newRefMap.find(refEg); - if (newref != refRemapper.old2newRefMap.end()) { - refEg = newref->second; - } - refRemapper.origRefAndPtr.push_back(std::make_pair(refEg, edm::Ptr(nullptr, 0))); - emu.sta_idx = refRemapper.origRefAndPtr.size() - 1; + constituentsPtrs.push_back(std::make_pair(tkem.egCaloPtr(), edm::Ptr(nullptr, 0))); + emu.src_idx = constituentsPtrs.size() - 1; // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso emu.setHwIso(EGIsoObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkem.trkIsol() * tkem.pt())); emu.setHwIso(EGIsoObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkem.pfIsol() * tkem.pt())); emu.setHwIso(EGIsoObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkem.puppiIsol() * tkem.pt())); emu.setHwIso(EGIsoObjEmu::IsoType::TkIsoPV, l1ct::Scales::makeIso(tkem.trkIsolPV() * tkem.pt())); emu.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, l1ct::Scales::makeIso(tkem.pfIsolPV() * tkem.pt())); - // std::cout << "[convertToEmu] TkEM pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl; + // std::cout << "[convertToEmu] TkEM pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.src_idx << std::endl; boarOut.egphoton.push_back(emu); } @@ -386,15 +359,16 @@ void L1TCtL2EgProducer::convertToPuppi(const l1t::PFCandidateCollection &l1PFCan } } -l1t::TkEm L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoObjEmu &egiso, const RefRemapper &refRemapper) const { - // std::cout << "[convertFromEmu] TkEm pt: " << egiso.hwPt << " eta: " << egiso.hwEta << " phi: " << egiso.hwPhi << " staidx: " << egiso.sta_idx << std::endl; +l1t::TkEm L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoObjEmu &egiso, + const ConstituentPtrVector &constituentsPtrs) const { + // std::cout << "[convertFromEmu] TkEm pt: " << egiso.hwPt << " eta: " << egiso.hwEta << " phi: " << egiso.hwPhi << " staidx: " << egiso.src_idx << std::endl; // NOTE: the TkEM object is created with the accuracy as in GT object (not the Correlator internal one)! const auto gteg = egiso.toGT(); reco::Candidate::PolarLorentzVector mom( l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.); // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso l1t::TkEm tkem(reco::Candidate::LorentzVector(mom), - refRemapper.origRefAndPtr[egiso.sta_idx].first, + constituentsPtrs[egiso.src_idx].first, egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso), egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV)); tkem.setHwQual(gteg.quality); @@ -406,16 +380,16 @@ l1t::TkEm L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoObjEmu &egiso, cons } l1t::TkElectron L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoEleObjEmu &egele, - const RefRemapper &refRemapper) const { - // std::cout << "[convertFromEmu] TkEle pt: " << egele.hwPt << " eta: " << egele.hwEta << " phi: " << egele.hwPhi << " staidx: " << egele.sta_idx << std::endl; + const ConstituentPtrVector &constituentsPtrs) const { + // std::cout << "[convertFromEmu] TkEle pt: " << egele.hwPt << " eta: " << egele.hwEta << " phi: " << egele.hwPhi << " staidx: " << egele.src_idx << std::endl; // NOTE: the TkElectron object is created with the accuracy as in GT object (not the Correlator internal one)! const auto gteg = egele.toGT(); reco::Candidate::PolarLorentzVector mom( l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.); // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso l1t::TkElectron tkele(reco::Candidate::LorentzVector(mom), - refRemapper.origRefAndPtr[egele.sta_idx].first, - refRemapper.origRefAndPtr[egele.sta_idx].second, + constituentsPtrs[egele.src_idx].first, + constituentsPtrs[egele.src_idx].second, egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso)); tkele.setHwQual(gteg.quality); tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso)); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc index 44a83bf22db7a..0a7f01fa8c254 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc @@ -20,11 +20,6 @@ class L1TEGMultiMerger : public edm::global::EDProducer<> { private: void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; - struct RefRemapper { - BXVector>> oldRefs; - std::map>, edm::Ref>> old2newRefMap; - }; - template class InstanceMerger { public: @@ -38,51 +33,26 @@ class L1TEGMultiMerger : public edm::global::EDProducer<> { prod->produces(instanceLabel_); } - void produce(edm::Event& iEvent, RefRemapper& refRemapper) const { + void produce(edm::Event& iEvent) const { edm::Handle handle; auto out = std::make_unique(); for (const auto& token : tokens_) { iEvent.getByToken(token, handle); - populate(out, handle, refRemapper); + populate(out, handle); } - remapRefs(iEvent, out, refRemapper); iEvent.put(std::move(out), instanceLabel_); } private: template - void remapRefs(edm::Event& iEvent, std::unique_ptr& out, RefRemapper& refRemapper) const { - for (auto& egobj : *out) { - auto newref = refRemapper.old2newRefMap.find(egobj.EGRef()); - if (newref != refRemapper.old2newRefMap.end()) { - egobj.setEGRef(newref->second); - } - } - } - - void remapRefs(edm::Event& iEvent, std::unique_ptr>& out, RefRemapper& refRemapper) const { - edm::RefProd> ref_egs = iEvent.getRefBeforePut>(instanceLabel_); - edm::Ref>::key_type idx = 0; - for (std::size_t ix = 0; ix < out->size(); ix++) { - refRemapper.old2newRefMap[refRemapper.oldRefs[ix]] = edm::Ref>(ref_egs, idx++); - } - } - - template - void populate(std::unique_ptr& out, const edm::Handle& in, RefRemapper& refRemapper) const { + void populate(std::unique_ptr& out, const edm::Handle& in) const { out->insert(out->end(), in->begin(), in->end()); } - void populate(std::unique_ptr>& out, - const edm::Handle>& in, - RefRemapper& refRemapper) const { - edm::Ref>::key_type idx = 0; + void populate(std::unique_ptr>& out, const edm::Handle>& in) const { for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) { for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) { out->push_back(bx, *egee_itr); - // this to ensure that the old ref and the new object have the same index in the BXVector collection so that we can still match them - // no matter which BX we will insert next - refRemapper.oldRefs.push_back(bx, edm::Ref>(in, idx++)); } } } @@ -111,13 +81,12 @@ L1TEGMultiMerger::L1TEGMultiMerger(const edm::ParameterSet& conf) { L1TEGMultiMerger::~L1TEGMultiMerger() {} void L1TEGMultiMerger::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const { - RefRemapper refmapper; for (const auto& egMerger : tkEGMerger) - egMerger.produce(iEvent, refmapper); + egMerger.produce(iEvent); for (const auto& eleMerger : tkEleMerger) - eleMerger.produce(iEvent, refmapper); + eleMerger.produce(iEvent); for (const auto& emMerger : tkEmMerger) - emMerger.produce(iEvent, refmapper); + emMerger.produce(iEvent); } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp index ca3038290dc4d..19d53ad3e78b1 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp @@ -376,7 +376,6 @@ void PFTkEGAlgoEmulator::eg_algo(const PFRegionEmu ®ion, } // 2. create EG objects with brem recovery - // NOTE: duplicating the object is suboptimal but this is done for keeping things as in TDR code... addEgObjsToPF(egstas, egobjs, egeleobjs, emcalo, track, ic, calo.hwEmID, ptBremReco, itk, bdt, components); } } @@ -477,16 +476,16 @@ void PFTkEGAlgoEmulator::addEgObjsToPF(std::vector &egstas, const int tk_idx, const id_score_t bdtScore, const std::vector &components) const { - int sta_idx = -1; + int src_idx = -1; if (writeEgSta()) { addEGStaToPF(egstas, emcalo[calo_idx], hwQual, ptCorr, components); - sta_idx = egstas.size() - 1; + src_idx = egstas.size() - 1; } EGIsoObjEmu &egobj = addEGIsoToPF(egobjs, emcalo[calo_idx], hwQual, ptCorr); - egobj.sta_idx = sta_idx; + egobj.src_idx = src_idx; if (tk_idx != -1) { EGIsoEleObjEmu &eleobj = addEGIsoEleToPF(egeleobjs, emcalo[calo_idx], track[tk_idx], hwQual, ptCorr, bdtScore); - eleobj.sta_idx = sta_idx; + eleobj.src_idx = src_idx; } } From a26dd6b30fce84024fbdd73a788fdddafb2faae3 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Wed, 8 Nov 2023 12:15:08 +0100 Subject: [PATCH 4/8] GT format: change charge convention, use eta and phi at vertex, use on pv-based isolation. Set charge of TkElectrons fix --- DataFormats/L1TParticleFlow/interface/egamma.h | 13 +++++++------ .../plugins/L1TCorrelatorLayer1Producer.cc | 3 ++- .../plugins/L1TCtL2EgProducer.cc | 1 + .../python/l1TkEgAlgoEmulator_cfi.py | 6 +----- .../src/egamma/pftkegalgo_ref.cpp | 1 + 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DataFormats/L1TParticleFlow/interface/egamma.h b/DataFormats/L1TParticleFlow/interface/egamma.h index 4a61e317a6a15..93a1a0b5dfa28 100644 --- a/DataFormats/L1TParticleFlow/interface/egamma.h +++ b/DataFormats/L1TParticleFlow/interface/egamma.h @@ -90,8 +90,8 @@ namespace l1ct { id_score_t hwIDScore; bool hwCharge; - phi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; } - eta_t hwVtxEta() const { return hwEta + hwDEta; } + glbphi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; } + glbeta_t hwVtxEta() const { return hwEta + hwDEta; } inline bool operator==(const EGIsoEleObj &other) const { return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwQual == other.hwQual && @@ -164,11 +164,12 @@ namespace l1ct { l1gt::Electron ele; ele.valid = hwPt != 0; ele.v3.pt = CTtoGT_pt(hwPt); - ele.v3.phi = CTtoGT_phi(hwPhi); - ele.v3.eta = CTtoGT_eta(hwEta); + ele.v3.phi = CTtoGT_phi(hwVtxPhi()); + ele.v3.eta = CTtoGT_eta(hwVtxEta()); ele.quality = hwQual; - ele.charge = hwCharge; - ele.z0 = hwZ0; + // NOTE: GT: 0 = positive, 1 = negative, CT: 0 = negative, 1 = positive + ele.charge = !hwCharge; + ele.z0(l1ct::z0_t::width - 1, 0) = hwZ0(l1ct::z0_t::width - 1, 0); ele.isolation = hwIso; return ele; } diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 70facf22c7aa0..5f1a0b55752c2 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -1078,7 +1078,7 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, if (egele.hwPt == 0) continue; - reco::Candidate::PolarLorentzVector mom(egele.floatPt(), egele.floatEta(), egele.floatPhi(), 0.); + reco::Candidate::PolarLorentzVector mom(egele.floatPt(), egele.floatVtxEta(), egele.floatVtxPhi(), 0.); l1t::TkElectron tkele(reco::Candidate::LorentzVector(mom), egele.srcCluster->constituentsAndFractions()[0].first, @@ -1088,6 +1088,7 @@ void L1TCorrelatorLayer1Producer::putEgObjects(edm::Event &iEvent, tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso)); tkele.setEgBinaryWord(egele.pack(), l1t::TkElectron::HWEncoding::CT); tkele.setIdScore(egele.floatIDScore()); + tkele.setCharge(egele.intCharge()); tkeles->push_back(tkele); nele_obj.push_back(tkeles->size() - 1); } diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index fa13bd6286137..7134ea9b2c25d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -396,6 +396,7 @@ l1t::TkElectron L1TCtL2EgProducer::convertFromEmu(const l1ct::EGIsoEleObjEmu &eg tkele.setPuppiIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso)); tkele.setEgBinaryWord(gteg.pack(), l1t::TkElectron::HWEncoding::GT); tkele.setIdScore(egele.floatIDScore()); + tkele.setCharge(egele.intCharge()); return tkele; } diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py b/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py index 9b68b7fa615a2..2fb19ea8b56eb 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1TkEgAlgoEmulator_cfi.py @@ -24,33 +24,29 @@ dZ=cms.double(0.6), dRMin=cms.double(0.07), dRMax=cms.double(0.30), - tkQualityChi2Max=cms.double(100), ), tkIsoParametersTkEle=cms.PSet( tkQualityPtMin=cms.double(2.), dZ=cms.double(0.6), dRMin=cms.double(0.03), dRMax=cms.double(0.20), - tkQualityChi2Max=cms.double(1e10), ), pfIsoParametersTkEm=cms.PSet( tkQualityPtMin=cms.double(1.), dZ=cms.double(0.6), dRMin=cms.double(0.07), dRMax=cms.double(0.30), - tkQualityChi2Max=cms.double(100), ), pfIsoParametersTkEle=cms.PSet( tkQualityPtMin=cms.double(1.), dZ=cms.double(0.6), dRMin=cms.double(0.03), dRMax=cms.double(0.20), - tkQualityChi2Max=cms.double(1e10), ), doTkIso=cms.bool(True), doPfIso=cms.bool(True), hwIsoTypeTkEle=cms.uint32(0), - hwIsoTypeTkEm=cms.uint32(2), + hwIsoTypeTkEm=cms.uint32(0), doCompositeTkEle=cms.bool(False), nCompCandPerCluster=cms.uint32(3), compositeParametersTkEle=cms.PSet( diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp index 19d53ad3e78b1..f66645a448ac6 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp @@ -51,6 +51,7 @@ l1ct::PFTkEGAlgoEmuConfig::IsoParameters::IsoParameters(const edm::ParameterSet pset.getParameter("dRMin"), pset.getParameter("dRMax")) {} + l1ct::PFTkEGAlgoEmuConfig::CompIDParameters::CompIDParameters(const edm::ParameterSet &pset) : CompIDParameters(pset.getParameter("loose_wp"), pset.getParameter("tight_wp"), From a93780c76167556daa230564d2b54227380c3cd1 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Fri, 17 Nov 2023 17:07:08 +0100 Subject: [PATCH 5/8] cosmetics --- DataFormats/L1TCorrelator/src/TkElectron.cc | 2 +- DataFormats/L1TCorrelator/src/TkEm.cc | 2 +- DataFormats/L1TParticleFlow/interface/egamma.h | 4 ++-- L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DataFormats/L1TCorrelator/src/TkElectron.cc b/DataFormats/L1TCorrelator/src/TkElectron.cc index 60a1ae72c91d7..6ceaa36165ccf 100644 --- a/DataFormats/L1TCorrelator/src/TkElectron.cc +++ b/DataFormats/L1TCorrelator/src/TkElectron.cc @@ -21,4 +21,4 @@ TkElectron::TkElectron(const LorentzVector& p4, } TkElectron::TkElectron(const LorentzVector& p4, float tkisol) - : TkElectron(p4, edm::Ptr(nullptr, 0), edm::Ptr(nullptr, 0), tkisol) {} + : TkElectron(p4, edm::Ptr(), edm::Ptr(), tkisol) {} diff --git a/DataFormats/L1TCorrelator/src/TkEm.cc b/DataFormats/L1TCorrelator/src/TkEm.cc index adbee94433ed3..9758a14285c52 100644 --- a/DataFormats/L1TCorrelator/src/TkEm.cc +++ b/DataFormats/L1TCorrelator/src/TkEm.cc @@ -13,7 +13,7 @@ using namespace l1t; TkEm::TkEm() {} TkEm::TkEm(const LorentzVector& p4, float tkisol, float tkisolPV) - : TkEm(p4, edm::Ptr(nullptr, 0), tkisol, tkisolPV) {} + : TkEm(p4, edm::Ptr(), tkisol, tkisolPV) {} TkEm::TkEm(const LorentzVector& p4, const edm::Ptr& egCaloPtr, float tkisol, float tkisolPV) : L1Candidate(p4), diff --git a/DataFormats/L1TParticleFlow/interface/egamma.h b/DataFormats/L1TParticleFlow/interface/egamma.h index 93a1a0b5dfa28..ea845d60e107d 100644 --- a/DataFormats/L1TParticleFlow/interface/egamma.h +++ b/DataFormats/L1TParticleFlow/interface/egamma.h @@ -85,8 +85,8 @@ namespace l1ct { // WARNING: for whatever reason, maybe connected with datamember alignment, // in 2019.2 synthesis fails if DEta & DPhi are put before Z0 & Dxy z0_t hwZ0; - tkdeta_t hwDEta; // relative to the region center, at calo - tkdphi_t hwDPhi; // relative to the region center, at calo + tkdeta_t hwDEta; + tkdphi_t hwDPhi; id_score_t hwIDScore; bool hwCharge; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 7134ea9b2c25d..25360347e03c6 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -321,7 +321,6 @@ void L1TCtL2EgProducer::convertToEmu(const l1t::TkElectron &tkele, emu.srcCluster = nullptr; emu.srcTrack = nullptr; - // FIXME: this is hugly constituentsPtrs.push_back(std::make_pair(tkele.egCaloPtr(), tkele.trkPtr())); emu.src_idx = constituentsPtrs.size() - 1; @@ -339,7 +338,7 @@ void L1TCtL2EgProducer::convertToEmu(const l1t::TkEm &tkem, EGIsoObjEmu emu; emu.initFromBits(tkem.egBinaryWord()); emu.srcCluster = nullptr; - constituentsPtrs.push_back(std::make_pair(tkem.egCaloPtr(), edm::Ptr(nullptr, 0))); + constituentsPtrs.push_back(std::make_pair(tkem.egCaloPtr(), edm::Ptr())); emu.src_idx = constituentsPtrs.size() - 1; // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso emu.setHwIso(EGIsoObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkem.trkIsol() * tkem.pt())); From 31317a4d6735cd1917557bcf6b2efde4cad1c164 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 23 Nov 2023 15:48:30 +0100 Subject: [PATCH 6/8] Add pattern files for Layer2 e/g with TMUX18 input --- .../plugins/L1TCtL2EgProducer.cc | 127 ++++++++++++------ .../python/l1ctLayer2EG_cff.py | 83 ++++++++++-- .../test/make_l1ct_binaryFiles_cfg.py | 9 +- 3 files changed, 167 insertions(+), 52 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 25360347e03c6..6bd03b11b2115 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -36,9 +36,10 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { std::vector> encodeLayer1(const std::vector &photons) const; std::vector> encodeLayer1(const std::vector &electrons) const; - std::vector> encodeLayer1EgObjs(unsigned int nObj, - const std::vector &photons, - const std::vector &electrons) const; + void encodeLayer1EgObjs(unsigned int nObj, + std::vector> &data, + const std::vector &photons, + const std::vector &electrons) const; void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; @@ -56,25 +57,25 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { template class PFInstanceInputs { public: - typedef std::vector, std::vector>> InputTokenAndChannels; + typedef std::vector, std::vector>> InputTokenAndRegions; PFInstanceInputs(L1TCtL2EgProducer *prod, const std::vector &confs) { for (const auto &conf : confs) { const auto &producer_tag = conf.getParameter("pfProducer"); - tokensAndChannels_.push_back(std::make_pair( + tokensAndRegions_.push_back(std::make_pair( prod->consumes(edm::InputTag(producer_tag.label(), producer_tag.instance(), producer_tag.process())), - conf.getParameter>("channels"))); + conf.getParameter>("regions"))); } } - const InputTokenAndChannels &tokensAndChannels() const { return tokensAndChannels_; } + const InputTokenAndRegions &tokensAndRegions() const { return tokensAndRegions_; } private: - InputTokenAndChannels tokensAndChannels_; + InputTokenAndRegions tokensAndRegions_; }; class PatternWriter { public: - PatternWriter(const edm::ParameterSet &conf) : dataWriter_(nullptr) { + PatternWriter(const edm::ParameterSet &conf) : region2link_(5), dataWriter_(nullptr) { unsigned int nFramesPerBX = conf.getParameter("nFramesPerBX"); std::map>> channelSpecs; @@ -84,11 +85,42 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { unsigned int eventGap = inTMUX * nFramesPerBX - channelConf.getParameter("nWords"); // assuming 96bit (= 3/2 word) // words = TMUX*9-2*3/2*words + std::vector chns = channelConf.getParameter>("channels"); - channelSpecs[l1t::demo::LinkId{channelConf.getParameter("interface"), - channelConf.getParameter("id")}] = - std::make_pair(l1t::demo::ChannelSpec{inTMUX, eventGap}, - std::vector(std::begin(chns), std::end(chns))); + + std::string interface = channelConf.getParameter("interface"); + unsigned int chId = channelConf.getParameter("id"); + l1t::demo::LinkId linkId{interface, size_t(chId)}; + channelSpecs[linkId] = std::make_pair(l1t::demo::ChannelSpec{inTMUX, eventGap}, + std::vector(std::begin(chns), std::end(chns))); + + // NOTE: this could be parametrized from CFG + if (inTMUX == 6) { + if (interface == "eglayer1Barrel" || interface == "eglayer1Endcap") { + // Layer1 TMUX=6 => each one of the regions is mapped to a link + // with the same ID + // # of words = 16 (pho) + 2*16 (ele) = 48 + // no filling words needed + region2link_[chId] = RegionLinkMetadata{linkId, 0}; + } + } else if (inTMUX == 18) { + if (interface == "eglayer1Barrel") { + // Layer1 TMUX=18 => 3 regions are mapped to the same link + // one every 6 BX x 9 words = 54 words + // # of data words = 16 (pho) + 2*16 (ele) = 48 + // # we fill with 54-48 = 6 empty words + region2link_[0] = RegionLinkMetadata{linkId, 6}; + region2link_[1] = RegionLinkMetadata{linkId, 6}; + region2link_[2] = RegionLinkMetadata{linkId, 0}; + } else if (interface == "eglayer1Endcap") { + // Layer1 TMUX=18 => 2 endcap regions are mapped to the same link + // one every 9 BX x 9 words = 81 words + // # of data words = 16 (pho) + 2*16 (ele) = 48 + // # we fill with 81-48 = 33 empty words + region2link_[3] = RegionLinkMetadata{linkId, 33}; + region2link_[4] = RegionLinkMetadata{linkId, 0}; + } + } } dataWriter_ = std::make_unique( @@ -101,11 +133,23 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { channelSpecs); } + struct RegionLinkMetadata { + l1t::demo::LinkId linkId; + unsigned int nTrailingWords; + }; + void addEvent(const l1t::demo::EventData &eventData) { dataWriter_->addEvent(eventData); } void flush() { dataWriter_->flush(); } + const RegionLinkMetadata ®ion2Link(unsigned int region) const { + assert(region < region2link_.size()); + return region2link_.at(region); + } + private: + std::vector region2link_; + std::unique_ptr dataWriter_; }; @@ -115,33 +159,33 @@ class L1TCtL2EgProducer : public edm::global::EDProducer<> { ConstituentPtrVector &constituentsPtrs, std::unique_ptr &out) const { edm::Handle handle; - for (const auto &tokenAndChannel : instance.tokensAndChannels()) { - iEvent.getByToken(tokenAndChannel.first, handle); - populate(out, handle, tokenAndChannel.second, constituentsPtrs); + for (const auto &tokenAndRegions : instance.tokensAndRegions()) { + iEvent.getByToken(tokenAndRegions.first, handle); + populate(out, handle, tokenAndRegions.second, constituentsPtrs); } } template void populate(std::unique_ptr &out, const edm::Handle &in, - const std::vector &links, + const std::vector ®ions, ConstituentPtrVector &constituentsPtrs) const { - assert(links.size() == in->nRegions()); + assert(regions.size() == in->nRegions()); for (unsigned int iBoard = 0, nBoard = in->nRegions(); iBoard < nBoard; ++iBoard) { auto region = in->region(iBoard); - int linkID = links[iBoard]; - if (linkID < 0) + int regionID = regions[iBoard]; + if (regionID < 0) continue; - // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << linkID << std::endl; + // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << regionID << std::endl; for (const auto &obj : region) { - convertToEmu(obj, constituentsPtrs, out->at(linkID)); + convertToEmu(obj, constituentsPtrs, out->at(regionID)); } } } void populate(std::unique_ptr> &out, const edm::Handle> &in, - const std::vector &links, + const std::vector ®ions, ConstituentPtrVector &constituentsPtrs) const { for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) { for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) { @@ -247,19 +291,17 @@ std::vector> L1TCtL2EgProducer::encodeLayer1(const std::vector> L1TCtL2EgProducer::encodeLayer1EgObjs(unsigned int nObj, - const std::vector &photons, - const std::vector &electrons) const { - std::vector> ret; +void L1TCtL2EgProducer::encodeLayer1EgObjs(unsigned int nObj, + std::vector> &data, + const std::vector &photons, + const std::vector &electrons) const { auto encoded_photons = encodeLayer1(photons); encoded_photons.resize(nObj, {0}); auto encoded_eles = encodeLayer1(electrons); encoded_eles.resize(2 * nObj, {0}); - std::copy(encoded_photons.begin(), encoded_photons.end(), std::back_inserter(ret)); - std::copy(encoded_eles.begin(), encoded_eles.end(), std::back_inserter(ret)); - - return ret; + std::copy(encoded_photons.begin(), encoded_photons.end(), std::back_inserter(data)); + std::copy(encoded_eles.begin(), encoded_eles.end(), std::back_inserter(data)); } void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &) const { @@ -269,24 +311,31 @@ void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev merge(tkEGInputs_, iEvent, constituents, outEgs); iEvent.put(std::move(outEgs), tkEGInstanceLabel_); - auto boards = std::make_unique>(l2egsorter.nInputBoards()); + auto regions = std::make_unique>(l2egsorter.nInputBoards()); - merge(tkEleInputs_, iEvent, constituents, boards); - merge(tkEmInputs_, iEvent, constituents, boards); + merge(tkEleInputs_, iEvent, constituents, regions); + merge(tkEmInputs_, iEvent, constituents, regions); if (doInPtrn_) { + std::map regio2link; + l1t::demo::EventData inData; - for (unsigned int ibrd = 0; ibrd < boards->size(); ibrd++) { - inData.add( - {"eglayer1", ibrd}, - encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), (*boards)[ibrd].egphoton, (*boards)[ibrd].egelectron)); + for (unsigned int ireg = 0; ireg < regions->size(); ireg++) { + const auto &linkData = inPtrnWrt_->region2Link(ireg); + std::vector> data; + + if (inData.has(linkData.linkId)) + data = inData.at(linkData.linkId); + encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), data, (*regions)[ireg].egphoton, (*regions)[ireg].egelectron); + data.resize(data.size() + linkData.nTrailingWords, {0}); + inData.add(linkData.linkId, data); } inPtrnWrt_->addEvent(inData); } std::vector out_photons_emu; std::vector out_eles_emu; - l2egsorter.run(*boards, out_photons_emu, out_eles_emu); + l2egsorter.run(*regions, out_photons_emu, out_eles_emu); // PUPPI isolation auto &pfObjs = iEvent.get(pfObjsToken_); diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py index 18e28d46752f0..f5f7308ce8a41 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py @@ -7,35 +7,35 @@ tkElectrons=cms.VPSet( cms.PSet( pfProducer=cms.InputTag("l1tLayer1HGCal", 'L1TkElePerBoard'), - channels=cms.vint32(3, 4) + regions=cms.vint32(3, 4) ), cms.PSet( pfProducer=cms.InputTag("l1tLayer1Barrel", 'L1TkElePerBoard'), - channels=cms.vint32(0, 1, 2) + regions=cms.vint32(0, 1, 2) ), ), tkEms=cms.VPSet( cms.PSet( pfProducer=cms.InputTag("l1tLayer1HGCal", 'L1TkEmPerBoard'), - channels=cms.vint32(3, 4) + regions=cms.vint32(3, 4) ), cms.PSet( pfProducer=cms.InputTag("l1tLayer1HGCalNoTK", 'L1TkEmPerBoard'), - channels=cms.vint32(-1) + regions=cms.vint32(-1) ), cms.PSet( pfProducer=cms.InputTag("l1tLayer1Barrel", 'L1TkEmPerBoard'), - channels=cms.vint32(0, 1, 2) + regions=cms.vint32(0, 1, 2) ), ), tkEgs=cms.VPSet( cms.PSet( pfProducer=cms.InputTag("l1tLayer1HGCal", 'L1Eg'), - channels=cms.vint32(-1) + regions=cms.vint32(-1) ), cms.PSet( pfProducer=cms.InputTag("l1tLayer1HGCalNoTK", 'L1Eg'), - channels=cms.vint32(-1) + regions=cms.vint32(-1) ), ), l1PFObjects = cms.InputTag("l1tLayer2Deregionizer", "Puppi"), @@ -81,35 +81,35 @@ cms.PSet( TMUX=cms.uint32(6), nWords=cms.uint32(48), # = 16*2words ele + 16words photons - interface=cms.string("eglayer1"), + interface=cms.string("eglayer1Barrel"), id=cms.uint32(0), channels=cms.vuint32(0) ), cms.PSet( TMUX=cms.uint32(6), nWords=cms.uint32(48), - interface=cms.string("eglayer1"), + interface=cms.string("eglayer1Barrel"), id=cms.uint32(1), channels=cms.vuint32(1) ), cms.PSet( TMUX=cms.uint32(6), nWords=cms.uint32(48), - interface=cms.string("eglayer1"), + interface=cms.string("eglayer1Barrel"), id=cms.uint32(2), channels=cms.vuint32(2) ), cms.PSet( TMUX=cms.uint32(6), nWords=cms.uint32(48), - interface=cms.string("eglayer1"), + interface=cms.string("eglayer1Endcap"), id=cms.uint32(3), channels=cms.vuint32(3) ), cms.PSet( TMUX=cms.uint32(6), nWords=cms.uint32(48), - interface=cms.string("eglayer1"), + interface=cms.string("eglayer1Endcap"), id=cms.uint32(4), channels=cms.vuint32(4) ), @@ -190,6 +190,65 @@ ), ) +# EG Layer2 with Layer1 @ TMUX18 +l1tLayer2EGTM18 = l1tLayer2EG.clone( + tkElectrons=cms.VPSet( + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1HGCalTM18", 'L1TkElePerBoard'), + regions=cms.vint32(3, 4) + ), + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1BarrelSerenityTM18", 'L1TkElePerBoard'), + regions=cms.vint32(0, 1, 2) + ), + ), + tkEms=cms.VPSet( + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1HGCalTM18", 'L1TkEmPerBoard'), + regions=cms.vint32(3, 4) + ), + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1HGCalNoTKTM18", 'L1TkEmPerBoard'), + regions=cms.vint32(-1) + ), + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1BarrelSerenityTM18", 'L1TkEmPerBoard'), + regions=cms.vint32(0, 1, 2) + ), + ), + tkEgs=cms.VPSet( + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1HGCalTM18", 'L1Eg'), + regions=cms.vint32(-1) + ), + cms.PSet( + pfProducer=cms.InputTag("l1tLayer1HGCalNoTKTM18", 'L1Eg'), + regions=cms.vint32(-1) + ), + ), +) + +l1tLayer2EGTM18.inPatternFile.outputFilename = "L1TCTL2EG_TMUX18_InPattern" +l1tLayer2EGTM18.inPatternFile.channels = cms.VPSet( + cms.PSet( + TMUX=cms.uint32(18), + nWords=cms.uint32(156), # = (16*2words ele + 16words photons) * 3 (regions) every 6 BX (54 words) = 48+6(empty)+48+6(empty)+48 = 156 + interface=cms.string("eglayer1Barrel"), + id=cms.uint32(0), + channels=cms.vuint32(0,2,4) + ), + cms.PSet( + TMUX=cms.uint32(18), + nWords=cms.uint32(129), # (16*2words ele + 16words photons) * 2 (regions) every 9 BX (81 words) = 48+33(empty)+48 + interface=cms.string("eglayer1Endcap"), + id=cms.uint32(1), + channels=cms.vuint32(1,3,5) + ), +) +l1tLayer2EGTM18.outPatternFile.outputFilename = 'L1TCTL2EG_TMUX18_OutPattern' +# FIXME: we need to schedule a new deregionizer for TM18 +# l1tLayer2EGTM18.l1PFObjects = cms.InputTag("l1tLayer2Deregionizer", "Puppi"), + L1TLayer2EGTask = cms.Task( l1tLayer2Deregionizer, diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index 249725522860e..dfd8ef4942e08 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -31,7 +31,7 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.load("FWCore.MessageLogger.MessageLogger_cfi") process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True), allowUnscheduled = cms.untracked.bool(False) ) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000)) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100)) process.MessageLogger.cerr.FwkReport.reportEvery = 1 process.source = cms.Source("PoolSource", @@ -172,9 +172,16 @@ process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nCaloLinks = 1 process.runPF.insert(process.runPF.index(process.l1tLayer1HGCal)+1, process.l1tLayer1HGCalTM18) process.runPF.insert(process.runPF.index(process.l1tLayer1HGCalNoTK)+1, process.l1tLayer1HGCalNoTKTM18) + process.runPF.insert(process.runPF.index(process.l1tLayer1BarrelSerenity)+1, process.l1tLayer1BarrelSerenityTM18) + # FIXME: we need to schedule a new deregionizer for TM18 + process.runPF.insert(process.runPF.index(process.l1tLayer2EG)+1, process.l1tLayer2EGTM18) if not args.patternFilesOFF: process.l1tLayer1HGCalTM18.patternWriters = cms.untracked.VPSet(*hgcalTM18WriterConfigs) process.l1tLayer1HGCalNoTKTM18.patternWriters = cms.untracked.VPSet(hgcalNoTKOutputTM18WriterConfig) + process.l1tLayer1BarrelSerenityTM18.patternWriters = cms.untracked.VPSet() + process.l1tLayer2EGTM18.writeInPattern = True + process.l1tLayer2EGTM18.writeOutPattern = True + if not args.dumpFilesOFF: for det in "HGCalTM18", "HGCalNoTKTM18": getattr(process, 'l1tLayer1'+det).dumpFileName = cms.untracked.string("TTbar_PU200_"+det+".dump") From ab9582808b78f981502c0cd584bf9616cb2ff77f Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 23 Nov 2023 17:48:10 +0100 Subject: [PATCH 7/8] Change naming to match TM18 and TM16 input logic --- .../interface/egamma/l2egsorter_ref.h | 51 +++++++++---------- .../plugins/L1TCtL2EgProducer.cc | 4 +- .../python/l1ctLayer2EG_cff.py | 4 +- .../src/egamma/l2egsorter_ref.cpp | 20 ++++---- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h index c5b75b37384e6..283ab6bcbcf94 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h @@ -17,28 +17,28 @@ namespace l1ct { class L2EgSorterEmulator { public: - L2EgSorterEmulator(unsigned int nBoards, unsigned int nEGPerBoard, unsigned int nEGOut, bool debug) - : nBOARDS(nBoards), nEGPerBoard(nEGPerBoard), nEGOut(nEGOut), debug_(debug) {} + L2EgSorterEmulator(unsigned int nRegions, unsigned int nEGPerRegion, unsigned int nEGOut, bool debug) + : nREGIONS(nRegions), nEGPerRegion(nEGPerRegion), nEGOut(nEGOut), debug_(debug) {} L2EgSorterEmulator(const edm::ParameterSet &iConfig); virtual ~L2EgSorterEmulator() {} - template + template void toFirmware(const std::vector &in, - EGIsoObj (&photons_in)[NBoards][NObjs], - EGIsoEleObj (&eles_in)[NBoards][NObjs]) const { - for (unsigned int ib = 0; ib < NBoards; ib++) { - const auto &board = in[ib]; + EGIsoObj (&photons_in)[NRegions][NObjs], + EGIsoEleObj (&eles_in)[NRegions][NObjs]) const { + for (unsigned int ib = 0; ib < NRegions; ib++) { + const auto ®ion = in[ib]; for (unsigned int io = 0; io < NObjs; io++) { EGIsoObj pho; EGIsoEleObj ele; - if (io < board.egphoton.size()) - pho = board.egphoton[io]; + if (io < region.egphoton.size()) + pho = region.egphoton[io]; else pho.clear(); - if (io < board.egelectron.size()) - ele = board.egelectron[io]; + if (io < region.egelectron.size()) + ele = region.egelectron[io]; else ele.clear(); @@ -59,17 +59,17 @@ namespace l1ct { void setDebug(int verbose) { debug_ = verbose; } - unsigned int nInputBoards() const { return nBOARDS; } - unsigned int nInputObjPerBoard() const { return nEGPerBoard; } + unsigned int nInputRegions() const { return nREGIONS; } + unsigned int nInputObjPerRegion() const { return nEGPerRegion; } unsigned int nOutputObj() const { return nEGOut; } private: template void resize_input(std::vector &in) const { - if (in.size() > nEGPerBoard) { - in.resize(nEGPerBoard); - } else if (in.size() < nEGPerBoard) { - for (unsigned int i = 0, diff = (nEGPerBoard - in.size()); i < diff; ++i) { + if (in.size() > nEGPerRegion) { + in.resize(nEGPerRegion); + } else if (in.size() < nEGPerRegion) { + for (unsigned int i = 0, diff = (nEGPerRegion - in.size()); i < diff; ++i) { in.push_back(T()); in.back().clear(); } @@ -90,17 +90,16 @@ namespace l1ct { } template - void merge_boards(const std::vector &in_board1, - const std::vector &in_board2, + void merge_regions(const std::vector &in_region1, + const std::vector &in_region2, std::vector &out, unsigned int nOut) const { // we crate a bitonic list - out = in_board1; + out = in_region1; std::reverse(out.begin(), out.end()); - std::copy(in_board2.begin(), in_board2.end(), std::back_inserter(out)); + std::copy(in_region2.begin(), in_region2.end(), std::back_inserter(out)); hybridBitonicMergeRef(&out[0], out.size(), 0, false); - // std::merge(in_board1.begin(), in_board1.end(), in_board2_copy.begin(), in_board2_copy.end(), std::back_inserter(out), comparePt); if (out.size() > nOut) out.resize(nOut); } @@ -112,7 +111,7 @@ namespace l1ct { if (out.size() > nEGOut) out.resize(nEGOut); } else if (in_objs.size() == 2) { - merge_boards(in_objs[0], in_objs[1], out, nEGOut); + merge_regions(in_objs[0], in_objs[1], out, nEGOut); } else { std::vector> to_merge; for (unsigned int id = 0, idn = 1; id < in_objs.size(); id += 2, idn = id + 1) { @@ -120,7 +119,7 @@ namespace l1ct { to_merge.push_back(in_objs[id]); } else { std::vector pair_merge; - merge_boards(in_objs[id], in_objs[idn], pair_merge, nEGPerBoard); + merge_regions(in_objs[id], in_objs[idn], pair_merge, nEGPerRegion); to_merge.push_back(pair_merge); } } @@ -128,8 +127,8 @@ namespace l1ct { } } - const unsigned int nBOARDS; - const unsigned int nEGPerBoard; + const unsigned int nREGIONS; + const unsigned int nEGPerRegion; const unsigned int nEGOut; int debug_; }; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 6bd03b11b2115..fa240a280af78 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -311,7 +311,7 @@ void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev merge(tkEGInputs_, iEvent, constituents, outEgs); iEvent.put(std::move(outEgs), tkEGInstanceLabel_); - auto regions = std::make_unique>(l2egsorter.nInputBoards()); + auto regions = std::make_unique>(l2egsorter.nInputRegions()); merge(tkEleInputs_, iEvent, constituents, regions); merge(tkEmInputs_, iEvent, constituents, regions); @@ -326,7 +326,7 @@ void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev if (inData.has(linkData.linkId)) data = inData.at(linkData.linkId); - encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), data, (*regions)[ireg].egphoton, (*regions)[ireg].egelectron); + encodeLayer1EgObjs(l2egsorter.nInputObjPerRegion(), data, (*regions)[ireg].egphoton, (*regions)[ireg].egelectron); data.resize(data.size() + linkData.nTrailingWords, {0}); inData.add(linkData.linkId, data); } diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py index f5f7308ce8a41..aef3d3be76e6e 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py @@ -43,8 +43,8 @@ tkEmInstanceLabel=cms.string("L1CtTkEm"), tkEleInstanceLabel=cms.string("L1CtTkElectron"), sorter=cms.PSet( - nBOARDS=cms.uint32(5), - nEGPerBoard=cms.uint32(16), + nREGIONS=cms.uint32(5), + nEGPerRegion=cms.uint32(16), nEGOut=cms.uint32(12), debug=cms.untracked.uint32(0), ), diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp index 751d75e467235..64bc9314ff5ce 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp @@ -12,8 +12,8 @@ using namespace l1ct; #include "FWCore/ParameterSet/interface/ParameterSet.h" l1ct::L2EgSorterEmulator::L2EgSorterEmulator(const edm::ParameterSet &pset) - : L2EgSorterEmulator(pset.getParameter("nBOARDS"), - pset.getParameter("nEGPerBoard"), + : L2EgSorterEmulator(pset.getParameter("nREGIONS"), + pset.getParameter("nEGPerRegion"), pset.getParameter("nEGOut"), pset.getUntrackedParameter("debug", 0)) {} #endif @@ -43,11 +43,11 @@ void L2EgSorterEmulator::run(const std::vector &in, std::vector &out_photons, std::vector &out_eles) const { if (debug_) { - unsigned int board_n = 0; - for (const auto &board : in) { - dbgCout() << "BOARD " << board_n++ << std::endl; - print_objects(board.egphoton, "photon_in"); - print_objects(board.egelectron, "electron_in"); + unsigned int region_n = 0; + for (const auto ®ion : in) { + dbgCout() << "REGION " << region_n++ << std::endl; + print_objects(region.egphoton, "photon_in"); + print_objects(region.egelectron, "electron_in"); } } @@ -56,9 +56,9 @@ void L2EgSorterEmulator::run(const std::vector &in, std::vector> eles_in; photons_in.reserve(in.size()); eles_in.reserve(in.size()); - for (const auto &board : in) { - std::vector photons = board.egphoton; - std::vector eles = board.egelectron; + for (const auto ®ion : in) { + std::vector photons = region.egphoton; + std::vector eles = region.egelectron; resize_input(photons); resize_input(eles); From 70ade3abe2b5fe62357b693c919392ad885d7eea Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 25 Jan 2024 10:00:19 +0100 Subject: [PATCH 8/8] Make L1TNtuples compile --- L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc | 110 +++++++++--------- .../L1TNtuples/src/L1AnalysisPhaseIIStep1.cc | 68 +++++------ 2 files changed, 89 insertions(+), 89 deletions(-) diff --git a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc index 18a4d89de1873..686594cdb2699 100644 --- a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc +++ b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc @@ -202,20 +202,20 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEG(const edm::Handleet()); l1extra_.tkElectronEta.push_back(it->eta()); l1extra_.tkElectronPhi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkElectronChg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkElectronChg.push_back(chargeFromCurvature); l1extra_.tkElectronzVtx.push_back(it->trkzVtx()); l1extra_.tkElectronTrkIso.push_back(it->trkIsol()); - l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); - l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); + // l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkElectronBx.push_back(0); //it->bx()); l1extra_.tkElectronHGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; // LooseTrackID should be the second bit - l1extra_.tkElectronPassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // LooseTrackID should be the second bit - l1extra_.tkElectronPassesPhotonID.push_back(quality); + // bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; // LooseTrackID should be the second bit + // l1extra_.tkElectronPassesLooseTrackID.push_back(quality); + // quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // LooseTrackID should be the second bit + // l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; } } @@ -227,19 +227,19 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEG(const edm::Handleet()); l1extra_.tkElectronEta.push_back(it->eta()); l1extra_.tkElectronPhi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkElectronChg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkElectronChg.push_back(chargeFromCurvature); l1extra_.tkElectronzVtx.push_back(it->trkzVtx()); l1extra_.tkElectronTrkIso.push_back(it->trkIsol()); - l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); - l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); + // l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkElectronBx.push_back(0); //it->bx()); l1extra_.tkElectronHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 5); - l1extra_.tkElectronPassesLooseTrackID.push_back(quality); - l1extra_.tkElectronPassesPhotonID.push_back(quality); + // bool quality = (it->EGRef()->hwQual() == 5); + // l1extra_.tkElectronPassesLooseTrackID.push_back(quality); + // l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; } } @@ -255,20 +255,20 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEGV2(const edm::Handleet()); l1extra_.tkElectronV2Eta.push_back(it->eta()); l1extra_.tkElectronV2Phi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkElectronV2Chg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkElectronV2Chg.push_back(chargeFromCurvature); l1extra_.tkElectronV2zVtx.push_back(it->trkzVtx()); l1extra_.tkElectronV2TrkIso.push_back(it->trkIsol()); - l1extra_.tkElectronV2HwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkElectronV2EGRefPt.push_back(it->EGRef()->et()); - l1extra_.tkElectronV2EGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkElectronV2EGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkElectronV2HwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkElectronV2EGRefPt.push_back(it->EGRef()->et()); + // l1extra_.tkElectronV2EGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkElectronV2EGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkElectronV2Bx.push_back(0); //it->bx()); l1extra_.tkElectronV2HGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; - l1extra_.tkElectronV2PassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; - l1extra_.tkElectronV2PassesPhotonID.push_back(quality); + // bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; + // l1extra_.tkElectronV2PassesLooseTrackID.push_back(quality); + // quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; + // l1extra_.tkElectronV2PassesPhotonID.push_back(quality); l1extra_.nTkElectronsV2++; } } @@ -280,19 +280,19 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEGV2(const edm::Handleet()); l1extra_.tkElectronV2Eta.push_back(it->eta()); l1extra_.tkElectronV2Phi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkElectronV2Chg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkElectronV2Chg.push_back(chargeFromCurvature); l1extra_.tkElectronV2zVtx.push_back(it->trkzVtx()); l1extra_.tkElectronV2TrkIso.push_back(it->trkIsol()); - l1extra_.tkElectronV2HwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkElectronV2EGRefPt.push_back(it->EGRef()->et()); - l1extra_.tkElectronV2EGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkElectronV2EGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkElectronV2HwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkElectronV2EGRefPt.push_back(it->EGRef()->et()); + // l1extra_.tkElectronV2EGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkElectronV2EGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkElectronV2Bx.push_back(0); //it->bx()); l1extra_.tkElectronV2HGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 5); - l1extra_.tkElectronV2PassesLooseTrackID.push_back(quality); - l1extra_.tkElectronV2PassesPhotonID.push_back(quality); + // bool quality = (it->EGRef()->hwQual() == 5); + // l1extra_.tkElectronV2PassesLooseTrackID.push_back(quality); + // l1extra_.tkElectronV2PassesPhotonID.push_back(quality); l1extra_.nTkElectronsV2++; } } @@ -311,15 +311,15 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEM(const edm::HandletrkIsol()); l1extra_.tkPhotonTrkIsoPV.push_back(it->trkIsolPV()); l1extra_.tkPhotonBx.push_back(0); //it->bx()); - l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); - l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); + // l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkPhotonHGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; - l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit - l1extra_.tkPhotonPassesPhotonID.push_back(quality); + // bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; + // l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); + // quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit + // l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; } } @@ -333,14 +333,14 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEM(const edm::HandletrkIsol()); l1extra_.tkPhotonTrkIsoPV.push_back(it->trkIsolPV()); l1extra_.tkPhotonBx.push_back(0); //it->bx()); - l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); - l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); + // l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkPhotonHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 5); - l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); - l1extra_.tkPhotonPassesPhotonID.push_back(quality); + // bool quality = (it->EGRef()->hwQual() == 5); + // l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); + // l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; } } @@ -423,8 +423,8 @@ void L1Analysis::L1AnalysisPhaseII::SetTkMuon(const edm::Handlept()); l1extra_.tkMuonEta.push_back(it->eta()); l1extra_.tkMuonPhi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkMuonChg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkMuonChg.push_back(chargeFromCurvature); l1extra_.tkMuonTrkIso.push_back(it->trkIsol()); if (it->muonDetector() != 3) { l1extra_.tkMuonMuRefPt.push_back(it->muRef()->hwPt() * 0.5); diff --git a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc index 0611575b68ad0..ac224e4808e3f 100644 --- a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc +++ b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc @@ -170,22 +170,22 @@ void L1Analysis::L1AnalysisPhaseIIStep1::SetTkEG(const edm::Handleet()); l1extra_.tkElectronEta.push_back(it->eta()); l1extra_.tkElectronPhi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkElectronChg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkElectronChg.push_back(chargeFromCurvature); l1extra_.tkElectronzVtx.push_back(it->trkzVtx()); l1extra_.tkElectronTrkIso.push_back(it->trkIsol()); l1extra_.tkElectronPfIso.push_back(it->pfIsol()); l1extra_.tkElectronPuppiIso.push_back(it->puppiIsol()); - l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); //Rename this? - l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); //Rename this? + // l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkElectronBx.push_back(0); //it->bx()); l1extra_.tkElectronHGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; // LooseTrackID should be the second bit - l1extra_.tkElectronPassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // LooseTrackID should be the second bit - l1extra_.tkElectronPassesPhotonID.push_back(quality); + // bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; // LooseTrackID should be the second bit + // l1extra_.tkElectronPassesLooseTrackID.push_back(quality); + // quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // LooseTrackID should be the second bit + // l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; } } @@ -198,21 +198,21 @@ void L1Analysis::L1AnalysisPhaseIIStep1::SetTkEG(const edm::Handleet()); l1extra_.tkElectronEta.push_back(it->eta()); l1extra_.tkElectronPhi.push_back(it->phi()); - int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck - l1extra_.tkElectronChg.push_back(chargeFromCurvature); + // int chargeFromCurvature = (it->trackCurvature() > 0) ? 1 : -1; // ThisIsACheck + // l1extra_.tkElectronChg.push_back(chargeFromCurvature); l1extra_.tkElectronzVtx.push_back(it->trkzVtx()); l1extra_.tkElectronTrkIso.push_back(it->trkIsol()); l1extra_.tkElectronPfIso.push_back(it->pfIsol()); l1extra_.tkElectronPuppiIso.push_back(it->puppiIsol()); - l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); //Rename this? - l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkElectronHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkElectronEGRefPt.push_back(it->EGRef()->et()); //Rename this? + // l1extra_.tkElectronEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkElectronEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkElectronBx.push_back(0); //it->bx()); l1extra_.tkElectronHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 3); - l1extra_.tkElectronPassesLooseTrackID.push_back(quality); - l1extra_.tkElectronPassesPhotonID.push_back(quality); + // bool quality = (it->EGRef()->hwQual() == 3); + // l1extra_.tkElectronPassesLooseTrackID.push_back(quality); + // l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; } } @@ -236,15 +236,15 @@ void L1Analysis::L1AnalysisPhaseIIStep1::SetTkEM(const edm::HandlepuppiIsol()); l1extra_.tkPhotonPuppiIsoPV.push_back(it->puppiIsolPV()); l1extra_.tkPhotonBx.push_back(0); //it->bx()); - l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); //REname this? - l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); //REname this? + // l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkPhotonHGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; - l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit - l1extra_.tkPhotonPassesPhotonID.push_back(quality); + // bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; + // l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); + // quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit + // l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; } } @@ -263,14 +263,14 @@ void L1Analysis::L1AnalysisPhaseIIStep1::SetTkEM(const edm::HandlepuppiIsol()); l1extra_.tkPhotonPuppiIsoPV.push_back(it->puppiIsolPV()); l1extra_.tkPhotonBx.push_back(0); //it->bx()); - l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); - l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); //rename this? - l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); - l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); + // l1extra_.tkPhotonHwQual.push_back(it->EGRef()->hwQual()); + // l1extra_.tkPhotonEGRefPt.push_back(it->EGRef()->et()); //rename this? + // l1extra_.tkPhotonEGRefEta.push_back(it->EGRef()->eta()); + // l1extra_.tkPhotonEGRefPhi.push_back(it->EGRef()->phi()); l1extra_.tkPhotonHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 3); - l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); - l1extra_.tkPhotonPassesPhotonID.push_back(quality); + // bool quality = (it->EGRef()->hwQual() == 3); + // l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); + // l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; } }