LArPandoraSliceIdHelper.h
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraEventBuilding/LArPandoraSliceIdHelper.h
3  *
4  * @brief helper class for slice id tools
5  *
6  */
7 #ifndef LAR_PANDORA_SLICE_ID_HELPER_H
8 #define LAR_PANDORA_SLICE_ID_HELPER_H
9 
13 
14 namespace lar_pandora
15 {
16 
17 /**
18  * @brief Helper class for slice id tools
19  */
21 {
22 public:
23  /**
24  * @brief Class to hold MC metdata about slices
25  */
27  {
28  public:
29  /**
30  * @brief Default constructor
31  */
32  SliceMetadata();
33 
34  float m_purity; ///< The fraction of hits in the slice that are neutrino induced
35  float m_completeness; ///< The fraction of all neutrino induced hits that are in the slice
36  unsigned int m_nHits; ///< The number of hits in the slice
37  bool m_isMostComplete; ///< If the slice has the highest completeness in the event
38  };
39 
40  typedef std::vector<SliceMetadata> SliceMetadataVector;
41 
42  /**
43  * @brief Get MC metadata about each slice
44  *
45  * @param slices the input vector of slices
46  * @param evt the art event
47  * @param truthLabel the label of the MCTruth producer
48  * @param mcParticleLabel the label of the MCParticle producer
49  * @param hitLabel the label of the Hit producer
50  * @param backtrackLabel the label of the Hit -> MCParticle association producer
51  * @param pandoraLabel the label of the Pandora all outcomes producer
52  * @param sliceMetadata the output vector of slice metadata (mapping 1:1 to the slices)
53  * @param interactionType the output true interaction type code of the MCNeutrino
54  * @param nuEnergy the output true energy of the neutrino
55  * @param nuNeutrino the mc neutrino from the beam neutrino MCTruth block
56  */
57  static void GetSliceMetadata(const SliceVector &slices, const art::Event &evt, const std::string &truthLabel,
58  const std::string &mcParticleLabel, const std::string &hitLabel, const std::string &backtrackLabel, const std::string &pandoraLabel,
59  SliceMetadataVector &sliceMetadata, simb::MCNeutrino &mcNeutrino);
60 
61 private:
62  typedef std::unordered_map<art::Ptr<recob::Hit>, bool> HitToBoolMap;
63 
64  /**
65  * @brief Get the MCTruth block for the simulated beam neutrino
66  *
67  * @param evt the art event
68  * @param truthLabel the label of the MCTruth producer
69  *
70  * @return the MCTruth block for the simulated beam neutrino
71  */
73 
74  /**
75  * @brief Collect all MCParticles that come from the beam neutrino interaction
76  *
77  * @param evt the art event
78  * @param truthLabel the label of the MCTruth producer
79  * @param mcParticleLabel the label of the MCParticle producer
80  * @param beamNuMCTruth the MCTruth block for the beam neutrino
81  * @param mcParticles the output vector of neutrino induced MCParticles
82  */
83  static void CollectNeutrinoMCParticles(const art::Event &evt, const std::string &truthLabel, const std::string &mcParticleLabel,
84  const art::Ptr<simb::MCTruth> &beamNuMCTruth, MCParticleVector &mcParticles);
85 
86  /**
87  * @brief For each hit in the event, determine if any of it's charge was deposited by a neutrino induced particle
88  *
89  * @param evt the art event
90  * @param hitLabel the label of the Hit producer
91  * @param backtrackLabel the label of the Hit->MCParticle association producer - backtracker
92  * @param mcParticles the input vector of neutrino induced MCParticles
93  * @param hits the output vector of all hits
94  * @param hitToIsNuInducedMap the output mapping from hits to a bool = true if hit is neutrino induced
95  */
96  static void GetHitOrigins(const art::Event &evt, const std::string &hitLabel, const std::string &backtrackLabel,
97  const MCParticleVector &mcParticles, HitVector &hits, HitToBoolMap &hitToIsNuInducedMap);
98 
99  /**
100  * @brief Count the number of hits in an input vector that are neutrino induced
101  *
102  * @param hits the input vector of hits
103  * @param hitToIsNuInducedMap the mapping from hits to isNuInduced boolean
104  *
105  * @return the number of hits that are neutrino induced
106  */
107  static unsigned int CountNeutrinoHits(const HitVector &hits, const HitToBoolMap &hitToIsNuInducedMap);
108 
109  /**
110  * @brief Get the mapping from PFParticles to associated hits (via clusters)
111  *
112  * @param evt the art event
113  * @param pandoraLabel the label of the PFParticle <-> Cluster and Cluster <-> Hit associations - Pandora pattern recognition
114  * @param pfParticleToHitsMap the output mapping from PFParticles to associated hits
115  */
116  static void GetPFParticleToHitsMap(const art::Event &evt, const std::string &pandoraLabel, PFParticlesToHits &pfParticleToHitsMap);
117 
118  /**
119  * @brief Collect the hits in the slice that have been added to a PFParticle (under either reconstruction hypothesis)
120  *
121  * @param slice the input slice
122  * @param pfParticleToHitsMap the input mapping from PFParticles to hits
123  * @param hits the output vector of reconstructed hits in the slice
124  */
125  static void GetReconstructedHitsInSlice(const Slice &slice, const PFParticlesToHits &pfParticleToHitsMap, HitVector &hits);
126 
127  /**
128  * @brief Collect the hits in a given vector of PFParticles
129  *
130  * @param pfParticles the input vector of PFParticles
131  * @param pfParticleToHitsMap the input mapping from PFParticles to hits
132  * @param hits the output vector of hits
133  */
134  static void CollectHits(const PFParticleVector &pfParticles, const PFParticlesToHits &pfParticleToHitsMap, HitVector &hits);
135 
136  /**
137  * @brief Calculate the MC slice metadata
138  *
139  * @param slices the input vector of slices
140  * @param pfParticleToHitsMap the input mapping from PFParticles to hits
141  * @param hitToIsNuInducedMap the input mapping from hits to isNuInduced boolean
142  * @param nNuHits the total number of neutrino induced hits in the event
143  * @param sliceMetadata the output vector of metadata objects correspoinding 1:1 to the input slices
144  */
145  static void GetSliceMetadata(const SliceVector &slices, const PFParticlesToHits &pfParticleToHitsMap,
146  const HitToBoolMap &hitToIsNuInducedMap, const unsigned int nNuHits, SliceMetadataVector &sliceMetadata);
147 };
148 
149 } // namespace lar_pandora
150 
151 #endif // LAR_PANDORA_SLICE_ID_HELPER_H
std::unordered_map< art::Ptr< recob::Hit >, bool > HitToBoolMap
Slice class.
Definition: Slice.h:18
static unsigned int CountNeutrinoHits(const HitVector &hits, const HitToBoolMap &hitToIsNuInducedMap)
Count the number of hits in an input vector that are neutrino induced.
static void CollectNeutrinoMCParticles(const art::Event &evt, const std::string &truthLabel, const std::string &mcParticleLabel, const art::Ptr< simb::MCTruth > &beamNuMCTruth, MCParticleVector &mcParticles)
Collect all MCParticles that come from the beam neutrino interaction.
float m_purity
The fraction of hits in the slice that are neutrino induced.
static void CollectHits(const PFParticleVector &pfParticles, const PFParticlesToHits &pfParticleToHitsMap, HitVector &hits)
Collect the hits in a given vector of PFParticles.
std::string string
Definition: nybbler.cc:12
unsigned int m_nHits
The number of hits in the slice.
static void GetPFParticleToHitsMap(const art::Event &evt, const std::string &pandoraLabel, PFParticlesToHits &pfParticleToHitsMap)
Get the mapping from PFParticles to associated hits (via clusters)
static void GetHitOrigins(const art::Event &evt, const std::string &hitLabel, const std::string &backtrackLabel, const MCParticleVector &mcParticles, HitVector &hits, HitToBoolMap &hitToIsNuInducedMap)
For each hit in the event, determine if any of it&#39;s charge was deposited by a neutrino induced partic...
std::vector< SliceMetadata > SliceMetadataVector
static void GetReconstructedHitsInSlice(const Slice &slice, const PFParticlesToHits &pfParticleToHitsMap, HitVector &hits)
Collect the hits in the slice that have been added to a PFParticle (under either reconstruction hypot...
Helper class for slice id tools.
float m_completeness
The fraction of all neutrino induced hits that are in the slice.
static void GetSliceMetadata(const SliceVector &slices, const art::Event &evt, const std::string &truthLabel, const std::string &mcParticleLabel, const std::string &hitLabel, const std::string &backtrackLabel, const std::string &pandoraLabel, SliceMetadataVector &sliceMetadata, simb::MCNeutrino &mcNeutrino)
Get MC metadata about each slice.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
header for the lar pandora slice class
std::vector< TCSlice > slices
Definition: DataStructs.cxx:12
std::vector< art::Ptr< recob::Hit > > HitVector
static art::Ptr< simb::MCTruth > GetBeamNeutrinoMCTruth(const art::Event &evt, const std::string &truthLabel)
Get the MCTruth block for the simulated beam neutrino.
std::vector< Slice > SliceVector
Definition: Slice.h:68
bool m_isMostComplete
If the slice has the highest completeness in the event.
TCEvent evt
Definition: DataStructs.cxx:7
Event generator information.
Definition: MCNeutrino.h:18
helper function for LArPandoraInterface producer module