Skip to content

Commit 4c454ef

Browse files
author
Sunanda
committed
Use ESGetToken in codes of Geometry/Calo... analyzers
1 parent 97ed514 commit 4c454ef

File tree

11 files changed

+56
-89
lines changed

11 files changed

+56
-89
lines changed

Geometry/CaloEventSetup/plugins/CaloGeometryBuilder.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ CaloGeometryBuilder::CaloGeometryBuilder(const edm::ParameterSet& iConfig) {
9292
// ------------ method called to produce the data ------------
9393

9494
CaloGeometryBuilder::ReturnType CaloGeometryBuilder::produceAligned(const CaloGeometryRecord& iRecord) {
95-
edm::ESHandle<CaloSubdetectorGeometry> pG;
96-
9795
ReturnType pCalo = std::make_unique<CaloGeometry>();
9896

9997
// look for HCAL parts

Geometry/CaloEventSetup/plugins/CaloGeometryBuilder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
// user include files
2323
#include "FWCore/Framework/interface/ESProducer.h"
2424

25-
#include "FWCore/Framework/interface/ESHandle.h"
2625
#include "FWCore/ParameterSet/interface/ParameterSet.h"
2726
#include "FWCore/Utilities/interface/ESGetToken.h"
2827
#include "Geometry/Records/interface/IdealGeometryRecord.h"

Geometry/CaloGeometry/doc/CaloGeometry.doc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,22 @@
2929
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
3030
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
3131
#include "Geometry/Records/interface/IdealGeometryRecord.h"
32-
#include "FWCore/Framework/interface/ESHandle.h"
32+
33+
...
34+
35+
private:
36+
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tokGeom_;
37+
38+
...
39+
40+
...(const edm::ParameterSet&)
41+
: tokGeom_{esConsumes<CaloGeometry, CaloGeometryRecord>()},
3342

3443
...
3544

3645
void ...(edm::Event& e, const edm::EventSetup& es) {
37-
edm::ESHandle<CaloGeometry> pGeo;
38-
c.get<IdealGeometryRecord>().get(pGeo);
3946

40-
const CaloGeometry* geom=pGeo.product();
47+
const CaloGeometry* geom=es.getData(tokGeom_);
4148
@endcode
4249

4350

@@ -46,10 +53,12 @@ void ...(edm::Event& e, const edm::EventSetup& es) {
4653
- CaloGeometry
4754
- CaloSubdetectorGeometry
4855
- CaloCellGeometry
56+
- FlatHexagon
57+
- FlatTrd
4958
- IdealObliquePrism
5059
- IdealZPrism
51-
- TruncatedPyramid
5260
- PreshowerStrip
61+
- TruncatedPyramid
5362

5463

5564

Geometry/CaloTopology/interface/EcalEndcapTopology.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
66
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
77
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
8-
#include "FWCore/Framework/interface/ESHandle.h"
98
#include <utility>
109
#include <vector>
1110
#include <iostream>

Geometry/CaloTopology/interface/EcalPreshowerTopology.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "DataFormats/EcalDetId/interface/ESDetId.h"
55
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
66
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
7-
#include "FWCore/Framework/interface/ESHandle.h"
87
#include <utility>
98
#include <vector>
109
#include <iostream>

Geometry/CaloTopology/test/CaloTowerMapTester.cc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
77
#include "FWCore/Framework/interface/Event.h"
88
#include "FWCore/Framework/interface/EventSetup.h"
9-
#include "FWCore/Framework/interface/ESHandle.h"
109
#include "FWCore/Framework/interface/MakerMacros.h"
1110

1211
#include "FWCore/ParameterSet/interface/ParameterSet.h"
@@ -39,9 +38,11 @@ class CaloTowerMapTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
3938

4039
private:
4140
// ----------member data ---------------------------
41+
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tokGeom_;
42+
const edm::ESGetToken<CaloTowerConstituentsMap, CaloGeometryRecord> tokMap_;
4243
};
4344

44-
CaloTowerMapTester::CaloTowerMapTester(const edm::ParameterSet&) {}
45+
CaloTowerMapTester::CaloTowerMapTester(const edm::ParameterSet&) : tokGeom_{esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{})}, tokMap_{esConsumes<CaloTowerConstituentsMap, CaloGeometryRecord>(edm::ESInputTag{})} {}
4546

4647
void CaloTowerMapTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4748
edm::ParameterSetDescription desc;
@@ -50,35 +51,29 @@ void CaloTowerMapTester::fillDescriptions(edm::ConfigurationDescriptions& descri
5051
}
5152

5253
void CaloTowerMapTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
53-
edm::ESHandle<CaloGeometry> pG;
54-
iSetup.get<CaloGeometryRecord>().get(pG);
55-
edm::ESHandle<CaloTowerConstituentsMap> ct;
56-
iSetup.get<CaloGeometryRecord>().get(ct);
57-
if (pG.isValid() && ct.isValid())
58-
doTest(pG.product(), ct.product());
59-
else
60-
std::cout << "CaloGeometry in EventSetup " << pG.isValid() << " and CaloTowerConstituentsMap " << ct.isValid()
61-
<< std::endl;
54+
const CaloGeometry* geo = &iSetup.getData(tokGeom_);
55+
const CaloTowerConstituentsMap* ctmap = &iSetup.getData(tokMap_);
56+
doTest(geo, ctmap);
6257
}
6358

6459
void CaloTowerMapTester::doTest(const CaloGeometry* geo, const CaloTowerConstituentsMap* ctmap) {
65-
HcalGeometry* hgeo = (HcalGeometry*)(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
60+
const HcalGeometry* hgeo = static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
6661
const std::vector<DetId>& dets = hgeo->getValidDetIds(DetId::Hcal, 0);
6762

6863
for (const auto& id : dets) {
6964
CaloTowerDetId tower = ctmap->towerOf(id);
7065
std::vector<DetId> ids = ctmap->constituentsOf(tower);
71-
std::cout << HcalDetId(id) << " belongs to " << tower << " which has " << ids.size() << " constituents\n";
66+
std::cout << static_cast<HcalDetId>(id) << " belongs to " << tower << " which has " << ids.size() << " constituents\n";
7267
for (unsigned int i = 0; i < ids.size(); ++i) {
7368
std::cout << "[" << i << "] " << std::hex << ids[i].rawId() << std::dec;
7469
if (ids[i].det() == DetId::Ecal && ids[i].subdetId() == EcalBarrel) {
75-
std::cout << " " << EBDetId(ids[i]) << std::endl;
70+
std::cout << " " << static_cast<EBDetId>(ids[i]) << std::endl;
7671
} else if (ids[i].det() == DetId::Ecal && ids[i].subdetId() == EcalEndcap) {
77-
std::cout << " " << EEDetId(ids[i]) << std::endl;
72+
std::cout << " " << static_cast<EEDetId>(ids[i]) << std::endl;
7873
} else if (ids[i].det() == DetId::Ecal && ids[i].subdetId() == EcalPreshower) {
79-
std::cout << " " << ESDetId(ids[i]) << std::endl;
74+
std::cout << " " << static_cast<ESDetId>(ids[i]) << std::endl;
8075
} else if (ids[i].det() == DetId::Hcal) {
81-
std::cout << " " << HcalDetId(ids[i]) << std::endl;
76+
std::cout << " " << static_cast<HcalDetId>(ids[i]) << std::endl;
8277
} else {
8378
std::cout << std::endl;
8479
}

Geometry/CaloTopology/test/CaloTowerTopologyTester.cc

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "FWCore/Framework/interface/Event.h"
88
#include "FWCore/Framework/interface/EventSetup.h"
99
#include "FWCore/Framework/interface/ESTransientHandle.h"
10-
#include "FWCore/Framework/interface/ESHandle.h"
1110
#include "FWCore/Framework/interface/MakerMacros.h"
1211

1312
#include "FWCore/ParameterSet/interface/ParameterSet.h"
@@ -34,9 +33,10 @@ class CaloTowerTopologyTester : public edm::one::EDAnalyzer<edm::one::WatchRuns>
3433
void doTest(const CaloTowerTopology& topology);
3534

3635
// ----------member data ---------------------------
36+
const edm::ESGetToken<CaloTowerTopology, HcalRecNumberingRecord> tokTopo_;
3737
};
3838

39-
CaloTowerTopologyTester::CaloTowerTopologyTester(const edm::ParameterSet&) {}
39+
CaloTowerTopologyTester::CaloTowerTopologyTester(const edm::ParameterSet&) : tokTopo_{esConsumes<CaloTowerTopology, HcalRecNumberingRecord>(edm::ESInputTag{})} {}
4040

4141
void CaloTowerTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4242
edm::ParameterSetDescription desc;
@@ -45,12 +45,7 @@ void CaloTowerTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& d
4545
}
4646

4747
void CaloTowerTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
48-
edm::ESHandle<CaloTowerTopology> topo;
49-
iSetup.get<HcalRecNumberingRecord>().get(topo);
50-
if (topo.isValid())
51-
doTest(*topo);
52-
else
53-
std::cout << "Cannot get a valid CaloTowerTopology Object\n";
48+
doTest(iSetup.getData(tokTopo_));
5449
}
5550

5651
void CaloTowerTopologyTester::doTest(const CaloTowerTopology& topology) {
@@ -65,19 +60,19 @@ void CaloTowerTopologyTester::doTest(const CaloTowerTopology& topology) {
6560
std::cout << "Neighbours for : Tower " << id << std::endl;
6661
std::cout << " " << idE.size() << " sets along East:";
6762
for (auto& i : idE)
68-
std::cout << " " << (CaloTowerDetId)(i());
63+
std::cout << " " << static_cast<CaloTowerDetId>(i());
6964
std::cout << std::endl;
7065
std::cout << " " << idW.size() << " sets along West:";
7166
for (auto& i : idW)
72-
std::cout << " " << (CaloTowerDetId)(i());
67+
std::cout << " " << static_cast<CaloTowerDetId>(i());
7368
std::cout << std::endl;
7469
std::cout << " " << idN.size() << " sets along North:";
7570
for (auto& i : idN)
76-
std::cout << " " << (CaloTowerDetId)(i());
71+
std::cout << " " << static_cast<CaloTowerDetId>(i());
7772
std::cout << std::endl;
7873
std::cout << " " << idS.size() << " sets along South:";
7974
for (auto& i : idS)
80-
std::cout << " " << (CaloTowerDetId)(i());
75+
std::cout << " " << static_cast<CaloTowerDetId>(i());
8176
std::cout << std::endl;
8277
}
8378
}

Geometry/CaloTopology/test/FastTimeTopologyTester.cc

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "FWCore/Framework/interface/Event.h"
88
#include "FWCore/Framework/interface/EventSetup.h"
99
#include "FWCore/Framework/interface/ESTransientHandle.h"
10-
#include "FWCore/Framework/interface/ESHandle.h"
1110
#include "FWCore/Framework/interface/MakerMacros.h"
1211

1312
#include "FWCore/ParameterSet/interface/ParameterSet.h"
@@ -32,9 +31,10 @@ class FastTimeTopologyTester : public edm::one::EDAnalyzer<edm::one::WatchRuns>
3231
void doTest(const FastTimeTopology& topology);
3332

3433
// ----------member data ---------------------------
34+
const edm::ESGetToken<FastTimeTopology, IdealGeometryRecord> tokTopo_;
3535
};
3636

37-
FastTimeTopologyTester::FastTimeTopologyTester(const edm::ParameterSet&) {}
37+
FastTimeTopologyTester::FastTimeTopologyTester(const edm::ParameterSet&) : tokTopo_{esConsumes<FastTimeTopology, IdealGeometryRecord>(edm::ESInputTag{"", "FastTimeBarrel"})} {}
3838

3939
void FastTimeTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4040
edm::ParameterSetDescription desc;
@@ -43,12 +43,7 @@ void FastTimeTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& de
4343
}
4444

4545
void FastTimeTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
46-
edm::ESHandle<FastTimeTopology> topo;
47-
iSetup.get<IdealGeometryRecord>().get("FastTimeBarrel", topo);
48-
if (topo.isValid())
49-
doTest(*topo);
50-
else
51-
std::cout << "Cannot get a valid FastTimeTopology Object for FastTimeBarrel\n";
46+
doTest(iSetup.getData(tokTopo_));
5247
}
5348

5449
void FastTimeTopologyTester::doTest(const FastTimeTopology& topology) {
@@ -65,19 +60,19 @@ void FastTimeTopologyTester::doTest(const FastTimeTopology& topology) {
6560
std::vector<DetId> idS = topology.south(id);
6661
std::cout << " " << idE.size() << " sets along East:";
6762
for (auto& i : idE)
68-
std::cout << " " << (FastTimeDetId)(i());
63+
std::cout << " " << static_cast<FastTimeDetId>(i());
6964
std::cout << std::endl;
7065
std::cout << " " << idW.size() << " sets along West:";
7166
for (auto& i : idW)
72-
std::cout << " " << (FastTimeDetId)(i());
67+
std::cout << " " << static_cast<FastTimeDetId>(i());
7368
std::cout << std::endl;
7469
std::cout << " " << idN.size() << " sets along North:";
7570
for (auto& i : idN)
76-
std::cout << " " << (FastTimeDetId)(i());
71+
std::cout << " " << static_cast<FastTimeDetId>(i());
7772
std::cout << std::endl;
7873
std::cout << " " << idS.size() << " sets along South:";
7974
for (auto& i : idS)
80-
std::cout << " " << (FastTimeDetId)(i());
75+
std::cout << " " << static_cast<FastTimeDetId>(i());
8176
std::cout << std::endl;
8277
}
8378
phi += 10;

Geometry/CaloTopology/test/HGCalTopologyTester.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "FWCore/Framework/interface/Event.h"
88
#include "FWCore/Framework/interface/EventSetup.h"
99
#include "FWCore/Framework/interface/ESTransientHandle.h"
10-
#include "FWCore/Framework/interface/ESHandle.h"
1110
#include "FWCore/Framework/interface/MakerMacros.h"
1211

1312
#include "FWCore/ParameterSet/interface/ParameterSet.h"
@@ -35,6 +34,7 @@ class HGCalTopologyTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
3534
// ----------member data ---------------------------
3635
const std::string detectorName_;
3736
const std::vector<int> type_, layer_, sec1_, sec2_, cell1_, cell2_;
37+
const edm::ESGetToken<HGCalTopology, IdealGeometryRecord> tokTopo_;
3838
};
3939

4040
HGCalTopologyTester::HGCalTopologyTester(const edm::ParameterSet& iC)
@@ -44,7 +44,8 @@ HGCalTopologyTester::HGCalTopologyTester(const edm::ParameterSet& iC)
4444
sec1_(iC.getParameter<std::vector<int> >("sector1")),
4545
sec2_(iC.getParameter<std::vector<int> >("sector2")),
4646
cell1_(iC.getParameter<std::vector<int> >("cell1")),
47-
cell2_(iC.getParameter<std::vector<int> >("cell2")) {}
47+
cell2_(iC.getParameter<std::vector<int> >("cell2")),
48+
tokTopo_{esConsumes<HGCalTopology, IdealGeometryRecord>(edm::ESInputTag{"", detectorName_ })} {}
4849

4950
void HGCalTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
5051
edm::ParameterSetDescription desc;
@@ -65,12 +66,7 @@ void HGCalTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descr
6566
}
6667

6768
void HGCalTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
68-
edm::ESHandle<HGCalTopology> topo;
69-
iSetup.get<IdealGeometryRecord>().get(detectorName_, topo);
70-
if (topo.isValid())
71-
doTest(*topo);
72-
else
73-
std::cout << "Cannot get a valid Topology Object for " << detectorName_;
69+
doTest(iSetup.getData(tokTopo_));
7470
}
7571

7672
void HGCalTopologyTester::doTest(const HGCalTopology& topology) {

Geometry/CaloTopology/test/HcalDetId2DenseTester.cc

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "FWCore/Framework/interface/Event.h"
99
#include "FWCore/Framework/interface/EventSetup.h"
1010
#include "FWCore/Framework/interface/ESTransientHandle.h"
11-
#include "FWCore/Framework/interface/ESHandle.h"
1211
#include "FWCore/Framework/interface/MakerMacros.h"
1312

1413
#include "FWCore/ParameterSet/interface/ParameterSet.h"
@@ -42,11 +41,13 @@ class HcalDetId2DenseTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
4241
// ----------member data ---------------------------
4342
const std::string fileName_;
4443
const bool testCalib_;
44+
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> tokTopo_;
4545
};
4646

4747
HcalDetId2DenseTester::HcalDetId2DenseTester(const edm::ParameterSet& iC)
4848
: fileName_(iC.getUntrackedParameter<std::string>("fileName", "")),
49-
testCalib_(iC.getUntrackedParameter<bool>("testCalib", false)) {}
49+
testCalib_(iC.getUntrackedParameter<bool>("testCalib", false)),
50+
tokTopo_{esConsumes<HcalTopology, HcalRecNumberingRecord>(edm::ESInputTag{})} {}
5051

5152
void HcalDetId2DenseTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
5253
edm::ParameterSetDescription desc;
@@ -56,18 +57,13 @@ void HcalDetId2DenseTester::fillDescriptions(edm::ConfigurationDescriptions& des
5657
}
5758

5859
void HcalDetId2DenseTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
59-
edm::ESHandle<HcalTopology> topo;
60-
iSetup.get<HcalRecNumberingRecord>().get(topo);
61-
if (topo.isValid()) {
62-
if (!testCalib_) {
63-
doTestFile(*topo);
64-
doTestHcalDetId(*topo);
65-
doTestHcalCalibDetId(*topo);
66-
} else {
67-
doTestOnlyHcalCalibDetId(*topo);
68-
}
60+
const auto& topo = iSetup.getData(tokTopo_);
61+
if (!testCalib_) {
62+
doTestFile(topo);
63+
doTestHcalDetId(topo);
64+
doTestHcalCalibDetId(topo);
6965
} else {
70-
std::cout << "Cannot get a valid HcalTopology Object\n";
66+
doTestOnlyHcalCalibDetId(topo);
7167
}
7268
}
7369

0 commit comments

Comments
 (0)