From 5e39c2a5d1513f0129f5aeab09edab4811ed8216 Mon Sep 17 00:00:00 2001 From: Shah Rukh Qasim Date: Mon, 26 Feb 2018 11:36:45 +0100 Subject: [PATCH 1/2] Add indices with simcluster hits and fractions --- HGCalAnalysis/plugins/HGCalAnalysis.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/HGCalAnalysis/plugins/HGCalAnalysis.cc b/HGCalAnalysis/plugins/HGCalAnalysis.cc index b965260..f500d8d 100644 --- a/HGCalAnalysis/plugins/HGCalAnalysis.cc +++ b/HGCalAnalysis/plugins/HGCalAnalysis.cc @@ -349,6 +349,7 @@ class HGCalAnalysis : public edm::one::EDAnalyzer simcluster_energy_; std::vector simcluster_simEnergy_; std::vector> simcluster_hits_; + std::vector> simcluster_hits_indices_; std::vector> simcluster_fractions_; std::vector> simcluster_layers_; std::vector> simcluster_wafers_; @@ -687,6 +688,7 @@ HGCalAnalysis::HGCalAnalysis(const edm::ParameterSet &iConfig) t_->Branch("simcluster_energy", &simcluster_energy_); t_->Branch("simcluster_simEnergy", &simcluster_simEnergy_); t_->Branch("simcluster_hits", &simcluster_hits_); + t_->Branch("simcluster_hits_indices", &simcluster_hits_indices_); t_->Branch("simcluster_fractions", &simcluster_fractions_); t_->Branch("simcluster_layers", &simcluster_layers_); t_->Branch("simcluster_wafers", &simcluster_wafers_); @@ -873,6 +875,7 @@ void HGCalAnalysis::clearVariables() { rechit_isHalf_.clear(); rechit_flags_.clear(); rechit_cluster2d_.clear(); + detIdToRecHitIndexMap_.clear(); //////////////////// // layer clusters @@ -934,6 +937,7 @@ void HGCalAnalysis::clearVariables() { simcluster_energy_.clear(); simcluster_simEnergy_.clear(); simcluster_hits_.clear(); + simcluster_hits_indices_.clear(); simcluster_fractions_.clear(); simcluster_layers_.clear(); simcluster_wafers_.clear(); @@ -1413,6 +1417,7 @@ void HGCalAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSe const std::vector> hits_and_fractions = it_simClus->hits_and_fractions(); std::vector hits; + std::vector hits_indices; std::vector fractions; std::vector layers; std::vector wafers; @@ -1420,6 +1425,10 @@ void HGCalAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSe for (std::vector>::const_iterator it_haf = hits_and_fractions.begin(); it_haf != hits_and_fractions.end(); ++it_haf) { + auto index_iterator = detIdToRecHitIndexMap_.find( it_haf->first); + if(index_iterator == detIdToRecHitIndexMap_.end()) + continue; + hits_indices.push_back(index_iterator->second); hits.push_back(it_haf->first); fractions.push_back(it_haf->second); layers.push_back(recHitTools_.getLayerWithOffset(it_haf->first)); @@ -1438,6 +1447,7 @@ void HGCalAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSe simcluster_energy_.push_back(it_simClus->energy()); simcluster_simEnergy_.push_back(it_simClus->simEnergy()); simcluster_hits_.push_back(hits); + simcluster_hits_indices_.push_back(hits_indices); simcluster_fractions_.push_back(fractions); simcluster_layers_.push_back(layers); simcluster_wafers_.push_back(wafers); From 21510f5fd9ccfd047c4e37806bba9f07881e73a5 Mon Sep 17 00:00:00 2001 From: Shah Rukh Qasim Date: Mon, 19 Mar 2018 10:54:52 +0100 Subject: [PATCH 2/2] Don't remove simcluster hits which have no corresponding rechits --- HGCalAnalysis/plugins/HGCalAnalysis.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/HGCalAnalysis/plugins/HGCalAnalysis.cc b/HGCalAnalysis/plugins/HGCalAnalysis.cc index f500d8d..d4991f7 100644 --- a/HGCalAnalysis/plugins/HGCalAnalysis.cc +++ b/HGCalAnalysis/plugins/HGCalAnalysis.cc @@ -349,7 +349,7 @@ class HGCalAnalysis : public edm::one::EDAnalyzer simcluster_energy_; std::vector simcluster_simEnergy_; std::vector> simcluster_hits_; - std::vector> simcluster_hits_indices_; + std::vector> simcluster_hits_indices_; std::vector> simcluster_fractions_; std::vector> simcluster_layers_; std::vector> simcluster_wafers_; @@ -1417,7 +1417,7 @@ void HGCalAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSe const std::vector> hits_and_fractions = it_simClus->hits_and_fractions(); std::vector hits; - std::vector hits_indices; + std::vector hits_indices; std::vector fractions; std::vector layers; std::vector wafers; @@ -1426,9 +1426,10 @@ void HGCalAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSe hits_and_fractions.begin(); it_haf != hits_and_fractions.end(); ++it_haf) { auto index_iterator = detIdToRecHitIndexMap_.find( it_haf->first); - if(index_iterator == detIdToRecHitIndexMap_.end()) - continue; - hits_indices.push_back(index_iterator->second); + int index_simcluster = -1; + if(index_iterator != detIdToRecHitIndexMap_.end()) + index_simcluster = index_iterator->second; + hits_indices.push_back(index_simcluster); hits.push_back(it_haf->first); fractions.push_back(it_haf->second); layers.push_back(recHitTools_.getLayerWithOffset(it_haf->first));