Skip to content

Commit 4e622e0

Browse files
authored
Merge pull request cms-sw#31778 from makortel/esConsumesHcal
Migrate rest of {HBHEPhase1,HcalHit,HcalSimple}Reconstructor to EventSetup consumes
2 parents fe2df40 + b77ed1d commit 4e622e0

13 files changed

+71
-49
lines changed

CalibCalorimetry/HcalAlgos/interface/HcalPulseContainmentManager.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
#include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h"
66
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
77
#include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
8-
#include "FWCore/Framework/interface/ESHandle.h"
8+
#include "CondFormats/DataRecord/interface/HcalTimeSlewRecord.h"
99

1010
class HcalPulseContainmentManager {
1111
public:
12+
// for callers not calling beginRun(EventSetup)
1213
HcalPulseContainmentManager(float max_fracerror);
14+
// for callers calling beginRun(EventSetup)
15+
HcalPulseContainmentManager(float max_fracerror, edm::ConsumesCollector iC);
1316
double correction(const HcalDetId& detId, int toAdd, float fixedphase_ns, double fc_ampl);
1417
const HcalPulseContainmentCorrection* get(const HcalDetId& detId, int toAdd, float fixedphase_ns);
1518

@@ -35,6 +38,7 @@ class HcalPulseContainmentManager {
3538
HcalPulseShapes shapes_;
3639
float fixedphase_ns_;
3740
float max_fracerror_;
41+
const edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> delayToken_;
3842

3943
const HcalTimeSlew* hcalTimeSlew_delay_;
4044
};

CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
99
#include "FWCore/Framework/interface/Frameworkfwd.h"
1010
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
11+
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
1112

1213
/** \class HcalPulseShapes
1314
*
@@ -21,7 +22,9 @@ namespace CLHEP {
2122
class HcalPulseShapes {
2223
public:
2324
typedef HcalPulseShape Shape;
25+
// Default constructor is for callers that do not call beginRun(EventSetup)
2426
HcalPulseShapes();
27+
explicit HcalPulseShapes(edm::ConsumesCollector iC);
2528
~HcalPulseShapes();
2629
// only needed if you'll be getting shapes by DetId
2730
void beginRun(edm::EventSetup const& es);
@@ -112,6 +115,7 @@ class HcalPulseShapes {
112115
Shape hpdShape_v2, hpdShapeMC_v2;
113116
Shape hpdShape_v3, hpdShapeMC_v3;
114117
Shape hpdBV30Shape_v2, hpdBV30ShapeMC_v2;
118+
edm::ESGetToken<HcalDbService, HcalDbRecord> theDbServiceToken;
115119
const HcalDbService* theDbService;
116120
typedef std::map<int, const Shape*> ShapeMap;
117121
ShapeMap theShapes;

CalibCalorimetry/HcalAlgos/src/HcalPulseContainmentManager.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#include "CalibCalorimetry/HcalAlgos/interface/HcalPulseContainmentManager.h"
2-
#include "FWCore/Framework/interface/ESHandle.h"
2+
#include "FWCore/Framework/interface/ConsumesCollector.h"
33
#include "FWCore/Framework/interface/EventSetup.h"
4-
#include "CondFormats/DataRecord/interface/HcalTimeSlewRecord.h"
54
#include <iostream>
65

76
HcalPulseContainmentManager::HcalPulseContainmentManager(float max_fracerror)
87
: entries_(), shapes_(), max_fracerror_(max_fracerror) {
98
hcalTimeSlew_delay_ = nullptr;
109
}
1110

11+
HcalPulseContainmentManager::HcalPulseContainmentManager(float max_fracerror, edm::ConsumesCollector iC)
12+
: entries_(),
13+
shapes_(iC),
14+
max_fracerror_(max_fracerror),
15+
delayToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "HBHE"))) {}
16+
1217
void HcalPulseContainmentManager::beginRun(edm::EventSetup const& es) {
13-
edm::ESHandle<HcalTimeSlew> delay;
14-
es.get<HcalTimeSlewRecord>().get("HBHE", delay);
15-
hcalTimeSlew_delay_ = &*delay;
18+
hcalTimeSlew_delay_ = &es.getData(delayToken_);
1619

1720
shapes_.beginRun(es);
1821
}

CalibCalorimetry/HcalAlgos/src/HcalPulseShapes.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h"
22
#include "FWCore/Utilities/interface/Exception.h"
3-
#include "FWCore/Framework/interface/ESHandle.h"
3+
#include "FWCore/Framework/interface/ConsumesCollector.h"
44
#include "FWCore/Framework/interface/EventSetup.h"
55
#include "FWCore/MessageLogger/interface/MessageLogger.h"
66
#include "CLHEP/Random/RandFlat.h"
7-
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
87

98
// #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
109
#include <cmath>
@@ -138,13 +137,13 @@ Reco MC
138137
//theShapes[401] = new CaloCachedShapeIntegrator(&theZDCShape);
139138
}
140139

140+
HcalPulseShapes::HcalPulseShapes(edm::ConsumesCollector iC) : HcalPulseShapes() {
141+
theDbServiceToken = iC.esConsumes<edm::Transition::BeginRun>();
142+
}
143+
141144
HcalPulseShapes::~HcalPulseShapes() {}
142145

143-
void HcalPulseShapes::beginRun(edm::EventSetup const& es) {
144-
edm::ESHandle<HcalDbService> conditions;
145-
es.get<HcalDbRecord>().get(conditions);
146-
theDbService = conditions.product();
147-
}
146+
void HcalPulseShapes::beginRun(edm::EventSetup const& es) { theDbService = &es.getData(theDbServiceToken); }
148147

149148
void HcalPulseShapes::beginRun(const HcalDbService* conditions) { theDbService = conditions; }
150149

RecoLocalCalo/HcalRecAlgos/interface/HcalSimpleRecAlgo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class HcalSimpleRecAlgo {
3535
public:
3636
/** Full featured constructor for HB/HE and HO (HPD-based detectors) */
37-
HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs);
37+
HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs, edm::ConsumesCollector iC);
3838

3939
void beginRun(edm::EventSetup const& es);
4040
void endRun();
@@ -73,6 +73,7 @@ class HcalSimpleRecAlgo {
7373
bool correctForTimeslew_;
7474
bool correctForPulse_;
7575
float phaseNS_;
76+
const edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> delayToken_;
7677
std::unique_ptr<HcalPulseContainmentManager> pulseCorr_;
7778
int runnum_; // data run numer
7879
bool setLeakCorrection_;

RecoLocalCalo/HcalRecAlgos/interface/SimpleHBHEPhase1Algo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class SimpleHBHEPhase1Algo : public AbsHBHEPhase1Algo {
4747
bool applyLegacyHBMCorrection,
4848
std::unique_ptr<PulseShapeFitOOTPileupCorrection> m2,
4949
std::unique_ptr<HcalDeterministicFit> detFit,
50-
std::unique_ptr<MahiFit> mahi);
50+
std::unique_ptr<MahiFit> mahi,
51+
edm::ConsumesCollector iC);
5152

5253
inline ~SimpleHBHEPhase1Algo() override {}
5354

@@ -69,6 +70,7 @@ class SimpleHBHEPhase1Algo : public AbsHBHEPhase1Algo {
6970
inline bool isCorrectingForPhaseContainment() const { return corrFPC_; }
7071
inline int getRunNumber() const { return runnum_; }
7172

73+
edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> delayToken_;
7274
const HcalTimeSlew* hcalTimeSlew_delay_;
7375

7476
protected:

RecoLocalCalo/HcalRecAlgos/interface/parseHBHEPhase1AlgoDescription.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33

44
#include <memory>
55
#include "RecoLocalCalo/HcalRecAlgos/interface/AbsHBHEPhase1Algo.h"
6+
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
67
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
78

8-
namespace edm {
9-
class ParameterSet;
10-
}
11-
129
//
1310
// Factory function for creating objects of types
1411
// inheriting from AbsHBHEPhase1Algo out of parameter sets.
1512
//
1613
// Update the implementation of this function if you need
1714
// to add a new algorithm to HBHEPhase1Reconstructor.
1815
//
19-
std::unique_ptr<AbsHBHEPhase1Algo> parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps);
16+
std::unique_ptr<AbsHBHEPhase1Algo> parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps,
17+
edm::ConsumesCollector iC);
2018

2119
//
2220
// Parameter descriptions for "parseHBHEPhase1AlgoDescription".

RecoLocalCalo/HcalRecAlgos/src/HcalSimpleRecAlgo.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalSimpleRecAlgo.h"
2+
#include "FWCore/Framework/interface/ConsumesCollector.h"
23
#include "FWCore/MessageLogger/interface/MessageLogger.h"
34
#include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
45
#include "RecoLocalCalo/HcalRecAlgos/src/HcalTDCReco.h"
56
#include "RecoLocalCalo/HcalRecAlgos/interface/rawEnergy.h"
67
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalCorrectionFunctions.h"
78
#include "DataFormats/METReco/interface/HcalCaloFlagLabels.h"
89
#include "CondFormats/DataRecord/interface/HcalTimeSlewRecord.h"
9-
#include "FWCore/Framework/interface/ESHandle.h"
1010
#include "FWCore/Framework/interface/EventSetup.h"
1111

1212
#include <algorithm>
@@ -17,21 +17,23 @@
1717

1818
constexpr double MaximumFractionalError = 0.002; // 0.2% error allowed from this source
1919

20-
HcalSimpleRecAlgo::HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForPulse, float phaseNS)
20+
HcalSimpleRecAlgo::HcalSimpleRecAlgo(bool correctForTimeslew,
21+
bool correctForPulse,
22+
float phaseNS,
23+
edm::ConsumesCollector iC)
2124
: correctForTimeslew_(correctForTimeslew),
2225
correctForPulse_(correctForPulse),
2326
phaseNS_(phaseNS),
27+
delayToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "HBHE"))),
2428
runnum_(0),
2529
setLeakCorrection_(false),
2630
puCorrMethod_(0) {
2731
hcalTimeSlew_delay_ = nullptr;
28-
pulseCorr_ = std::make_unique<HcalPulseContainmentManager>(MaximumFractionalError);
32+
pulseCorr_ = std::make_unique<HcalPulseContainmentManager>(MaximumFractionalError, iC);
2933
}
3034

3135
void HcalSimpleRecAlgo::beginRun(edm::EventSetup const& es) {
32-
edm::ESHandle<HcalTimeSlew> delay;
33-
es.get<HcalTimeSlewRecord>().get("HBHE", delay);
34-
hcalTimeSlew_delay_ = &*delay;
36+
hcalTimeSlew_delay_ = &es.getData(delayToken_);
3537

3638
pulseCorr_->beginRun(es);
3739
}

RecoLocalCalo/HcalRecAlgos/src/SimpleHBHEPhase1Algo.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
#include "RecoLocalCalo/HcalRecAlgos/interface/SimpleHBHEPhase1Algo.h"
66
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalCorrectionFunctions.h"
77

8+
#include "FWCore/Framework/interface/ConsumesCollector.h"
89
#include "FWCore/Framework/interface/Run.h"
910

1011
#include "DataFormats/HcalRecHit/interface/HBHERecHitAuxSetter.h"
1112
#include "DataFormats/METReco/interface/HcalPhase1FlagLabels.h"
1213
#include "CondFormats/DataRecord/interface/HcalTimeSlewRecord.h"
1314
#include "FWCore/Framework/interface/EventSetup.h"
14-
#include "FWCore/Framework/interface/ESHandle.h"
1515

16-
// Maximum fractional error for calculating Method 0
17-
// pulse containment correction
18-
constexpr float PulseContainmentFractionalError = 0.002f;
16+
namespace {
17+
// Maximum fractional error for calculating Method 0
18+
// pulse containment correction
19+
constexpr float PulseContainmentFractionalError = 0.002f;
20+
} // namespace
1921

2022
SimpleHBHEPhase1Algo::SimpleHBHEPhase1Algo(const int firstSampleShift,
2123
const int samplesToAdd,
@@ -25,8 +27,10 @@ SimpleHBHEPhase1Algo::SimpleHBHEPhase1Algo(const int firstSampleShift,
2527
const bool applyLegacyHBMCorrection,
2628
std::unique_ptr<PulseShapeFitOOTPileupCorrection> m2,
2729
std::unique_ptr<HcalDeterministicFit> detFit,
28-
std::unique_ptr<MahiFit> mahi)
29-
: pulseCorr_(PulseContainmentFractionalError),
30+
std::unique_ptr<MahiFit> mahi,
31+
edm::ConsumesCollector iC)
32+
: delayToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "HBHE"))),
33+
pulseCorr_(PulseContainmentFractionalError, iC),
3034
firstSampleShift_(firstSampleShift),
3135
samplesToAdd_(samplesToAdd),
3236
phaseNS_(phaseNS),
@@ -41,9 +45,7 @@ SimpleHBHEPhase1Algo::SimpleHBHEPhase1Algo(const int firstSampleShift,
4145
}
4246

4347
void SimpleHBHEPhase1Algo::beginRun(const edm::Run& r, const edm::EventSetup& es) {
44-
edm::ESHandle<HcalTimeSlew> delay;
45-
es.get<HcalTimeSlewRecord>().get("HBHE", delay);
46-
hcalTimeSlew_delay_ = &*delay;
48+
hcalTimeSlew_delay_ = &es.getData(delayToken_);
4749

4850
runnum_ = r.run();
4951
pulseCorr_.beginRun(es);

RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <cassert>
22

33
#include "RecoLocalCalo/HcalRecAlgos/interface/parseHBHEPhase1AlgoDescription.h"
4+
#include "FWCore/Framework/interface/ConsumesCollector.h"
45
#include "FWCore/ParameterSet/interface/ParameterSet.h"
56
#include "FWCore/MessageLogger/interface/MessageLogger.h"
67

@@ -104,7 +105,8 @@ static std::unique_ptr<HcalDeterministicFit> parseHBHEMethod3Description(const e
104105
return fit;
105106
}
106107

107-
std::unique_ptr<AbsHBHEPhase1Algo> parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps) {
108+
std::unique_ptr<AbsHBHEPhase1Algo> parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps,
109+
edm::ConsumesCollector iC) {
108110
std::unique_ptr<AbsHBHEPhase1Algo> algo;
109111

110112
const std::string& className = ps.getParameter<std::string>("Class");
@@ -126,16 +128,16 @@ std::unique_ptr<AbsHBHEPhase1Algo> parseHBHEPhase1AlgoDescription(const edm::Par
126128
if (ps.getParameter<bool>("useM3"))
127129
detFit = parseHBHEMethod3Description(ps);
128130

129-
algo =
130-
std::unique_ptr<AbsHBHEPhase1Algo>(new SimpleHBHEPhase1Algo(ps.getParameter<int>("firstSampleShift"),
131-
ps.getParameter<int>("samplesToAdd"),
132-
ps.getParameter<double>("correctionPhaseNS"),
133-
ps.getParameter<double>("tdcTimeShift"),
134-
ps.getParameter<bool>("correctForPhaseContainment"),
135-
ps.getParameter<bool>("applyLegacyHBMCorrection"),
136-
std::move(m2),
137-
std::move(detFit),
138-
std::move(mahi)));
131+
algo = std::make_unique<SimpleHBHEPhase1Algo>(ps.getParameter<int>("firstSampleShift"),
132+
ps.getParameter<int>("samplesToAdd"),
133+
ps.getParameter<double>("correctionPhaseNS"),
134+
ps.getParameter<double>("tdcTimeShift"),
135+
ps.getParameter<bool>("correctForPhaseContainment"),
136+
ps.getParameter<bool>("applyLegacyHBMCorrection"),
137+
std::move(m2),
138+
std::move(detFit),
139+
std::move(mahi),
140+
iC);
139141
}
140142

141143
return algo;

0 commit comments

Comments
 (0)