From ef80134294fce48bff55af688596a00c31027ec5 Mon Sep 17 00:00:00 2001 From: Georgios Karathanasis Date: Wed, 1 Jun 2022 16:59:31 +0200 Subject: [PATCH] changing to ES consumes for topology (cherry picked from commit 5c0a4a56c24cab2edc51eee6d8e80d9d3f72688f) --- .../plugins/L1TrackJetProducer.cc | 26 ++++++++++--------- .../plugins/L1TrackJetProducer.h | 16 ++++++------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.cc b/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.cc index b0c2bba6fdeff..9a46fe3704bd3 100644 --- a/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.cc +++ b/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.cc @@ -63,6 +63,7 @@ class L1TrackJetProducer : public stream::EDProducer<> { // ----------member data --------------------------- + edm::ESGetToken tTopoToken_; const EDGetTokenT>> trackToken_; const edm::EDGetTokenT> PVtxToken_; vector> L1TrkPtrs_; @@ -99,7 +100,8 @@ class L1TrackJetProducer : public stream::EDProducer<> { }; L1TrackJetProducer::L1TrackJetProducer(const ParameterSet &iConfig) - : trackToken_(consumes>>(iConfig.getParameter("L1TrackInputTag"))), + : tTopoToken_(esConsumes(edm::ESInputTag("", ""))), + trackToken_(consumes>>(iConfig.getParameter("L1TrackInputTag"))), PVtxToken_(consumes>(iConfig.getParameter("L1PVertexCollection"))) { trkZMax_ = (float)iConfig.getParameter("trk_zMax"); trkPtMax_ = (float)iConfig.getParameter("trk_ptMax"); @@ -144,11 +146,7 @@ void L1TrackJetProducer::produce(Event &iEvent, const EventSetup &iSetup) { unique_ptr L1L1TrackJetProducer(new TkJetCollection); // Read inputs - ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - ESHandle tGeomHandle; - iSetup.get().get(tGeomHandle); - const TrackerTopology *const tTopo = tTopoHandle.product(); + const TrackerTopology& tTopo = iSetup.getData(tTopoToken_); edm::Handle>> TTTrackHandle; iEvent.getByToken(trackToken_, TTTrackHandle); @@ -172,8 +170,8 @@ void L1TrackJetProducer::produce(Event &iEvent, const EventSetup &iSetup) { for (int istub = 0; istub < trk_nstubs; istub++) { // loop over the stubs DetId detId(trkPtr->getStubRefs().at(istub)->getDetId()); if (detId.det() == DetId::Detector::Tracker) { - if ((detId.subdetId() == StripSubdetector::TOB && tTopo->tobLayer(detId) <= 3) || - (detId.subdetId() == StripSubdetector::TID && tTopo->tidRing(detId) <= 9)) + if ((detId.subdetId() == StripSubdetector::TOB && tTopo.tobLayer(detId) <= 3) || + (detId.subdetId() == StripSubdetector::TID && tTopo.tidRing(detId) <= 9)) trk_nPS++; } } @@ -356,14 +354,18 @@ void L1TrackJetProducer::endStream() {} bool L1TrackJetProducer::trackQualityCuts(int trk_nstub, float trk_chi2, float trk_bendchi2) { bool PassQuality = false; if (!displaced_) { - if (trk_nstub == 4 && trk_bendchi2 < nStubs4PromptBend_ && trk_chi2 < nStubs4PromptChi2_) // 4 stubs are the lowest track quality and have different cuts + if (trk_nstub == 4 && trk_bendchi2 < nStubs4PromptBend_ && + trk_chi2 < nStubs4PromptChi2_) // 4 stubs are the lowest track quality and have different cuts PassQuality = true; - if (trk_nstub > 4 && trk_bendchi2 < nStubs5PromptBend_ && trk_chi2 < nStubs5PromptChi2_) // above 4 stubs diffent selection imposed (genrally looser) + if (trk_nstub > 4 && trk_bendchi2 < nStubs5PromptBend_ && + trk_chi2 < nStubs5PromptChi2_) // above 4 stubs diffent selection imposed (genrally looser) PassQuality = true; } else { - if (trk_nstub == 4 && trk_bendchi2 < nStubs4DisplacedBend_ && trk_chi2 < nStubs4DisplacedChi2_) // 4 stubs are the lowest track quality and have different cuts + if (trk_nstub == 4 && trk_bendchi2 < nStubs4DisplacedBend_ && + trk_chi2 < nStubs4DisplacedChi2_) // 4 stubs are the lowest track quality and have different cuts PassQuality = true; - if (trk_nstub > 4 && trk_bendchi2 < nStubs5DisplacedBend_ && trk_chi2 < nStubs5DisplacedChi2_) // above 4 stubs diffent selection imposed (genrally looser) + if (trk_nstub > 4 && trk_bendchi2 < nStubs5DisplacedBend_ && + trk_chi2 < nStubs5DisplacedChi2_) // above 4 stubs diffent selection imposed (genrally looser) PassQuality = true; } return PassQuality; diff --git a/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.h b/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.h index a70e96c443c94..01b2b505944e8 100644 --- a/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.h +++ b/L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.h @@ -29,7 +29,7 @@ struct MaxZBin { float ht; //sum of all cluster pTs--only the zbin with the maximum ht is stored }; -std::vector L1_clustering(EtaPhiBin *phislice, int etaBins_, float etaStep_) { +inline std::vector L1_clustering(EtaPhiBin *phislice, int etaBins_, float etaStep_) { std::vector clusters; // Find eta-phibin with maxpT, make center of cluster, add neighbors if not already used int nclust = 0; @@ -117,7 +117,7 @@ std::vector L1_clustering(EtaPhiBin *phislice, int etaBins_, float et return clusters; } -void Fill_L2Cluster(EtaPhiBin &bin, float pt, int ntrk, int ndtrk, std::vector trkidx) { +inline void Fill_L2Cluster(EtaPhiBin &bin, float pt, int ntrk, int ndtrk, std::vector trkidx) { bin.pTtot += pt; bin.numtracks += ntrk; bin.numtdtrks += ndtrk; @@ -125,7 +125,7 @@ void Fill_L2Cluster(EtaPhiBin &bin, float pt, int ntrk, int ndtrk, std::vector= M_PI) x -= 2 * M_PI; @@ -134,13 +134,13 @@ float DPhi(float phi1, float phi2) { return x; } -std::vector L2_clustering(std::vector> &L1clusters, - int phiBins_, - float phiStep_, - float etaStep_) { +inline std::vector L2_clustering(std::vector> &L1clusters, + int phiBins_, + float phiStep_, + float etaStep_) { std::vector clusters; for (int phibin = 0; phibin < phiBins_; ++phibin) { //Find eta-phibin with highest pT - if (L1clusters[phibin].size() == 0) + if (L1clusters[phibin].empty()) continue; // sort L1 clusters max -> min