All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArPandoraHelper.h
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraInterface/LArPandoraHelper.h
3  *
4  * @brief helper function for LArPandoraInterface producer module
5  *
6  */
7 #ifndef LAR_PANDORA_HELPER_H
8 #define LAR_PANDORA_HELPER_H
9 
10 namespace art { class Event; }
11 
12 #include "canvas/Persistency/Common/Ptr.h"
13 
14 #include <map>
15 #include <set>
16 #include <unordered_set>
17 #include <vector>
18 
19 namespace anab {
20  class CosmicTag;
21  class T0;
22 }
23 namespace pandora {
24  class ParticleFlowObject;
25  class Vertex;
26  typedef std::vector<int> IntVector;
27 }
28 namespace recob {
29  class Cluster;
30  class Hit;
31  class PFParticle;
32  class Seed;
33  class Shower;
34  class Slice;
35  class SpacePoint;
36  class Track;
37  class Vertex;
38  class Wire;
39 }
40 namespace larpandoraobj {
41  class PFParticleMetadata;
42 }
43 
44 #include "nusimdata/SimulationBase/MCParticle.h"
46 
47 namespace simb {
48  class MCTruth;
49 }
50 
51 //------------------------------------------------------------------------------------------------------------------------------------------
52 
53 namespace lar_pandora {
54 
55  typedef std::set<art::Ptr<recob::Hit>> HitList;
56 
57  typedef std::vector<art::Ptr<recob::Wire>> WireVector;
58  typedef std::vector<art::Ptr<recob::Hit>> HitVector;
59  typedef std::vector<art::Ptr<recob::SpacePoint>> SpacePointVector;
60  typedef std::vector<art::Ptr<recob::Cluster>> ClusterVector;
61  typedef std::vector<art::Ptr<recob::Seed>> SeedVector;
62  typedef std::vector<art::Ptr<recob::Vertex>> VertexVector;
63  typedef std::vector<art::Ptr<recob::Track>> TrackVector;
64  typedef std::vector<art::Ptr<recob::Shower>> ShowerVector;
65  typedef std::vector<art::Ptr<recob::PFParticle>> PFParticleVector;
66  typedef std::vector<art::Ptr<simb::MCTruth>> MCTruthVector;
67  typedef std::vector<art::Ptr<simb::MCParticle>> MCParticleVector;
68  typedef std::vector<simb::MCParticle> RawMCParticleVector;
69  typedef std::vector<art::Ptr<sim::SimChannel>> SimChannelVector;
70  typedef std::vector<sim::TrackIDE> TrackIDEVector;
71  typedef std::vector<art::Ptr<anab::CosmicTag>> CosmicTagVector;
72  typedef std::vector<art::Ptr<anab::T0>> T0Vector;
73  typedef std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>> MetadataVector;
74 
75  typedef std::unordered_set<art::Ptr<recob::Hit>> HitSet;
76 
77  typedef std::map<art::Ptr<recob::PFParticle>, TrackVector> PFParticlesToTracks;
78  typedef std::map<art::Ptr<recob::PFParticle>, ShowerVector> PFParticlesToShowers;
79  typedef std::map<art::Ptr<recob::PFParticle>, ClusterVector> PFParticlesToClusters;
80  typedef std::map<art::Ptr<recob::PFParticle>, SeedVector> PFParticlesToSeeds;
81  typedef std::map<art::Ptr<recob::PFParticle>, VertexVector> PFParticlesToVertices;
82  typedef std::map<art::Ptr<recob::PFParticle>, SpacePointVector> PFParticlesToSpacePoints;
83  typedef std::map<art::Ptr<recob::PFParticle>, HitVector> PFParticlesToHits;
84  typedef std::map<art::Ptr<recob::PFParticle>, MetadataVector> PFParticlesToMetadata;
85  typedef std::map<art::Ptr<recob::Track>, HitVector> TracksToHits;
86  typedef std::map<art::Ptr<recob::Shower>, HitVector> ShowersToHits;
87  typedef std::map<art::Ptr<recob::Cluster>, HitVector> ClustersToHits;
88  typedef std::map<art::Ptr<recob::Seed>, art::Ptr<recob::Hit>> SeedsToHits;
89  typedef std::map<art::Ptr<recob::SpacePoint>, art::Ptr<recob::Hit>> SpacePointsToHits;
90  typedef std::map<art::Ptr<simb::MCTruth>, MCParticleVector> MCTruthToMCParticles;
91  typedef std::map<art::Ptr<simb::MCTruth>, HitVector> MCTruthToHits;
92  typedef std::map<art::Ptr<simb::MCTruth>, art::Ptr<recob::PFParticle>> MCTruthToPFParticles;
93  typedef std::map<art::Ptr<simb::MCParticle>, art::Ptr<simb::MCTruth>> MCParticlesToMCTruth;
94  typedef std::map<art::Ptr<simb::MCParticle>, HitVector> MCParticlesToHits;
95  typedef std::map<art::Ptr<simb::MCParticle>, art::Ptr<recob::PFParticle>>
97  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<recob::SpacePoint>> HitsToSpacePoints;
98  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<recob::PFParticle>> HitsToPFParticles;
99  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<simb::MCParticle>> HitsToMCParticles;
100  typedef std::map<art::Ptr<recob::Hit>, art::Ptr<simb::MCTruth>> HitsToMCTruth;
101  typedef std::map<art::Ptr<recob::Hit>, TrackIDEVector> HitsToTrackIDEs;
102  typedef std::map<art::Ptr<recob::Track>, CosmicTagVector> TracksToCosmicTags;
103  typedef std::map<art::Ptr<recob::PFParticle>, T0Vector> PFParticlesToT0s;
104 
105  typedef std::map<int, art::Ptr<recob::PFParticle>> PFParticleMap;
106  typedef std::map<int, art::Ptr<recob::Cluster>> ClusterMap;
107  typedef std::map<int, art::Ptr<recob::SpacePoint>> SpacePointMap;
108  typedef std::map<int, art::Ptr<recob::Hit>> HitMap;
109  typedef std::map<int, art::Ptr<simb::MCParticle>> MCParticleMap;
110  typedef std::map<int, art::Ptr<sim::SimChannel>> SimChannelMap;
111 
112  typedef std::map<const pandora::ParticleFlowObject*, size_t> ThreeDParticleMap;
113  typedef std::map<const pandora::Vertex*, unsigned int> ThreeDVertexMap;
114  typedef std::map<int, HitVector> HitArray;
115 
116  /**
117  * @brief LArPandoraHelper class
118  */
120  public:
121  /**
122  * @brief DaughterMode enumeration
123  */
125  kIgnoreDaughters = 0, // Only use parent particles
126  kUseDaughters = 1, // Use both parent and daughter partcles
127  kAddDaughters = 2 // Absorb daughter particles into parent particles
128  };
129 
130  /**
131  * @brief Collect the reconstructed wires from the ART event record
132  *
133  * @param evt the ART event record
134  * @param label the label for the Wire list in the event
135  * @param wireVector the ouput vector of Wire objects
136  */
137  static void CollectWires(const art::Event& evt,
138  const std::string& label,
139  WireVector& wireVector);
140 
141  /**
142  * @brief Collect the reconstructed Hits from the ART event record
143  *
144  * @param evt the ART event record
145  * @param label the label for the Hit list in the event
146  * @param hitVector the ouput vector of Hit objects
147  */
148  static void CollectHits(const art::Event& evt, const std::string& label, HitVector& hitVector);
149 
150  /**
151  * @brief Collect the reconstructed PFParticles from the ART event record
152  *
153  * @param evt the ART event record
154  * @param label the label for the PFParticle list in the event
155  * @param particleVector the output vector of PFParticle objects
156  */
157  static void CollectPFParticles(const art::Event& evt,
158  const std::string& label,
159  PFParticleVector& particleVector);
160 
161  /**
162  * @brief Collect the reconstructed SpacePoints and associated hits from the ART event record
163  *
164  * @param evt the ART event record
165  * @param label the label for the SpacePoint list in the event
166  * @param spacePointVector the output vector of SpacePoint objects
167  * @param spacePointsToHits the output map from SpacePoint to Hit objects
168  */
169  static void CollectSpacePoints(const art::Event& evt,
170  const std::string& label,
171  SpacePointVector& spacePointVector,
172  SpacePointsToHits& spacePointsToHits);
173 
174  /**
175  * @brief Collect the reconstructed SpacePoints and associated hits from the ART event record
176  *
177  * @param evt the ART event record
178  * @param label the label for the SpacePoint list in the event
179  * @param spacePointVector the output vector of SpacePoint objects
180  * @param spacePointsToHits the output map from SpacePoint to Hit objects
181  * @param hitsToSpacePoints the output map from Hit to SpacePoint objects
182  */
183  static void CollectSpacePoints(const art::Event& evt,
184  const std::string& label,
185  SpacePointVector& spacePointVector,
186  SpacePointsToHits& spacePointsToHits,
187  HitsToSpacePoints& hitsToSpacePoints);
188 
189  /**
190  * @brief Collect the reconstructed Clusters and associated hits from the ART event record
191  *
192  * @param evt the ART event record
193  * @param label the label for the SpacePoint list in the event
194  * @param clusterVector the output vector of Cluster objects
195  * @param clustersToHits the output map from Cluster to Hit objects
196  */
197  static void CollectClusters(const art::Event& evt,
198  const std::string& label,
199  ClusterVector& clusterVector,
200  ClustersToHits& clustersToHits);
201 
202  /**
203  * @brief Collect the reconstructed PFParticles and associated SpacePoints from the ART event record
204  *
205  * @param evt the ART event record
206  * @param label the label for the PFParticle list in the event
207  * @param particleVector the output vector of PFParticle objects
208  * @param particlesToSpacePoints the output map from PFParticle to SpacePoint objects
209  */
210  static void CollectPFParticles(const art::Event& evt,
211  const std::string& label,
212  PFParticleVector& particleVector,
213  PFParticlesToSpacePoints& particlesToSpacePoints);
214 
215  /**
216  * @brief Collect the reconstructed PFParticles and associated Clusters from the ART event record
217  *
218  * @param evt the ART event record
219  * @param label the label for the PFParticle list in the event
220  * @param particleVector the output vector of PFParticle objects
221  * @param particlesToClusters the output map from PFParticle to Cluster objects
222  */
223  static void CollectPFParticles(const art::Event& evt,
224  const std::string& label,
225  PFParticleVector& particleVector,
226  PFParticlesToClusters& particlesToClusters);
227 
228  /**
229  * @brief Collect the reconstructed PFParticle Metadata from the ART event record
230  *
231  * @param evt the ART event record
232  * @param label the label for the PFParticle list in the event
233  * @param particleVector the output vector of PFParticle objects
234  * @param particlesToSpacePoints the output map from PFParticle to PFParticleMetadata objects
235  */
236  static void CollectPFParticleMetadata(const art::Event& evt,
237  const std::string& label,
238  PFParticleVector& particleVector,
239  PFParticlesToMetadata& particlesToMetadata);
240 
241  /**
242  * @brief Collect the reconstructed PFParticles and associated Showers from the ART event record
243  *
244  * @param evt the ART event record
245  * @param label the label for the PFParticle list in the event
246  * @param showerVector the output vector of Shower objects
247  * @param particlesToShowers the output map from PFParticle to Shower objects
248  */
249  static void CollectShowers(const art::Event& evt,
250  const std::string& label,
251  ShowerVector& showerVector,
252  PFParticlesToShowers& particlesToShowers);
253 
254  /**
255  * @brief Collect the reconstructed Showers and associated Hits from the ART event record
256  *
257  * @param evt the ART event record
258  * @param label the label for the PFParticle list in the event
259  * @param showerVector the output vector of Shower objects
260  * @param showersToHits the output map from Shower to Hit objects
261  */
262  static void CollectShowers(const art::Event& evt,
263  const std::string& label,
264  ShowerVector& showerVector,
265  ShowersToHits& showersToHits);
266 
267  /**
268  * @brief Collect the reconstructed PFParticles and associated Tracks from the ART event record
269  *
270  * @param evt the ART event record
271  * @param label the label for the PFParticle list in the event
272  * @param trackVector the output vector of Track objects
273  * @param particlesToTracks the output map from PFParticle to Track objects
274  */
275  static void CollectTracks(const art::Event& evt,
276  const std::string& label,
277  TrackVector& trackVector,
278  PFParticlesToTracks& particlesToTracks);
279 
280  /**
281  * @brief Collect the reconstructed Tracks and associated Hits from the ART event record
282  *
283  * @param evt the ART event record
284  * @param label the label for the PFParticle list in the event
285  * @param trackVector the output vector of Track objects
286  * @param tracksToHits the output map from Track to Hit objects
287  */
288  static void CollectTracks(const art::Event& evt,
289  const std::string& label,
290  TrackVector& trackVector,
291  TracksToHits& tracksToHits);
292 
293  /**
294  * @brief Collect the reconstructed PFParticles and associated Seeds from the ART event record
295  *
296  * @param evt the ART event record
297  * @param label the label for the PFParticle list in the event
298  * @param seedVector the output vector of Seed objects
299  * @param particlesToSeeds the output map from PFParticle to Seed objects
300  */
301  static void CollectSeeds(const art::Event& evt,
302  const std::string& label,
303  SeedVector& seedVector,
304  PFParticlesToSeeds& particlesToSeeds);
305 
306  /**
307  * @brief Collect the reconstructed Seeds and associated Hits from the ART event record
308  *
309  * @param evt the ART event record
310  * @param label the label for the PFParticle list in the event
311  * @param seedVector the output vector of Seed objects
312  * @param seedsToHits the output map from Seed to Hit objects
313  */
314  static void CollectSeeds(const art::Event& evt,
315  const std::string& label,
316  SeedVector& seedVector,
317  SeedsToHits& seedsToHits);
318 
319  /**
320  * @brief Collect the reconstructed PFParticles and associated Vertices from the ART event record
321  *
322  * @param evt the ART event record
323  * @param label the label for the PFParticle list in the event
324  * @param vertexVector the output vector of Vertex objects
325  * @param particlesToVertices the output map from PFParticle to Vertex objects
326  */
327  static void CollectVertices(const art::Event& evt,
328  const std::string& label,
329  VertexVector& vertexVector,
330  PFParticlesToVertices& particlesToVertices);
331 
332  /**
333  * @brief Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps
334  *
335  * @param particleVector the input vector of PFParticle objects
336  * @param particlesToSpacePoints the input map from PFParticle to SpacePoint objects
337  * @param spacePointsToHits the input map from SpacePoint to Hit objects
338  * @param particlesToHits the output map from PFParticle to Hit objects
339  * @param hitsToParticles the output map from Hit to PFParticle objects
340  * @param daughterMode treatment of daughter particles in construction of maps
341  */
342  static void BuildPFParticleHitMaps(const PFParticleVector& particleVector,
343  const PFParticlesToSpacePoints& particlesToSpacePoints,
344  const SpacePointsToHits& spacePointsToHits,
345  PFParticlesToHits& particlesToHits,
346  HitsToPFParticles& hitsToParticles,
347  const DaughterMode daughterMode = kUseDaughters);
348 
349  /**
350  * @brief Build mapping between PFParticles and Hits using PFParticle/Cluster/Hit maps
351  *
352  * @param particleVector the input vector of PFParticle objects
353  * @param particlesToClusters the input map from PFParticle to Cluster objects
354  * @param clustersToHits the input map from Cluster to Hit objects
355  * @param particlesToHits the output map from PFParticle to Hit objects
356  * @param hitsToParticles the output map from Hit to PFParticle objects
357  * @param daughterMode treatment of daughter particles in construction of maps
358  */
359  static void BuildPFParticleHitMaps(const PFParticleVector& particleVector,
360  const PFParticlesToClusters& particlesToClusters,
361  const ClustersToHits& clustersToHits,
362  PFParticlesToHits& particlesToHits,
363  HitsToPFParticles& hitsToParticles,
364  const DaughterMode daughterMode = kUseDaughters);
365 
366  /**
367  * @brief Build mapping between PFParticles and Hits starting from ART event record
368  *
369  * @param evt the ART event record
370  * @param label_pfpart the label for the PFParticle list in the event
371  * @param label_space the label for the Intermediate list in the event
372  * @param particlesToHits output map from PFParticle to Hit objects
373  * @param hitsToParticles output map from Hit to PFParticle objects
374  * @param daughterMode treatment of daughter particles in construction of maps
375  * @param useClusters choice of intermediate object (true for Clusters, false for SpacePoints)
376  */
377  static void BuildPFParticleHitMaps(const art::Event& evt,
378  const std::string& label_pfpart,
379  const std::string& label_mid,
380  PFParticlesToHits& particlesToHits,
381  HitsToPFParticles& hitsToParticles,
382  const DaughterMode daughterMode = kUseDaughters,
383  const bool useClusters = true);
384 
385  /**
386  * @brief Build mapping between PFParticles and Hits starting from ART event record
387  *
388  * @param evt the ART event record
389  * @param label the label for the PFParticle list in the event
390  * @param particlesToHits output map from PFParticle to Hit objects
391  * @param hitsToParticles output map from Hit to PFParticle objects
392  * @param daughterMode treatment of daughter particles in construction of maps
393  * @param useClusters choice of intermediate object (true for Clusters, false for SpacePoints)
394  */
395  static void BuildPFParticleHitMaps(const art::Event& evt,
396  const std::string& label,
397  PFParticlesToHits& particlesToHits,
398  HitsToPFParticles& hitsToParticles,
399  const DaughterMode daughterMode = kUseDaughters,
400  const bool useClusters = true);
401 
402  /**
403  * @brief Collect a vector of cosmic tags from the ART event record
404  *
405  * @param evt the ART event record
406  * @param label the label for the cosmic tag information in the event
407  * @param cosmicTagVector output vector of CosmicTag objects
408  * @param tracksToCosmicTags output map from tracks to cosmic tags
409  */
410  static void CollectCosmicTags(const art::Event& evt,
411  const std::string& label,
412  CosmicTagVector& cosmicTagVector,
413  TracksToCosmicTags& tracksToCosmicTags);
414 
415  /**
416  * @brief Collect a vector of T0s from the ART event record
417  *
418  * @param evt the ART event record
419  * @param label the label for the T0 information in the event
420  * @param t0Vector output vector of T0 objects
421  * @param particlesToT0s output map from PParticles to T0s
422  */
423  static void CollectT0s(const art::Event& evt,
424  const std::string& label,
425  T0Vector& t0Vector,
426  PFParticlesToT0s& particlesToT0s);
427 
428  /**
429  * @brief Collect a vector of SimChannel objects from the ART event record
430  *
431  * @param evt the ART event record
432  * @param label the label for the truth information in the event
433  * @param simChannelVector output vector of SimChannel objects
434  * @param areSimChannelsValid boolean parameter indicating if the sim channel collection exists
435  */
436  static void CollectSimChannels(const art::Event& evt,
437  const std::string& label,
438  SimChannelVector& simChannelVector,
439  bool& areSimChannelsValid);
440 
441  /**
442  * @brief Collect a vector of MCParticle objects from the ART event record
443  *
444  * @param evt the ART event record
445  * @param label the label for the truth information in the event
446  * @param particleVector the output vector of MCParticle objects
447  */
448  static void CollectMCParticles(const art::Event& evt,
449  const std::string& label,
450  MCParticleVector& particleVector);
451 
452  /**
453  * @brief Collect a vector of MCParticle objects from the generator in the ART event record. ATTN: This function is
454  * needed as accessing generator (opposed to Geant4) level MCParticles requires use of MCTruth block.
455  *
456  * @param evt the ART event record
457  * @param label the label for the truth information in the generator
458  * @param particleVector the output vector of MCParticle objects
459  */
460  static void CollectGeneratorMCParticles(const art::Event& evt,
461  const std::string& label,
462  RawMCParticleVector& particleVector);
463 
464  /**
465  * @brief Collect truth information from the ART event record
466  *
467  * @param evt the ART event record
468  * @param label the label for the truth information in the event
469  * @param truthToParticles output map from MCTruth to MCParticle objects
470  * @param particlesToTruth output map from MCParticle to MCTruth objects
471  */
472  static void CollectMCParticles(const art::Event& evt,
473  const std::string& label,
474  MCTruthToMCParticles& truthToParticles,
475  MCParticlesToMCTruth& particlesToTruth);
476 
477  /**
478  * @brief Collect the links from reconstructed hits to their true energy deposits
479  *
480  * @param evt the art event containers
481  * @param hitVector the input vector of reconstructed hits
482  * @param simChannelVector the input vector of SimChannels
483  * @param hitsToTrackIDEs the out map from hits to true energy deposits
484  */
485  static void BuildMCParticleHitMaps(const art::Event& evt,
486  const HitVector& hitVector,
487  const SimChannelVector& simChannelVector,
488  HitsToTrackIDEs& hitsToTrackIDEs);
489 
490  /**
491  * @brief Build mapping between Hits and MCParticles, starting from Hit/TrackIDE/MCParticle information
492  *
493  * @param hitsToTrackIDEs the input map from hits to true energy deposits
494  * @param truthToParticles the input map of truth information
495  * @param particlesToHits the mapping between true particles and reconstructed hits
496  * @param hitsToParticles the mapping between reconstructed hits and true particles
497  * @param daughterMode treatment of daughter particles in construction of maps
498  */
499  static void BuildMCParticleHitMaps(const HitsToTrackIDEs& hitsToTrackIDEs,
500  const MCTruthToMCParticles& truthToParticles,
501  MCParticlesToHits& particlesToHits,
502  HitsToMCParticles& hitsToParticles,
503  const DaughterMode daughterMode = kUseDaughters);
504 
505  /**
506  * @brief Build mapping between Hits and MCParticles, starting from ART event record
507  *
508  * @param evt the ART event record
509  * @param label the label for the truth information in the event
510  * @param hitVector the input vector of reconstructed hits
511  * @param particlesToHits the output mapping between true particles and reconstructed hits
512  * @param hitsToParticles the output mapping between reconstructed hits and true particles
513  * @param daughterMode treatment of daughter particles in construction of maps
514  */
515  static void BuildMCParticleHitMaps(const art::Event& evt,
516  const std::string& label,
517  const HitVector& hitVector,
518  MCParticlesToHits& particlesToHits,
519  HitsToMCParticles& hitsToParticles,
520  const DaughterMode daughterMode = kUseDaughters);
521 
522  /**
523  * @brief Get mapping between hits and true energy deposits using back-tracker information
524  *
525  * @param evt the event record
526  * @param hitLabel the label of the collection of hits
527  * @param backtrackLabel the label of the collection of back-tracker information
528  * @param hitsToTrackIDEs the output map between hits and true energy deposits
529  */
530  static void BuildMCParticleHitMaps(const art::Event& evt,
531  const std::string& hitLabel,
532  const std::string& backtrackLabel,
533  HitsToTrackIDEs& hitsToTrackIDEs);
534 
535  /**
536  * @brief Build mapping between Hits and MCParticles, starting from Hit/TrackIDE/MCParticle information
537  *
538  * @param evt the event record
539  * @param truthLabel the label describing the G4 truth information
540  * @param hitLabel the label describing the hit collection
541  * @param backtrackLabel the label describing the back-tracker information
542  * @param particlesToHits the mapping between true particles and reconstructed hits
543  * @param hitsToParticles the mapping between reconstructed hits and true particles
544  * @param daughterMode treatment of daughter particles in construction of maps
545  */
546  static void BuildMCParticleHitMaps(const art::Event& evt,
547  const std::string& truthLabel,
548  const std::string& hitLabel,
549  const std::string& backtrackLabel,
550  MCParticlesToHits& particlesToHits,
551  HitsToMCParticles& hitsToParticles,
552  const DaughterMode daughterMode = kUseDaughters);
553 
554  /**
555  * @brief Get all hits associated with input clusters
556  *
557  * @param evt the event containing the hits
558  * @param label the label of the collection producing PFParticles
559  * @param input vector input of T (clusters, spacepoints)
560  * @param associatedHits output hits associated with T
561  * @param indexVector vector of spacepoint indices reflecting trajectory points sorting order
562  */
563  template <typename T>
564  static void GetAssociatedHits(const art::Event& evt,
565  const std::string& label,
566  const std::vector<art::Ptr<T>>& inputVector,
567  HitVector& associatedHits,
568  const pandora::IntVector* const indexVector = nullptr);
569 
570  /**
571  * @brief Select reconstructed neutrino particles from a list of all reconstructed particles
572  *
573  * @param inputParticles the input vector of all particles (it has to be all of them!)
574  * @param outputParticles the output vector of final-state particles
575  */
576  static void SelectNeutrinoPFParticles(const PFParticleVector& inputParticles,
577  PFParticleVector& outputParticles);
578 
579  /**
580  * @brief Select final-state reconstructed particles from a list of all reconstructed particles
581  *
582  * @param inputParticles the input vector of all particles (it has to be all of them!)
583  * @param outputParticles the output vector of final-state particles
584  */
585  static void SelectFinalStatePFParticles(const PFParticleVector& inputParticles,
586  PFParticleVector& outputParticles);
587 
588  /**
589  * @brief Build particle maps for true particles
590  *
591  * @param particleVector the input vector of true particles
592  * @param particleMap the output mapping between true particle and true track ID
593  */
594  static void BuildMCParticleMap(const MCParticleVector& particleVector,
595  MCParticleMap& particleMap);
596 
597  /**
598  * @brief Build particle maps for reconstructed particles
599  *
600  * @param particleVector the input vector of reconstructed particles
601  * @param particleMap the output mapping between reconstructed particles and particle ID
602  */
603  static void BuildPFParticleMap(const PFParticleVector& particleVector,
604  PFParticleMap& particleMap);
605 
606  /**
607  * @brief Return the top-level parent particle by navigating up the chain of parent/daughter associations
608  *
609  * @param particleMap the mapping between reconstructed particle and particle ID
610  * @param daughterParticle the input PF particle
611  *
612  * @return the top-level parent particle
613  */
614  static art::Ptr<recob::PFParticle> GetParentPFParticle(
615  const PFParticleMap& particleMap,
616  const art::Ptr<recob::PFParticle> daughterParticle);
617 
618  /**
619  * @brief Return the final-state parent particle by navigating up the chain of parent/daughter associations
620  *
621  * @param particleMap the mapping between reconstructed particle and particle ID
622  * @param daughterParticle the input PF particle
623  *
624  * @return the final-state parent particle
625  */
626  static art::Ptr<recob::PFParticle> GetFinalStatePFParticle(
627  const PFParticleMap& particleMap,
628  const art::Ptr<recob::PFParticle> daughterParticle);
629 
630  /**
631  * @brief Return the top-level parent particle by navigating up the chain of parent/daughter associations
632  *
633  * @param particleMap the mapping between true particle and true track ID
634  * @param daughterParticle the input MC particle
635  *
636  * @return the top-level parent particle
637  */
638  static art::Ptr<simb::MCParticle> GetParentMCParticle(
639  const MCParticleMap& particleMap,
640  const art::Ptr<simb::MCParticle> daughterParticle);
641 
642  /**
643  * @brief Return the final-state parent particle by navigating up the chain of parent/daughter associations
644  *
645  * @param particleMap the mapping between true particle and true track ID
646  * @param daughterParticle the input MC particle
647  *
648  * @return the final-state parent particle
649  */
650  static art::Ptr<simb::MCParticle> GetFinalStateMCParticle(
651  const MCParticleMap& particleMap,
652  const art::Ptr<simb::MCParticle> daughterParticle);
653 
654  /**
655  * @brief Return the primary track associated with a PFParticle
656  *
657  * @param particlesToTracks the mapping between particles and tracks
658  * @param particle the input particle
659  */
660  static art::Ptr<recob::Track> GetPrimaryTrack(const PFParticlesToTracks& particlesToTracks,
661  const art::Ptr<recob::PFParticle> particle);
662 
663  /**
664  * @brief Return the generation of this particle (first generation if primary)
665  *
666  * @param particleMap the mapping between reconstructed particle and particle ID
667  * @param daughterParticle the input daughter particle
668  *
669  * @return the nth generation in the particle hierarchy
670  */
671  static int GetGeneration(const PFParticleMap& particleMap,
672  const art::Ptr<recob::PFParticle> daughterParticle);
673 
674  /**
675  * @brief Return the parent neutrino PDG code (or zero for cosmics) for a given reconstructed particle
676  *
677  * @param particleMap the mapping between reconstructed particle and particle ID
678  * @param daughterParticle the input daughter particle
679  *
680  * @return the PDG code of the parent neutrinos (or zero for cosmics)
681  */
682  static int GetParentNeutrino(const PFParticleMap& particleMap,
683  const art::Ptr<recob::PFParticle> daughterParticle);
684 
685  /**
686  * @brief Determine whether a particle has been reconstructed as a final-state particle
687  *
688  * @param particleMap the mapping between reconstructed particle and particle ID
689  * @param daughterParticle the input daughter particle
690  *
691  * @return true/false
692  */
693  static bool IsFinalState(const PFParticleMap& particleMap,
694  const art::Ptr<recob::PFParticle> daughterParticle);
695 
696  /**
697  * @brief Determine whether a particle has been reconstructed as a neutrino
698  *
699  * @param particle the input particle
700  *
701  * @return true/false
702  */
703  static bool IsNeutrino(const art::Ptr<recob::PFParticle> particle);
704 
705  /**
706  * @brief Determine whether a particle has been reconstructed as track-like
707  *
708  * @param particle the input particle
709  *
710  * @return true/false
711  */
712  static bool IsTrack(const art::Ptr<recob::PFParticle> particle);
713 
714  /**
715  * @brief Determine whether a particle has been reconstructed as shower-like
716  *
717  * @param particle the input particle
718  *
719  * @return true/false
720  */
721  static bool IsShower(const art::Ptr<recob::PFParticle> particle);
722 
723  /**
724  * @brief Determine whether a particle is visible (i.e. long-lived charged particle)
725  *
726  * @param particle the input mc particle
727  *
728  * @return true/false
729  */
730  static bool IsVisible(const art::Ptr<simb::MCParticle> particle);
731 
732  /**
733  * @brief Get metadata associated to a PFO
734  *
735  * @param pPfo input ParticleFlowObject
736  *
737  * @return larpandoraobj::PFParticleMetadata
738  */
740  const pandora::ParticleFlowObject* const pPfo);
741  };
742 
743 } // namespace lar_pandora
744 
745 #endif // LAR_PANDORA_HELPER_H
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
static void CollectClusters(const art::Event &evt, const std::string &label, ClusterVector &clusterVector, ClustersToHits &clustersToHits)
Collect the reconstructed Clusters and associated hits from the ART event record. ...
std::vector< art::Ptr< simb::MCTruth > > MCTruthVector
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
static void BuildPFParticleMap(const PFParticleVector &particleVector, PFParticleMap &particleMap)
Build particle maps for reconstructed particles.
std::map< int, art::Ptr< sim::SimChannel > > SimChannelMap
SlicingAlgorithm::Slice Slice
static int GetParentNeutrino(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the parent neutrino PDG code (or zero for cosmics) for a given reconstructed particle...
std::unordered_set< art::Ptr< recob::Hit > > HitSet
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
std::map< int, HitVector > HitArray
std::map< art::Ptr< simb::MCTruth >, HitVector > MCTruthToHits
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
static art::Ptr< recob::PFParticle > GetFinalStatePFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
static void CollectWires(const art::Event &evt, const std::string &label, WireVector &wireVector)
Collect the reconstructed wires from the ART event record.
static bool IsShower(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as shower-like.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< recob::PFParticle > > MCParticlesToPFParticles
std::vector< art::Ptr< recob::Shower > > ShowerVector
Definition: Data.h:14
std::vector< int > IntVector
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
static art::Ptr< recob::PFParticle > GetParentPFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
Definition: Data.h:7
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
static void CollectGeneratorMCParticles(const art::Event &evt, const std::string &label, RawMCParticleVector &particleVector)
Collect a vector of MCParticle objects from the generator in the ART event record. ATTN: This function is needed as accessing generator (opposed to Geant4) level MCParticles requires use of MCTruth block.
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
static void GetAssociatedHits(const art::Event &evt, const std::string &label, const std::vector< art::Ptr< T >> &inputVector, HitVector &associatedHits, const pandora::IntVector *const indexVector=nullptr)
Get all hits associated with input clusters.
static void CollectSpacePoints(const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
Collect the reconstructed SpacePoints and associated hits from the ART event record.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::vector< art::Ptr< recob::Seed > > SeedVector
static void CollectSeeds(const art::Event &evt, const std::string &label, SeedVector &seedVector, PFParticlesToSeeds &particlesToSeeds)
Collect the reconstructed PFParticles and associated Seeds from the ART event record.
static bool IsVisible(const art::Ptr< simb::MCParticle > particle)
Determine whether a particle is visible (i.e. long-lived charged particle)
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
static art::Ptr< simb::MCParticle > GetParentMCParticle(const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
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
static void CollectShowers(const art::Event &evt, const std::string &label, ShowerVector &showerVector, PFParticlesToShowers &particlesToShowers)
Collect the reconstructed PFParticles and associated Showers from the ART event record.
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
static art::Ptr< recob::Track > GetPrimaryTrack(const PFParticlesToTracks &particlesToTracks, const art::Ptr< recob::PFParticle > particle)
Return the primary track associated with a PFParticle.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
static void CollectVertices(const art::Event &evt, const std::string &label, VertexVector &vertexVector, PFParticlesToVertices &particlesToVertices)
Collect the reconstructed PFParticles and associated Vertices from the ART event record.
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > HitsToSpacePoints
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static void CollectSimChannels(const art::Event &evt, const std::string &label, SimChannelVector &simChannelVector, bool &areSimChannelsValid)
Collect a vector of SimChannel objects from the ART event record.
std::vector< sim::TrackIDE > TrackIDEVector
std::vector< art::Ptr< larpandoraobj::PFParticleMetadata > > MetadataVector
static void SelectFinalStatePFParticles(const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
Select final-state reconstructed particles from a list of all reconstructed particles.
std::vector< art::Ptr< recob::Track > > TrackVector
static void CollectPFParticleMetadata(const art::Event &evt, const std::string &label, PFParticleVector &particleVector, PFParticlesToMetadata &particlesToMetadata)
Collect the reconstructed PFParticle Metadata from the ART event record.
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
std::map< art::Ptr< recob::Track >, HitVector > TracksToHits
static void CollectTracks(const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
Collect the reconstructed PFParticles and associated Tracks from the ART event record.
std::map< int, art::Ptr< recob::SpacePoint > > SpacePointMap
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
DaughterMode
DaughterMode enumeration.
static void SelectNeutrinoPFParticles(const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
Select reconstructed neutrino particles from a list of all reconstructed particles.
std::map< const pandora::ParticleFlowObject *, size_t > ThreeDParticleMap
std::vector< art::Ptr< recob::Hit > > HitVector
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
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
static bool IsTrack(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as track-like.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::vector< art::Ptr< recob::Vertex > > VertexVector
std::vector< art::Ptr< recob::Cluster > > ClusterVector
static int GetGeneration(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the generation of this particle (first generation if primary)
TCEvent evt
Definition: DataStructs.cxx:8
std::vector< art::Ptr< anab::T0 > > T0Vector
static void CollectT0s(const art::Event &evt, const std::string &label, T0Vector &t0Vector, PFParticlesToT0s &particlesToT0s)
Collect a vector of T0s from the ART event record.
std::map< art::Ptr< recob::Seed >, art::Ptr< recob::Hit > > SeedsToHits
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
std::map< const pandora::Vertex *, unsigned int > ThreeDVertexMap
std::set< art::Ptr< recob::Hit > > HitList
static art::Ptr< simb::MCParticle > GetFinalStateMCParticle(const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
static bool IsFinalState(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Determine whether a particle has been reconstructed as a final-state particle.
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
static larpandoraobj::PFParticleMetadata GetPFParticleMetadata(const pandora::ParticleFlowObject *const pPfo)
Get metadata associated to a PFO.
static void CollectCosmicTags(const art::Event &evt, const std::string &label, CosmicTagVector &cosmicTagVector, TracksToCosmicTags &tracksToCosmicTags)
Collect a vector of cosmic tags from the ART event record.
process_name opdaq physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator T0
Definition: gen_protons.fcl:45
static void BuildMCParticleMap(const MCParticleVector &particleVector, MCParticleMap &particleMap)
Build particle maps for true particles.