LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
LArPandoraEvent.cxx
Go to the documentation of this file.
1 
8 
9 namespace lar_pandora
10 {
11 
12 LArPandoraEvent::LArPandoraEvent(art::EDProducer *pProducer, art::Event *pEvent, const Labels &inputLabels, const bool shouldProduceT0s, const size_t shift) :
13  m_pProducer(pProducer),
14  m_pEvent(pEvent),
15  m_labels(inputLabels),
16  m_shouldProduceT0s(shouldProduceT0s),
17  m_shift(shift)
18 {
19  this->GetCollections();
20 
22  {
23  if (!m_pfParticleToOriginIdMap.insert(std::map< art::Ptr< recob::PFParticle >, unsigned int >::value_type(part, 0)).second)
24  throw cet::exception("LArPandora") << " LArPandoraEvent::LArPandoraEvent -- Repeated input PFParticles!" << std::endl;
25  }
26 }
27 
28 //------------------------------------------------------------------------------------------------------------------------------------------
29 
31  m_pProducer(event.m_pProducer),
32  m_pEvent(event.m_pEvent),
33  m_labels(event.m_labels),
35  m_shift(event.m_shift),
36  m_hits(event.m_hits)
37 {
38  m_pfParticles = selectedPFParticles;
40 
41  for (art::Ptr< recob::PFParticle > part : selectedPFParticles)
42  {
50 
53  }
54 
67 
69 }
70 
71 //------------------------------------------------------------------------------------------------------------------------------------------
72 
73 LArPandoraEvent LArPandoraEvent::FilterByPdgCode(const bool shouldProduceNeutrinos) const
74 {
75  PFParticleVector primaryPFParticles;
76  this->GetPrimaryPFParticles(primaryPFParticles);
77 
78  PFParticleVector filteredPFParticles;
79  this->GetFilteredParticlesByPdgCode(shouldProduceNeutrinos, primaryPFParticles, filteredPFParticles);
80 
81  PFParticleVector selectedPFParticles;
82  this->GetDownstreamPFParticles(filteredPFParticles, selectedPFParticles);
83 
84  LArPandoraEvent filteredEvent(*this, selectedPFParticles);
85 
86  return filteredEvent;
87 }
88 
89 //------------------------------------------------------------------------------------------------------------------------------------------
90 
91 LArPandoraEvent LArPandoraEvent::FilterByCRTag(const bool shouldProduceNeutrinos, const std::string &tagProducerLabel) const
92 {
93  PFParticleVector primaryPFParticles;
94  this->GetPrimaryPFParticles(primaryPFParticles);
95 
96  PFParticleVector filteredPFParticles;
97  this->GetFilteredParticlesByCRTag(shouldProduceNeutrinos, tagProducerLabel, primaryPFParticles, filteredPFParticles);
98 
99  PFParticleVector selectedPFParticles;
100  this->GetDownstreamPFParticles(filteredPFParticles, selectedPFParticles);
101 
102  LArPandoraEvent filteredEvent(*this, selectedPFParticles);
103 
104  return filteredEvent;
105 }
106 
107 //------------------------------------------------------------------------------------------------------------------------------------------
108 
110 {
115  this->WriteCollection(m_tracks);
116  this->WriteCollection(m_showers);
117  this->WriteCollection(m_pcAxes);
119 
132 
133  if (m_shouldProduceT0s)
134  {
135  this->WriteCollection(m_t0s);
137  }
138 }
139 
140 //------------------------------------------------------------------------------------------------------------------------------------------
141 
143 {
144  if (m_shift != other.m_shift)
145  throw cet::exception("LArPandora") << " LArPandoraEvent::Merge - Can't merge LArPandoraEvents with differing shift values." << std::endl;
146 
147  LArPandoraEvent outputEvent(other);
148 
150 
151  this->MergeCollection(outputEvent.m_pfParticles, m_pfParticles);
152  this->MergeCollection(outputEvent.m_spacePoints, m_spacePoints);
153  this->MergeCollection(outputEvent.m_clusters, m_clusters);
154  this->MergeCollection(outputEvent.m_vertices, m_vertices);
155  this->MergeCollection(outputEvent.m_tracks, m_tracks);
156  this->MergeCollection(outputEvent.m_showers, m_showers);
157  this->MergeCollection(outputEvent.m_pcAxes, m_pcAxes);
158  this->MergeCollection(outputEvent.m_metadata, m_metadata);
159  this->MergeCollection(outputEvent.m_hits, m_hits);
160 
161  if (m_shouldProduceT0s)
162  this->MergeCollection(outputEvent.m_t0s, m_t0s);
163 
171 
172  if (m_shouldProduceT0s)
174 
177  this->MergeAssociation(outputEvent.m_trackHitMap, m_trackHitMap);
178  this->MergeAssociation(outputEvent.m_showerHitMap, m_showerHitMap);
180 
181  return outputEvent;
182 }
183 
184 //------------------------------------------------------------------------------------------------------------------------------------------
185 
187 {
197 
198  this->GetCollection(Labels::PFParticleLabel, pfParticleHandle, m_pfParticles);
199  this->GetCollection(Labels::SpacePointLabel, spacePointHandle, m_spacePoints);
200  this->GetCollection(Labels::ClusterLabel, clusterHandle, m_clusters);
201  this->GetCollection(Labels::VertexLabel, vertexHandle, m_vertices);
202  this->GetCollection(Labels::TrackLabel, trackHandle, m_tracks);
203  this->GetCollection(Labels::ShowerLabel, showerHandle, m_showers);
204  this->GetCollection(Labels::PCAxisLabel, pcAxisHandle, m_pcAxes);
206  this->GetCollection(Labels::HitLabel, hitHandle, m_hits);
207 
220 
221  if (m_shouldProduceT0s)
222  {
224  this->GetCollection(Labels::T0Label, t0Handle, m_t0s);
226  }
227 
228  this->GetPFParticleHierarchy();
229 }
230 
231 //------------------------------------------------------------------------------------------------------------------------------------------
232 
234 {
235  std::map< size_t, art::Ptr< recob::PFParticle > > idToPFParticleMap;
236  this->GetIdToPFParticleMap(idToPFParticleMap);
237 
239  {
240  PFParticleVector daughters;
241  if (!m_pfParticleDaughterMap.insert(PFParticlesToPFParticles::value_type(part, daughters)).second)
242  throw cet::exception("LArPandora") << " LArPandoraEvent::GetPFParticleHierarchy -- Repeated PFParticle in heirarchy map!" << std::endl;
243 
244  for (const size_t & daughterId : part->Daughters())
245  {
246  if (idToPFParticleMap.find(daughterId) == idToPFParticleMap.end())
247  throw cet::exception("LArPandora") << " LArPandoraEvent::GetPFParticleHierarchy -- Can't access map entry for daughter of PFParticle supplied." << std::endl;
248 
249  art::Ptr< recob::PFParticle > daughter = idToPFParticleMap.at(daughterId);
251  throw cet::exception("LArPandora") << " LArPandoraEvent::GetPFParticleHierarchy -- Can't have the same daughter twice!" << std::endl;
252 
253  m_pfParticleDaughterMap[part].push_back(daughter);
254  }
255  }
256 }
257 
258 //------------------------------------------------------------------------------------------------------------------------------------------
259 
261 {
263  {
264  if (part->IsPrimary())
265  primaryPFParticles.push_back(part);
266  }
267 }
268 
269 //------------------------------------------------------------------------------------------------------------------------------------------
270 
271 void LArPandoraEvent::GetFilteredParticlesByPdgCode(const bool shouldProduceNeutrinos, const PFParticleVector &inputPFParticles, PFParticleVector &outputPFParticles) const
272 {
273  for (art::Ptr<recob::PFParticle> part : inputPFParticles)
274  {
275  unsigned int pdg = std::abs(part->PdgCode());
276  bool isNeutrino = (pdg == nue || pdg == numu || pdg == nutau);
277 
278  if ((shouldProduceNeutrinos && isNeutrino) || (!shouldProduceNeutrinos && !isNeutrino))
279  outputPFParticles.push_back(part);
280  }
281 }
282 
283 //------------------------------------------------------------------------------------------------------------------------------------------
284 
285 void LArPandoraEvent::GetFilteredParticlesByCRTag(const bool shouldProduceNeutrinos, const std::string &tagProducerLabel, const PFParticleVector &inputPFParticles,
286  PFParticleVector &outputPFParticles) const
287 {
288 
291 
292  art::FindManyP< anab::CosmicTag > pfParticleTagAssoc(pfParticleHandle, *m_pEvent, tagProducerLabel);
293 
294  for (art::Ptr< recob::PFParticle > part : inputPFParticles)
295  {
296  const CosmicTagVector cosmicTags = pfParticleTagAssoc.at(part.key());
297 
298  if (cosmicTags.size() != 1)
299  throw cet::exception("LArPandora") << " LArPandoraEvent::GetFilteredParticlesByCRTag -- Found " << cosmicTags.size() << " CR tags for a PFParticle (require 1)." << std::endl;
300 
301  art::Ptr< anab::CosmicTag > cosmicTag = cosmicTags.front();
302  bool isNeutrino = (cosmicTag->CosmicType() == anab::kNotTagged);
303 
304  if ((shouldProduceNeutrinos && isNeutrino) || (!shouldProduceNeutrinos && !isNeutrino))
305  outputPFParticles.push_back(part);
306  }
307 }
308 
309 //------------------------------------------------------------------------------------------------------------------------------------------
310 
311 void LArPandoraEvent::GetFilteredHierarchyMap(const PFParticleVector &filteredParticles, const PFParticlesToPFParticles &unfilteredPFParticleDaughterMap,
312  PFParticlesToPFParticles &outputPFParticleDaughterMap) const
313 {
314  for (PFParticlesToPFParticles::const_iterator it = unfilteredPFParticleDaughterMap.begin(); it != unfilteredPFParticleDaughterMap.end(); ++it)
315  {
316  if (std::find(filteredParticles.begin(), filteredParticles.end(), it->first) == filteredParticles.end()) continue;
317 
318  if (! outputPFParticleDaughterMap.insert(PFParticlesToPFParticles::value_type(it->first, it->second)).second)
319  throw cet::exception("LArPandora") << " LArPandoraEvent::GetFilteredHierarchyMap -- Can't add multiple map entries for same PFParticle" << std::endl;
320  }
321 }
322 
323 //------------------------------------------------------------------------------------------------------------------------------------------
324 
325 void LArPandoraEvent::GetIdToPFParticleMap(std::map<size_t, art::Ptr<recob::PFParticle> > &idToPFParticleMap) const
326 {
328  {
329  if (!idToPFParticleMap.insert(std::map<size_t, art::Ptr<recob::PFParticle> >::value_type(part->Self(), part)).second)
330  throw cet::exception("LArPandora") << " LArPandoraEvent::GetIdToPFParticleMap -- Can't insert multiple entries with the same Id" << std::endl;
331  }
332 }
333 
334 //------------------------------------------------------------------------------------------------------------------------------------------
335 
336 void LArPandoraEvent::GetDownstreamPFParticles(const PFParticleVector &inputPFParticles, PFParticleVector &downstreamPFParticles) const
337 {
338  for (art::Ptr<recob::PFParticle> part : inputPFParticles)
339  this->GetDownstreamPFParticles(part, downstreamPFParticles);
340 }
341 
342 //------------------------------------------------------------------------------------------------------------------------------------------
343 
345 {
346  if (m_pfParticleDaughterMap.find(part) == m_pfParticleDaughterMap.end())
347  throw cet::exception("LArPandora") << " LArPandoraEvent::GetDownstreamPFParticles -- Could not find PFParticle in the hierarchy map" << std::endl;
348 
349  if (std::find(downstreamPFParticles.begin(), downstreamPFParticles.end(), part) == downstreamPFParticles.end())
350  downstreamPFParticles.push_back(part);
351 
352  for (const art::Ptr< recob::PFParticle > & daughter : m_pfParticleDaughterMap.at(part))
353  this->GetDownstreamPFParticles(daughter, downstreamPFParticles);
354 }
355 
356 //------------------------------------------------------------------------------------------------------------------------------------------
357 
358 void LArPandoraEvent::FillPFParticleToOriginIdMap(const std::map<art::Ptr<recob::PFParticle>, unsigned int> &existingMap)
359 {
361  {
362  if (existingMap.find(part) == existingMap.end())
363  throw cet::exception("LArPandora") << " LArPandoraEvent::FillPFParticleToOriginIdMap -- Can't access map entry for PFParticle supplied." << std::endl;
364 
365  if (!m_pfParticleToOriginIdMap.insert(std::map< art::Ptr< recob::PFParticle >, unsigned int >::value_type(part, existingMap.at(part))).second)
366  throw cet::exception("LArPandora") << " LArPandoraEvent::FillPFParticleToOriginIdMap -- Can't add multiple map entries for same PFParticle" << std::endl;
367  }
368 }
369 
370 //------------------------------------------------------------------------------------------------------------------------------------------
371 
373  const std::map<art::Ptr<recob::PFParticle>, unsigned int> &mapToAdd) const
374 {
375  unsigned int maxID = 0;
376  if (mapToMerge.size() != 0)
377  {
378  maxID = std::max_element(mapToMerge.begin(), mapToMerge.end(), [](const std::pair<art::Ptr<recob::PFParticle>, unsigned int> &p1, const std::pair< art::Ptr<recob::PFParticle>, unsigned int> &p2) {return p1.second < p2.second;})->second;
379  }
380 
381  for (std::map< art::Ptr< recob::PFParticle >, unsigned int >::const_iterator it=mapToAdd.begin(); it != mapToAdd.end(); ++it)
382  {
383  if (!mapToMerge.insert(std::map< art::Ptr<recob::PFParticle>, unsigned int>::value_type(it->first, it->second + maxID + 1)).second)
384  throw cet::exception("LArPandora") << " LArPandoraEvent::MergePFParticleToOriginIdMap - Can't merge collections containing repeated PFParticles." << std::endl;
385  }
386 }
387 
388 //------------------------------------------------------------------------------------------------------------------------------------------
389 //------------------------------------------------------------------------------------------------------------------------------------------
390 
391 LArPandoraEvent::Labels::Labels(const std::string &pfParticleProducerLabel, const std::string &hitProducerLabel)
392 {
393  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleLabel, pfParticleProducerLabel));
394  m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointLabel, pfParticleProducerLabel));
395  m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterLabel, pfParticleProducerLabel));
396  m_labels.insert(std::map< LabelType, std::string >::value_type(VertexLabel, pfParticleProducerLabel));
397  m_labels.insert(std::map< LabelType, std::string >::value_type(TrackLabel, pfParticleProducerLabel));
398  m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerLabel, pfParticleProducerLabel));
399  m_labels.insert(std::map< LabelType, std::string >::value_type(T0Label, pfParticleProducerLabel));
400  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleMetadataLabel, pfParticleProducerLabel));
401  m_labels.insert(std::map< LabelType, std::string >::value_type(PCAxisLabel, pfParticleProducerLabel));
402  m_labels.insert(std::map< LabelType, std::string >::value_type(HitLabel, hitProducerLabel));
403 
404  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToSpacePointLabel, pfParticleProducerLabel));
405  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToClusterLabel, pfParticleProducerLabel));
406  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToVertexLabel, pfParticleProducerLabel));
407  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToTrackLabel, pfParticleProducerLabel));
408  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToShowerLabel, pfParticleProducerLabel));
409  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToT0Label, pfParticleProducerLabel));
410  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToMetadataLabel, pfParticleProducerLabel));
411  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToPCAxisLabel, pfParticleProducerLabel));
412  m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointToHitLabel, pfParticleProducerLabel));
413  m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterToHitLabel, pfParticleProducerLabel));
414  m_labels.insert(std::map< LabelType, std::string >::value_type(TrackToHitLabel, pfParticleProducerLabel));
415  m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToHitLabel, pfParticleProducerLabel));
416  m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToPCAxisLabel, pfParticleProducerLabel));
417 }
418 
419 //------------------------------------------------------------------------------------------------------------------------------------------
420 
421 LArPandoraEvent::Labels::Labels(const std::string &pfParticleProducerLabel, const std::string &trackProducerLabel, const std::string &showerProducerLabel,
422  const std::string &hitProducerLabel)
423 {
424  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleLabel, pfParticleProducerLabel));
425  m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointLabel, pfParticleProducerLabel));
426  m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterLabel, pfParticleProducerLabel));
427  m_labels.insert(std::map< LabelType, std::string >::value_type(VertexLabel, pfParticleProducerLabel));
428  m_labels.insert(std::map< LabelType, std::string >::value_type(TrackLabel, trackProducerLabel));
429  m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerLabel, showerProducerLabel));
430  m_labels.insert(std::map< LabelType, std::string >::value_type(T0Label, pfParticleProducerLabel));
431  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleMetadataLabel, pfParticleProducerLabel));
432  m_labels.insert(std::map< LabelType, std::string >::value_type(PCAxisLabel, showerProducerLabel));
433  m_labels.insert(std::map< LabelType, std::string >::value_type(HitLabel, hitProducerLabel));
434 
435  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToSpacePointLabel, pfParticleProducerLabel));
436  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToClusterLabel, pfParticleProducerLabel));
437  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToVertexLabel, pfParticleProducerLabel));
438  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToTrackLabel, trackProducerLabel));
439  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToShowerLabel, showerProducerLabel));
440  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToT0Label, pfParticleProducerLabel));
441  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToMetadataLabel, pfParticleProducerLabel));
442  m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToPCAxisLabel, showerProducerLabel));
443  m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointToHitLabel, pfParticleProducerLabel));
444  m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterToHitLabel, pfParticleProducerLabel));
445  m_labels.insert(std::map< LabelType, std::string >::value_type(TrackToHitLabel, trackProducerLabel));
446  m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToHitLabel, showerProducerLabel));
447  m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToPCAxisLabel, showerProducerLabel));
448 }
449 
450 //------------------------------------------------------------------------------------------------------------------------------------------
451 
452 const std::string &LArPandoraEvent::Labels::GetLabel(const LabelType &type) const
453 {
454  return m_labels.at(type);
455 }
456 
457 //------------------------------------------------------------------------------------------------------------------------------------------
458 
460 {
461  m_labels[SpacePointLabel] = label;
462 }
463 
464 //------------------------------------------------------------------------------------------------------------------------------------------
465 
467 {
468  m_labels[ClusterLabel] = label;
469 }
470 
471 //------------------------------------------------------------------------------------------------------------------------------------------
472 
474 {
475  m_labels[VertexLabel] = label;
476 }
477 
478 //------------------------------------------------------------------------------------------------------------------------------------------
479 
481 {
482  m_labels[TrackLabel] = label;
483 }
484 
485 //------------------------------------------------------------------------------------------------------------------------------------------
486 
488 {
489  m_labels[ShowerLabel] = label;
490 }
491 
492 //------------------------------------------------------------------------------------------------------------------------------------------
493 
494 void LArPandoraEvent::Labels::SetT0ProducerLabel(const std::string &label)
495 {
496  m_labels[T0Label] = label;
497 }
498 
499 //------------------------------------------------------------------------------------------------------------------------------------------
500 
502 {
503  m_labels[PFParticleMetadataLabel] = label;
504 }
505 
506 //------------------------------------------------------------------------------------------------------------------------------------------
507 
509 {
510  m_labels[PCAxisLabel] = label;
511 }
512 
513 //------------------------------------------------------------------------------------------------------------------------------------------
514 
516 {
517  m_labels[PFParticleToSpacePointLabel] = label;
518 }
519 
520 //------------------------------------------------------------------------------------------------------------------------------------------
521 
523 {
524  m_labels[PFParticleToClusterLabel] = label;
525 }
526 
527 //------------------------------------------------------------------------------------------------------------------------------------------
528 
530 {
531  m_labels[PFParticleToVertexLabel] = label;
532 }
533 
534 //------------------------------------------------------------------------------------------------------------------------------------------
535 
537 {
538  m_labels[PFParticleToTrackLabel] = label;
539 }
540 
541 //------------------------------------------------------------------------------------------------------------------------------------------
542 
544 {
545  m_labels[PFParticleToShowerLabel] = label;
546 }
547 
548 //------------------------------------------------------------------------------------------------------------------------------------------
549 
551 {
552  m_labels[PFParticleToT0Label] = label;
553 }
554 
555 //------------------------------------------------------------------------------------------------------------------------------------------
556 
558 {
559  m_labels[PFParticleToPCAxisLabel] = label;
560 }
561 
562 //------------------------------------------------------------------------------------------------------------------------------------------
563 
565 {
566  m_labels[SpacePointToHitLabel] = label;
567 }
568 
569 //------------------------------------------------------------------------------------------------------------------------------------------
570 
572 {
573  m_labels[ClusterToHitLabel] = label;
574 }
575 
576 //------------------------------------------------------------------------------------------------------------------------------------------
577 
579 {
580  m_labels[TrackToHitLabel] = label;
581 }
582 
583 //------------------------------------------------------------------------------------------------------------------------------------------
584 
586 {
587  m_labels[ShowerToHitLabel] = label;
588 }
589 
590 //------------------------------------------------------------------------------------------------------------------------------------------
591 
593 {
594  m_labels[ShowerToPCAxisLabel] = label;
595 }
596 
597 } // namespace lar_pandora
void GetPFParticleHierarchy()
Get the mapping from PFParticles to their daughters.
ShowersToHits m_showerHitMap
The input associations: Shower -> Hit.
void GetFilteredAssociationMap(const std::vector< art::Ptr< T > > &collectionT, const std::vector< art::Ptr< U > > &collectionU, const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &inputAssociationTtoU, std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &outputAssociationTtoU) const
Gets the mapping between two filtered collections.
SpacePointVector m_spacePoints
The input collection of SpacePoints.
MetadataVector m_metadata
The input collection of PFParticle metadata.
void WriteAssociation(const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &associationMap, const std::vector< art::Ptr< T > > &collectionT, const std::vector< art::Ptr< U > > &collectionU, const bool thisProducesU=true) const
Write a given association to the event.
void SetSpacePointToHitProducerLabel(const std::string &label)
ShowerVector m_showers
The input collection of Showers.
LArPandoraEvent class.
void SetVertexProducerLabel(const std::string &label)
LArPandoraEvent(art::EDProducer *pProducer, art::Event *pEvent, const Labels &inputLabels, const bool shouldProduceT0s=false, const size_t shift=100000)
Constructor from an art::Event.
const std::string & GetLabel(const LabelType &type) const
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
LabelType
Label type enumeration.
ClustersToHits m_clusterHitMap
The input associations: Cluster -> Hit.
void SetPFParticleToShowerProducerLabel(const std::string &label)
PFParticlesToVertices m_pfParticleVertexMap
The input associations: PFParticle -> Vertex.
PFParticlesToMetadata m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
void SetClusterProducerLabel(const std::string &label)
ShowersToPCAxes m_showerPCAxisMap
The input associations: PCAxis -> Shower.
void SetMetadataProducerLabel(const std::string &label)
void FillPFParticleToOriginIdMap(const std::map< art::Ptr< recob::PFParticle >, unsigned int > &existingMap)
Fills the PFParticleToOriginIdMap using an existing map from another LArPandoraEvent.
void GetAssociationMap(const Labels::LabelType &inputLabel, art::Handle< std::vector< T > > &inputHandleT, std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &outputAssociationMap) const
Get the mapping between two collections using the specified label.
Labels(const std::string &pfParticleProducerLabel, const std::string &hitProducerLabel)
Minimal parametrised constructor. Sets all collection labels to be the same as the PFParticle produce...
void SetPFParticleToVertexProducerLabel(const std::string &label)
void GetCollections()
Get the collections and associations from m_pEvent with the required labels.
void GetCollection(const Labels::LabelType &inputLabel, art::Handle< std::vector< T > > &outputHandle, std::vector< art::Ptr< T > > &outputCollection) const
Gets a given collection from m_pEvent with the label supplied.
VertexVector m_vertices
The input collection of Vertices.
void SetPFParticleToSpacePointProducerLabel(const std::string &label)
PFParticlesToPFParticles m_pfParticleDaughterMap
The mapping from parent to daughter PFParticles.
LArPandoraEvent FilterByPdgCode(const bool shouldProduceNeutrinos) const
Produce a copy of the event keeping only the collections that are associated with a top-level particl...
std::map< art::Ptr< recob::PFParticle >, unsigned int > m_pfParticleToOriginIdMap
Mapping between PFParticles, and an ID for the LArPandoraEvent from which they originated (to keep tr...
void WriteCollection(const std::vector< art::Ptr< T > > &collection) const
Write a given collection to the event.
void SetPFParticleToPCAxisProducerLabel(const std::string &label)
HitVector m_hits
The input collection of Hits.
std::map< art::Ptr< recob::PFParticle >, std::vector< art::Ptr< recob::PFParticle > > > PFParticlesToPFParticles
PFParticlesToT0s m_pfParticleT0Map
The input associations: PFParticle -> T0.
void GetFilteredParticlesByCRTag(const bool shouldProduceNeutrinos, const std::string &tagProducerLabel, const PFParticleVector &inputPFParticles, PFParticleVector &outputPFParticles) const
Filters PFParticles based on their Pdg from the inputPFParticles.
intermediate_table::const_iterator const_iterator
PFParticlesToSpacePoints m_pfParticleSpacePointMap
The input associations: PFParticle -> SpacePoint.
A description of all outputs from an instance of pandora with functionality to filter and merge multi...
void SetTrackProducerLabel(const std::string &label)
void MergeAssociation(std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &associationToMerge, const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &association) const
Append an association to another association.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
TString part[npart]
Definition: Style.C:32
TrackVector m_tracks
The input collection of Tracks.
PFParticlesToTracks m_pfParticleTrackMap
The input associations: PFParticle -> Track.
void SetSpacePointProducerLabel(const std::string &label)
art::Event * m_pEvent
The event to consider.
void GetFilteredHierarchyMap(const PFParticleVector &filteredParticles, const PFParticlesToPFParticles &unfilteredPFParticleDaughterMap, PFParticlesToPFParticles &outputPFParticleDaughterMap) const
Filters the hierarchy map using a given vector of filteredParticles.
void SetClusterToHitProducerLabel(const std::string &label)
T0Vector m_t0s
The input collection of T0s.
void SetShowerProducerLabel(const std::string &label)
void MergeCollection(std::vector< art::Ptr< T > > &collectionToMerge, const std::vector< art::Ptr< T > > &collection) const
Append a collection onto an other collection.
PCAxisVector m_pcAxes
The input collection of PCAxes.
SpacePointsToHitVector m_spacePointHitMap
The input associations: SpacePoint -> Hit.
ClusterVector m_clusters
The input collection of Clusters.
void GetFilteredParticlesByPdgCode(const bool shouldProduceNeutrinos, const PFParticleVector &inputPFParticles, PFParticleVector &outputPFParticles) const
Filters PFParticles based on their Pdg from the inputPFParticles.
void GetDownstreamPFParticles(const PFParticleVector &inputPFParticles, PFParticleVector &downstreamPFParticles) const
Get particles downstream of any particle in an input vector.
PFParticleVector m_pfParticles
The input collection of PFParticles.
void SetShowerToHitProducerLabel(const std::string &label)
void SetPFParticleToClusterProducerLabel(const std::string &label)
void MergePFParticleToOriginIdMap(std::map< art::Ptr< recob::PFParticle >, unsigned int > &mapToMerge, const std::map< art::Ptr< recob::PFParticle >, unsigned int > &mapToAdd) const
Merge two PFParticle to origin ID maps ensuring no ID collisions.
void GetIdToPFParticleMap(std::map< size_t, art::Ptr< recob::PFParticle > > &idToPFParticleMap) const
Produce a mapping between PFParticles and their ID.
art::EDProducer * m_pProducer
The producer which should write the output collections and associations.
void CollectAssociated(const art::Ptr< T > &anObject, const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &associationTtoU, std::vector< art::Ptr< U > > &associatedU) const
Collects all objects of type U associated to a given object of type T.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
Class to handle the required producer labels.
void SetT0ProducerLabel(const std::string &label)
LArPandoraEvent FilterByCRTag(const bool shouldProduceNeutrinos, const std::string &tagProducerLabel) const
Produce a copy of the event keeping only the collections that are associated with a top-level particl...
TracksToHits m_trackHitMap
The input associations: Track -> Hit.
void SetPCAxisProducerLabel(const std::string &label)
Labels m_labels
A set of labels describing the producers for each input collection.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void SetShowerToPCAxisProducerLabel(const std::string &label)
PFParticlesToPCAxes m_pfParticlePCAxisMap
The input associations: PFParticle -> PCAxis.
void SetPFParticleToT0ProducerLabel(const std::string &label)
LArPandoraEvent Merge(const LArPandoraEvent &other) const
Merge collections from two events into one.
PFParticlesToClusters m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
void SetTrackToHitProducerLabel(const std::string &label)
CosmicTagID_t & CosmicType()
Definition: CosmicTag.h:66
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void SetPFParticleToTrackProducerLabel(const std::string &label)
Event finding and building.
const size_t m_shift
Amount by which to shift PFParticle IDs when merging two reconstructions of the same event...
void GetPrimaryPFParticles(PFParticleVector &primaryPFParticles) const
Filters primary PFParticles from the m_pfParticles.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...
PFParticlesToShowers m_pfParticleShowerMap
The input associations: PFParticle -> Shower.
void WriteToEvent() const
Write (put) the collections in this LArPandoraEvent to the art::Event.