All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMCTruthMatching.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file IMCTruthMatching.h
4 /// \brief This provides an interface which defines truth matching functions
5 /// made available to downstream analysis code
6 ///
7 /// \author usher@slac.stanford.edu
8 ///
9 ////////////////////////////////////////////////////////////////////////
10 #ifndef IMCTRUTHMATCHING_H
11 #define IMCTRUTHMATCHING_H
12 
13 #include "fhiclcpp/ParameterSet.h"
14 
15 #include "art/Framework/Principal/Event.h"
16 #include "canvas/Persistency/Common/Ptr.h"
17 #include "canvas/Persistency/Common/PtrVector.h"
18 #include "nusimdata/SimulationBase/MCParticle.h"
19 #include "nusimdata/SimulationBase/MCTruth.h"
20 #include "nug4/ParticleNavigation/ParticleList.h"
21 #include "nug4/ParticleNavigation/EveIdCalculator.h"
22 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
25 
27 
28 namespace detinfo {
29  class DetectorClocksData;
30 }
31 
32 namespace recob{
33  class SpacePoint;
34 }
35 
36 ///code to link reconstructed objects back to the MC truth information
37 namespace truth
38 {
39 
41 {
42 public:
43  /**
44  * @brief Virtual Destructor
45  */
46  virtual ~IMCTruthMatching() noexcept = default;
47 
48  /**
49  * @brief Interface for configuring the particular algorithm tool
50  *
51  * @param ParameterSet The input set of parameters for configuration
52  */
53  virtual void reconfigure(fhicl::ParameterSet const& pset) = 0;
54 
55  /**
56  * @brief This rebuilds the internal maps
57  */
58  virtual void Rebuild(const art::Event& evt) = 0;
59 
60  /**
61  * @brief Get a reference to the ParticleList
62  */
63  virtual const sim::ParticleList& ParticleList() const = 0;
64 
65 // // Set the EveIdCalculator for the owned ParticleList
66 // void SetEveIdCalculator(sim::EveIdCalculator *ec) { fParticleList.AdoptEveIdCalculator(ec); }
67 
68  // Return a pointer to the simb::MCParticle object corresponding to
69  // the given TrackID
70  virtual const simb::MCParticle* TrackIDToParticle(int id) const = 0;
71  virtual const simb::MCParticle* TrackIDToMotherParticle(int id) const = 0;
72 
73  // Get art::Ptr<> to simb::MCTruth and related information
74  virtual const art::Ptr<simb::MCTruth>& TrackIDToMCTruth(int id) const = 0;
75  virtual const art::Ptr<simb::MCTruth>& ParticleToMCTruth(const simb::MCParticle* p) const = 0;
76  virtual std::vector<const simb::MCParticle*> MCTruthToParticles(art::Ptr<simb::MCTruth> const& mct) const = 0;
77  virtual const std::vector< art::Ptr<simb::MCTruth> >& MCTruthVector() const = 0;
78 
79  // this method will return the Geant4 track IDs of
80  // the particles contributing ionization electrons to the identified hit
81  virtual std::vector<sim::TrackIDE> HitToTrackID(detinfo::DetectorClocksData const& clockData,
82  recob::Hit const& hit) const = 0;
83  virtual std::vector<sim::TrackIDE> HitToTrackID(detinfo::DetectorClocksData const& clockData,
84  art::Ptr<recob::Hit> const& hit) const = 0;
85 
86  // method to return a subset of allhits that are matched to a list of TrackIDs
87  virtual std::vector<std::vector<art::Ptr<recob::Hit>>> TrackIDsToHits(detinfo::DetectorClocksData const& clockData,
88  std::vector<art::Ptr<recob::Hit>> const& allhits,
89  std::vector<int> const& tkIDs) const = 0;
90 
91  // method to return the EveIDs of particles contributing ionization
92  // electrons to the identified hit
93  virtual std::vector<sim::TrackIDE> HitToEveID(detinfo::DetectorClocksData const& clockData,
94  art::Ptr<recob::Hit> const& hit) const = 0;
95 
96  // method to return the XYZ position of the weighted average energy deposition for a given hit
97  virtual std::vector<double> HitToXYZ(detinfo::DetectorClocksData const& clockData,
98  art::Ptr<recob::Hit> const& hit) const = 0;
99 
100  // method to return the XYZ position of a space point (unweighted average XYZ of component hits).
101  virtual std::vector<double> SpacePointToXYZ(detinfo::DetectorClocksData const& clockData,
102  art::Ptr<recob::SpacePoint> const& spt,
103  art::Event const& evt,
104  std::string const& label) const = 0;
105 
106  // method to return the XYZ position of a space point (unweighted average XYZ of component hits).
107  virtual std::vector<double> SpacePointHitsToXYZ(detinfo::DetectorClocksData const& clockData,
108  art::PtrVector<recob::Hit> const& hits) const = 0;
109 
110  // method to return the fraction of hits in a collection that come from the specified Geant4 track ids
111  virtual double HitCollectionPurity(detinfo::DetectorClocksData const& clockData,
112  std::set<int> const& trackIDs,
113  std::vector< art::Ptr<recob::Hit> > const& hits) const = 0;
114 
115  // method to return the fraction of all hits in an event from a specific set of Geant4 track IDs that are
116  // represented in a collection of hits
117  virtual double HitCollectionEfficiency(detinfo::DetectorClocksData const& clockData,
118  std::set<int> const& trackIDs,
119  std::vector< art::Ptr<recob::Hit> > const& hits,
120  std::vector< art::Ptr<recob::Hit> > const& allhits,
121  geo::View_t view) const = 0;
122 
123  // method to return the fraction of charge in a collection that come from the specified Geant4 track ids
124  virtual double HitChargeCollectionPurity(detinfo::DetectorClocksData const& clockData,
125  std::set<int> const& trackIDs,
126  std::vector< art::Ptr<recob::Hit> > const& hits) const = 0;
127 
128  // method to return the fraction of all charge in an event from a specific set of Geant4 track IDs that are
129  // represented in a collection of hits
130  virtual double HitChargeCollectionEfficiency(detinfo::DetectorClocksData const& clockData,
131  std::set<int> const& trackIDs,
132  std::vector< art::Ptr<recob::Hit> > const& hits,
133  std::vector< art::Ptr<recob::Hit> > const& allhits,
134  geo::View_t const view) const = 0;
135 
136  // method to return all EveIDs corresponding to the current sim::ParticleList
137  virtual std::set<int> GetSetOfEveIDs() const = 0;
138 
139  // method to return all TrackIDs corresponding to the current sim::ParticleList
140  virtual std::set<int> GetSetOfTrackIDs() const = 0;
141 
142  // method to return all EveIDs corresponding to the given list of hits
143  virtual std::set<int> GetSetOfEveIDs(detinfo::DetectorClocksData const& clockData,
144  std::vector< art::Ptr<recob::Hit> > const& hits) const = 0;
145 
146  // method to return all TrackIDs corresponding to the given list of hits
147  virtual std::set<int> GetSetOfTrackIDs(detinfo::DetectorClocksData const& clockData,
148  std::vector< art::Ptr<recob::Hit> > const& hits) const = 0;
149 };
150 
151 } // namespace
152 #endif // IMCTRUTHMATCHING_H
virtual const art::Ptr< simb::MCTruth > & ParticleToMCTruth(const simb::MCParticle *p) const =0
virtual std::set< int > GetSetOfEveIDs() const =0
virtual double HitCollectionEfficiency(detinfo::DetectorClocksData const &clockData, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t view) const =0
virtual void reconfigure(fhicl::ParameterSet const &pset)=0
Interface for configuring the particular algorithm tool.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
virtual std::vector< const simb::MCParticle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const =0
virtual std::vector< double > SpacePointToXYZ(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::SpacePoint > const &spt, art::Event const &evt, std::string const &label) const =0
Declaration of signal hit object.
pdgs p
Definition: selectors.fcl:22
virtual void Rebuild(const art::Event &evt)=0
This rebuilds the internal maps.
virtual double HitCollectionPurity(detinfo::DetectorClocksData const &clockData, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits) const =0
virtual std::vector< sim::TrackIDE > HitToTrackID(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const =0
virtual std::vector< double > SpacePointHitsToXYZ(detinfo::DetectorClocksData const &clockData, art::PtrVector< recob::Hit > const &hits) const =0
process_name hit
Definition: cheaterreco.fcl:51
virtual double HitChargeCollectionPurity(detinfo::DetectorClocksData const &clockData, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits) const =0
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
virtual const simb::MCParticle * TrackIDToMotherParticle(int id) const =0
virtual std::vector< sim::TrackIDE > HitToEveID(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit) const =0
Definition of data types for geometry description.
virtual const simb::MCParticle * TrackIDToParticle(int id) const =0
Contains all timing reference information for the detector.
virtual std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIDsToHits(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> const &allhits, std::vector< int > const &tkIDs) const =0
virtual const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int id) const =0
object containing MC truth information necessary for making RawDigits and doing back tracking ...
virtual double HitChargeCollectionEfficiency(detinfo::DetectorClocksData const &clockData, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const view) const =0
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
virtual const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector() const =0
virtual ~IMCTruthMatching() noexcept=default
Virtual Destructor.
TCEvent evt
Definition: DataStructs.cxx:8
virtual std::set< int > GetSetOfTrackIDs() const =0
virtual std::vector< double > HitToXYZ(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit) const =0
virtual const sim::ParticleList & ParticleList() const =0
Get a reference to the ParticleList.