Skip to content

Commit d12fec0

Browse files
authored
Merge pull request #44967 from bsunanda/Run3-alca247X
Run3-alca247X Add possibility to uncorrect the RecHit energies for AlCaReco tests
2 parents c77a0ea + 8b9fb41 commit d12fec0

File tree

2 files changed

+123
-18
lines changed

2 files changed

+123
-18
lines changed

Calibration/HcalCalibAlgos/plugins/HcalIsoTrackAnalyzer.cc

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
// Root objects
66
#include "TTree.h"
77

8+
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
9+
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
10+
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
11+
12+
#include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
13+
#include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
14+
815
#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkCalibVariables.h"
916
#include "DataFormats/HcalCalibObjects/interface/HcalIsoTrkEventVariables.h"
1017

@@ -17,6 +24,9 @@
1724
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1825
#include "CommonTools/UtilAlgos/interface/TFileService.h"
1926

27+
#include "Geometry/CaloTopology/interface/HcalTopology.h"
28+
#include "Geometry/Records/interface/HcalRecNumberingRecord.h"
29+
2030
//#define EDM_ML_DEBUG
2131

2232
class HcalIsoTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
@@ -29,15 +39,23 @@ class HcalIsoTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, ed
2939
private:
3040
void analyze(edm::Event const&, edm::EventSetup const&) override;
3141
void beginJob() override;
32-
void beginRun(edm::Run const&, edm::EventSetup const&) override {}
42+
void beginRun(edm::Run const&, edm::EventSetup const&) override;
3343
void endRun(edm::Run const&, edm::EventSetup const&) override;
44+
double respCorr(const DetId& id);
45+
double gainFactor(const HcalDbService* dbserv, const HcalDetId& id);
3446

3547
const double pTrackLow_, pTrackHigh_;
36-
const int useRaw_, dataType_;
48+
const int useRaw_, dataType_, unCorrect_;
3749
const edm::InputTag labelIsoTkVar_, labelIsoTkEvt_;
3850
const std::vector<int> debEvents_;
51+
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> tok_htopo_;
52+
const edm::ESGetToken<HcalRespCorrs, HcalRespCorrsRcd> tok_respcorr_;
53+
const edm::ESGetToken<HcalDbService, HcalDbRecord> tok_dbservice_;
3954
edm::EDGetTokenT<HcalIsoTrkCalibVariablesCollection> tokIsoTrkVar_;
4055
edm::EDGetTokenT<HcalIsoTrkEventVariablesCollection> tokIsoTrkEvt_;
56+
const HcalTopology* theHBHETopology_;
57+
HcalRespCorrs* respCorrs_;
58+
4159
unsigned int nRun_, nRange_, nLow_, nHigh_;
4260

4361
TTree *tree, *tree2;
@@ -69,11 +87,17 @@ HcalIsoTrackAnalyzer::HcalIsoTrackAnalyzer(const edm::ParameterSet& iConfig)
6987
pTrackHigh_(iConfig.getParameter<double>("momentumHigh")),
7088
useRaw_(iConfig.getUntrackedParameter<int>("useRaw", 0)),
7189
dataType_(iConfig.getUntrackedParameter<int>("dataType", 0)),
90+
unCorrect_(iConfig.getUntrackedParameter<int>("unCorrect", 0)),
7291
labelIsoTkVar_(iConfig.getParameter<edm::InputTag>("isoTrackVarLabel")),
7392
labelIsoTkEvt_(iConfig.getParameter<edm::InputTag>("isoTrackEvtLabel")),
7493
debEvents_(iConfig.getParameter<std::vector<int>>("debugEvents")),
94+
tok_htopo_(esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun>()),
95+
tok_respcorr_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd, edm::Transition::BeginRun>()),
96+
tok_dbservice_(esConsumes<HcalDbService, HcalDbRecord>()),
7597
tokIsoTrkVar_(consumes<HcalIsoTrkCalibVariablesCollection>(labelIsoTkVar_)),
7698
tokIsoTrkEvt_(consumes<HcalIsoTrkEventVariablesCollection>(labelIsoTkEvt_)),
99+
theHBHETopology_(nullptr),
100+
respCorrs_(nullptr),
77101
nRun_(0),
78102
nRange_(0),
79103
nLow_(0),
@@ -85,11 +109,12 @@ HcalIsoTrackAnalyzer::HcalIsoTrackAnalyzer(const edm::ParameterSet& iConfig)
85109

86110
edm::LogVerbatim("HcalIsoTrack") << "Parameters read from config file \n\t momentumLow_ " << pTrackLow_
87111
<< "\t momentumHigh_ " << pTrackHigh_ << "\t useRaw_ " << useRaw_
88-
<< "\t dataType_ " << dataType_ << " and " << debEvents_.size()
89-
<< " events to be debugged";
112+
<< "\t dataType_ " << dataType_ << "\t unCorrect " << unCorrect_ << " and "
113+
<< debEvents_.size() << " events to be debugged";
90114
}
91115

92116
void HcalIsoTrackAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
117+
const HcalDbService* conditions = &iSetup.getData(tok_dbservice_);
93118
t_Run = iEvent.id().run();
94119
t_Event = iEvent.id().event();
95120
t_DataType = dataType_;
@@ -200,6 +225,27 @@ void HcalIsoTrackAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup con
200225
t_HitEnergies = itr.hitEnergies_;
201226
t_HitEnergies1 = itr.hitEnergies1_;
202227
t_HitEnergies3 = itr.hitEnergies3_;
228+
if (unCorrect_ > 0) {
229+
t_eHcal = t_eHcal10 = t_eHcal30 = 0;
230+
for (unsigned int k = 0; k < t_DetIds.size(); ++k) {
231+
double corr = (unCorrect_ == 2) ? gainFactor(conditions, HcalDetId(t_DetIds[k])) : respCorr(t_DetIds[k]);
232+
if (corr != 0)
233+
t_HitEnergies[k] /= corr;
234+
t_eHcal += t_HitEnergies[k];
235+
}
236+
for (unsigned int k = 0; k < t_DetIds1.size(); ++k) {
237+
double corr = (unCorrect_ == 2) ? gainFactor(conditions, HcalDetId(t_DetIds1[k])) : respCorr(t_DetIds1[k]);
238+
if (corr != 0)
239+
t_HitEnergies1[k] /= corr;
240+
t_eHcal10 += t_HitEnergies1[k];
241+
}
242+
for (unsigned int k = 0; k < t_DetIds3.size(); ++k) {
243+
double corr = (unCorrect_ == 2) ? gainFactor(conditions, HcalDetId(t_DetIds3[k])) : respCorr(t_DetIds3[k]);
244+
if (corr != 0)
245+
t_HitEnergies3[k] /= corr;
246+
t_eHcal30 += t_HitEnergies3[k];
247+
}
248+
}
203249
}
204250
#ifdef EDM_ML_DEBUG
205251
if (debug)
@@ -324,13 +370,24 @@ void HcalIsoTrackAnalyzer::beginJob() {
324370
}
325371

326372
// ------------ method called when starting to processes a run ------------
373+
void HcalIsoTrackAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
374+
theHBHETopology_ = &iSetup.getData(tok_htopo_);
375+
const HcalRespCorrs* resp = &iSetup.getData(tok_respcorr_);
376+
respCorrs_ = new HcalRespCorrs(*resp);
377+
respCorrs_->setTopo(theHBHETopology_);
378+
edm::LogVerbatim("HcalIsoTrack") << "beginRun " << iRun.run() << " get responseCoorection " << respCorrs_;
379+
}
327380

328381
// ------------ method called when ending the processing of a run ------------
329382
void HcalIsoTrackAnalyzer::endRun(edm::Run const& iRun, edm::EventSetup const&) {
330383
nRun_++;
331384
edm::LogVerbatim("HcalIsoTrack") << "endRun[" << nRun_ << "] " << iRun.run() << " with " << nLow_
332385
<< " events with p < " << pTrackLow_ << ", " << nHigh_ << " events with p > "
333386
<< pTrackHigh_ << ", and " << nRange_ << " events in the right momentum range";
387+
if (respCorrs_) {
388+
delete respCorrs_;
389+
respCorrs_ = nullptr;
390+
}
334391
}
335392

336393
void HcalIsoTrackAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
@@ -339,12 +396,28 @@ void HcalIsoTrackAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& desc
339396
desc.add<double>("momentumHigh", 60.0);
340397
desc.addUntracked<int>("useRaw", 0);
341398
desc.addUntracked<int>("dataType", 0);
399+
desc.addUntracked<int>("unCorrect", 0);
342400
desc.add<edm::InputTag>("isoTrackVarLabel", edm::InputTag("alcaHcalIsotrkProducer", "HcalIsoTrack"));
343401
desc.add<edm::InputTag>("isoTrackEvtLabel", edm::InputTag("alcaHcalIsotrkProducer", "HcalIsoTrackEvent"));
344402
std::vector<int> events;
345403
desc.add<std::vector<int>>("debugEvents", events);
346404
descriptions.add("hcalIsoTrackAnalyzer", desc);
347405
}
348406

407+
double HcalIsoTrackAnalyzer::respCorr(const DetId& id) {
408+
double cfac(1.0);
409+
if (respCorrs_ != nullptr)
410+
cfac = (respCorrs_->getValues(id))->getValue();
411+
return cfac;
412+
}
413+
414+
double HcalIsoTrackAnalyzer::gainFactor(const HcalDbService* conditions, const HcalDetId& id) {
415+
double gain(0.0);
416+
const HcalCalibrations& calibs = conditions->getHcalCalibrations(id);
417+
for (int capid = 0; capid < 4; ++capid)
418+
gain += (0.25 * calibs.respcorrgain(capid));
419+
return gain;
420+
}
421+
349422
//define this as a plug-in
350423
DEFINE_FWK_MODULE(HcalIsoTrackAnalyzer);

Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77
#include "TLorentzVector.h"
88
#include "TTree.h"
99

10-
#include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
10+
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
11+
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
12+
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
13+
1114
#include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
15+
#include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
16+
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
17+
#include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
18+
#include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
1219

1320
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
1421
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
@@ -41,10 +48,6 @@
4148
#include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
4249
#include "DataFormats/L1Trigger/interface/BXVector.h"
4350

44-
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
45-
#include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
46-
#include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
47-
4851
//Generator information
4952
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
5053
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
@@ -112,6 +115,7 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
112115
edm::Handle<CaloTowerCollection>& towerHandle,
113116
edm::Handle<reco::GenParticleCollection>& genParticles,
114117
const HcalRespCorrs* respCorrs,
118+
const HcalDbService* conditions,
115119
const edm::Handle<reco::MuonCollection>& muonh);
116120
double dR(math::XYZTLorentzVector&, math::XYZTLorentzVector&);
117121
double trackP(const reco::Track*, const edm::Handle<reco::GenParticleCollection>&);
@@ -120,12 +124,14 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
120124
DetId newId(const DetId&);
121125
void storeEnergy(int indx,
122126
const HcalRespCorrs* respCorrs,
127+
const HcalDbService* conditions,
123128
const std::vector<DetId>& ids,
124129
std::vector<double>& edet,
125130
double& eHcal,
126131
std::vector<unsigned int>* detIds,
127132
std::vector<double>* hitEnergies);
128133
bool notaMuon(const reco::Track* pTrack0, const edm::Handle<reco::MuonCollection>& muonh);
134+
double gainFactor(const HcalDbService* dbserv, const HcalDetId& id);
129135

130136
l1t::L1TGlobalUtil* l1GtUtils_;
131137
HLTConfigProvider hltConfig_;
@@ -142,7 +148,7 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
142148
const int prescaleLow_, prescaleHigh_;
143149
const int useRaw_, dataType_, mode_;
144150
const bool ignoreTrigger_, useL1Trigger_;
145-
const bool unCorrect_, collapseDepth_;
151+
const bool unCorrect_, getCharge_, collapseDepth_;
146152
const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_;
147153
const double hitEthrEE2_, hitEthrEE3_;
148154
const double hitEthrEELo_, hitEthrEEHi_;
@@ -178,10 +184,12 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
178184
const edm::ESGetToken<CaloTopology, CaloTopologyRecord> tok_caloTopology_;
179185
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> tok_htopo_;
180186
const edm::ESGetToken<HcalRespCorrs, HcalRespCorrsRcd> tok_resp_;
187+
const edm::ESGetToken<HcalDbService, HcalDbRecord> tok_dbservice_;
181188
const edm::ESGetToken<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd> tok_ecalPFRecHitThresholds_;
182189

183190
unsigned int nRun_, nLow_, nHigh_;
184191
double a_charIsoR_, a_coneR1_, a_coneR2_;
192+
const HcalTopology* theHBHETopology_;
185193
const HcalDDDRecConstants* hdc_;
186194
const EcalPFRecHitThresholds* eThresholds_;
187195

@@ -244,6 +252,7 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
244252
ignoreTrigger_(iConfig.getUntrackedParameter<bool>("ignoreTriggers", false)),
245253
useL1Trigger_(iConfig.getUntrackedParameter<bool>("useL1Trigger", false)),
246254
unCorrect_(iConfig.getUntrackedParameter<bool>("unCorrect", false)),
255+
getCharge_(iConfig.getUntrackedParameter<bool>("getCharge")),
247256
collapseDepth_(iConfig.getUntrackedParameter<bool>("collapseDepth", false)),
248257
hitEthrEB_(iConfig.getParameter<double>("EBHitEnergyThreshold")),
249258
hitEthrEE0_(iConfig.getParameter<double>("EEHitEnergyThreshold0")),
@@ -297,10 +306,12 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
297306
tok_caloTopology_(esConsumes<CaloTopology, CaloTopologyRecord>()),
298307
tok_htopo_(esConsumes<HcalTopology, HcalRecNumberingRecord>()),
299308
tok_resp_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd>()),
309+
tok_dbservice_(esConsumes<HcalDbService, HcalDbRecord>()),
300310
tok_ecalPFRecHitThresholds_(esConsumes<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd>()),
301311
nRun_(0),
302312
nLow_(0),
303313
nHigh_(0),
314+
theHBHETopology_(nullptr),
304315
hdc_(nullptr) {
305316
usesResource(TFileService::kSharedResource);
306317

@@ -368,10 +379,10 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
368379
<< "\t momentumHigh_ " << pTrackHigh_ << "\t prescaleHigh_ " << prescaleHigh_ << "\n\t useRaw_ " << useRaw_
369380
<< "\t ignoreTrigger_ " << ignoreTrigger_ << "\n\t useL1Trigegr_ " << useL1Trigger_ << "\t dataType_ "
370381
<< dataType_ << "\t mode_ " << mode_ << "\t unCorrect_ " << unCorrect_ << "\t collapseDepth_ "
371-
<< collapseDepth_ << "\t L1TrigName_ " << l1TrigName_ << "\nThreshold flag used " << usePFThresh_
372-
<< " value for EB " << hitEthrEB_ << " EE " << hitEthrEE0_ << ":" << hitEthrEE1_ << ":" << hitEthrEE2_ << ":"
373-
<< hitEthrEE3_ << ":" << hitEthrEELo_ << ":" << hitEthrEEHi_ << " and " << debEvents_.size()
374-
<< " events to be debugged";
382+
<< collapseDepth_ << "\t GetCharge " << getCharge_ << "\t L1TrigName_ " << l1TrigName_
383+
<< "\nThreshold flag used " << usePFThresh_ << " value for EB " << hitEthrEB_ << " EE " << hitEthrEE0_ << ":"
384+
<< hitEthrEE1_ << ":" << hitEthrEE2_ << ":" << hitEthrEE3_ << ":" << hitEthrEELo_ << ":" << hitEthrEEHi_
385+
<< " and " << debEvents_.size() << " events to be debugged";
375386
edm::LogVerbatim("HcalIsoTrack") << "Process " << processName_ << " L1Filter:" << l1Filter_
376387
<< " L2Filter:" << l2Filter_ << " L3Filter:" << l3Filter_;
377388
for (unsigned int k = 0; k < trigNames_.size(); ++k) {
@@ -428,6 +439,7 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
428439
const HcalTopology* theHBHETopology = &iSetup.getData(tok_htopo_);
429440

430441
// get Hcal response corrections
442+
const HcalDbService* conditions = &iSetup.getData(tok_dbservice_);
431443
const HcalRespCorrs* respCorrs = &iSetup.getData(tok_resp_);
432444

433445
//=== genParticle information
@@ -590,6 +602,7 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
590602
caloTower,
591603
genParticles,
592604
respCorrs,
605+
conditions,
593606
muonh);
594607
t_TracksSaved = ntksave[0];
595608
t_TracksLoose = ntksave[1];
@@ -704,6 +717,7 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
704717
caloTower,
705718
genParticles,
706719
respCorrs,
720+
conditions,
707721
muonh);
708722
t_TracksSaved += ntksave[0];
709723
t_TracksLoose += ntksave[1];
@@ -920,6 +934,7 @@ void HcalIsoTrkAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descri
920934
desc.addUntracked<double>("hcalScale", 1.0);
921935
desc.addUntracked<int>("dataType", 0);
922936
desc.addUntracked<bool>("unCorrect", false);
937+
desc.addUntracked<bool>("getCharge", false);
923938
desc.addUntracked<bool>("collapseDepth", false);
924939
desc.addUntracked<std::string>("l1TrigName", "L1_SingleJet60");
925940
desc.addUntracked<int>("outMode", 11);
@@ -949,6 +964,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
949964
edm::Handle<CaloTowerCollection>& tower,
950965
edm::Handle<reco::GenParticleCollection>& genParticles,
951966
const HcalRespCorrs* respCorrs,
967+
const HcalDbService* conditions,
952968
const edm::Handle<reco::MuonCollection>& muonh) {
953969
int nSave(0), nLoose(0), nTight(0);
954970
//Loop over tracks
@@ -1205,7 +1221,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
12051221
for (unsigned k = 0; k < ids.size(); ++k)
12061222
ids[k] = newId(ids[k]);
12071223
}
1208-
storeEnergy(0, respCorrs, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);
1224+
storeEnergy(0, respCorrs, conditions, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);
12091225

12101226
//----- hcal energy in the extended cone 1 (a_coneR+10) --------------
12111227
t_eHcal10 = spr::eCone_hcal(geo,
@@ -1222,7 +1238,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
12221238
for (unsigned k = 0; k < ids1.size(); ++k)
12231239
ids1[k] = newId(ids1[k]);
12241240
}
1225-
storeEnergy(1, respCorrs, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1);
1241+
storeEnergy(1, respCorrs, conditions, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1);
12261242

12271243
//----- hcal energy in the extended cone 3 (a_coneR+30) --------------
12281244
t_eHcal30 = spr::eCone_hcal(geo,
@@ -1239,7 +1255,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
12391255
for (unsigned k = 0; k < ids3.size(); ++k)
12401256
ids3[k] = newId(ids3[k]);
12411257
}
1242-
storeEnergy(3, respCorrs, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3);
1258+
storeEnergy(3, respCorrs, conditions, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3);
12431259

12441260
#ifdef EDM_ML_DEBUG
12451261
if (debug_) {
@@ -1401,6 +1417,7 @@ DetId HcalIsoTrkAnalyzer::newId(const DetId& id) {
14011417

14021418
void HcalIsoTrkAnalyzer::storeEnergy(int indx,
14031419
const HcalRespCorrs* respCorrs,
1420+
const HcalDbService* conditions,
14041421
const std::vector<DetId>& ids,
14051422
std::vector<double>& edet,
14061423
double& eHcal,
@@ -1414,11 +1431,18 @@ void HcalIsoTrkAnalyzer::storeEnergy(int indx,
14141431
edet[k] /= corr;
14151432
ehcal += edet[k];
14161433
}
1434+
} else if (getCharge_) {
1435+
for (unsigned int k = 0; k < ids.size(); ++k) {
1436+
double gain = gainFactor(conditions, HcalDetId(ids[k]));
1437+
if (gain != 0)
1438+
edet[k] /= gain;
1439+
ehcal += edet[k];
1440+
}
14171441
} else {
14181442
for (const auto& en : edet)
14191443
ehcal += en;
14201444
}
1421-
if ((std::abs(ehcal - eHcal) > 0.001) && (!unCorrect_))
1445+
if ((std::abs(ehcal - eHcal) > 0.001) && (!unCorrect_) && (!getCharge_))
14221446
edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << indx << " " << eHcal << ":" << ehcal
14231447
<< " from " << ids.size() << " cells";
14241448
eHcal = hcalScale_ * ehcal;
@@ -1485,5 +1509,13 @@ bool HcalIsoTrkAnalyzer::notaMuon(const reco::Track* pTrack0, const edm::Handle<
14851509
return flag;
14861510
}
14871511

1512+
double HcalIsoTrkAnalyzer::gainFactor(const HcalDbService* conditions, const HcalDetId& id) {
1513+
double gain(0.0);
1514+
const HcalCalibrations& calibs = conditions->getHcalCalibrations(id);
1515+
for (int capid = 0; capid < 4; ++capid)
1516+
gain += (0.25 * calibs.respcorrgain(capid));
1517+
return gain;
1518+
}
1519+
14881520
//define this as a plug-in
14891521
DEFINE_FWK_MODULE(HcalIsoTrkAnalyzer);

0 commit comments

Comments
 (0)