8989class HcalIsoTrkAnalyzer : public edm ::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
9090public:
9191 explicit HcalIsoTrkAnalyzer (edm::ParameterSet const &);
92- ~HcalIsoTrkAnalyzer () override {}
92+ ~HcalIsoTrkAnalyzer () override ;
9393
9494 static void fillDescriptions (edm::ConfigurationDescriptions& descriptions);
9595
@@ -106,15 +106,13 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
106106 std::vector<spr::propagatedTrackID>& trkCaloDets,
107107 const CaloGeometry* geo,
108108 const CaloTopology* topo,
109- const HcalTopology* theHBHETopology,
110109 const EcalChannelStatus* theEcalChStatus,
111110 const EcalSeverityLevelAlgo* theEcalSevlv,
112111 edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
113112 edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
114113 edm::Handle<HBHERecHitCollection>& hbhe,
115114 edm::Handle<CaloTowerCollection>& towerHandle,
116115 edm::Handle<reco::GenParticleCollection>& genParticles,
117- const HcalRespCorrs* respCorrs,
118116 const HcalDbService* conditions,
119117 const edm::Handle<reco::MuonCollection>& muonh);
120118 double dR (math::XYZTLorentzVector&, math::XYZTLorentzVector&);
@@ -123,7 +121,6 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
123121 double eThreshold (const DetId& id, const CaloGeometry* geo) const ;
124122 DetId newId (const DetId&);
125123 void storeEnergy (int indx,
126- const HcalRespCorrs* respCorrs,
127124 const HcalDbService* conditions,
128125 const std::vector<DetId>& ids,
129126 std::vector<double >& edet,
@@ -190,6 +187,7 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
190187 unsigned int nRun_, nLow_, nHigh_;
191188 double a_charIsoR_, a_coneR1_, a_coneR2_;
192189 const HcalTopology* theHBHETopology_;
190+ HcalRespCorrs* respCorrs_;
193191 const HcalDDDRecConstants* hdc_;
194192 const EcalPFRecHitThresholds* eThresholds_;
195193
@@ -304,14 +302,15 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
304302 tok_sevlv_(esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd>()),
305303 tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
306304 tok_caloTopology_(esConsumes<CaloTopology, CaloTopologyRecord>()),
307- tok_htopo_(esConsumes<HcalTopology, HcalRecNumberingRecord>()),
308- tok_resp_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd>()),
305+ tok_htopo_(esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun >()),
306+ tok_resp_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd, edm::Transition::BeginRun >()),
309307 tok_dbservice_(esConsumes<HcalDbService, HcalDbRecord>()),
310308 tok_ecalPFRecHitThresholds_(esConsumes<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd>()),
311309 nRun_(0 ),
312310 nLow_(0 ),
313311 nHigh_(0 ),
314312 theHBHETopology_(nullptr ),
313+ respCorrs_(nullptr ),
315314 hdc_(nullptr ) {
316315 usesResource (TFileService::kSharedResource );
317316
@@ -414,6 +413,11 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
414413 }
415414}
416415
416+ HcalIsoTrkAnalyzer::~HcalIsoTrkAnalyzer () {
417+ if (respCorrs_)
418+ delete respCorrs_;
419+ }
420+
417421void HcalIsoTrkAnalyzer::analyze (edm::Event const & iEvent, edm::EventSetup const & iSetup) {
418422 t_Run = iEvent.id ().run ();
419423 t_Event = iEvent.id ().event ();
@@ -436,11 +440,9 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
436440 // get calogeometry and calotopology
437441 const CaloGeometry* geo = &iSetup.getData (tok_geom_);
438442 const CaloTopology* caloTopology = &iSetup.getData (tok_caloTopology_);
439- const HcalTopology* theHBHETopology = &iSetup.getData (tok_htopo_);
440443
441444 // get Hcal response corrections
442445 const HcalDbService* conditions = &iSetup.getData (tok_dbservice_);
443- const HcalRespCorrs* respCorrs = &iSetup.getData (tok_resp_);
444446
445447 // === genParticle information
446448 edm::Handle<reco::GenParticleCollection> genParticles = iEvent.getHandle (tok_parts_);
@@ -593,15 +595,13 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
593595 trkCaloDets,
594596 geo,
595597 caloTopology,
596- theHBHETopology,
597598 theEcalChStatus,
598599 theEcalSevlv,
599600 barrelRecHitsHandle,
600601 endcapRecHitsHandle,
601602 hbhe,
602603 caloTower,
603604 genParticles,
604- respCorrs,
605605 conditions,
606606 muonh);
607607 t_TracksSaved = ntksave[0 ];
@@ -708,15 +708,13 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
708708 trkCaloDets,
709709 geo,
710710 caloTopology,
711- theHBHETopology,
712711 theEcalChStatus,
713712 theEcalSevlv,
714713 barrelRecHitsHandle,
715714 endcapRecHitsHandle,
716715 hbhe,
717716 caloTower,
718717 genParticles,
719- respCorrs,
720718 conditions,
721719 muonh);
722720 t_TracksSaved += ntksave[0 ];
@@ -821,6 +819,12 @@ void HcalIsoTrkAnalyzer::beginJob() {
821819
822820// ------------ method called when starting to processes a run ------------
823821void HcalIsoTrkAnalyzer::beginRun (edm::Run const & iRun, edm::EventSetup const & iSetup) {
822+ theHBHETopology_ = &iSetup.getData (tok_htopo_);
823+ const HcalRespCorrs* resp = &iSetup.getData (tok_resp_);
824+ respCorrs_ = new HcalRespCorrs (*resp);
825+ respCorrs_->setTopo (theHBHETopology_);
826+ edm::LogVerbatim (" HcalIsoTrack" ) << " beginRun " << iRun.run () << " get responseCoorection " << respCorrs_;
827+
824828 hdc_ = &iSetup.getData (tok_ddrec_);
825829
826830 if (!ignoreTrigger_) {
@@ -853,6 +857,11 @@ void HcalIsoTrkAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& i
853857void HcalIsoTrkAnalyzer::endRun (edm::Run const & iRun, edm::EventSetup const &) {
854858 nRun_++;
855859 edm::LogVerbatim (" HcalIsoTrack" ) << " endRun[" << nRun_ << " ] " << iRun.run ();
860+
861+ if (respCorrs_) {
862+ delete respCorrs_;
863+ respCorrs_ = nullptr ;
864+ }
856865}
857866
858867void HcalIsoTrkAnalyzer::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
@@ -955,15 +964,13 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
955964 std::vector<spr::propagatedTrackID>& trkCaloDets,
956965 const CaloGeometry* geo,
957966 const CaloTopology* caloTopology,
958- const HcalTopology* theHBHETopology,
959967 const EcalChannelStatus* theEcalChStatus,
960968 const EcalSeverityLevelAlgo* theEcalSevlv,
961969 edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
962970 edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
963971 edm::Handle<HBHERecHitCollection>& hbhe,
964972 edm::Handle<CaloTowerCollection>& tower,
965973 edm::Handle<reco::GenParticleCollection>& genParticles,
966- const HcalRespCorrs* respCorrs,
967974 const HcalDbService* conditions,
968975 const edm::Handle<reco::MuonCollection>& muonh) {
969976 int nSave (0 ), nLoose (0 ), nTight (0 );
@@ -1186,9 +1193,9 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
11861193 t_hmaxNearP = spr::chargeIsolationCone (nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false );
11871194 const DetId cellH (trkDetItr.detIdHCAL );
11881195 double h5x5 = spr::eHCALmatrix (
1189- theHBHETopology , cellH, hbhe, 2 , 2 , false , true , -100.0 , -100.0 , -100.0 , -100.0 , -100.0 , 100.0 );
1196+ theHBHETopology_ , cellH, hbhe, 2 , 2 , false , true , -100.0 , -100.0 , -100.0 , -100.0 , -100.0 , 100.0 );
11901197 double h7x7 = spr::eHCALmatrix (
1191- theHBHETopology , cellH, hbhe, 3 , 3 , false , true , -100.0 , -100.0 , -100.0 , -100.0 , -100.0 , 100.0 );
1198+ theHBHETopology_ , cellH, hbhe, 3 , 3 , false , true , -100.0 , -100.0 , -100.0 , -100.0 , -100.0 , 100.0 );
11921199 t_hAnnular = h7x7 - h5x5;
11931200#ifdef EDM_ML_DEBUG
11941201 if (debug_)
@@ -1221,7 +1228,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
12211228 for (unsigned k = 0 ; k < ids.size (); ++k)
12221229 ids[k] = newId (ids[k]);
12231230 }
1224- storeEnergy (0 , respCorrs, conditions, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);
1231+ storeEnergy (0 , conditions, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);
12251232
12261233 // ----- hcal energy in the extended cone 1 (a_coneR+10) --------------
12271234 t_eHcal10 = spr::eCone_hcal (geo,
@@ -1238,7 +1245,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
12381245 for (unsigned k = 0 ; k < ids1.size (); ++k)
12391246 ids1[k] = newId (ids1[k]);
12401247 }
1241- storeEnergy (1 , respCorrs, conditions, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1);
1248+ storeEnergy (1 , conditions, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1);
12421249
12431250 // ----- hcal energy in the extended cone 3 (a_coneR+30) --------------
12441251 t_eHcal30 = spr::eCone_hcal (geo,
@@ -1255,7 +1262,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
12551262 for (unsigned k = 0 ; k < ids3.size (); ++k)
12561263 ids3[k] = newId (ids3[k]);
12571264 }
1258- storeEnergy (3 , respCorrs, conditions, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3);
1265+ storeEnergy (3 , conditions, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3);
12591266
12601267#ifdef EDM_ML_DEBUG
12611268 if (debug_) {
@@ -1416,7 +1423,6 @@ DetId HcalIsoTrkAnalyzer::newId(const DetId& id) {
14161423}
14171424
14181425void HcalIsoTrkAnalyzer::storeEnergy (int indx,
1419- const HcalRespCorrs* respCorrs,
14201426 const HcalDbService* conditions,
14211427 const std::vector<DetId>& ids,
14221428 std::vector<double >& edet,
@@ -1426,7 +1432,7 @@ void HcalIsoTrkAnalyzer::storeEnergy(int indx,
14261432 double ehcal (0 );
14271433 if (unCorrect_) {
14281434 for (unsigned int k = 0 ; k < ids.size (); ++k) {
1429- double corr = (respCorrs ->getValues (ids[k]))->getValue ();
1435+ double corr = (respCorrs_ ->getValues (ids[k]))->getValue ();
14301436 if (corr != 0 )
14311437 edet[k] /= corr;
14321438 ehcal += edet[k];
0 commit comments