CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
CaloTruthAccumulator Class Reference
Inheritance diagram for CaloTruthAccumulator:
DigiAccumulatorMixMod

Classes

struct  calo_particles
 
struct  OutputCollections
 

Public Member Functions

 CaloTruthAccumulator (const edm::ParameterSet &config, edm::ProducesCollector, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from DigiAccumulatorMixMod
virtual void beginRun (edm::Run const &run, edm::EventSetup const &setup)
 
 DigiAccumulatorMixMod ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void endRun (edm::Run const &run, edm::EventSetup const &setup)
 
virtual void finalizeBunchCrossing (edm::Event &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual PileupMixingContentgetEventPileupInfo ()
 
virtual void initializeBunchCrossing (edm::Event const &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual void StorePileupInformation (std::vector< int > &numInteractionList, std::vector< int > &bunchCrossingList, std::vector< float > &TrueInteractionList, std::vector< edm::EventID > &eventList, int bunchSpace)
 
virtual ~DigiAccumulatorMixMod ()
 

Private Member Functions

void accumulate (const edm::Event &event, const edm::EventSetup &setup) override
 
void accumulate (const PileUpEventPrincipal &event, const edm::EventSetup &setup, edm::StreamID const &) override
 
template<class T >
void accumulateEvent (const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
 Both forms of accumulate() delegate to this templated method. More...
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
 
template<class T >
void fillSimHits (std::vector< std::pair< DetId, const PCaloHit * >> &returnValue, std::unordered_map< int, std::map< int, float >> &simTrackDetIdEnergyMap, const T &event, const edm::EventSetup &setup)
 Fills the supplied vector with pointers to the SimHits, checking for bad modules if required. More...
 
void finalizeEvent (edm::Event &event, const edm::EventSetup &setup) override
 
void initializeEvent (const edm::Event &event, const edm::EventSetup &setup) override
 

Private Attributes

std::vector< edm::InputTagcollectionTags_
 
bool doHGCAL
 
edm::InputTag genParticleLabel_
 
int geometryType_
 
const HcalDDDRecConstantshcddd_ = nullptr
 
edm::InputTag hepMCproductLabel_
 Needed to add HepMC::GenVertex to SimVertex. More...
 
const HGCalDDDConstantshgddd_ [3] = {nullptr, nullptr, nullptr}
 
const HGCalTopologyhgtopo_ [3] = {nullptr, nullptr, nullptr}
 
edm::Handle< std::vector< SimTrack > > hSimTracks
 
edm::Handle< std::vector< SimVertex > > hSimVertices
 
calo_particles m_caloParticles
 
std::unordered_map< Index_t, float > m_detIdToTotalSimEnergy
 
std::unordered_multimap< Barcode_t, Index_t > m_simHitBarcodeToIndex
 
const unsigned int maximumPreviousBunchCrossing_
 
const unsigned int maximumSubsequentBunchCrossing_
 
const double maxPseudoRapidity_
 
const std::string messageCategory_
 
const double minEnergy_
 
OutputCollections output_
 
const bool premixStage1_
 
const edm::InputTag simTrackLabel_
 
const edm::InputTag simVertexLabel_
 

Detailed Description

Definition at line 126 of file CaloTruthAccumulator.cc.

Constructor & Destructor Documentation

◆ CaloTruthAccumulator()

CaloTruthAccumulator::CaloTruthAccumulator ( const edm::ParameterSet config,
edm::ProducesCollector  producesCollector,
edm::ConsumesCollector iC 
)
explicit

Definition at line 360 of file CaloTruthAccumulator.cc.

363  : messageCategory_("CaloTruthAccumulator"),
364  maximumPreviousBunchCrossing_(config.getParameter<unsigned int>("maximumPreviousBunchCrossing")),
365  maximumSubsequentBunchCrossing_(config.getParameter<unsigned int>("maximumSubsequentBunchCrossing")),
366  simTrackLabel_(config.getParameter<edm::InputTag>("simTrackCollection")),
367  simVertexLabel_(config.getParameter<edm::InputTag>("simVertexCollection")),
368  collectionTags_(),
369  genParticleLabel_(config.getParameter<edm::InputTag>("genParticleCollection")),
370  hepMCproductLabel_(config.getParameter<edm::InputTag>("HepMCProductLabel")),
371  minEnergy_(config.getParameter<double>("MinEnergy")),
372  maxPseudoRapidity_(config.getParameter<double>("MaxPseudoRapidity")),
373  premixStage1_(config.getParameter<bool>("premixStage1")),
374  geometryType_(-1),
375  doHGCAL(config.getParameter<bool>("doHGCAL")) {
376  producesCollector.produces<SimClusterCollection>("MergedCaloTruth");
377  producesCollector.produces<CaloParticleCollection>("MergedCaloTruth");
378  if (premixStage1_) {
379  producesCollector.produces<std::vector<std::pair<unsigned int, float>>>("MergedCaloTruth");
380  }
381 
382  iC.consumes<std::vector<SimTrack>>(simTrackLabel_);
383  iC.consumes<std::vector<SimVertex>>(simVertexLabel_);
384  iC.consumes<std::vector<reco::GenParticle>>(genParticleLabel_);
385  iC.consumes<std::vector<int>>(genParticleLabel_);
386  iC.consumes<std::vector<int>>(hepMCproductLabel_);
387 
388  // Fill the collection tags
389  const edm::ParameterSet &simHitCollectionConfig = config.getParameterSet("simHitCollections");
390  std::vector<std::string> parameterNames = simHitCollectionConfig.getParameterNames();
391 
392  for (auto const &parameterName : parameterNames) {
393  std::vector<edm::InputTag> tags = simHitCollectionConfig.getParameter<std::vector<edm::InputTag>>(parameterName);
394  collectionTags_.insert(collectionTags_.end(), tags.begin(), tags.end());
395  }
396 
397  for (auto const &collectionTag : collectionTags_) {
398  iC.consumes<std::vector<PCaloHit>>(collectionTag);
399  }
400 }

References collectionTags_, edm::ConsumesCollector::consumes(), genParticleLabel_, hepMCproductLabel_, premixStage1_, edm::ProducesCollector::produces(), simTrackLabel_, simVertexLabel_, and triggerMatcherToHLTDebug_cfi::tags.

Member Function Documentation

◆ accumulate() [1/2]

void CaloTruthAccumulator::accumulate ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Create handle to edm::HepMCProduct here because event.getByLabel with edm::HepMCProduct only works for edm::Event but not for PileUpEventPrincipal; PileUpEventPrincipal::getByLabel tries to call T::value_type and T::iterator (where T is the type of the object one wants to get a handle to) which is only implemented for container-like objects like std::vector but not for edm::HepMCProduct!

Implements DigiAccumulatorMixMod.

Definition at line 455 of file CaloTruthAccumulator.cc.

455  {
457  event.getByLabel(hepMCproductLabel_, hepmc);
458 
459  edm::LogInfo(messageCategory_) << " CaloTruthAccumulator::accumulate (signal)";
460  accumulateEvent(event, setup, hepmc);
461 }

References accumulateEvent(), hepMCproductLabel_, messageCategory_, and singleTopDQM_cfi::setup.

◆ accumulate() [2/2]

void CaloTruthAccumulator::accumulate ( const PileUpEventPrincipal event,
const edm::EventSetup setup,
edm::StreamID const &   
)
overrideprivatevirtual

Implements DigiAccumulatorMixMod.

Definition at line 463 of file CaloTruthAccumulator.cc.

465  {
466  if (event.bunchCrossing() >= -static_cast<int>(maximumPreviousBunchCrossing_) &&
467  event.bunchCrossing() <= static_cast<int>(maximumSubsequentBunchCrossing_)) {
468  // simply create empty handle as we do not have a HepMCProduct in PU anyway
470  edm::LogInfo(messageCategory_) << " CaloTruthAccumulator::accumulate (pileup) bunchCrossing="
471  << event.bunchCrossing();
472  accumulateEvent(event, setup, hepmc);
473  } else {
474  edm::LogInfo(messageCategory_) << "Skipping pileup event for bunch crossing " << event.bunchCrossing();
475  }
476 }

References accumulateEvent(), maximumPreviousBunchCrossing_, maximumSubsequentBunchCrossing_, messageCategory_, and singleTopDQM_cfi::setup.

◆ accumulateEvent()

template<class T >
void CaloTruthAccumulator::accumulateEvent ( const T event,
const edm::EventSetup setup,
const edm::Handle< edm::HepMCProduct > &  hepMCproduct 
)
private

Both forms of accumulate() delegate to this templated method.

Build the main decay graph and assign the SimTrack to each edge. The graph built here will only contain the particles that have a decay vertex associated to them. In order to recover also the particles that will not decay, we need to keep track of the SimTrack used here and add, a-posteriori, the ones not used, associating a ghost vertex (starting from the highest simulated vertex number), in order to build the edge and identify them immediately as stable (i.e. not decayed).

To take into account the multi-bremsstrahlung effects in which a single particle is emitting photons in different vertices keeping the same track index, we also collapsed those vertices into 1 unique vertex. The other approach of fully representing the decay chain keeping the same track index would have the problem of over-counting the contributions of that track, especially in terms of hits.

The 2 auxiliary vectors are structured as follow:

  1. used_sim_tracks is a vector that has the same size as the overall number of simulated tracks. The associated integer is the vertexId of the decaying vertex for that track.
  2. collapsed_vertices is a vector that has the same size as the overall number of simulated vertices. The vector's index is the vertexId itself, the associated value is the vertexId of the vertex on which this should collapse.

Definition at line 533 of file CaloTruthAccumulator.cc.

535  {
537  edm::Handle<std::vector<int>> hGenParticleIndices;
538 
539  event.getByLabel(simTrackLabel_, hSimTracks);
540  event.getByLabel(simVertexLabel_, hSimVertices);
541 
542  event.getByLabel(genParticleLabel_, hGenParticles);
543  event.getByLabel(genParticleLabel_, hGenParticleIndices);
544 
545  std::vector<std::pair<DetId, const PCaloHit *>> simHitPointers;
546  std::unordered_map<int, std::map<int, float>> simTrackDetIdEnergyMap;
547  fillSimHits(simHitPointers, simTrackDetIdEnergyMap, event, setup);
548 
549  // Clear maps from previous event fill them for this one
550  m_simHitBarcodeToIndex.clear();
551  for (unsigned int i = 0; i < simHitPointers.size(); ++i) {
552  m_simHitBarcodeToIndex.emplace(simHitPointers[i].second->geantTrackId(), i);
553  }
554 
555  auto const &tracks = *hSimTracks;
556  auto const &vertices = *hSimVertices;
557  std::unordered_map<int, int> trackid_to_track_index;
559  int idx = 0;
560 
561  IfLogDebug(DEBUG, messageCategory_) << " TRACKS" << std::endl;
562  for (auto const &t : tracks) {
563  IfLogDebug(DEBUG, messageCategory_) << " " << idx << "\t" << t.trackId() << "\t" << t << std::endl;
564  trackid_to_track_index[t.trackId()] = idx;
565  idx++;
566  }
567 
594  idx = 0;
595  std::vector<int> used_sim_tracks(tracks.size(), 0);
596  std::vector<int> collapsed_vertices(vertices.size(), 0);
597  IfLogDebug(DEBUG, messageCategory_) << " VERTICES" << std::endl;
598  for (auto const &v : vertices) {
599  IfLogDebug(DEBUG, messageCategory_) << " " << idx++ << "\t" << v << std::endl;
600  if (v.parentIndex() != -1) {
601  auto trk_idx = trackid_to_track_index[v.parentIndex()];
602  auto origin_vtx = tracks[trk_idx].vertIndex();
603  if (used_sim_tracks[trk_idx]) {
604  // collapse the vertex into the original first vertex we saw associated
605  // to this track. Omit adding the edge in order to avoid double
606  // counting of the very same particles and its associated hits.
607  collapsed_vertices[v.vertexId()] = used_sim_tracks[trk_idx];
608  continue;
609  }
610  // Perform the actual vertex collapsing, if needed.
611  if (collapsed_vertices[origin_vtx])
612  origin_vtx = collapsed_vertices[origin_vtx];
613  add_edge(origin_vtx,
614  v.vertexId(),
615  EdgeProperty(&tracks[trk_idx], simTrackDetIdEnergyMap[v.parentIndex()].size(), 0),
616  decay);
617  used_sim_tracks[trk_idx] = v.vertexId();
618  }
619  }
620  // Build the motherParticle property to each vertex
621  auto const &vertexMothersProp = get(vertex_name, decay);
622  // Now recover the particles that did not decay. Append them with an index
623  // bigger than the size of the generated vertices.
624  int offset = vertices.size();
625  for (size_t i = 0; i < tracks.size(); ++i) {
626  if (!used_sim_tracks[i]) {
627  auto origin_vtx = tracks[i].vertIndex();
628  // Perform the actual vertex collapsing, if needed.
629  if (collapsed_vertices[origin_vtx])
630  origin_vtx = collapsed_vertices[origin_vtx];
631  add_edge(
632  origin_vtx, offset, EdgeProperty(&tracks[i], simTrackDetIdEnergyMap[tracks[i].trackId()].size(), 0), decay);
633  // The properties for "fake" vertices associated to stable particles have
634  // to be set inside this loop, since they do not belong to the vertices
635  // collection and would be skipped by that loop (coming next)
636  put(vertexMothersProp, offset, VertexProperty(&tracks[i], 0));
637  offset++;
638  }
639  }
640  for (auto const &v : vertices) {
641  if (v.parentIndex() != -1) {
642  // Skip collapsed_vertices
643  if (collapsed_vertices[v.vertexId()])
644  continue;
645  put(vertexMothersProp, v.vertexId(), VertexProperty(&tracks[trackid_to_track_index[v.parentIndex()]], 0));
646  }
647  }
648  SimHitsAccumulator_dfs_visitor vis;
649  depth_first_search(decay, visitor(vis));
650  CaloParticle_dfs_visitor caloParticleCreator(
651  output_,
654  simTrackDetIdEnergyMap,
655  [&](EdgeProperty &edge_property) -> bool {
656  // Apply selection on SimTracks in order to promote them to be
657  // CaloParticles. The function returns TRUE if the particle satisfies
658  // the selection, FALSE otherwise. Therefore the correct logic to select
659  // the particle is to ask for TRUE as return value.
660  return (edge_property.cumulative_simHits != 0 and !edge_property.simTrack->noGenpart() and
661  edge_property.simTrack->momentum().E() > minEnergy_ and
662  std::abs(edge_property.simTrack->momentum().Eta()) < maxPseudoRapidity_);
663  });
664  depth_first_search(decay, visitor(caloParticleCreator));
665 
666 #if DEBUG
667  boost::write_graphviz(std::cout,
668  decay,
669  make_label_writer(make_transform_value_property_map(&graphviz_vertex, get(vertex_name, decay))),
670  make_label_writer(make_transform_value_property_map(&graphviz_edge, get(edge_weight, decay))));
671 #endif
672 }

References funct::abs(), gather_cfg::cout, EdgeProperty::cumulative_simHits, DEBUG, PA_ZEESkim_cff::decay, fillSimHits(), genParticleLabel_, get, hSimTracks, hSimVertices, mps_fire::i, heavyIonCSV_trainingSettings::idx, IfLogDebug, m_caloParticles, m_simHitBarcodeToIndex, maxPseudoRapidity_, messageCategory_, minEnergy_, CoreSimTrack::momentum(), SimTrack::noGenpart(), hltrates_dqm_sourceclient-live_cfg::offset, output_, put(), edm::second(), singleTopDQM_cfi::setup, EdgeProperty::simTrack, simTrackLabel_, simVertexLabel_, findQualityFiles::size, submitPVValidationJobs::t, tracks, findQualityFiles::v, pwdgSkimBPark_cfi::vertices, and runTauDisplay::vis.

Referenced by accumulate().

◆ beginLuminosityBlock()

void CaloTruthAccumulator::beginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  setup 
)
overrideprivatevirtual

Reimplemented from DigiAccumulatorMixMod.

Definition at line 402 of file CaloTruthAccumulator.cc.

402  {
404  iSetup.get<CaloGeometryRecord>().get(geom);
405  const HGCalGeometry *eegeom = nullptr, *fhgeom = nullptr, *bhgeomnew = nullptr;
406  const HcalGeometry *bhgeom = nullptr;
407  bhgeom = static_cast<const HcalGeometry *>(geom->getSubdetectorGeometry(DetId::Hcal, HcalEndcap));
408 
409  if (doHGCAL) {
410  eegeom = static_cast<const HGCalGeometry *>(
411  geom->getSubdetectorGeometry(DetId::HGCalEE, ForwardSubdetector::ForwardEmpty));
412  // check if it's the new geometry
413  if (eegeom) {
414  geometryType_ = 1;
415  fhgeom = static_cast<const HGCalGeometry *>(
416  geom->getSubdetectorGeometry(DetId::HGCalHSi, ForwardSubdetector::ForwardEmpty));
417  bhgeomnew = static_cast<const HGCalGeometry *>(
418  geom->getSubdetectorGeometry(DetId::HGCalHSc, ForwardSubdetector::ForwardEmpty));
419  } else {
420  geometryType_ = 0;
421  eegeom = static_cast<const HGCalGeometry *>(geom->getSubdetectorGeometry(DetId::Forward, HGCEE));
422  fhgeom = static_cast<const HGCalGeometry *>(geom->getSubdetectorGeometry(DetId::Forward, HGCHEF));
423  bhgeom = static_cast<const HcalGeometry *>(geom->getSubdetectorGeometry(DetId::Hcal, HcalEndcap));
424  }
425  hgtopo_[0] = &(eegeom->topology());
426  hgtopo_[1] = &(fhgeom->topology());
427  if (bhgeomnew)
428  hgtopo_[2] = &(bhgeomnew->topology());
429 
430  for (unsigned i = 0; i < 3; ++i) {
431  if (hgtopo_[i])
432  hgddd_[i] = &(hgtopo_[i]->dddConstants());
433  }
434  }
435 
436  if (bhgeom) {
437  hcddd_ = bhgeom->topology().dddConstants();
438  }
439 }

References HGCalTopology::dddConstants(), HcalTopology::dddConstants(), doHGCAL, EcalMappingRecord_cfi::eegeom, DetId::Forward, ForwardEmpty, relativeConstraints::geom, geometryType_, edm::EventSetup::get(), get, DetId::Hcal, HcalEndcap, hcddd_, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEF, hgddd_, hgtopo_, mps_fire::i, and HcalGeometry::topology().

◆ fillSimHits()

template<class T >
void CaloTruthAccumulator::fillSimHits ( std::vector< std::pair< DetId, const PCaloHit * >> &  returnValue,
std::unordered_map< int, std::map< int, float >> &  simTrackDetIdEnergyMap,
const T event,
const edm::EventSetup setup 
)
private

Fills the supplied vector with pointers to the SimHits, checking for bad modules if required.

Definition at line 675 of file CaloTruthAccumulator.cc.

678  {
679  for (auto const &collectionTag : collectionTags_) {
681  const bool isHcal = (collectionTag.instance().find("HcalHits") != std::string::npos);
682  event.getByLabel(collectionTag, hSimHits);
683 
684  for (auto const &simHit : *hSimHits) {
685  DetId id(0);
686 
687  //Relabel as necessary for HGCAL
688  if (doHGCAL) {
689  const uint32_t simId = simHit.id();
690  if (geometryType_ == 1) {
691  // no test numbering in new geometry
692  id = simId;
693  } else if (isHcal) {
695  if (hid.subdet() == HcalEndcap)
696  id = hid;
697  } else {
698  int subdet, layer, cell, sec, subsec, zp;
699  HGCalTestNumbering::unpackHexagonIndex(simId, subdet, zp, layer, sec, subsec, cell);
700  const HGCalDDDConstants *ddd = hgddd_[subdet - 3];
701  std::pair<int, int> recoLayerCell = ddd->simToReco(cell, layer, sec, hgtopo_[subdet - 3]->detectorType());
702  cell = recoLayerCell.first;
703  layer = recoLayerCell.second;
704  // skip simhits with bad barcodes or non-existant layers
705  if (layer == -1 || simHit.geantTrackId() == 0)
706  continue;
707  id = HGCalDetId((ForwardSubdetector)subdet, zp, layer, subsec, sec, cell);
708  }
709  } else {
710  id = simHit.id();
711  //Relabel all HCAL hits
712  if (isHcal) {
714  id = hid;
715  }
716  }
717 
718  if (id == DetId(0)) {
719  continue;
720  }
721  if (simHit.geantTrackId() == 0) {
722  continue;
723  }
724 
725  returnValue.emplace_back(id, &simHit);
726  simTrackDetIdEnergyMap[simHit.geantTrackId()][id.rawId()] += simHit.energy();
727  m_detIdToTotalSimEnergy[id.rawId()] += simHit.energy();
728  }
729  } // end of loop over InputTags
730 }

References collectionTags_, doHGCAL, geometryType_, HcalEndcap, hcddd_, hgddd_, hgtopo_, triggerObjects_cff::id, phase1PixelTopology::layer, m_detIdToTotalSimEnergy, HcalHitRelabeller::relabel(), fileinputsource_cfi::sec, rpcPointValidation_cfi::simHit, HGCalDDDConstants::simToReco(), HcalDetId::subdet(), and HGCalTestNumbering::unpackHexagonIndex().

Referenced by accumulateEvent().

◆ finalizeEvent()

void CaloTruthAccumulator::finalizeEvent ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements DigiAccumulatorMixMod.

Definition at line 478 of file CaloTruthAccumulator.cc.

478  {
479  edm::LogInfo(messageCategory_) << "Adding " << output_.pSimClusters->size() << " SimParticles and "
480  << output_.pCaloParticles->size() << " CaloParticles to the event.";
481 
482  // We need to normalize the hits and energies into hits and fractions (since
483  // we have looped over all pileup events)
484  // For premixing stage1 we keep the energies, they will be normalized to
485  // fractions in stage2
486 
487  if (premixStage1_) {
488  auto totalEnergies = std::make_unique<std::vector<std::pair<unsigned int, float>>>();
489  totalEnergies->reserve(m_detIdToTotalSimEnergy.size());
490  std::copy(m_detIdToTotalSimEnergy.begin(), m_detIdToTotalSimEnergy.end(), std::back_inserter(*totalEnergies));
491  std::sort(totalEnergies->begin(), totalEnergies->end());
492  event.put(std::move(totalEnergies), "MergedCaloTruth");
493  } else {
494  for (auto &sc : *(output_.pSimClusters)) {
495  auto hitsAndEnergies = sc.hits_and_fractions();
496  sc.clearHitsAndFractions();
497  sc.clearHitsEnergy();
498  for (auto &hAndE : hitsAndEnergies) {
499  const float totalenergy = m_detIdToTotalSimEnergy[hAndE.first];
500  float fraction = 0.;
501  if (totalenergy > 0)
502  fraction = hAndE.second / totalenergy;
503  else
505  << "TotalSimEnergy for hit " << hAndE.first << " is 0! The fraction for this hit cannot be computed.";
506  sc.addRecHitAndFraction(hAndE.first, fraction);
507  sc.addHitEnergy(hAndE.second);
508  }
509  }
510  }
511 
512  // save the SimCluster orphan handle so we can fill the calo particles
513  auto scHandle = event.put(std::move(output_.pSimClusters), "MergedCaloTruth");
514 
515  // now fill the calo particles
516  for (unsigned i = 0; i < output_.pCaloParticles->size(); ++i) {
517  auto &cp = (*output_.pCaloParticles)[i];
518  for (unsigned j = m_caloParticles.sc_start_[i]; j < m_caloParticles.sc_stop_[i]; ++j) {
519  edm::Ref<SimClusterCollection> ref(scHandle, j);
520  cp.addSimCluster(ref);
521  }
522  }
523 
524  event.put(std::move(output_.pCaloParticles), "MergedCaloTruth");
525 
526  calo_particles().swap(m_caloParticles);
527 
528  std::unordered_map<Index_t, float>().swap(m_detIdToTotalSimEnergy);
529  std::unordered_multimap<Barcode_t, Index_t>().swap(m_simHitBarcodeToIndex);
530 }

References filterCSVwithJSON::copy, HLT_FULL_cff::fraction, mps_fire::i, dqmiolumiharvest::j, m_caloParticles, m_detIdToTotalSimEnergy, m_simHitBarcodeToIndex, messageCategory_, eostools::move(), output_, CaloTruthAccumulator::OutputCollections::pCaloParticles, premixStage1_, CaloTruthAccumulator::OutputCollections::pSimClusters, CaloTruthAccumulator::calo_particles::sc_start_, CaloTruthAccumulator::calo_particles::sc_stop_, jetUpdater_cfi::sort, and CaloTruthAccumulator::calo_particles::swap().

◆ initializeEvent()

void CaloTruthAccumulator::initializeEvent ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements DigiAccumulatorMixMod.

Definition at line 441 of file CaloTruthAccumulator.cc.

441  {
442  output_.pSimClusters = std::make_unique<SimClusterCollection>();
443  output_.pCaloParticles = std::make_unique<CaloParticleCollection>();
444 
445  m_detIdToTotalSimEnergy.clear();
446 }

References m_detIdToTotalSimEnergy, output_, CaloTruthAccumulator::OutputCollections::pCaloParticles, and CaloTruthAccumulator::OutputCollections::pSimClusters.

Member Data Documentation

◆ collectionTags_

std::vector<edm::InputTag> CaloTruthAccumulator::collectionTags_
private

Definition at line 174 of file CaloTruthAccumulator.cc.

Referenced by CaloTruthAccumulator(), and fillSimHits().

◆ doHGCAL

bool CaloTruthAccumulator::doHGCAL
private

Definition at line 211 of file CaloTruthAccumulator.cc.

Referenced by beginLuminosityBlock(), and fillSimHits().

◆ genParticleLabel_

edm::InputTag CaloTruthAccumulator::genParticleLabel_
private

Definition at line 175 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent(), and CaloTruthAccumulator().

◆ geometryType_

int CaloTruthAccumulator::geometryType_
private

Definition at line 210 of file CaloTruthAccumulator.cc.

Referenced by beginLuminosityBlock(), and fillSimHits().

◆ hcddd_

const HcalDDDRecConstants* CaloTruthAccumulator::hcddd_ = nullptr
private

Definition at line 206 of file CaloTruthAccumulator.cc.

Referenced by beginLuminosityBlock(), and fillSimHits().

◆ hepMCproductLabel_

edm::InputTag CaloTruthAccumulator::hepMCproductLabel_
private

Needed to add HepMC::GenVertex to SimVertex.

Definition at line 177 of file CaloTruthAccumulator.cc.

Referenced by accumulate(), and CaloTruthAccumulator().

◆ hgddd_

const HGCalDDDConstants* CaloTruthAccumulator::hgddd_[3] = {nullptr, nullptr, nullptr}
private

Definition at line 205 of file CaloTruthAccumulator.cc.

Referenced by beginLuminosityBlock(), and fillSimHits().

◆ hgtopo_

const HGCalTopology* CaloTruthAccumulator::hgtopo_[3] = {nullptr, nullptr, nullptr}
private

Definition at line 204 of file CaloTruthAccumulator.cc.

Referenced by beginLuminosityBlock(), and fillSimHits().

◆ hSimTracks

edm::Handle<std::vector<SimTrack> > CaloTruthAccumulator::hSimTracks
private

Definition at line 171 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent().

◆ hSimVertices

edm::Handle<std::vector<SimVertex> > CaloTruthAccumulator::hSimVertices
private

Definition at line 172 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent().

◆ m_caloParticles

calo_particles CaloTruthAccumulator::m_caloParticles
private

Definition at line 208 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent(), and finalizeEvent().

◆ m_detIdToTotalSimEnergy

std::unordered_map<Index_t, float> CaloTruthAccumulator::m_detIdToTotalSimEnergy
private

Definition at line 153 of file CaloTruthAccumulator.cc.

Referenced by fillSimHits(), finalizeEvent(), and initializeEvent().

◆ m_simHitBarcodeToIndex

std::unordered_multimap<Barcode_t, Index_t> CaloTruthAccumulator::m_simHitBarcodeToIndex
private

Definition at line 154 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent(), and finalizeEvent().

◆ maximumPreviousBunchCrossing_

const unsigned int CaloTruthAccumulator::maximumPreviousBunchCrossing_
private

The maximum bunch crossing BEFORE the signal crossing to create TrackinParticles for. Use positive values. If set to zero no previous bunches are added and only in-time, signal and after bunches (defined by maximumSubsequentBunchCrossing_) are used.

Definition at line 161 of file CaloTruthAccumulator.cc.

Referenced by accumulate().

◆ maximumSubsequentBunchCrossing_

const unsigned int CaloTruthAccumulator::maximumSubsequentBunchCrossing_
private

The maximum bunch crossing AFTER the signal crossing to create TrackinParticles for. E.g. if set to zero only uses the signal and in time pileup (and previous bunches defined by the maximumPreviousBunchCrossing_ parameter).

Definition at line 167 of file CaloTruthAccumulator.cc.

Referenced by accumulate().

◆ maxPseudoRapidity_

const double CaloTruthAccumulator::maxPseudoRapidity_
private

Definition at line 179 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent().

◆ messageCategory_

const std::string CaloTruthAccumulator::messageCategory_
private

Definition at line 151 of file CaloTruthAccumulator.cc.

Referenced by accumulate(), accumulateEvent(), and finalizeEvent().

◆ minEnergy_

const double CaloTruthAccumulator::minEnergy_
private

Definition at line 179 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent().

◆ output_

OutputCollections CaloTruthAccumulator::output_
private

Definition at line 207 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

◆ premixStage1_

const bool CaloTruthAccumulator::premixStage1_
private

Definition at line 180 of file CaloTruthAccumulator.cc.

Referenced by CaloTruthAccumulator(), and finalizeEvent().

◆ simTrackLabel_

const edm::InputTag CaloTruthAccumulator::simTrackLabel_
private

Definition at line 169 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent(), and CaloTruthAccumulator().

◆ simVertexLabel_

const edm::InputTag CaloTruthAccumulator::simVertexLabel_
private

Definition at line 170 of file CaloTruthAccumulator.cc.

Referenced by accumulateEvent(), and CaloTruthAccumulator().

CaloTruthAccumulator::m_simHitBarcodeToIndex
std::unordered_multimap< Barcode_t, Index_t > m_simHitBarcodeToIndex
Definition: CaloTruthAccumulator.cc:154
CaloTruthAccumulator::hSimVertices
edm::Handle< std::vector< SimVertex > > hSimVertices
Definition: CaloTruthAccumulator.cc:172
CaloTruthAccumulator::fillSimHits
void fillSimHits(std::vector< std::pair< DetId, const PCaloHit * >> &returnValue, std::unordered_map< int, std::map< int, float >> &simTrackDetIdEnergyMap, const T &event, const edm::EventSetup &setup)
Fills the supplied vector with pointers to the SimHits, checking for bad modules if required.
Definition: CaloTruthAccumulator.cc:675
CoreSimTrack::momentum
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
put
void put(edm::Event &evt, double value, const char *instanceName)
Definition: EventShapeVarsProducer.cc:27
SimClusterCollection
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
mps_fire.i
i
Definition: mps_fire.py:428
HGCalTopology::dddConstants
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
ForwardEmpty
Definition: ForwardSubdetector.h:5
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
HcalDDDRecConstants::dddConstants
const HcalDDDSimConstants * dddConstants() const
Definition: HcalDDDRecConstants.h:126
ForwardSubdetector
ForwardSubdetector
Definition: ForwardSubdetector.h:4
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
CaloTruthAccumulator::OutputCollections::pSimClusters
std::unique_ptr< SimClusterCollection > pSimClusters
Definition: CaloTruthAccumulator.cc:184
CaloTruthAccumulator::calo_particles::sc_stop_
std::vector< uint32_t > sc_stop_
Definition: CaloTruthAccumulator.cc:190
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HGCalTestNumbering::unpackHexagonIndex
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
Definition: HGCalTestNumbering.cc:46
CaloTruthAccumulator::hgtopo_
const HGCalTopology * hgtopo_[3]
Definition: CaloTruthAccumulator.cc:204
DetId::Hcal
Definition: DetId.h:28
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
CaloTruthAccumulator::maximumPreviousBunchCrossing_
const unsigned int maximumPreviousBunchCrossing_
Definition: CaloTruthAccumulator.cc:161
hgcal_conditions::parameters
Definition: HGCConditions.h:86
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
EcalMappingRecord_cfi.eegeom
eegeom
Definition: EcalMappingRecord_cfi.py:3
edm::Handle< edm::HepMCProduct >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DEBUG
#define DEBUG
Definition: CaloTruthAccumulator.cc:1
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CaloTruthAccumulator::minEnergy_
const double minEnergy_
Definition: CaloTruthAccumulator.cc:179
CaloTruthAccumulator::simVertexLabel_
const edm::InputTag simVertexLabel_
Definition: CaloTruthAccumulator.cc:170
CaloTruthAccumulator::maxPseudoRapidity_
const double maxPseudoRapidity_
Definition: CaloTruthAccumulator.cc:179
edm::Ref
Definition: AssociativeIterator.h:58
HGCalDDDConstants
Definition: HGCalDDDConstants.h:27
CaloTruthAccumulator::maximumSubsequentBunchCrossing_
const unsigned int maximumSubsequentBunchCrossing_
Definition: CaloTruthAccumulator.cc:167
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
SimTrack::noGenpart
bool noGenpart() const
Definition: SimTrack.h:38
config
Definition: config.py:1
DetId
Definition: DetId.h:17
DetId::HGCalHSi
Definition: DetId.h:33
DetId::HGCalEE
Definition: DetId.h:32
HGCalDDDConstants::simToReco
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
Definition: HGCalDDDConstants.cc:1018
CaloTruthAccumulator::calo_particles::sc_start_
std::vector< uint32_t > sc_start_
Definition: CaloTruthAccumulator.cc:189
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52802
CaloTruthAccumulator::m_detIdToTotalSimEnergy
std::unordered_map< Index_t, float > m_detIdToTotalSimEnergy
Definition: CaloTruthAccumulator.cc:153
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
runTauDisplay.vis
vis
Definition: runTauDisplay.py:328
CaloTruthAccumulator::OutputCollections::pCaloParticles
std::unique_ptr< CaloParticleCollection > pCaloParticles
Definition: CaloTruthAccumulator.cc:185
edm::ESHandle< CaloGeometry >
CaloTruthAccumulator::output_
OutputCollections output_
Definition: CaloTruthAccumulator.cc:207
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
HGCalGeometry
Definition: HGCalGeometry.h:29
CaloParticleCollection
std::vector< CaloParticle > CaloParticleCollection
Definition: CaloParticleFwd.h:8
EdgeProperty::cumulative_simHits
int cumulative_simHits
Definition: CaloTruthAccumulator.cc:110
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
CaloTruthAccumulator::collectionTags_
std::vector< edm::InputTag > collectionTags_
Definition: CaloTruthAccumulator.cc:174
HGCEE
Definition: ForwardSubdetector.h:8
CaloTruthAccumulator::premixStage1_
const bool premixStage1_
Definition: CaloTruthAccumulator.cc:180
CaloTruthAccumulator::messageCategory_
const std::string messageCategory_
Definition: CaloTruthAccumulator.cc:151
edm::ParameterSet
Definition: ParameterSet.h:47
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
CaloTruthAccumulator::hgddd_
const HGCalDDDConstants * hgddd_[3]
Definition: CaloTruthAccumulator.cc:205
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalDetId
Definition: HcalDetId.h:12
DecayChain
adjacency_list< listS, vecS, directedS, VertexMotherParticleProperty, EdgeParticleClustersProperty > DecayChain
Definition: CaloTruthAccumulator.cc:124
CaloTruthAccumulator::hepMCproductLabel_
edm::InputTag hepMCproductLabel_
Needed to add HepMC::GenVertex to SimVertex.
Definition: CaloTruthAccumulator.cc:177
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
get
#define get
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
HcalHitRelabeller::relabel
DetId relabel(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:49
HGCalDetId
Definition: HGCalDetId.h:8
PA_ZEESkim_cff.decay
decay
Definition: PA_ZEESkim_cff.py:26
EdgeProperty
Definition: CaloTruthAccumulator.cc:106
eostools.move
def move(src, dest)
Definition: eostools.py:511
CaloTruthAccumulator::hSimTracks
edm::Handle< std::vector< SimTrack > > hSimTracks
Definition: CaloTruthAccumulator.cc:171
CaloTruthAccumulator::accumulateEvent
void accumulateEvent(const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
Both forms of accumulate() delegate to this templated method.
Definition: CaloTruthAccumulator.cc:533
CaloTruthAccumulator::geometryType_
int geometryType_
Definition: CaloTruthAccumulator.cc:210
HcalEndcap
Definition: HcalAssistant.h:34
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
DetId::HGCalHSc
Definition: DetId.h:34
VertexProperty
Definition: CaloTruthAccumulator.cc:113
CaloTruthAccumulator::doHGCAL
bool doHGCAL
Definition: CaloTruthAccumulator.cc:211
IfLogDebug
#define IfLogDebug(cond, cat)
Definition: MessageLogger.h:259
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
CaloTruthAccumulator::hcddd_
const HcalDDDRecConstants * hcddd_
Definition: CaloTruthAccumulator.cc:206
CaloTruthAccumulator::simTrackLabel_
const edm::InputTag simTrackLabel_
Definition: CaloTruthAccumulator.cc:169
HGCHEF
Definition: ForwardSubdetector.h:9
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CaloTruthAccumulator::m_caloParticles
calo_particles m_caloParticles
Definition: CaloTruthAccumulator.cc:208
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
DetId::Forward
Definition: DetId.h:30
event
Definition: event.py:1
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HcalGeometry
Definition: HcalGeometry.h:17
edm::InputTag
Definition: InputTag.h:15
EdgeProperty::simTrack
const SimTrack * simTrack
Definition: CaloTruthAccumulator.cc:108
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
CaloTruthAccumulator::genParticleLabel_
edm::InputTag genParticleLabel_
Definition: CaloTruthAccumulator.cc:175