Skip to content

Commit

Permalink
cPIndices function
Browse files Browse the repository at this point in the history
  • Loading branch information
lecriste committed Feb 4, 2021
1 parent a2affb5 commit 7169675
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
void removeCPFromPU(const std::vector<CaloParticle>& caloParticles, std::vector<size_t>& cPIndices) {
//Consider CaloParticles coming from the hard scatterer
//excluding the PU contribution and save the indices.
for (unsigned int cpId = 0; cpId < caloParticles.size(); ++cpId) {
if (caloParticles[cpId].g4Tracks()[0].eventId().event() != 0 or
caloParticles[cpId].g4Tracks()[0].eventId().bunchCrossing() != 0) {
LogDebug("HGCalValidator") << "Excluding CaloParticles from event: "
<< caloParticles[cpId].g4Tracks()[0].eventId().event()
<< " with BX: " << caloParticles[cpId].g4Tracks()[0].eventId().bunchCrossing()
<< std::endl;
continue;
}
cPIndices.emplace_back(cpId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h"
#include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"

#include "SimCalorimetry/HGCalAssociatorProducers/interface/AssociatorTools.h"

LayerClusterAssociatorByEnergyScoreImpl::LayerClusterAssociatorByEnergyScoreImpl(
edm::EDProductGetter const& productGetter,
bool hardScatterOnly,
Expand All @@ -23,21 +25,11 @@ hgcal::association LayerClusterAssociatorByEnergyScoreImpl::makeConnections(
const auto& caloParticles = *cPCH.product();
auto nLayerClusters = clusters.size();
//Consider CaloParticles coming from the hard scatterer, excluding the PU contribution.
auto nCaloParticles = caloParticles.size();
std::vector<size_t> cPIndices;
//Consider CaloParticles coming from the hard scatterer
//excluding the PU contribution and save the indices.
for (unsigned int cpId = 0; cpId < nCaloParticles; ++cpId) {
if (hardScatterOnly_ && (caloParticles[cpId].g4Tracks()[0].eventId().event() != 0 or
caloParticles[cpId].g4Tracks()[0].eventId().bunchCrossing() != 0)) {
LogDebug("LayerClusterAssociatorByEnergyScoreImpl")
<< "Excluding CaloParticles from event: " << caloParticles[cpId].g4Tracks()[0].eventId().event()
<< " with BX: " << caloParticles[cpId].g4Tracks()[0].eventId().bunchCrossing() << std::endl;
continue;
}
cPIndices.emplace_back(cpId);
}
nCaloParticles = cPIndices.size();
removeCPFromPU(caloParticles, cPIndices);
auto nCaloParticles = cPIndices.size();

// Initialize cPOnLayer. To be returned outside, since it contains the
// information to compute the CaloParticle-To-LayerCluster score.
Expand Down
15 changes: 3 additions & 12 deletions Validation/HGCalValidation/plugins/HGCalValidator.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Validation/HGCalValidation/interface/HGCalValidator.h"

#include "SimCalorimetry/HGCalAssociatorProducers/interface/AssociatorTools.h"

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Expand Down Expand Up @@ -250,21 +252,10 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event,
histoProducerAlgo_->fill_info_histos(histograms.histoProducerAlgo, totallayers_to_monitor_);
}

auto nCaloParticles = caloParticles.size();
std::vector<size_t> cPIndices;
//Consider CaloParticles coming from the hard scatterer
//excluding the PU contribution and save the indices.
for (unsigned int cpId = 0; cpId < nCaloParticles; ++cpId) {
if (caloParticles[cpId].g4Tracks()[0].eventId().event() != 0 or
caloParticles[cpId].g4Tracks()[0].eventId().bunchCrossing() != 0) {
LogDebug("HGCalValidator") << "Excluding CaloParticles from event: "
<< caloParticles[cpId].g4Tracks()[0].eventId().event()
<< " with BX: " << caloParticles[cpId].g4Tracks()[0].eventId().bunchCrossing()
<< std::endl;
continue;
}
cPIndices.emplace_back(cpId);
}
removeCPFromPU(caloParticles, cPIndices);

// ##############################################
// fill caloparticles histograms
Expand Down

0 comments on commit 7169675

Please sign in to comment.