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
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&) : tokGeom_{esConsumes<CaloGeometry, CaloGeometryRecord>(edm::ESInputTag{})}, tokMap_{esConsumes<CaloTowerConstituentsMap, CaloGeometryRecord>(edm::ESInputTag{})} {}
4546
4647void CaloTowerMapTester::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
4748 edm::ParameterSetDescription desc;
@@ -50,35 +51,29 @@ void CaloTowerMapTester::fillDescriptions(edm::ConfigurationDescriptions& descri
5051}
5152
5253void 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
6459void 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 }
0 commit comments