CMS 3D CMS Logo

CaloTruthAccumulator.cc
Go to the documentation of this file.
1 // S Zenz/L Gray, May 2016
2 // Loosely based on TrackingTruthAccumulator (M Grimes)
3 
6 
11 
19 
25 
30 
33 
36 
37 #include <iterator>
38 
40  messageCategory_("CaloTruthAccumulator"),
41  maximumPreviousBunchCrossing_( config.getParameter<unsigned int>("maximumPreviousBunchCrossing") ),
42  maximumSubsequentBunchCrossing_( config.getParameter<unsigned int>("maximumSubsequentBunchCrossing") ),
43  simTrackLabel_( config.getParameter<edm::InputTag>("simTrackCollection") ),
44  simVertexLabel_( config.getParameter<edm::InputTag>("simVertexCollection") ),
45  collectionTags_( ),
46  genParticleLabel_( config.getParameter<edm::InputTag>("genParticleCollection") ),
47  hepMCproductLabel_( config.getParameter<edm::InputTag>("HepMCProductLabel") ),
48  minEnergy_( config.getParameter<double>("MinEnergy") ),
49  maxPseudoRapidity_( config.getParameter<double>("MaxPseudoRapidity") )
50 {
52 
53  mixMod.produces<SimClusterCollection>("MergedCaloTruth");
54  mixMod.produces<CaloParticleCollection>("MergedCaloTruth");
55 
56  iC.consumes<std::vector<SimTrack> >(simTrackLabel_);
57  iC.consumes<std::vector<SimVertex> >(simVertexLabel_);
58  iC.consumes<std::vector<reco::GenParticle> >(genParticleLabel_);
59  iC.consumes<std::vector<int> >(genParticleLabel_);
60  iC.consumes<std::vector<int> >(hepMCproductLabel_);
61 
62  // Fill the collection tags
63  const edm::ParameterSet& simHitCollectionConfig=config.getParameterSet("simHitCollections");
64  std::vector<std::string> parameterNames=simHitCollectionConfig.getParameterNames();
65 
66  for( const auto& parameterName : parameterNames )
67  {
68  std::vector<edm::InputTag> tags=simHitCollectionConfig.getParameter<std::vector<edm::InputTag> >(parameterName);
69  collectionTags_.insert(collectionTags_.end(), tags.begin(), tags.end());
70  }
71 
72  for( const auto& collectionTag : collectionTags_ ) {
73  iC.consumes<std::vector<PCaloHit> >(collectionTag);
74  }
75 }
76 
79  iSetup.get<CaloGeometryRecord>().get(geom);
80  const HGCalGeometry *eegeom, *fhgeom;
81  const HcalGeometry *bhgeom;
82 
83  eegeom = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::Forward,HGCEE));
84  fhgeom = dynamic_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(DetId::Forward,HGCHEF));
85  bhgeom = dynamic_cast<const HcalGeometry*>(geom->getSubdetectorGeometry(DetId::Hcal,HcalEndcap));
86 
87  hgtopo_[0] = &(eegeom->topology());
88  hgtopo_[1] = &(fhgeom->topology());
89 
90  for( unsigned i = 0; i < 2; ++i ) {
91  hgddd_[i] = &(hgtopo_[i]->dddConstants());
92  }
93 
94  hcddd_ = bhgeom->topology().dddConstants();
95 
96  caloStartZ = hgddd_[0]->waferZ(1,false)*10.0; // get the location of the first plane of silicon, put in mm
97 }
98 
100 {
103 
104  m_detIdToCluster.clear();
105  m_detIdToTotalSimEnergy.clear();
106 }
107 
112 
114  // Call the templated version that does the same for both signal and pileup events
115 
117  event.getByLabel(hepMCproductLabel_, hepmc);
118 
119  edm::LogInfo(messageCategory_) << " CaloTruthAccumulator::accumulate (signal)";
120  accumulateEvent( event, setup, hepmc );
121 }
122 
123 void CaloTruthAccumulator::accumulate( PileUpEventPrincipal const& event, edm::EventSetup const& setup, edm::StreamID const& ) {
124  // If this bunch crossing is outside the user configured limit, don't do anything.
125  if( event.bunchCrossing()>=-static_cast<int>(maximumPreviousBunchCrossing_) && event.bunchCrossing()<=static_cast<int>(maximumSubsequentBunchCrossing_) )
126  {
127  //edm::LogInfo(messageCategory_) << "Analysing pileup event for bunch crossing " << event.bunchCrossing();
128 
129  //simply create empty handle as we do not have a HepMCProduct in PU anyway
131  edm::LogInfo(messageCategory_) << " CaloTruthAccumulator::accumulate (pileup) bunchCrossing=" << event.bunchCrossing();
132  accumulateEvent( event, setup, hepmc );
133  }
134  else edm::LogInfo(messageCategory_) << "Skipping pileup event for bunch crossing " << event.bunchCrossing();
135 }
136 
138  edm::LogInfo("CaloTruthAccumulator") << "Adding " << output_.pSimClusters->size()
139  << " SimParticles and " << output_.pCaloParticles->size()
140  << " CaloParticles to the event.";
141 
142  // now we need to normalize the hits and energies into hits and fractions
143  // (since we have looped over all pileup events)
144 
145  for( auto& sc : *(output_.pSimClusters) ) {
146  auto hitsAndEnergies = sc.hits_and_fractions();
148  for( auto& hAndE : hitsAndEnergies ) {
149  const float fraction = hAndE.second/m_detIdToTotalSimEnergy[hAndE.first];
150  sc.addRecHitAndFraction(hAndE.first,fraction);
151  }
152  }
153 
154  // save the SimCluster orphan handle so we can fill the calo particles
155  auto scHandle = event.put( std::move(output_.pSimClusters), "MergedCaloTruth" );
156 
157  // now fill the calo particles
158  for( unsigned i = 0; i < output_.pCaloParticles->size(); ++i ) {
159  auto& cp = (*output_.pCaloParticles)[i];
160  for( unsigned j = m_caloParticles.sc_start_[i]; j < m_caloParticles.sc_stop_[i]; ++j ) {
161  edm::Ref<SimClusterCollection> ref(scHandle,j);
162  cp.addSimCluster(ref);
163  }
164  }
165 
166  event.put( std::move(output_.pCaloParticles), "MergedCaloTruth" );
167 
169 
170  std::unordered_map<Index_t,float>().swap(m_detIdToTotalSimEnergy);
171 
172  std::unordered_map<Barcode_t,Index_t>().swap(m_genParticleBarcodeToIndex);
173  std::unordered_map<Barcode_t,Index_t>().swap(m_simTrackBarcodeToIndex);
174  std::unordered_map<Barcode_t,Index_t>().swap(m_genBarcodeToSimTrackIndex);
175  std::unordered_map<Barcode_t,Index_t>().swap(m_simVertexBarcodeToIndex);
176 
177  std::unordered_multimap<Index_t,Index_t>().swap(m_detIdToCluster);
178  std::unordered_multimap<Barcode_t,Index_t>().swap(m_simHitBarcodeToIndex);
179  std::unordered_multimap<Barcode_t,Barcode_t>().swap(m_simVertexBarcodeToSimTrackBarcode);
180  std::unordered_map<Barcode_t,Barcode_t>().swap(m_simTrackBarcodeToSimVertexParentBarcode);
181  std::unordered_multimap<Barcode_t,Index_t>().swap(m_simTrackToSimVertex);
182  std::unordered_multimap<Barcode_t,Index_t>().swap(m_simVertexToSimTrackParent);
183  std::vector<Barcode_t>().swap(m_simVertexBarcodes);
184  std::unordered_map<Index_t,float>().swap(m_detIdToTotalSimEnergy);
185 }
186 
187 template<class T>
189  const edm::EventSetup& setup,
190  const edm::Handle< edm::HepMCProduct >& hepMCproduct) {
191  //
192  // Get the collections
193  //
194 
196  edm::Handle< std::vector<int> > hGenParticleIndices;
197 
198  event.getByLabel( simTrackLabel_, hSimTracks );
199  event.getByLabel( simVertexLabel_, hSimVertices );
200 
201  event.getByLabel( genParticleLabel_, hGenParticles );
202  event.getByLabel( genParticleLabel_, hGenParticleIndices );
203 
204  std::vector<std::pair<DetId,const PCaloHit*> > simHitPointers;
205  fillSimHits( simHitPointers, event, setup );
206 
207  // Clear maps from previous event fill them for this one
208  m_simHitBarcodeToIndex.clear();
210  for (unsigned int i = 0 ; i < simHitPointers.size(); ++i) {
211  m_simHitBarcodeToIndex.emplace(simHitPointers[i].second->geantTrackId(),i);
212  }
214  if( hGenParticles.isValid() && hGenParticleIndices.isValid() ) {
215  for (unsigned int i = 0 ; i < hGenParticles->size() ; ++i) {
216  m_genParticleBarcodeToIndex.emplace(hGenParticleIndices->at(i),i);
217  }
218  }
222  m_simTrackBarcodeToIndex.clear();
223  for (unsigned int i = 0 ; i < hSimTracks->size() ; i++) {
224  if( !hSimTracks->at(i).noGenpart() ) {
225  m_genBarcodeToSimTrackIndex.emplace(hSimTracks->at(i).genpartIndex(), i);
226  }
227  if( !hSimTracks->at(i).noVertex() ) {
228  m_simVertexBarcodeToSimTrackBarcode.emplace(hSimTracks->at(i).vertIndex(), hSimTracks->at(i).trackId());
229  m_simTrackBarcodeToSimVertexParentBarcode.emplace(hSimTracks->at(i).trackId(), hSimTracks->at(i).vertIndex());
230  }
231  m_simTrackBarcodeToIndex.emplace(hSimTracks->at(i).trackId(), i);
232  }
233  m_simVertexBarcodes.clear();
235  m_simTrackToSimVertex.clear();
237  for (unsigned int i = 0 ; i < hSimVertices->size() ; i++) {
238  m_simVertexBarcodes.push_back(i);
239  m_simVertexBarcodeToIndex.emplace(hSimVertices->at(i).vertexId(), i);
240  if (!hSimVertices->at(i).noParent()) {
241  m_simTrackToSimVertex.emplace(hSimVertices->at(i).parentIndex(), i);
242  m_simVertexToSimTrackParent.emplace( hSimVertices->at(i).vertexId(), hSimVertices->at(i).parentIndex() );
243  }
244  }
245 
246  std::vector<Index_t> tracksToBecomeClustersInitial;
247  std::vector<Barcode_t> descendantTracks;
248  SimClusterCollection simClustersForGenParts;
249  std::vector<std::unique_ptr<SimHitInfoPerSimTrack_t> > hitInfoList;
250  std::vector<std::vector<uint32_t> > simClusterPrimitives;
251  std::unordered_multimap<Index_t,Index_t> genPartsToSimClusters;
252  const auto& simTracks = *hSimTracks;
253  // loop over
254  for (unsigned int i = 0 ; i < simTracks.size() ; ++i) {
255  if ( simTracks[i].momentum().E() < minEnergy_ || std::abs(simTracks[i].momentum().Eta()) >= maxPseudoRapidity_ ) continue;
256  if ( simTracks[i].noGenpart() ) continue;
257  auto temp = CaloTruthAccumulator::descendantSimClusters( simTracks[i].trackId(),simHitPointers );
258  if( temp.size() ) {
259  output_.pCaloParticles->emplace_back(simTracks[i]);
260  m_caloParticles.sc_start_.push_back(output_.pSimClusters->size());
261  auto mbegin = std::make_move_iterator(temp.begin());
262  auto mend = std::make_move_iterator(temp.end());
263  output_.pSimClusters->insert(output_.pSimClusters->end(), mbegin, mend);
264  m_caloParticles.sc_stop_.push_back(output_.pSimClusters->size());
265  }
266  }
267 }
268 
269 std::vector<Barcode_t> CaloTruthAccumulator::descendantTrackBarcodes( Barcode_t barcode ) {
270  std::vector<Barcode_t> result;
271  if (m_simTrackToSimVertex.count(barcode)) {
272  auto vertex_range = m_simTrackToSimVertex.equal_range(barcode);
273  for ( auto vertex_iter = vertex_range.first ; vertex_iter != vertex_range.second ; vertex_iter++ ) {
274  Index_t decayVertexIndex = vertex_iter->second;
275  Barcode_t decayVertexBarcode = m_simVertexBarcodes[decayVertexIndex];
276  auto track_range = m_simVertexBarcodeToSimTrackBarcode.equal_range( decayVertexBarcode );
277  for ( auto track_iter = track_range.first ; track_iter != track_range.second ; track_iter++ ) {
278  result.push_back( track_iter->second );
279  std::vector<Barcode_t> daughter_result = CaloTruthAccumulator::descendantTrackBarcodes( track_iter->second );
280  result.insert(result.end(),daughter_result.begin(),daughter_result.end());
281  }
282  }
283  }
284  return result;
285 }
286 
287 SimClusterCollection CaloTruthAccumulator::descendantSimClusters( Barcode_t barcode, const std::vector<std::pair<DetId,const PCaloHit*> >& hits ) {
289  const auto& simTracks = *hSimTracks;
290  if ( CaloTruthAccumulator::consideredBarcode( barcode ) ) {
291  LogDebug("CaloParticles") << "SCZ DEBUG Ignoring descendantSimClusters call because this particle is already marked used: " << barcode << std::endl;
292  //return result;
293  }
294 
295  std::unique_ptr<SimHitInfoPerSimTrack_t> hit_info = std::move(CaloTruthAccumulator::attachedSimHitInfo(barcode,hits, true, false, false));
296  //std::unique_ptr<SimHitInfoPerSimTrack_t> inclusive_hit_info = std::move(CaloTruthAccumulator::allAttachedSimHitInfo(barcode,hits, false) );
297 
298  const auto& simTrack = simTracks[m_simTrackBarcodeToIndex[barcode]];
300  const auto& vtx = hSimVertices->at(m_simVertexBarcodeToIndex[vtxBarcode]);
301  const bool isInCalo = (std::abs(vtx.position().z()) > caloStartZ - 30.0); // add a buffer region in front of the calo face
302 
303  if (hit_info->size() > 0) {
304  // define the sim cluster starting from the earliest particle that has hits in the calorimeter
305  // grab everything that descends from it
306  std::unique_ptr<SimHitInfoPerSimTrack_t> marked_hit_info;
307 
308 
309  if( isInCalo ) {
310  marked_hit_info = std::move( CaloTruthAccumulator::allAttachedSimHitInfo(barcode,hits,true) );
311  } else {
312  marked_hit_info = std::move( CaloTruthAccumulator::attachedSimHitInfo(barcode,hits,true,false,true) );
313  }
314 
315  if( marked_hit_info->size() != 0 ) {
316  result.emplace_back(simTrack);
317  auto& simcluster = result.back();
318 
319  std::unordered_map<uint32_t,float> acc_energy;
320 
321  for( const auto& hit_and_energy : *marked_hit_info ) {
322  const uint32_t id = hit_and_energy.first.rawId();
323  if( acc_energy.count(id) ) acc_energy[id] += hit_and_energy.second;
324  else acc_energy[id] = hit_and_energy.second;
325  }
326 
327  for( const auto& hit_and_energy : acc_energy ) {
328  simcluster.addRecHitAndFraction(hit_and_energy.first,hit_and_energy.second);
329  }
330  }
331  }
332 
333  if ( m_simTrackToSimVertex.count(barcode) ) {
334  auto vertex_range = m_simTrackToSimVertex.equal_range(barcode);
335  for ( auto vertex_iter = vertex_range.first ; vertex_iter != vertex_range.second ; vertex_iter++ ) {
336  Index_t decayVertexIndex = vertex_iter->second;
337  Barcode_t decayVertexBarcode = m_simVertexBarcodes[decayVertexIndex];
338  auto track_range = m_simVertexBarcodeToSimTrackBarcode.equal_range( decayVertexBarcode );
339  for ( auto track_iter = track_range.first ; track_iter != track_range.second ; track_iter++ ) {
340 
341  auto daughter_result = CaloTruthAccumulator::descendantSimClusters(track_iter->second,hits);
342  result.insert(result.end(),daughter_result.begin(),daughter_result.end());
343  }
344  }
345  }
346 
347  return result;
348 }
349 
350 std::unique_ptr<SimHitInfoPerSimTrack_t> CaloTruthAccumulator::attachedSimHitInfo( Barcode_t barcode , const std::vector<std::pair<DetId,const PCaloHit*> >& hits,
351  bool includeOwn , bool includeOther, bool markUsed ) {
352  const auto& simTracks = *hSimTracks;
353  std::unique_ptr<SimHitInfoPerSimTrack_t> result(new SimHitInfoPerSimTrack_t);
354 
355  const auto& simTrack = simTracks[m_simTrackBarcodeToIndex[barcode]];
356 
357  if ( markUsed ) {
358  if ( CaloTruthAccumulator::consideredBarcode( barcode ) ) {
359  return result;
360  }
362  }
363  if (includeOwn) {
364  auto range = m_simHitBarcodeToIndex.equal_range( barcode );
365  unsigned n = 0;
366  for ( auto iter = range.first ; iter != range.second ; iter++ ) {
367  const auto& the_hit = hits[iter->second];
368  result->emplace_back(the_hit.first,the_hit.second->energy());
369  ++n;
370  }
371  }
372 
373  // need to sim to the next sim track if we explicitly ask or
374  // if we are in the calorimeter next (no interaction)
375  // or if this is a continuation of the same particle
376  if (m_simTrackToSimVertex.count(barcode)) {
377  auto vertex_range = m_simTrackToSimVertex.equal_range(barcode);
378  for ( auto vertex_iter = vertex_range.first ; vertex_iter != vertex_range.second ; vertex_iter++ ) {
379  Index_t decayVertexIndex = vertex_iter->second;
380  const auto& nextVtx = (*hSimVertices)[decayVertexIndex];
381  const bool nextInCalo = (std::abs(nextVtx.position().z()) > caloStartZ*0.1 - 20.0); // add a buffer region in front of the calo face
382 
383  Barcode_t decayVertexBarcode = m_simVertexBarcodes[decayVertexIndex];
384  auto track_range = m_simVertexBarcodeToSimTrackBarcode.equal_range( decayVertexBarcode );
385  for ( auto track_iter = track_range.first ; track_iter != track_range.second ; track_iter++ ) {
386  if( !barcodeLogicWarningAlready_ && track_iter->second < barcode ) {
388  edm::LogWarning(messageCategory_) << " Daughter particle has a lower barcode than parent. This may screw up the logic!" << std::endl;
389  }
390  const auto& daughter = simTracks[m_simTrackBarcodeToIndex[track_iter->second]];
391 
392  if( includeOther || nextInCalo ) {
393  std::unique_ptr<SimHitInfoPerSimTrack_t> daughter_result = std::move(CaloTruthAccumulator::allAttachedSimHitInfo(track_iter->second,hits,markUsed));
394  result->insert(result->end(),daughter_result->begin(),daughter_result->end());
395  } else if ( daughter.type() == simTrack.type() ) {
396  std::unique_ptr<SimHitInfoPerSimTrack_t> daughter_result = std::move(CaloTruthAccumulator::attachedSimHitInfo(track_iter->second,hits,includeOwn, includeOther, markUsed));
397  result->insert(result->end(),daughter_result->begin(),daughter_result->end());
398  }
399  }
400  }
401  }
402  return result;
403 }
404 
405 std::unique_ptr<SimHitInfoPerSimTrack_t>
407  const std::vector<std::pair<DetId,const PCaloHit*> >& hits,
408  bool markUsed) {
409  return CaloTruthAccumulator::attachedSimHitInfo(barcode,hits,false,true,markUsed);
410 }
411 
412 std::unique_ptr<SimHitInfoPerSimTrack_t>
414  const std::vector<std::pair<DetId,const PCaloHit*> >& hits,
415  bool markUsed ) {
416  return CaloTruthAccumulator::attachedSimHitInfo(barcode,hits,true,true,markUsed);
417 }
418 
419 template<class T> void CaloTruthAccumulator::fillSimHits( std::vector<std::pair<DetId, const PCaloHit*> >& returnValue, const T& event, const edm::EventSetup& setup ) {
420  // loop over the collections
421  for( const auto& collectionTag : collectionTags_ ) {
423  const bool isHcal = ( collectionTag.instance().find("HcalHits") != std::string::npos );
424  event.getByLabel( collectionTag, hSimHits );
425  for( const auto& simHit : *hSimHits ) {
426  DetId id(0);
427  const uint32_t simId = simHit.id();
428  if( isHcal ) {
429  int subdet, z, depth0, eta0, phi0, lay;
430  HcalTestNumbering::unpackHcalIndex(simId, subdet, z, depth0, eta0, phi0, lay);
431  int sign = (z==0) ? (-1):(1);
432  HcalDDDRecConstants::HcalID tempid = hcddd_->getHCID(subdet, sign*eta0, phi0, lay, depth0);
433  if (subdet==int(HcalEndcap)) {
434  id = HcalDetId(HcalEndcap,sign*tempid.eta,tempid.phi,tempid.depth);
435  }
436  } else {
437  int subdet, layer, cell, sec, subsec, zp;
438  HGCalTestNumbering::unpackHexagonIndex(simId, subdet, zp, layer, sec, subsec, cell);
439  const HGCalDDDConstants* ddd = hgddd_[subdet-3];
440  std::pair<int,int> recoLayerCell = ddd->simToReco(cell,layer,sec,
441  hgtopo_[subdet-3]->detectorType());
442  cell = recoLayerCell.first;
443  layer = recoLayerCell.second;
444  // skip simhits with bad barcodes or non-existant layers
445  if( layer == -1 || simHit.geantTrackId() == 0 ) continue;
446  id = HGCalDetId((ForwardSubdetector)subdet,zp,layer,subsec,sec,cell);
447  }
448 
449  if( DetId(0) == id ) continue;
450 
451  uint32_t detId = id.rawId();
452  returnValue.emplace_back(id, &simHit);
453 
454  if( m_detIdToTotalSimEnergy.count(detId) ) m_detIdToTotalSimEnergy[detId] += simHit.energy();
455  else m_detIdToTotalSimEnergy[detId] = simHit.energy();
456  }
457  } // end of loop over InputTags
458 }
459 
460 // Register with the framework
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
void setConsideredBarcode(Barcode_t barcode)
calo_particles m_caloParticles
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:161
std::unordered_multimap< Index_t, Index_t > m_detIdToCluster
edm::Handle< std::vector< SimVertex > > hSimVertices
std::unordered_multimap< Barcode_t, Index_t > m_simTrackToSimVertex
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup) override
std::vector< Barcode_t > descendantTrackBarcodes(Barcode_t barcode)
std::unordered_multimap< Barcode_t, Index_t > m_simHitBarcodeToIndex
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
Definition: SimCluster.h:210
const unsigned int maximumSubsequentBunchCrossing_
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::unordered_map< Barcode_t, Index_t > m_genParticleBarcodeToIndex
std::unordered_map< Barcode_t, Index_t > m_genBarcodeToSimTrackIndex
std::vector< edm::InputTag > collectionTags_
Definition: config.py:1
std::unique_ptr< SimHitInfoPerSimTrack_t > attachedSimHitInfo(Barcode_t st, const std::vector< std::pair< DetId, const PCaloHit * > > &hits, bool includeOwn=true, bool includeOther=false, bool markUsed=false)
ForwardSubdetector
OutputCollections output_
void addRecHitAndFraction(uint32_t hit, float fraction)
add rechit with fraction
Definition: SimCluster.h:204
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
const HcalTopology & topology() const
Definition: HcalGeometry.h:117
U second(std::pair< T, U > const &p)
edm::InputTag hepMCproductLabel_
Needed to add HepMC::GenVertex to SimVertex.
const std::string messageCategory_
The message category used to send messages to MessageLogger.
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
std::unique_ptr< SimHitInfoPerSimTrack_t > allAttachedSimHitInfo(Barcode_t st, const std::vector< std::pair< DetId, const PCaloHit * > > &hits, bool markUsed=false)
simTrack
per collection params
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
const HGCalTopology & topology() const
Definition: HGCalGeometry.h:96
void fillSimHits(std::vector< std::pair< DetId, const PCaloHit * > > &returnValue, const T &event, const edm::EventSetup &setup)
Fills the supplied vector with pointers to the SimHits, checking for bad modules if required...
void clearHitsAndFractions()
clear the hits and fractions list
Definition: SimCluster.h:219
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
const edm::InputTag simVertexLabel_
void addSimCluster(const SimClusterRef &ref)
Definition: CaloParticle.h:62
std::vector< std::string > getParameterNames() const
bool isValid() const
Definition: HandleBase.h:74
bool consideredBarcode(Barcode_t barcode)
std::unordered_map< Barcode_t, Barcode_t > m_simTrackBarcodeToSimVertexParentBarcode
const HGCalDDDConstants * hgddd_[2]
std::vector< Barcode_t > m_simVertexBarcodes
double waferZ(int layer, bool reco) const
const edm::InputTag simTrackLabel_
If bremsstrahlung merging, whether to also add the unmerged collection to the event or not...
CaloTruthAccumulator(const edm::ParameterSet &config, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
std::unordered_map< Barcode_t, Index_t > m_simTrackBarcodeToIndex
edm::Handle< std::vector< SimTrack > > hSimTracks
std::unordered_map< Barcode_t, Index_t > m_simVertexBarcodeToIndex
Definition: DetId.h:18
void accumulateEvent(const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
Both forms of accumulate() delegate to this templated method.
virtual void accumulate(const edm::Event &event, const edm::EventSetup &setup) override
std::unique_ptr< CaloParticleCollection > pCaloParticles
const HGCalDDDConstants & dddConstants() const
ParameterSet const & getParameterSet(std::string const &) const
const T & get() const
Definition: EventSetup.h:56
unsigned Index_t
std::unique_ptr< SimHitInfoPerSimTrack_t > descendantOnlySimHitInfo(Barcode_t st, const std::vector< std::pair< DetId, const PCaloHit * > > &hits, bool markUsed=false)
const HcalDDDRecConstants * hcddd_
virtual void finalizeEvent(edm::Event &event, const edm::EventSetup &setup) override
std::vector< SimHitInfoPerRecoDetId_t > SimHitInfoPerSimTrack_t
int Barcode_t
std::set< Barcode_t > m_simTracksConsideredForSimClusters
HLT enums.
#define DEFINE_DIGI_ACCUMULATOR(type)
std::vector< CaloParticle > CaloParticleCollection
SimClusterCollection descendantSimClusters(Barcode_t barcode, const std::vector< std::pair< DetId, const PCaloHit * > > &hits)
std::unique_ptr< SimClusterCollection > pSimClusters
const HGCalTopology * hgtopo_[2]
std::unordered_multimap< Barcode_t, Index_t > m_simVertexToSimTrackParent
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
std::unordered_map< Index_t, float > m_detIdToTotalSimEnergy
long double T
std::unordered_multimap< Barcode_t, Barcode_t > m_simVertexBarcodeToSimTrackBarcode
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1
const unsigned int maximumPreviousBunchCrossing_
maximum distance for HepMC::GenVertex to be added to SimVertex