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,13 @@ class CaloTowerMapTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
3938
4039private:
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&)
46+ : tokGeom_{esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{})},
47+ tokMap_{esConsumes<CaloTowerConstituentsMap, CaloGeometryRecord>(edm::ESInputTag{})} {}
4548
4649void CaloTowerMapTester::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
4750 edm::ParameterSetDescription desc;
@@ -50,35 +53,30 @@ void CaloTowerMapTester::fillDescriptions(edm::ConfigurationDescriptions& descri
5053}
5154
5255void 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;
56+ const CaloGeometry* geo = &iSetup.getData (tokGeom_);
57+ const CaloTowerConstituentsMap* ctmap = &iSetup.getData (tokMap_);
58+ doTest (geo, ctmap);
6259}
6360
6461void CaloTowerMapTester::doTest (const CaloGeometry* geo, const CaloTowerConstituentsMap* ctmap) {
65- HcalGeometry* hgeo = ( HcalGeometry*) (geo->getSubdetectorGeometry (DetId::Hcal, HcalBarrel));
62+ const HcalGeometry* hgeo = static_cast < const HcalGeometry*> (geo->getSubdetectorGeometry (DetId::Hcal, HcalBarrel));
6663 const std::vector<DetId>& dets = hgeo->getValidDetIds (DetId::Hcal, 0 );
6764
6865 for (const auto & id : dets) {
6966 CaloTowerDetId tower = ctmap->towerOf (id);
7067 std::vector<DetId> ids = ctmap->constituentsOf (tower);
71- std::cout << HcalDetId (id) << " belongs to " << tower << " which has " << ids.size () << " constituents\n " ;
68+ std::cout << static_cast <HcalDetId>(id) << " belongs to " << tower << " which has " << ids.size ()
69+ << " constituents\n " ;
7270 for (unsigned int i = 0 ; i < ids.size (); ++i) {
7371 std::cout << " [" << i << " ] " << std::hex << ids[i].rawId () << std::dec;
7472 if (ids[i].det () == DetId::Ecal && ids[i].subdetId () == EcalBarrel) {
75- std::cout << " " << EBDetId (ids[i]) << std::endl;
73+ std::cout << " " << static_cast < EBDetId> (ids[i]) << std::endl;
7674 } else if (ids[i].det () == DetId::Ecal && ids[i].subdetId () == EcalEndcap) {
77- std::cout << " " << EEDetId (ids[i]) << std::endl;
75+ std::cout << " " << static_cast < EEDetId> (ids[i]) << std::endl;
7876 } else if (ids[i].det () == DetId::Ecal && ids[i].subdetId () == EcalPreshower) {
79- std::cout << " " << ESDetId (ids[i]) << std::endl;
77+ std::cout << " " << static_cast < ESDetId> (ids[i]) << std::endl;
8078 } else if (ids[i].det () == DetId::Hcal) {
81- std::cout << " " << HcalDetId (ids[i]) << std::endl;
79+ std::cout << " " << static_cast < HcalDetId> (ids[i]) << std::endl;
8280 } else {
8381 std::cout << std::endl;
8482 }
0 commit comments