Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-alca247A Bug fix to the code Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc for initialiting uncorrection of RecHit energies #45046

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Calibration/HcalCalibAlgos/plugins/HcalIsoTrackAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class HcalIsoTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
public:
explicit HcalIsoTrackAnalyzer(edm::ParameterSet const&);
~HcalIsoTrackAnalyzer() override {}
~HcalIsoTrackAnalyzer() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

Expand Down Expand Up @@ -113,6 +113,11 @@ HcalIsoTrackAnalyzer::HcalIsoTrackAnalyzer(const edm::ParameterSet& iConfig)
<< debEvents_.size() << " events to be debugged";
}

HcalIsoTrackAnalyzer::~HcalIsoTrackAnalyzer() {
if (respCorrs_)
delete respCorrs_;
}

void HcalIsoTrackAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
const HcalDbService* conditions = &iSetup.getData(tok_dbservice_);
t_Run = iEvent.id().run();
Expand Down
48 changes: 27 additions & 21 deletions Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
public:
explicit HcalIsoTrkAnalyzer(edm::ParameterSet const&);
~HcalIsoTrkAnalyzer() override {}
~HcalIsoTrkAnalyzer() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

Expand All @@ -106,15 +106,13 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
std::vector<spr::propagatedTrackID>& trkCaloDets,
const CaloGeometry* geo,
const CaloTopology* topo,
const HcalTopology* theHBHETopology,
const EcalChannelStatus* theEcalChStatus,
const EcalSeverityLevelAlgo* theEcalSevlv,
edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
edm::Handle<HBHERecHitCollection>& hbhe,
edm::Handle<CaloTowerCollection>& towerHandle,
edm::Handle<reco::GenParticleCollection>& genParticles,
const HcalRespCorrs* respCorrs,
const HcalDbService* conditions,
const edm::Handle<reco::MuonCollection>& muonh);
double dR(math::XYZTLorentzVector&, math::XYZTLorentzVector&);
Expand All @@ -123,7 +121,6 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
double eThreshold(const DetId& id, const CaloGeometry* geo) const;
DetId newId(const DetId&);
void storeEnergy(int indx,
const HcalRespCorrs* respCorrs,
const HcalDbService* conditions,
const std::vector<DetId>& ids,
std::vector<double>& edet,
Expand Down Expand Up @@ -190,6 +187,7 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
unsigned int nRun_, nLow_, nHigh_;
double a_charIsoR_, a_coneR1_, a_coneR2_;
const HcalTopology* theHBHETopology_;
HcalRespCorrs* respCorrs_;
const HcalDDDRecConstants* hdc_;
const EcalPFRecHitThresholds* eThresholds_;

Expand Down Expand Up @@ -304,14 +302,15 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
tok_sevlv_(esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd>()),
tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
tok_caloTopology_(esConsumes<CaloTopology, CaloTopologyRecord>()),
tok_htopo_(esConsumes<HcalTopology, HcalRecNumberingRecord>()),
tok_resp_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd>()),
tok_htopo_(esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun>()),
tok_resp_(esConsumes<HcalRespCorrs, HcalRespCorrsRcd, edm::Transition::BeginRun>()),
tok_dbservice_(esConsumes<HcalDbService, HcalDbRecord>()),
tok_ecalPFRecHitThresholds_(esConsumes<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd>()),
nRun_(0),
nLow_(0),
nHigh_(0),
theHBHETopology_(nullptr),
respCorrs_(nullptr),
hdc_(nullptr) {
usesResource(TFileService::kSharedResource);

Expand Down Expand Up @@ -414,6 +413,11 @@ HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig)
}
}

HcalIsoTrkAnalyzer::~HcalIsoTrkAnalyzer() {
if (respCorrs_)
delete respCorrs_;
}

void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
t_Run = iEvent.id().run();
t_Event = iEvent.id().event();
Expand All @@ -436,11 +440,9 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
// get calogeometry and calotopology
const CaloGeometry* geo = &iSetup.getData(tok_geom_);
const CaloTopology* caloTopology = &iSetup.getData(tok_caloTopology_);
const HcalTopology* theHBHETopology = &iSetup.getData(tok_htopo_);

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

//=== genParticle information
edm::Handle<reco::GenParticleCollection> genParticles = iEvent.getHandle(tok_parts_);
Expand Down Expand Up @@ -593,15 +595,13 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
trkCaloDets,
geo,
caloTopology,
theHBHETopology,
theEcalChStatus,
theEcalSevlv,
barrelRecHitsHandle,
endcapRecHitsHandle,
hbhe,
caloTower,
genParticles,
respCorrs,
conditions,
muonh);
t_TracksSaved = ntksave[0];
Expand Down Expand Up @@ -708,15 +708,13 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const
trkCaloDets,
geo,
caloTopology,
theHBHETopology,
theEcalChStatus,
theEcalSevlv,
barrelRecHitsHandle,
endcapRecHitsHandle,
hbhe,
caloTower,
genParticles,
respCorrs,
conditions,
muonh);
t_TracksSaved += ntksave[0];
Expand Down Expand Up @@ -821,6 +819,12 @@ void HcalIsoTrkAnalyzer::beginJob() {

// ------------ method called when starting to processes a run ------------
void HcalIsoTrkAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
theHBHETopology_ = &iSetup.getData(tok_htopo_);
const HcalRespCorrs* resp = &iSetup.getData(tok_resp_);
respCorrs_ = new HcalRespCorrs(*resp);
respCorrs_->setTopo(theHBHETopology_);
edm::LogVerbatim("HcalIsoTrack") << "beginRun " << iRun.run() << " get responseCoorection " << respCorrs_;

hdc_ = &iSetup.getData(tok_ddrec_);

if (!ignoreTrigger_) {
Expand Down Expand Up @@ -853,6 +857,11 @@ void HcalIsoTrkAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& i
void HcalIsoTrkAnalyzer::endRun(edm::Run const& iRun, edm::EventSetup const&) {
nRun_++;
edm::LogVerbatim("HcalIsoTrack") << "endRun[" << nRun_ << "] " << iRun.run();

if (respCorrs_) {
delete respCorrs_;
respCorrs_ = nullptr;
}
}

void HcalIsoTrkAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down Expand Up @@ -955,15 +964,13 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
std::vector<spr::propagatedTrackID>& trkCaloDets,
const CaloGeometry* geo,
const CaloTopology* caloTopology,
const HcalTopology* theHBHETopology,
const EcalChannelStatus* theEcalChStatus,
const EcalSeverityLevelAlgo* theEcalSevlv,
edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
edm::Handle<HBHERecHitCollection>& hbhe,
edm::Handle<CaloTowerCollection>& tower,
edm::Handle<reco::GenParticleCollection>& genParticles,
const HcalRespCorrs* respCorrs,
const HcalDbService* conditions,
const edm::Handle<reco::MuonCollection>& muonh) {
int nSave(0), nLoose(0), nTight(0);
Expand Down Expand Up @@ -1186,9 +1193,9 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
t_hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false);
const DetId cellH(trkDetItr.detIdHCAL);
double h5x5 = spr::eHCALmatrix(
theHBHETopology, cellH, hbhe, 2, 2, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
theHBHETopology_, cellH, hbhe, 2, 2, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
double h7x7 = spr::eHCALmatrix(
theHBHETopology, cellH, hbhe, 3, 3, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
theHBHETopology_, cellH, hbhe, 3, 3, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
t_hAnnular = h7x7 - h5x5;
#ifdef EDM_ML_DEBUG
if (debug_)
Expand Down Expand Up @@ -1221,7 +1228,7 @@ std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVec
for (unsigned k = 0; k < ids.size(); ++k)
ids[k] = newId(ids[k]);
}
storeEnergy(0, respCorrs, conditions, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);
storeEnergy(0, conditions, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);

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

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

#ifdef EDM_ML_DEBUG
if (debug_) {
Expand Down Expand Up @@ -1416,7 +1423,6 @@ DetId HcalIsoTrkAnalyzer::newId(const DetId& id) {
}

void HcalIsoTrkAnalyzer::storeEnergy(int indx,
const HcalRespCorrs* respCorrs,
const HcalDbService* conditions,
const std::vector<DetId>& ids,
std::vector<double>& edet,
Expand All @@ -1426,7 +1432,7 @@ void HcalIsoTrkAnalyzer::storeEnergy(int indx,
double ehcal(0);
if (unCorrect_) {
for (unsigned int k = 0; k < ids.size(); ++k) {
double corr = (respCorrs->getValues(ids[k]))->getValue();
double corr = (respCorrs_->getValues(ids[k]))->getValue();
if (corr != 0)
edet[k] /= corr;
ehcal += edet[k];
Expand Down