LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArPandoraHelper.h
Go to the documentation of this file.
1 
7 #ifndef LAR_PANDORA_HELPER_H
8 #define LAR_PANDORA_HELPER_H
9 
10 namespace art {
11  class Event;
12 }
13 
15 
16 #include <map>
17 #include <set>
18 #include <unordered_set>
19 #include <vector>
20 
21 namespace anab {
22  class CosmicTag;
23  class T0;
24 }
25 namespace pandora {
26  class ParticleFlowObject;
27  class Vertex;
28  typedef std::vector<int> IntVector;
29 }
30 namespace recob {
31  class Cluster;
32  class Hit;
33  class PFParticle;
34  class Seed;
35  class Shower;
36  class Slice;
37  class SpacePoint;
38  class Track;
39  class Vertex;
40  class Wire;
41 }
42 namespace larpandoraobj {
43  class PFParticleMetadata;
44 }
45 
48 
49 namespace simb {
50  class MCTruth;
51 }
52 
53 //------------------------------------------------------------------------------------------------------------------------------------------
54 
55 namespace lar_pandora {
56 
57  typedef std::set<art::Ptr<recob::Hit>> HitList;
58 
59  typedef std::vector<art::Ptr<recob::Wire>> WireVector;
60  typedef std::vector<art::Ptr<recob::Hit>> HitVector;
61  typedef std::vector<art::Ptr<recob::SpacePoint>> SpacePointVector;
62  typedef std::vector<art::Ptr<recob::Cluster>> ClusterVector;
63  typedef std::vector<art::Ptr<recob::Seed>> SeedVector;
64  typedef std::vector<art::Ptr<recob::Vertex>> VertexVector;
65  typedef std::vector<art::Ptr<recob::Track>> TrackVector;
66  typedef std::vector<art::Ptr<recob::Shower>> ShowerVector;
67  typedef std::vector<art::Ptr<recob::PFParticle>> PFParticleVector;
68  typedef std::vector<art::Ptr<simb::MCTruth>> MCTruthVector;
69  typedef std::vector<art::Ptr<simb::MCParticle>> MCParticleVector;
70  typedef std::vector<simb::MCParticle> RawMCParticleVector;
71  typedef std::vector<art::Ptr<sim::SimChannel>> SimChannelVector;
72  typedef std::vector<sim::TrackIDE> TrackIDEVector;
73  typedef std::vector<art::Ptr<anab::CosmicTag>> CosmicTagVector;
74  typedef std::vector<art::Ptr<anab::T0>> T0Vector;
75  typedef std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>> MetadataVector;
76 
77  typedef std::unordered_set<art::Ptr<recob::Hit>> HitSet;
78 
79  typedef std::map<art::Ptr<recob::PFParticle>, TrackVector> PFParticlesToTracks;
80  typedef std::map<art::Ptr<recob::PFParticle>, ShowerVector> PFParticlesToShowers;
81  typedef std::map<art::Ptr<recob::PFParticle>, ClusterVector> PFParticlesToClusters;
82  typedef std::map<art::Ptr<recob::PFParticle>, SeedVector> PFParticlesToSeeds;
83  typedef std::map<art::Ptr<recob::PFParticle>, VertexVector> PFParticlesToVertices;
84  typedef std::map<art::Ptr<recob::PFParticle>, SpacePointVector> PFParticlesToSpacePoints;
85  typedef std::map<art::Ptr<recob::PFParticle>, HitVector> PFParticlesToHits;
86  typedef std::map<art::Ptr<recob::PFParticle>, MetadataVector> PFParticlesToMetadata;
87  typedef std::map<art::Ptr<recob::Track>, HitVector> TracksToHits;
88  typedef std::map<art::Ptr<recob::Shower>, HitVector> ShowersToHits;
89  typedef std::map<art::Ptr<recob::Cluster>, HitVector> ClustersToHits;
90  typedef std::map<art::Ptr<recob::Seed>, art::Ptr<recob::Hit>> SeedsToHits;
91  typedef std::map<art::Ptr<recob::SpacePoint>, art::Ptr<recob::Hit>> SpacePointsToHits;
92  typedef std::map<art::Ptr<simb::MCTruth>, MCParticleVector> MCTruthToMCParticles;
93  typedef std::map<art::Ptr<simb::MCTruth>, HitVector> MCTruthToHits;
94  typedef std::map<art::Ptr<simb::MCTruth>, art::Ptr<recob::PFParticle>> MCTruthToPFParticles;
95  typedef std::map<art::Ptr<simb::MCParticle>, art::Ptr<simb::MCTruth>> MCParticlesToMCTruth;
96  typedef std::map<art::Ptr<simb::MCParticle>, HitVector> MCParticlesToHits;
97  typedef std::map<art::Ptr<simb::MCParticle>, art::Ptr<recob::PFParticle>>
99  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<recob::SpacePoint>> HitsToSpacePoints;
100  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<recob::PFParticle>> HitsToPFParticles;
101  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<simb::MCParticle>> HitsToMCParticles;
102  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<simb::MCTruth>> HitsToMCTruth;
103  typedef std::map<art::Ptr<recob::Hit>, TrackIDEVector> HitsToTrackIDEs;
104  typedef std::map<art::Ptr<recob::Track>, CosmicTagVector> TracksToCosmicTags;
105  typedef std::map<art::Ptr<recob::PFParticle>, T0Vector> PFParticlesToT0s;
106 
107  typedef std::map<int, art::Ptr<recob::PFParticle>> PFParticleMap;
108  typedef std::map<int, art::Ptr<recob::Cluster>> ClusterMap;
109  typedef std::map<int, art::Ptr<recob::SpacePoint>> SpacePointMap;
110  typedef std::map<int, art::Ptr<recob::Hit>> HitMap;
111  typedef std::map<int, art::Ptr<simb::MCParticle>> MCParticleMap;
112  typedef std::map<int, art::Ptr<sim::SimChannel>> SimChannelMap;
113 
114  typedef std::map<const pandora::ParticleFlowObject*, size_t> ThreeDParticleMap;
115  typedef std::map<const pandora::Vertex*, unsigned int> ThreeDVertexMap;
116  typedef std::map<int, HitVector> HitArray;
117 
122  public:
127  kIgnoreDaughters = 0, // Only use parent particles
128  kUseDaughters = 1, // Use both parent and daughter partcles
129  kAddDaughters = 2 // Absorb daughter particles into parent particles
130  };
131 
139  static void CollectWires(const art::Event& evt,
140  const std::string& label,
141  WireVector& wireVector);
142 
150  static void CollectHits(const art::Event& evt, const std::string& label, HitVector& hitVector);
151 
159  static void CollectPFParticles(const art::Event& evt,
160  const std::string& label,
161  PFParticleVector& particleVector);
162 
171  static void CollectSpacePoints(const art::Event& evt,
172  const std::string& label,
173  SpacePointVector& spacePointVector,
174  SpacePointsToHits& spacePointsToHits);
175 
185  static void CollectSpacePoints(const art::Event& evt,
186  const std::string& label,
187  SpacePointVector& spacePointVector,
188  SpacePointsToHits& spacePointsToHits,
189  HitsToSpacePoints& hitsToSpacePoints);
190 
199  static void CollectClusters(const art::Event& evt,
200  const std::string& label,
201  ClusterVector& clusterVector,
202  ClustersToHits& clustersToHits);
203 
212  static void CollectPFParticles(const art::Event& evt,
213  const std::string& label,
214  PFParticleVector& particleVector,
215  PFParticlesToSpacePoints& particlesToSpacePoints);
216 
225  static void CollectPFParticles(const art::Event& evt,
226  const std::string& label,
227  PFParticleVector& particleVector,
228  PFParticlesToClusters& particlesToClusters);
229 
238  static void CollectPFParticleMetadata(const art::Event& evt,
239  const std::string& label,
240  PFParticleVector& particleVector,
241  PFParticlesToMetadata& particlesToMetadata);
242 
251  static void CollectShowers(const art::Event& evt,
252  const std::string& label,
253  ShowerVector& showerVector,
254  PFParticlesToShowers& particlesToShowers);
255 
264  static void CollectShowers(const art::Event& evt,
265  const std::string& label,
266  ShowerVector& showerVector,
267  ShowersToHits& showersToHits);
268 
277  static void CollectTracks(const art::Event& evt,
278  const std::string& label,
279  TrackVector& trackVector,
280  PFParticlesToTracks& particlesToTracks);
281 
290  static void CollectTracks(const art::Event& evt,
291  const std::string& label,
292  TrackVector& trackVector,
293  TracksToHits& tracksToHits);
294 
303  static void CollectSeeds(const art::Event& evt,
304  const std::string& label,
305  SeedVector& seedVector,
306  PFParticlesToSeeds& particlesToSeeds);
307 
316  static void CollectSeeds(const art::Event& evt,
317  const std::string& label,
318  SeedVector& seedVector,
319  SeedsToHits& seedsToHits);
320 
329  static void CollectVertices(const art::Event& evt,
330  const std::string& label,
331  VertexVector& vertexVector,
332  PFParticlesToVertices& particlesToVertices);
333 
344  static void BuildPFParticleHitMaps(const PFParticleVector& particleVector,
345  const PFParticlesToSpacePoints& particlesToSpacePoints,
346  const SpacePointsToHits& spacePointsToHits,
347  PFParticlesToHits& particlesToHits,
348  HitsToPFParticles& hitsToParticles,
349  const DaughterMode daughterMode = kUseDaughters);
350 
361  static void BuildPFParticleHitMaps(const PFParticleVector& particleVector,
362  const PFParticlesToClusters& particlesToClusters,
363  const ClustersToHits& clustersToHits,
364  PFParticlesToHits& particlesToHits,
365  HitsToPFParticles& hitsToParticles,
366  const DaughterMode daughterMode = kUseDaughters);
367 
379  static void BuildPFParticleHitMaps(const art::Event& evt,
380  const std::string& label_pfpart,
381  const std::string& label_mid,
382  PFParticlesToHits& particlesToHits,
383  HitsToPFParticles& hitsToParticles,
384  const DaughterMode daughterMode = kUseDaughters,
385  const bool useClusters = true);
386 
397  static void BuildPFParticleHitMaps(const art::Event& evt,
398  const std::string& label,
399  PFParticlesToHits& particlesToHits,
400  HitsToPFParticles& hitsToParticles,
401  const DaughterMode daughterMode = kUseDaughters,
402  const bool useClusters = true);
403 
412  static void CollectCosmicTags(const art::Event& evt,
413  const std::string& label,
414  CosmicTagVector& cosmicTagVector,
415  TracksToCosmicTags& tracksToCosmicTags);
416 
425  static void CollectT0s(const art::Event& evt,
426  const std::string& label,
427  T0Vector& t0Vector,
428  PFParticlesToT0s& particlesToT0s);
429 
438  static void CollectSimChannels(const art::Event& evt,
439  const std::string& label,
440  SimChannelVector& simChannelVector,
441  bool& areSimChannelsValid);
442 
450  static void CollectMCParticles(const art::Event& evt,
451  const std::string& label,
452  MCParticleVector& particleVector);
453 
462  static void CollectGeneratorMCParticles(const art::Event& evt,
463  const std::string& label,
464  RawMCParticleVector& particleVector);
465 
474  static void CollectMCParticles(const art::Event& evt,
475  const std::string& label,
476  MCTruthToMCParticles& truthToParticles,
477  MCParticlesToMCTruth& particlesToTruth);
478 
487  static void BuildMCParticleHitMaps(const art::Event& evt,
488  const HitVector& hitVector,
489  const SimChannelVector& simChannelVector,
490  HitsToTrackIDEs& hitsToTrackIDEs);
491 
501  static void BuildMCParticleHitMaps(const HitsToTrackIDEs& hitsToTrackIDEs,
502  const MCTruthToMCParticles& truthToParticles,
503  MCParticlesToHits& particlesToHits,
504  HitsToMCParticles& hitsToParticles,
505  const DaughterMode daughterMode = kUseDaughters);
506 
517  static void BuildMCParticleHitMaps(const art::Event& evt,
518  const std::string& label,
519  const HitVector& hitVector,
520  MCParticlesToHits& particlesToHits,
521  HitsToMCParticles& hitsToParticles,
522  const DaughterMode daughterMode = kUseDaughters);
523 
532  static void BuildMCParticleHitMaps(const art::Event& evt,
533  const std::string& hitLabel,
534  const std::string& backtrackLabel,
535  HitsToTrackIDEs& hitsToTrackIDEs);
536 
548  static void BuildMCParticleHitMaps(const art::Event& evt,
549  const std::string& truthLabel,
550  const std::string& hitLabel,
551  const std::string& backtrackLabel,
552  MCParticlesToHits& particlesToHits,
553  HitsToMCParticles& hitsToParticles,
554  const DaughterMode daughterMode = kUseDaughters);
555 
565  template <typename T>
566  static void GetAssociatedHits(const art::Event& evt,
567  const std::string& label,
568  const std::vector<art::Ptr<T>>& inputVector,
569  HitVector& associatedHits,
570  const pandora::IntVector* const indexVector = nullptr);
571 
578  static void SelectNeutrinoPFParticles(const PFParticleVector& inputParticles,
579  PFParticleVector& outputParticles);
580 
587  static void SelectFinalStatePFParticles(const PFParticleVector& inputParticles,
588  PFParticleVector& outputParticles);
589 
596  static void BuildMCParticleMap(const MCParticleVector& particleVector,
597  MCParticleMap& particleMap);
598 
605  static void BuildPFParticleMap(const PFParticleVector& particleVector,
606  PFParticleMap& particleMap);
607 
616  static art::Ptr<recob::PFParticle> GetParentPFParticle(
617  const PFParticleMap& particleMap,
618  const art::Ptr<recob::PFParticle> daughterParticle);
619 
628  static art::Ptr<recob::PFParticle> GetFinalStatePFParticle(
629  const PFParticleMap& particleMap,
630  const art::Ptr<recob::PFParticle> daughterParticle);
631 
640  static art::Ptr<simb::MCParticle> GetParentMCParticle(
641  const MCParticleMap& particleMap,
642  const art::Ptr<simb::MCParticle> daughterParticle);
643 
652  static art::Ptr<simb::MCParticle> GetFinalStateMCParticle(
653  const MCParticleMap& particleMap,
654  const art::Ptr<simb::MCParticle> daughterParticle);
655 
662  static art::Ptr<recob::Track> GetPrimaryTrack(const PFParticlesToTracks& particlesToTracks,
663  const art::Ptr<recob::PFParticle> particle);
664 
673  static int GetGeneration(const PFParticleMap& particleMap,
674  const art::Ptr<recob::PFParticle> daughterParticle);
675 
684  static int GetParentNeutrino(const PFParticleMap& particleMap,
685  const art::Ptr<recob::PFParticle> daughterParticle);
686 
695  static bool IsFinalState(const PFParticleMap& particleMap,
696  const art::Ptr<recob::PFParticle> daughterParticle);
697 
705  static bool IsNeutrino(const art::Ptr<recob::PFParticle> particle);
706 
714  static bool IsTrack(const art::Ptr<recob::PFParticle> particle);
715 
723  static bool IsShower(const art::Ptr<recob::PFParticle> particle);
724 
732  static bool IsVisible(const art::Ptr<simb::MCParticle> particle);
733 
741  static larpandoraobj::PFParticleMetadata GetPFParticleMetadata(
742  const pandora::ParticleFlowObject* const pPfo);
743  };
744 
745 } // namespace lar_pandora
746 
747 #endif // LAR_PANDORA_HELPER_H
std::vector< art::Ptr< simb::MCTruth > > MCTruthVector
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
std::map< int, art::Ptr< sim::SimChannel > > SimChannelMap
Reconstruction base classes.
std::unordered_set< art::Ptr< recob::Hit > > HitSet
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
std::map< int, HitVector > HitArray
std::map< art::Ptr< simb::MCTruth >, HitVector > MCTruthToHits
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::map< art::Ptr< simb::MCParticle >, art::Ptr< recob::PFParticle > > MCParticlesToPFParticles
std::vector< art::Ptr< recob::Shower > > ShowerVector
std::vector< int > IntVector
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
Particle class.
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
std::map< int, art::Ptr< recob::Hit > > HitMap
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
std::map< art::Ptr< recob::Track >, CosmicTagVector > TracksToCosmicTags
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
std::vector< art::Ptr< recob::Seed > > SeedVector
std::map< art::Ptr< recob::PFParticle >, MetadataVector > PFParticlesToMetadata
std::map< art::Ptr< recob::PFParticle >, T0Vector > PFParticlesToT0s
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCTruth > > HitsToMCTruth
std::map< int, art::Ptr< recob::Cluster > > ClusterMap
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
std::vector< simb::MCParticle > RawMCParticleVector
LArPandoraHelper class.
Metadata associated to PFParticles.
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
std::map< art::Ptr< recob::PFParticle >, SeedVector > PFParticlesToSeeds
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< recob::Cluster >, HitVector > ClustersToHits
std::map< art::Ptr< recob::Shower >, HitVector > ShowersToHits
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
std::map< art::Ptr< simb::MCTruth >, art::Ptr< recob::PFParticle > > MCTruthToPFParticles
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > HitsToSpacePoints
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
std::vector< sim::TrackIDE > TrackIDEVector
std::vector< art::Ptr< larpandoraobj::PFParticleMetadata > > MetadataVector
std::vector< art::Ptr< recob::Track > > TrackVector
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
std::map< art::Ptr< recob::Track >, HitVector > TracksToHits
std::map< int, art::Ptr< recob::SpacePoint > > SpacePointMap
ART objects.
DaughterMode
DaughterMode enumeration.
std::map< const pandora::ParticleFlowObject *, size_t > ThreeDParticleMap
std::vector< art::Ptr< recob::Hit > > HitVector
std::vector< art::Ptr< sim::SimChannel > > SimChannelVector
std::vector< art::Ptr< recob::Wire > > WireVector
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::vector< art::Ptr< recob::Vertex > > VertexVector
Definition: MVAAlg.h:12
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< art::Ptr< recob::Cluster > > ClusterVector
TCEvent evt
Definition: DataStructs.cxx:8
std::vector< art::Ptr< anab::T0 > > T0Vector
std::map< art::Ptr< recob::Seed >, art::Ptr< recob::Hit > > SeedsToHits
std::map< const pandora::Vertex *, unsigned int > ThreeDVertexMap
std::set< art::Ptr< recob::Hit > > HitList
Definition: Track.hh:42
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits