|
3 | 3 | #include "Geometry/Records/interface/CaloGeometryRecord.h" |
4 | 4 | #include "FWCore/MessageLogger/interface/MessageLogger.h" |
5 | 5 | #include "Geometry/Records/interface/CaloGeometryRecord.h" |
6 | | -#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h" |
| 6 | +#include "FWCore/Framework/interface/ConsumesCollector.h" |
7 | 7 |
|
8 | 8 | using namespace reco; |
9 | 9 |
|
10 | | -void ElectronHcalHelper::beginEvent(const edm::Event& evt, const edm::EventSetup& es) { |
| 10 | +ElectronHcalHelper::ElectronHcalHelper(const Configuration& cfg, edm::ConsumesCollector&& cc) : cfg_(cfg) { |
| 11 | + if (cfg_.hOverEConeSize == 0) { |
| 12 | + return; |
| 13 | + } |
| 14 | + |
| 15 | + if (cfg_.useTowers) { |
| 16 | + hcalChannelQualityToken_ = cc.esConsumes(edm::ESInputTag("", "withTopo")); |
| 17 | + hcalTopologyToken_ = cc.esConsumes(); |
| 18 | + towerMapToken_ = cc.esConsumes(); |
| 19 | + } else { |
| 20 | + caloGeometryToken_ = cc.esConsumes(); |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +void ElectronHcalHelper::beginEvent(const edm::Event& evt, const edm::EventSetup& eventSetup) { |
11 | 25 | if (cfg_.hOverEConeSize == 0) { |
12 | 26 | return; |
13 | 27 | } |
14 | 28 |
|
15 | 29 | if (cfg_.useTowers) { |
16 | 30 | towersFromCollection_ = &evt.get(cfg_.hcalTowers); |
| 31 | + |
| 32 | + towerMap_ = &eventSetup.getData(towerMapToken_); |
| 33 | + hcalQuality_ = &eventSetup.getData(hcalChannelQualityToken_); |
| 34 | + hcalTopology_ = &eventSetup.getData(hcalTopologyToken_); |
| 35 | + |
17 | 36 | towerIso1_ = |
18 | 37 | std::make_unique<EgammaTowerIsolation>(cfg_.hOverEConeSize, 0., cfg_.hOverEPtMin, 1, towersFromCollection_); |
19 | 38 | towerIso2_ = |
20 | 39 | std::make_unique<EgammaTowerIsolation>(cfg_.hOverEConeSize, 0., cfg_.hOverEPtMin, 2, towersFromCollection_); |
21 | | - |
22 | | - edm::ESHandle<CaloTowerConstituentsMap> ctmaph; |
23 | | - es.get<CaloGeometryRecord>().get(ctmaph); |
24 | | - towerMap_ = ctmaph.product(); |
25 | | - |
26 | | - edm::ESHandle<HcalChannelQuality> hQuality; |
27 | | - es.get<HcalChannelQualityRcd>().get("withTopo", hQuality); |
28 | | - hcalQuality_ = hQuality.product(); |
29 | | - edm::ESHandle<HcalTopology> hcalTopology; |
30 | | - es.get<HcalRecNumberingRecord>().get(hcalTopology); |
31 | | - hcalTopology_ = hcalTopology.product(); |
32 | 40 | } else { |
33 | | - edm::Handle<HBHERecHitCollection> hbhe_; |
34 | | - if (!evt.getByToken(cfg_.hcalRecHits, hbhe_)) { |
35 | | - edm::LogError("ElectronHcalHelper::readEvent") << "failed to get the rechits"; |
36 | | - } |
37 | | - |
38 | | - hcalIso_ = std::make_unique<EgammaHcalIsolation>( |
39 | | - cfg_.hOverEConeSize, 0., cfg_.hOverEHBMinE, cfg_.hOverEHFMinE, 0., 0., caloGeom_, *hbhe_); |
40 | | - |
41 | | - unsigned long long newCaloGeomCacheId_ = es.get<CaloGeometryRecord>().cacheIdentifier(); |
42 | | - if (caloGeomCacheId_ != newCaloGeomCacheId_) { |
43 | | - caloGeomCacheId_ = newCaloGeomCacheId_; |
44 | | - es.get<CaloGeometryRecord>().get(caloGeom_); |
45 | | - } |
| 41 | + hcalIso_ = std::make_unique<EgammaHcalIsolation>(cfg_.hOverEConeSize, |
| 42 | + 0., |
| 43 | + cfg_.hOverEHBMinE, |
| 44 | + cfg_.hOverEHFMinE, |
| 45 | + 0., |
| 46 | + 0., |
| 47 | + eventSetup.getHandle(caloGeometryToken_), |
| 48 | + evt.get(cfg_.hcalRecHits)); |
46 | 49 | } |
47 | 50 | } |
48 | 51 |
|
|
0 commit comments