From b3d5232ced9b730a079c7dde275d8d6aa1dd15f5 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 5 Oct 2023 15:41:31 +0200 Subject: [PATCH] Remove Ref to Standalone object in favor of generic pointer to L1Candidate --- .../L1TCorrelator/interface/TkElectron.h | 7 +- DataFormats/L1TCorrelator/interface/TkEm.h | 21 +--- DataFormats/L1TCorrelator/src/TkElectron.cc | 12 +- DataFormats/L1TCorrelator/src/TkEm.cc | 10 +- DataFormats/L1TCorrelator/src/classes_def.xml | 10 +- .../interface/layer1_emulator.h | 16 ++- .../L1TParticleFlow/src/layer1_emulator.cpp | 4 +- L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc | 66 +++++------ .../L1TNtuples/src/L1AnalysisPhaseIIStep1.cc | 44 ++++---- .../plugins/L1TCorrelatorLayer1Producer.cc | 57 +--------- .../plugins/L1TCtL2EgProducer.cc | 106 +++++++----------- .../plugins/L1TEGMultiMerger.cc | 45 ++------ .../src/egamma/pftkegalgo_ref.cpp | 9 +- 13 files changed, 156 insertions(+), 251 deletions(-) diff --git a/DataFormats/L1TCorrelator/interface/TkElectron.h b/DataFormats/L1TCorrelator/interface/TkElectron.h index 8d006a65809e4..3afc327655563 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,10 +28,12 @@ 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_; } @@ -42,6 +43,7 @@ namespace l1t { 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; } @@ -56,6 +58,7 @@ namespace l1t { private: edm::Ptr trkPtr_; float trkzVtx_; + // FIXME: do we really need this? double trackCurvature_; float idScore_; }; 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..1b5c85f514eee 100644 --- a/DataFormats/L1TCorrelator/src/TkElectron.cc +++ b/DataFormats/L1TCorrelator/src/TkElectron.cc @@ -5,20 +5,22 @@ // #include "DataFormats/L1TCorrelator/interface/TkElectron.h" +// FIXME: can remove +#include "DataFormats/Common/interface/RefToPtr.h" 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..49474b8f81a3f 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_)); + ]]> + + @@ -46,7 +52,7 @@ - + diff --git a/DataFormats/L1TParticleFlow/interface/layer1_emulator.h b/DataFormats/L1TParticleFlow/interface/layer1_emulator.h index f3a1b2d90cea5..50ebbd9893afe 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(); } @@ -193,15 +195,17 @@ 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; + + // 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/L1TNtuples/src/L1AnalysisPhaseII.cc b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc index 18a4d89de1873..147ef36cc31ec 100644 --- a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc +++ b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseII.cc @@ -206,15 +206,15 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEG(const edm::HandletrkzVtx()); 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->egCaloPtr()->hwQual()); + l1extra_.tkElectronEGRefPt.push_back(it->egCaloPtr()->et()); + l1extra_.tkElectronEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkElectronEGRefPhi.push_back(it->egCaloPtr()->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 + bool quality = ((it->egCaloPtr()->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 + quality = ((it->egCaloPtr()->hwQual() >> 2) & 1) > 0; // LooseTrackID should be the second bit l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; } @@ -231,13 +231,13 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEG(const edm::HandletrkzVtx()); 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->egCaloPtr()->hwQual()); + l1extra_.tkElectronEGRefPt.push_back(it->egCaloPtr()->et()); + l1extra_.tkElectronEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkElectronEGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkElectronBx.push_back(0); //it->bx()); l1extra_.tkElectronHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 5); + bool quality = (it->egCaloPtr()->hwQual() == 5); l1extra_.tkElectronPassesLooseTrackID.push_back(quality); l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; @@ -259,15 +259,15 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEGV2(const edm::HandletrkzVtx()); 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->egCaloPtr()->hwQual()); + l1extra_.tkElectronV2EGRefPt.push_back(it->egCaloPtr()->et()); + l1extra_.tkElectronV2EGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkElectronV2EGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkElectronV2Bx.push_back(0); //it->bx()); l1extra_.tkElectronV2HGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; + bool quality = ((it->egCaloPtr()->hwQual() >> 1) & 1) > 0; l1extra_.tkElectronV2PassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; + quality = ((it->egCaloPtr()->hwQual() >> 2) & 1) > 0; l1extra_.tkElectronV2PassesPhotonID.push_back(quality); l1extra_.nTkElectronsV2++; } @@ -284,13 +284,13 @@ void L1Analysis::L1AnalysisPhaseII::SetTkEGV2(const edm::HandletrkzVtx()); 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->egCaloPtr()->hwQual()); + l1extra_.tkElectronV2EGRefPt.push_back(it->egCaloPtr()->et()); + l1extra_.tkElectronV2EGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkElectronV2EGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkElectronV2Bx.push_back(0); //it->bx()); l1extra_.tkElectronV2HGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 5); + bool quality = (it->egCaloPtr()->hwQual() == 5); l1extra_.tkElectronV2PassesLooseTrackID.push_back(quality); l1extra_.tkElectronV2PassesPhotonID.push_back(quality); l1extra_.nTkElectronsV2++; @@ -311,14 +311,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->egCaloPtr()->hwQual()); + l1extra_.tkPhotonEGRefPt.push_back(it->egCaloPtr()->et()); + l1extra_.tkPhotonEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkPhotonEGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkPhotonHGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; + bool quality = ((it->egCaloPtr()->hwQual() >> 1) & 1) > 0; l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit + quality = ((it->egCaloPtr()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; } @@ -333,12 +333,12 @@ 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->egCaloPtr()->hwQual()); + l1extra_.tkPhotonEGRefPt.push_back(it->egCaloPtr()->et()); + l1extra_.tkPhotonEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkPhotonEGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkPhotonHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 5); + bool quality = (it->egCaloPtr()->hwQual() == 5); l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; diff --git a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc index 0611575b68ad0..ba5fe648d3d43 100644 --- a/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc +++ b/L1Trigger/L1TNtuples/src/L1AnalysisPhaseIIStep1.cc @@ -176,15 +176,15 @@ void L1Analysis::L1AnalysisPhaseIIStep1::SetTkEG(const edm::HandletrkIsol()); 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->egCaloPtr()->hwQual()); + l1extra_.tkElectronEGRefPt.push_back(it->egCaloPtr()->et()); //Rename this? + l1extra_.tkElectronEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkElectronEGRefPhi.push_back(it->egCaloPtr()->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 + bool quality = ((it->egCaloPtr()->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 + quality = ((it->egCaloPtr()->hwQual() >> 2) & 1) > 0; // LooseTrackID should be the second bit l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; } @@ -204,13 +204,13 @@ void L1Analysis::L1AnalysisPhaseIIStep1::SetTkEG(const edm::HandletrkIsol()); 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->egCaloPtr()->hwQual()); + l1extra_.tkElectronEGRefPt.push_back(it->egCaloPtr()->et()); //Rename this? + l1extra_.tkElectronEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkElectronEGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkElectronBx.push_back(0); //it->bx()); l1extra_.tkElectronHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 3); + bool quality = (it->egCaloPtr()->hwQual() == 3); l1extra_.tkElectronPassesLooseTrackID.push_back(quality); l1extra_.tkElectronPassesPhotonID.push_back(quality); l1extra_.nTkElectrons++; @@ -236,14 +236,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->egCaloPtr()->hwQual()); + l1extra_.tkPhotonEGRefPt.push_back(it->egCaloPtr()->et()); //REname this? + l1extra_.tkPhotonEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkPhotonEGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkPhotonHGC.push_back(0); - bool quality = ((it->EGRef()->hwQual() >> 1) & 1) > 0; + bool quality = ((it->egCaloPtr()->hwQual() >> 1) & 1) > 0; l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); - quality = ((it->EGRef()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit + quality = ((it->egCaloPtr()->hwQual() >> 2) & 1) > 0; // Photon Id should be the third bit l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; } @@ -263,12 +263,12 @@ 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->egCaloPtr()->hwQual()); + l1extra_.tkPhotonEGRefPt.push_back(it->egCaloPtr()->et()); //rename this? + l1extra_.tkPhotonEGRefEta.push_back(it->egCaloPtr()->eta()); + l1extra_.tkPhotonEGRefPhi.push_back(it->egCaloPtr()->phi()); l1extra_.tkPhotonHGC.push_back(1); - bool quality = (it->EGRef()->hwQual() == 3); + bool quality = (it->egCaloPtr()->hwQual() == 3); l1extra_.tkPhotonPassesLooseTrackID.push_back(quality); l1extra_.tkPhotonPassesPhotonID.push_back(quality); l1extra_.nTkPhotons++; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 9dfa78e9f294e..512226777371d 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 047b5a0b6feb8..2c19c9d5a2ee3 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; } }