TruthMatchUtils.h
Go to the documentation of this file.
1 /**
2  * @file larsim/Utils/TruthMatchUtils.h
3  *
4  * @brief Utilities for matching a recob::Hit or vector of recob::Hit to the ID of the most significantly contributing G4 particle. Various functions using different definitions of 'most significantly contributing' are provided.
5  *
6  * @author Dom Brailsford (d.brailsford@lancaster.ac.uk)
7  *
8  * $log: $
9  */
10 #ifndef TRUTHMATCHUTILS_H_SEEN
11 #define TRUTHMATCHUTILS_H_SEEN
12 
13 // LArSoft
15 
16 // c++
17 #include <limits>
18 #include <map>
19 #include <vector>
20 
21 namespace detinfo {
22  class DetectorClocksData;
23 }
24 
25 namespace TruthMatchUtils {
26 
27  typedef int G4ID;
28  typedef float EDeposit;
29  typedef std::map<G4ID, EDeposit> IDToEDepositMap;
30 
31  /**
32  * @brief Test whether a G4ID returned by the TruthMatchUtils functions is valid
33  *
34  * @param g4ID the G4ID to be tested
35  *
36  * @return validity bool
37  */
38  bool Valid(const G4ID g4ID) noexcept;
39 
40  /**
41  * @brief The G4 ID of the true particle which deposits the most energy in the recob::Hit
42  *
43  * @param pHit the recob::Hit to be assessed
44  * @param rollupUnsavedIDs whether to squash energy deposits for non-saved G4 particles (e.g. shower secondaries) its saved ancestor particle
45  *
46  * @return the ID of the G4 particle
47  */
48  G4ID TrueParticleID(detinfo::DetectorClocksData const& clockData,
49  const art::Ptr<recob::Hit>& pHit,
50  const bool rollupUnsavedIDs);
51 
52  /**
53  * @brief The G4 ID of the true particle which deposits the most energy in a vector of recob::Hit
54  *
55  * @param pHits the recob::Hit vector to be assessed
56  * @param rollupUnsavedIDs whether to squash energy deposits for non-saved G4 particles (e.g. shower secondaries) its saved ancestor particle
57  *
58  * @return the ID of the G4 particle
59  */
61  const std::vector<art::Ptr<recob::Hit>>& pHits,
62  const bool rollupUnsavedIDs);
63 
64  /**
65  * @brief The G4 ID of the true particle whose matched hits have produced the largest amount of reconstructed charge in a recob::Hit vector
66  *
67  * @param pHits the recob::Hit vector to be assessed
68  * @param rollupUnsavedIDs whether to squash energy deposits for non-saved G4 particles (e.g. shower secondaries) its saved ancestor particle
69  *
70  * @return the ID of the G4 particle
71  */
73  const std::vector<art::Ptr<recob::Hit>>& pHits,
74  const bool rollupUnsavedIDs);
75 
76  /**
77  * @brief The G4 ID of the true particle who has been truth-matched to the most hits in a recob::Hit vector
78  *
79  * @param pHits the recob::Hit vector to be assessed
80  * @param rollupUnsavedIDs whether to squash energy deposits for non-saved G4 particles (e.g. shower secondaries) its saved ancestor particle
81  *
82  * @return the ID of the G4 particle
83  */
85  const std::vector<art::Ptr<recob::Hit>>& pHits,
86  const bool rollupUnsavedIDs);
87 
88  /**
89  * @brief Fill an energy deposition map (maps G4 ID to true energy deposition) for a recob::Hit
90  *
91  * @param idToEDepMap the energy deposition map to be filled
92  * @param pHit the recob::Hit to be assessed
93  * @param rollupUnsavedIDs whether to squash energy deposits for non-saved G4 particles (e.g. shower secondaries) its saved ancestor particle
94  */
95  void FillG4IDToEnergyDepositMap(IDToEDepositMap& idToEDepMap,
96  detinfo::DetectorClocksData const& clockData,
97  const art::Ptr<recob::Hit>& pHit,
98  const bool rollupUnsavedIDs);
99 
100 } // namespace TruthMatchUtils
101 
102 #endif // #ifndef TRUTHMATCHUTILS_H_SEEN
G4ID TrueParticleIDFromTotalRecoCharge(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit >> &pHits, const bool rollupUnsavedIDs)
The G4 ID of the true particle whose matched hits have produced the largest amount of reconstructed c...
G4ID TrueParticleID(detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > &pHit, const bool rollupUnsavedIDs)
The G4 ID of the true particle which deposits the most energy in the recob::Hit.
struct vector vector
std::map< G4ID, EDeposit > IDToEDepositMap
General LArSoft Utilities.
bool Valid(const G4ID g4ID) noexcept
Test whether a G4ID returned by the TruthMatchUtils functions is valid.
void FillG4IDToEnergyDepositMap(IDToEDepositMap &idToEDepMap, detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > &pHit, const bool rollupUnsavedIDs)
Fill an energy deposition map (maps G4 ID to true energy deposition) for a recob::Hit.
Declaration of signal hit object.
Contains all timing reference information for the detector.
G4ID TrueParticleIDFromTotalTrueEnergy(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit >> &pHits, const bool rollupUnsavedIDs)
The G4 ID of the true particle which deposits the most energy in a vector of recob::Hit.
G4ID TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit >> &pHits, const bool rollupUnsavedIDs)
The G4 ID of the true particle who has been truth-matched to the most hits in a recob::Hit vector...