CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PreMixingCaloParticleWorker Class Reference
Inheritance diagram for PreMixingCaloParticleWorker:
PreMixingWorker

Public Member Functions

void addPileups (PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
 
void addSignals (edm::Event const &iEvent, edm::EventSetup const &iSetup) override
 
void initializeEvent (edm::Event const &iEvent, edm::EventSetup const &iSetup) override
 
 PreMixingCaloParticleWorker (const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
 
void put (edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
 
 ~PreMixingCaloParticleWorker () override=default
 
- Public Member Functions inherited from PreMixingWorker
virtual void beginLuminosityBlock (edm::LuminosityBlock const &iLumi, edm::EventSetup const &iSetup)
 
virtual void beginRun (edm::Run const &iRun, edm::EventSetup const &iSetup)
 
virtual void endRun ()
 
virtual void finalizeBunchCrossing (edm::Event &iEvent, edm::EventSetup const &iSetup, int bunchCrossing)
 
virtual void initializeBunchCrossing (edm::Event const &iEvent, edm::EventSetup const &iSetup, int bunchCrossing)
 
 PreMixingWorker ()=default
 
virtual ~PreMixingWorker ()=default
 

Private Types

using EnergyMap = std::vector< std::pair< unsigned, float > >
 

Private Member Functions

void add (const SimClusterCollection &clusters, const CaloParticleCollection &particles, const EnergyMap &energyMap)
 

Private Attributes

SimClusterRefProd clusterRef_
 
std::unique_ptr< SimClusterCollectionnewClusters_
 
std::unique_ptr< CaloParticleCollectionnewParticles_
 
std::string particleCollectionDM_
 
edm::InputTag particlePileInputTag_
 
edm::EDGetTokenT< SimClusterCollectionsigClusterToken_
 
edm::EDGetTokenT< EnergyMapsigEnergyToken_
 
edm::EDGetTokenT< CaloParticleCollectionsigParticleToken_
 
std::unordered_map< unsigned, float > totalEnergy_
 

Detailed Description

Definition at line 17 of file PreMixingCaloParticleWorker.cc.

Member Typedef Documentation

◆ EnergyMap

using PreMixingCaloParticleWorker::EnergyMap = std::vector<std::pair<unsigned, float> >
private

Definition at line 31 of file PreMixingCaloParticleWorker.cc.

Constructor & Destructor Documentation

◆ PreMixingCaloParticleWorker()

PreMixingCaloParticleWorker::PreMixingCaloParticleWorker ( const edm::ParameterSet ps,
edm::ProducesCollector  producesCollector,
edm::ConsumesCollector &&  iC 
)

◆ ~PreMixingCaloParticleWorker()

PreMixingCaloParticleWorker::~PreMixingCaloParticleWorker ( )
overridedefault

Member Function Documentation

◆ add()

void PreMixingCaloParticleWorker::add ( const SimClusterCollection clusters,
const CaloParticleCollection particles,
const EnergyMap energyMap 
)
private

Definition at line 101 of file PreMixingCaloParticleWorker.cc.

103  {
104  const size_t startingIndex = newClusters_->size();
105 
106  // Copy SimClusters
107  newClusters_->reserve(newClusters_->size() + clusters.size());
108  std::copy(clusters.begin(), clusters.end(), std::back_inserter(*newClusters_));
109 
110  // Copy CaloParticles
111  newParticles_->reserve(newParticles_->size() + particles.size());
112  for (const auto &p : particles) {
113  newParticles_->push_back(p);
114  auto &particle = newParticles_->back();
115 
116  // re-key the refs to SimClusters
117  particle.clearSimClusters();
118  for (const auto &ref : p.simClusters()) {
119  particle.addSimCluster(SimClusterRef(clusterRef_, startingIndex + ref.index()));
120  }
121  }
122 
123  // Add energies
124  for (const auto &elem : energy) {
125  totalEnergy_[elem.first] += elem.second;
126  }
127 }

References clusterRef_, bsc_activity_cfg::clusters, filterCSVwithJSON::copy, HCALHighEnergyHPDFilter_cfi::energy, newClusters_, newParticles_, AlCaHLTBitMon_ParallelJobs::p, ecalTrigSettings_cff::particles, and totalEnergy_.

Referenced by addPileups(), addSignals(), and counter.Counter::register().

◆ addPileups()

void PreMixingCaloParticleWorker::addPileups ( PileUpEventPrincipal const &  pep,
edm::EventSetup const &  iSetup 
)
overridevirtual

◆ addSignals()

void PreMixingCaloParticleWorker::addSignals ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

◆ initializeEvent()

void PreMixingCaloParticleWorker::initializeEvent ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements PreMixingWorker.

Definition at line 61 of file PreMixingCaloParticleWorker.cc.

61  {
62  newClusters_ = std::make_unique<SimClusterCollection>();
63  newParticles_ = std::make_unique<CaloParticleCollection>();
64 
65  // need RefProds in order to re-key the CaloParticle->SimCluster refs
66  // TODO: try to remove const_cast, requires making Event non-const in
67  // BMixingModule::initializeEvent
68  clusterRef_ = const_cast<edm::Event &>(iEvent).getRefBeforePut<SimClusterCollection>(particleCollectionDM_);
69 }

References clusterRef_, iEvent, newClusters_, newParticles_, and particleCollectionDM_.

◆ put()

void PreMixingCaloParticleWorker::put ( edm::Event iEvent,
edm::EventSetup const &  iSetup,
std::vector< PileupSummaryInfo > const &  ps,
int  bunchSpacing 
)
overridevirtual

Implements PreMixingWorker.

Definition at line 129 of file PreMixingCaloParticleWorker.cc.

132  {
133  for (auto &sc : *newClusters_) {
134  auto hitsAndEnergies = sc.hits_and_fractions();
135  sc.clearHitsAndFractions();
136  for (auto &hAndE : hitsAndEnergies) {
137  const float totalenergy = totalEnergy_[hAndE.first];
138  float fraction = 0.;
139  if (totalenergy > 0)
140  fraction = hAndE.second / totalenergy;
141  else
142  edm::LogWarning("PreMixingParticleWorker")
143  << "TotalSimEnergy for hit " << hAndE.first << " is 0! The fraction for this hit cannot be computed.";
144  sc.addRecHitAndFraction(hAndE.first, fraction);
145  }
146  }
147 
148  // clear memory
149  std::unordered_map<unsigned, float>{}.swap(totalEnergy_);
150 
153 }

References HLT_FULL_cff::fraction, iEvent, eostools::move(), newClusters_, newParticles_, particleCollectionDM_, and totalEnergy_.

Member Data Documentation

◆ clusterRef_

SimClusterRefProd PreMixingCaloParticleWorker::clusterRef_
private

Definition at line 46 of file PreMixingCaloParticleWorker.cc.

Referenced by add(), and initializeEvent().

◆ newClusters_

std::unique_ptr<SimClusterCollection> PreMixingCaloParticleWorker::newClusters_
private

Definition at line 44 of file PreMixingCaloParticleWorker.cc.

Referenced by add(), initializeEvent(), and put().

◆ newParticles_

std::unique_ptr<CaloParticleCollection> PreMixingCaloParticleWorker::newParticles_
private

Definition at line 45 of file PreMixingCaloParticleWorker.cc.

Referenced by add(), initializeEvent(), and put().

◆ particleCollectionDM_

std::string PreMixingCaloParticleWorker::particleCollectionDM_
private

◆ particlePileInputTag_

edm::InputTag PreMixingCaloParticleWorker::particlePileInputTag_
private

Definition at line 39 of file PreMixingCaloParticleWorker.cc.

Referenced by addPileups().

◆ sigClusterToken_

edm::EDGetTokenT<SimClusterCollection> PreMixingCaloParticleWorker::sigClusterToken_
private

Definition at line 35 of file PreMixingCaloParticleWorker.cc.

Referenced by addSignals().

◆ sigEnergyToken_

edm::EDGetTokenT<EnergyMap> PreMixingCaloParticleWorker::sigEnergyToken_
private

Definition at line 37 of file PreMixingCaloParticleWorker.cc.

Referenced by addSignals().

◆ sigParticleToken_

edm::EDGetTokenT<CaloParticleCollection> PreMixingCaloParticleWorker::sigParticleToken_
private

Definition at line 36 of file PreMixingCaloParticleWorker.cc.

Referenced by addSignals().

◆ totalEnergy_

std::unordered_map<unsigned, float> PreMixingCaloParticleWorker::totalEnergy_
private

Definition at line 42 of file PreMixingCaloParticleWorker.cc.

Referenced by add(), and put().

SimClusterCollection
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
SimClusterRef
edm::Ref< SimClusterCollection > SimClusterRef
Definition: SimClusterFwd.h:10
edm::Handle< SimClusterCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
PreMixingCaloParticleWorker::totalEnergy_
std::unordered_map< unsigned, float > totalEnergy_
Definition: PreMixingCaloParticleWorker.cc:42
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52823
PreMixingCaloParticleWorker::clusterRef_
SimClusterRefProd clusterRef_
Definition: PreMixingCaloParticleWorker.cc:46
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
PreMixingCaloParticleWorker::EnergyMap
std::vector< std::pair< unsigned, float > > EnergyMap
Definition: PreMixingCaloParticleWorker.cc:31
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
CaloParticleCollection
std::vector< CaloParticle > CaloParticleCollection
Definition: CaloParticleFwd.h:8
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PreMixingCaloParticleWorker::newParticles_
std::unique_ptr< CaloParticleCollection > newParticles_
Definition: PreMixingCaloParticleWorker.cc:45
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
PreMixingCaloParticleWorker::sigEnergyToken_
edm::EDGetTokenT< EnergyMap > sigEnergyToken_
Definition: PreMixingCaloParticleWorker.cc:37
PreMixingCaloParticleWorker::particlePileInputTag_
edm::InputTag particlePileInputTag_
Definition: PreMixingCaloParticleWorker.cc:39
PreMixingCaloParticleWorker::sigClusterToken_
edm::EDGetTokenT< SimClusterCollection > sigClusterToken_
Definition: PreMixingCaloParticleWorker.cc:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PreMixingCaloParticleWorker::newClusters_
std::unique_ptr< SimClusterCollection > newClusters_
Definition: PreMixingCaloParticleWorker.cc:44
PreMixingCaloParticleWorker::sigParticleToken_
edm::EDGetTokenT< CaloParticleCollection > sigParticleToken_
Definition: PreMixingCaloParticleWorker.cc:36
PreMixingCaloParticleWorker::add
void add(const SimClusterCollection &clusters, const CaloParticleCollection &particles, const EnergyMap &energyMap)
Definition: PreMixingCaloParticleWorker.cc:101
edm::InputTag
Definition: InputTag.h:15
PreMixingCaloParticleWorker::particleCollectionDM_
std::string particleCollectionDM_
Definition: PreMixingCaloParticleWorker.cc:40