Skip to content

Commit 93ac253

Browse files
author
ccaillol
committed
clean ESHandle
1 parent a201815 commit 93ac253

File tree

7 files changed

+69
-46
lines changed

7 files changed

+69
-46
lines changed

L1Trigger/L1TTrackMatch/plugins/L1TrackFastJetProducer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "FWCore/Framework/interface/EDProducer.h"
1414
#include "FWCore/Framework/interface/Event.h"
1515
#include "FWCore/Framework/interface/MakerMacros.h"
16-
#include "FWCore/Framework/interface/ESHandle.h"
1716
#include "FWCore/Framework/interface/EventSetup.h"
1817
#include "DataFormats/Common/interface/Handle.h"
1918
#include "FWCore/Utilities/interface/InputTag.h"

L1Trigger/L1TTrackMatch/plugins/L1TrackJetProducer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "FWCore/Framework/interface/Frameworkfwd.h"
1818
#include "FWCore/Framework/interface/stream/EDProducer.h"
1919
#include "FWCore/Framework/interface/Event.h"
20-
#include "FWCore/Framework/interface/ESHandle.h"
2120
#include "FWCore/Framework/interface/EventSetup.h"
2221
#include "FWCore/Framework/interface/MakerMacros.h"
2322
#include "FWCore/ParameterSet/interface/ParameterSet.h"

L1Trigger/L1TTrackMatch/plugins/L1TrackObjectNtupleMaker.cc

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "FWCore/Framework/interface/MakerMacros.h"
1111
#include "FWCore/Framework/interface/EDAnalyzer.h"
1212
#include "FWCore/Framework/interface/Event.h"
13-
#include "FWCore/Framework/interface/ESHandle.h"
1413
#include "FWCore/Framework/interface/EventSetup.h"
1514
#include "FWCore/MessageLogger/interface/MessageLogger.h"
1615
#include "FWCore/Utilities/interface/InputTag.h"
@@ -176,6 +175,9 @@ class L1TrackObjectNtupleMaker : public edm::EDAnalyzer {
176175
edm::EDGetTokenT<l1t::TkJetCollection> TrackJetsToken_;
177176
edm::EDGetTokenT<l1t::TkJetCollection> TrackJetsExtendedToken_;
178177

178+
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
179+
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
180+
179181
//-----------------------------------------------------------------------------------------------
180182
// tree & branches for mini-ntuple
181183

@@ -452,6 +454,9 @@ L1TrackObjectNtupleMaker::L1TrackObjectNtupleMaker(edm::ParameterSet const& iCon
452454
GenJetToken_ = consumes<std::vector<reco::GenJet> >(GenJetInputTag);
453455
GenParticleToken_ = consumes<std::vector<reco::GenParticle> >(GenParticleInputTag);
454456
L1VertexToken_ = consumes<l1t::TkPrimaryVertexCollection>(RecoVertexInputTag);
457+
458+
tTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""));
459+
tGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>(edm::ESInputTag("", ""));
455460
}
456461

457462
/////////////
@@ -1093,7 +1098,10 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
10931098

10941099
// -----------------------------------------------------------------------------------------------
10951100
// more for TTStubs
1096-
edm::ESHandle<TrackerGeometry> geometryHandle;
1101+
const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
1102+
const TrackerGeometry& tGeom = iSetup.getData(tGeomToken_);
1103+
1104+
/*edm::ESHandle<TrackerGeometry> geometryHandle;
10971105
iSetup.get<TrackerDigiGeometryRecord>().get(geometryHandle);
10981106
10991107
edm::ESHandle<TrackerTopology> tTopoHandle;
@@ -1103,7 +1111,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
11031111
iSetup.get<TrackerDigiGeometryRecord>().get(tGeomHandle);
11041112
11051113
const TrackerTopology* const tTopo = tTopoHandle.product();
1106-
const TrackerGeometry* const theTrackerGeom = tGeomHandle.product();
1114+
const TrackerGeometry* const theTrackerGeom = tGeomHandle.product();*/
11071115

11081116
//Gen particles
11091117
edm::Handle<std::vector<reco::GenParticle> > GenParticleHandle;
@@ -1186,20 +1194,20 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
11861194
// loop over L1 stubs
11871195
// ----------------------------------------------------------------------------------------------
11881196
if (SaveStubs) {
1189-
for (auto gd = theTrackerGeom->dets().begin(); gd != theTrackerGeom->dets().end(); gd++) {
1197+
for (auto gd = tGeom.dets().begin(); gd != tGeom.dets().end(); gd++) {
11901198
DetId detid = (*gd)->geographicalId();
11911199
if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID)
11921200
continue;
1193-
if (!tTopo->isLower(detid))
1194-
continue; // loop on the stacks: choose the lower arbitrarily
1195-
DetId stackDetid = tTopo->stack(detid); // Stub module detid
1201+
if (!tTopo.isLower(detid))
1202+
continue; // loop on the stacks: choose the lower arbitrarily
1203+
DetId stackDetid = tTopo.stack(detid); // Stub module detid
11961204

11971205
if (TTStubHandle->find(stackDetid) == TTStubHandle->end())
11981206
continue;
11991207

12001208
// Get the DetSets of the Clusters
12011209
edmNew::DetSet<TTStub<Ref_Phase2TrackerDigi_> > stubs = (*TTStubHandle)[stackDetid];
1202-
const GeomDetUnit* det0 = theTrackerGeom->idToDetUnit(detid);
1210+
const GeomDetUnit* det0 = tGeom.idToDetUnit(detid);
12031211
const auto* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(det0);
12041212
const PixelTopology* topol = dynamic_cast<const PixelTopology*>(&(theGeomDet->specificTopology()));
12051213

@@ -1212,10 +1220,10 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
12121220
int layer = -999999;
12131221
if (detid.subdetId() == StripSubdetector::TOB) {
12141222
isBarrel = 1;
1215-
layer = static_cast<int>(tTopo->layer(detid));
1223+
layer = static_cast<int>(tTopo.layer(detid));
12161224
} else if (detid.subdetId() == StripSubdetector::TID) {
12171225
isBarrel = 0;
1218-
layer = static_cast<int>(tTopo->layer(detid));
1226+
layer = static_cast<int>(tTopo.layer(detid));
12191227
} else {
12201228
edm::LogVerbatim("Tracklet") << "WARNING -- neither TOB or TID stub, shouldn't happen...";
12211229
layer = -1;
@@ -1330,9 +1338,9 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
13301338
// loop over stubs
13311339
for (int is = 0; is < tmp_trk_nstub; is++) {
13321340
//detID of stub
1333-
DetId detIdStub = theTrackerGeom->idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
1341+
DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
13341342
MeasurementPoint coords = stubRefs.at(is)->clusterRef(0)->findAverageLocalCoordinatesCentered();
1335-
const GeomDet* theGeomDet = theTrackerGeom->idToDet(detIdStub);
1343+
const GeomDet* theGeomDet = tGeom.idToDet(detIdStub);
13361344
Global3DPoint posStub = theGeomDet->surface().toGlobal(theGeomDet->topology().localPosition(coords));
13371345

13381346
double x = posStub.x();
@@ -1341,13 +1349,13 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
13411349

13421350
int layer = -999999;
13431351
if (detIdStub.subdetId() == StripSubdetector::TOB) {
1344-
layer = static_cast<int>(tTopo->layer(detIdStub));
1352+
layer = static_cast<int>(tTopo.layer(detIdStub));
13451353
if (DebugMode)
13461354
edm::LogVerbatim("Tracklet")
13471355
<< " stub in layer " << layer << " at position x y z = " << x << " " << y << " " << z;
13481356
tmp_trk_lhits += pow(10, layer - 1);
13491357
} else if (detIdStub.subdetId() == StripSubdetector::TID) {
1350-
layer = static_cast<int>(tTopo->layer(detIdStub));
1358+
layer = static_cast<int>(tTopo.layer(detIdStub));
13511359
if (DebugMode)
13521360
edm::LogVerbatim("Tracklet")
13531361
<< " stub in disk " << layer << " at position x y z = " << x << " " << y << " " << z;
@@ -1509,9 +1517,9 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
15091517
// loop over stubs
15101518
for (int is = 0; is < tmp_trk_nstub; is++) {
15111519
//detID of stub
1512-
DetId detIdStub = theTrackerGeom->idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
1520+
DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
15131521
MeasurementPoint coords = stubRefs.at(is)->clusterRef(0)->findAverageLocalCoordinatesCentered();
1514-
const GeomDet* theGeomDet = theTrackerGeom->idToDet(detIdStub);
1522+
const GeomDet* theGeomDet = tGeom.idToDet(detIdStub);
15151523
Global3DPoint posStub = theGeomDet->surface().toGlobal(theGeomDet->topology().localPosition(coords));
15161524

15171525
double x = posStub.x();
@@ -1520,13 +1528,13 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
15201528

15211529
int layer = -999999;
15221530
if (detIdStub.subdetId() == StripSubdetector::TOB) {
1523-
layer = static_cast<int>(tTopo->layer(detIdStub));
1531+
layer = static_cast<int>(tTopo.layer(detIdStub));
15241532
if (DebugMode)
15251533
edm::LogVerbatim("Tracklet")
15261534
<< " stub in layer " << layer << " at position x y z = " << x << " " << y << " " << z;
15271535
tmp_trk_lhits += pow(10, layer - 1);
15281536
} else if (detIdStub.subdetId() == StripSubdetector::TID) {
1529-
layer = static_cast<int>(tTopo->layer(detIdStub));
1537+
layer = static_cast<int>(tTopo.layer(detIdStub));
15301538
if (DebugMode)
15311539
edm::LogVerbatim("Tracklet")
15321540
<< " stub in disk " << layer << " at position x y z = " << x << " " << y << " " << z;
@@ -1738,9 +1746,9 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
17381746

17391747
int layer = -1;
17401748
if (detid.subdetId() == StripSubdetector::TOB) {
1741-
layer = static_cast<int>(tTopo->layer(detid)) - 1; //fill in array as entries 0-5
1749+
layer = static_cast<int>(tTopo.layer(detid)) - 1; //fill in array as entries 0-5
17421750
} else if (detid.subdetId() == StripSubdetector::TID) {
1743-
layer = static_cast<int>(tTopo->layer(detid)) + 5; //fill in array as entries 6-10
1751+
layer = static_cast<int>(tTopo.layer(detid)) + 5; //fill in array as entries 6-10
17441752
}
17451753

17461754
//treat genuine stubs separately (==2 is genuine, ==1 is not)
@@ -1932,13 +1940,13 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
19321940
int tmp_nstub = stubRefs.size();
19331941

19341942
for (int is = 0; is < tmp_nstub; is++) {
1935-
DetId detIdStub = theTrackerGeom->idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
1943+
DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
19361944
int layer = -999999;
19371945
if (detIdStub.subdetId() == StripSubdetector::TOB) {
1938-
layer = static_cast<int>(tTopo->layer(detIdStub));
1946+
layer = static_cast<int>(tTopo.layer(detIdStub));
19391947
tmp_matchtrk_lhits += pow(10, layer - 1);
19401948
} else if (detIdStub.subdetId() == StripSubdetector::TID) {
1941-
layer = static_cast<int>(tTopo->layer(detIdStub));
1949+
layer = static_cast<int>(tTopo.layer(detIdStub));
19421950
tmp_matchtrk_dhits += pow(10, layer - 1);
19431951
}
19441952
}
@@ -2102,13 +2110,13 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
21022110
int tmp_nstub = stubRefs.size();
21032111

21042112
for (int is = 0; is < tmp_nstub; is++) {
2105-
DetId detIdStub = theTrackerGeom->idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
2113+
DetId detIdStub = tGeom.idToDet((stubRefs.at(is)->clusterRef(0))->getDetId())->geographicalId();
21062114
int layer = -999999;
21072115
if (detIdStub.subdetId() == StripSubdetector::TOB) {
2108-
layer = static_cast<int>(tTopo->layer(detIdStub));
2116+
layer = static_cast<int>(tTopo.layer(detIdStub));
21092117
tmp_matchtrkExt_lhits += pow(10, layer - 1);
21102118
} else if (detIdStub.subdetId() == StripSubdetector::TID) {
2111-
layer = static_cast<int>(tTopo->layer(detIdStub));
2119+
layer = static_cast<int>(tTopo.layer(detIdStub));
21122120
tmp_matchtrkExt_dhits += pow(10, layer - 1);
21132121
}
21142122
}

L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissProducer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "FWCore/Framework/interface/EDProducer.h"
1111
#include "FWCore/Framework/interface/Event.h"
1212
#include "FWCore/Framework/interface/MakerMacros.h"
13-
#include "FWCore/Framework/interface/ESHandle.h"
1413
#include "FWCore/Framework/interface/EventSetup.h"
1514
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1615
#include "DataFormats/Math/interface/LorentzVector.h"

L1Trigger/VertexFinder/interface/InputData.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#ifndef __L1Trigger_VertexFinder_InputData_h__
22
#define __L1Trigger_VertexFinder_InputData_h__
33

4+
#include "FWCore/Framework/interface/EDProducer.h"
5+
#include "FWCore/Framework/interface/Event.h"
6+
#include "FWCore/Framework/interface/MakerMacros.h"
7+
#include "FWCore/Framework/interface/EventSetup.h"
8+
#include "FWCore/Utilities/interface/ESGetToken.h"
49
#include "FWCore/Framework/interface/EDAnalyzer.h"
510
#include "FWCore/Framework/interface/Frameworkfwd.h"
611
#include "FWCore/MessageLogger/interface/MessageLogger.h"
@@ -10,6 +15,9 @@
1015
#include "L1Trigger/VertexFinder/interface/Vertex.h"
1116
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
1217
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
18+
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
19+
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
20+
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
1321

1422
#include <vector>
1523

@@ -35,7 +43,9 @@ namespace l1tVertexFinder {
3543
const edm::EDGetTokenT<edm::View<reco::GenParticle>> genParticlesToken,
3644
const edm::EDGetTokenT<edm::View<TrackingParticle>> tpToken,
3745
const edm::EDGetTokenT<edm::ValueMap<l1tVertexFinder::TP>> tpValueMapToken,
38-
const edm::EDGetTokenT<DetSetVec> stubToken);
46+
const edm::EDGetTokenT<DetSetVec> stubToken,
47+
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken,
48+
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken);
3949
~InputData();
4050

4151
// Sort Tracking Particles by vertex z position

L1Trigger/VertexFinder/plugins/InputDataProducer.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class InputDataProducer : public edm::global::EDProducer<> {
6464
const edm::EDGetTokenT<edm::ValueMap<l1tVertexFinder::TP>> tpValueMapToken_;
6565
const edm::EDGetTokenT<DetSetVec> stubToken_;
6666
const edm::EDGetTokenT<edm::ValueMap<l1tVertexFinder::Stub>> stubValueMapToken_;
67+
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
68+
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
6769
};
6870

6971
//
@@ -78,7 +80,9 @@ InputDataProducer::InputDataProducer(const edm::ParameterSet& iConfig)
7880
tpToken_(consumes<edm::View<TrackingParticle>>(iConfig.getParameter<edm::InputTag>("tpInputTag"))),
7981
tpValueMapToken_(
8082
consumes<edm::ValueMap<l1tVertexFinder::TP>>(iConfig.getParameter<edm::InputTag>("tpValueMapInputTag"))),
81-
stubToken_(consumes<DetSetVec>(iConfig.getParameter<edm::InputTag>("stubInputTag"))) {
83+
stubToken_(consumes<DetSetVec>(iConfig.getParameter<edm::InputTag>("stubInputTag"))),
84+
tTopoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""))),
85+
tGeomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>(edm::ESInputTag("", ""))) {
8286
// Define EDM output to be written to file (if required)
8387
produces<l1tVertexFinder::InputData>(outputCollectionName_);
8488

@@ -93,8 +97,16 @@ InputDataProducer::~InputDataProducer() {}
9397

9498
// ------------ method called to produce the data ------------
9599
void InputDataProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
96-
std::unique_ptr<l1tVertexFinder::InputData> product = std::make_unique<l1tVertexFinder::InputData>(
97-
iEvent, iSetup, settings_, hepMCToken_, genParticlesToken_, tpToken_, tpValueMapToken_, stubToken_);
100+
std::unique_ptr<l1tVertexFinder::InputData> product = std::make_unique<l1tVertexFinder::InputData>(iEvent,
101+
iSetup,
102+
settings_,
103+
hepMCToken_,
104+
genParticlesToken_,
105+
tpToken_,
106+
tpValueMapToken_,
107+
stubToken_,
108+
tTopoToken_,
109+
tGeomToken_);
98110

99111
iEvent.put(std::move(product), outputCollectionName_);
100112
}

L1Trigger/VertexFinder/src/InputData.cc

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
2-
#include "FWCore/Framework/interface/ESHandle.h"
32
#include "FWCore/Framework/interface/Event.h"
43
#include "FWCore/Framework/interface/EventSetup.h"
54
#include "FWCore/Utilities/interface/InputTag.h"
@@ -28,15 +27,12 @@ namespace l1tVertexFinder {
2827
const edm::EDGetTokenT<edm::View<reco::GenParticle>> genParticlesToken,
2928
const edm::EDGetTokenT<edm::View<TrackingParticle>> tpToken,
3029
const edm::EDGetTokenT<edm::ValueMap<l1tVertexFinder::TP>> tpValueMapToken,
31-
const edm::EDGetTokenT<DetSetVec> stubToken) {
30+
const edm::EDGetTokenT<DetSetVec> stubToken,
31+
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken,
32+
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken) {
3233
// Get the tracker geometry info needed to unpack the stub info.
33-
edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
34-
iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle);
35-
const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product();
36-
37-
edm::ESHandle<TrackerTopology> trackerTopologyHandle;
38-
iSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle);
39-
const TrackerTopology* trackerTopology = trackerTopologyHandle.product();
34+
const TrackerTopology& tTopo = iSetup.getData(tTopoToken);
35+
const TrackerGeometry& tGeom = iSetup.getData(tGeomToken);
4036

4137
// Get stub info, by looping over modules and then stubs inside each module.
4238
// Also get the association map from stubs to tracking particles.
@@ -51,13 +47,13 @@ namespace l1tVertexFinder {
5147
}
5248

5349
std::map<DetId, DetId> stubGeoDetIdMap;
54-
for (auto gd = trackerGeometry->dets().begin(); gd != trackerGeometry->dets().end(); gd++) {
50+
for (auto gd = tGeom.dets().begin(); gd != tGeom.dets().end(); gd++) {
5551
DetId detid = (*gd)->geographicalId();
5652
if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID)
5753
continue; // only run on OT
58-
if (!trackerTopology->isLower(detid))
59-
continue; // loop on the stacks: choose the lower arbitrarily
60-
DetId stackDetid = trackerTopology->stack(detid); // Stub module detid
54+
if (!tTopo.isLower(detid))
55+
continue; // loop on the stacks: choose the lower arbitrarily
56+
DetId stackDetid = tTopo.stack(detid); // Stub module detid
6157

6258
if (lStubDetIds.count(stackDetid) > 0) {
6359
assert(stubGeoDetIdMap.count(stackDetid) == 0);

0 commit comments

Comments
 (0)