All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
icaruscode/icaruscode/CRT/CRTUtils/CRTBackTracker.h
Go to the documentation of this file.
1 #ifndef CRTBACKTRACKER_H_SEEN
2 
3 #define CRTBACKTRACKER_H_SEEN
4 
5 /////////////////////////////////////////////////////////////////
6 // CRTBackTracker.h
7 //
8 // Quick and dirty backtracker for SBND CRT
9 // written by T Brooks (tbrooks@fnal.gov), November 2018
10 //
11 // Ported into icaruscode for use with ICARUS CRT
12 // by C Hilgenberg (Chris.Hilgenberg@colostate.edu), April 2020
13 /////////////////////////////////////////////////////////////////
14 
15 // framework
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Core/ModuleMacros.h"
18 #include "fhiclcpp/ParameterSet.h"
19 #include "art/Framework/Principal/Handle.h"
20 #include "canvas/Persistency/Common/Ptr.h"
21 #include "art/Framework/Services/Registry/ServiceHandle.h"
22 #include "messagefacility/MessageLogger/MessageLogger.h"
23 #include "canvas/Persistency/Common/FindManyP.h"
24 
25 // Utility libraries
26 #include "messagefacility/MessageLogger/MessageLogger.h"
27 #include "fhiclcpp/ParameterSet.h"
28 #include "fhiclcpp/types/Atom.h"
33 
34 // c++
35 #include <vector>
36 
37 namespace icarus{
38  namespace crt {
39  class CRTBackTracker;
40  }
41 }
42 
44 
45  public:
46 
50 
51  struct Config {
52  using Name = fhicl::Name;
53  using Comment = fhicl::Comment;
54  fhicl::Atom<art::InputTag> CRTTrueHitLabel {
55  Name("CRTTrueHitLabel")
56  };
57  fhicl::Atom<art::InputTag> CRTDataLabel {
58  Name("CRTDataLabel")
59  };
60 
61  fhicl::Atom<art::InputTag> CRTSimHitLabel {
62  Name("CRTSimHitLabel")
63  };
64 
65  fhicl::Atom<art::InputTag> CRTTrackLabel {
66  Name("CRTTrackLabel")
67  };
68 
69  fhicl::Atom<bool> RollupUnsavedIds {
70  Name("RollupUnsavedIds")
71  };
72  };
73 
74  CRTBackTracker(const Config& config);
75  CRTBackTracker(const fhicl::ParameterSet& pset) :
76  CRTBackTracker(fhicl::Table<Config>(pset, {})()) {}
79 
80  void reconfigure(const Config& config);
81 
82  // Initialize to speed things up
83  void Initialize(const art::Event& event);
84 
85  // Check that two CRT data products are the same
86  bool DataCompare(const CRTData& data1, const CRTData& data2);
87 
88  // Check that two CRT hits are the same
89  bool HitCompare(const CRTHit& hit1, const CRTHit& hit2);
90 
91  // Check that two CRT tracks are the same
92  bool TrackCompare(const CRTTrack& track1, const CRTTrack& track2);
93 
94  // Get all the true particle IDs that contributed to the CRT data product
95  std::vector<int> AllTrueIds(const art::Event& event, const CRTData& data);
96 
97  // Get all the true particle IDs that contributed to the CRT hit
98  std::vector<int> AllTrueIds(const art::Event& event, const CRTHit& hit);
99 
100  // Get all the true particle IDs that contributed to the CRT track
101  std::vector<int> AllTrueIds(const art::Event& event, const CRTTrack& track);
102 
103  // Get the true particle ID that contributed the most energy to the CRT data product
104  int TrueIdFromTotalEnergy(const art::Event& event, const CRTData& data);
105 
106  // Faster function - needs Initialize() to be called first
107  int TrueIdFromDataId(const art::Event& event, int data_i);
108 
109  // Get the true particle ID that contributed the most energy to the CRT hit
110  int TrueIdFromTotalEnergy(const art::Event& event, const CRTHit& hit);
111 
112  // Faster function - needs Initialize() to be called first
113  int TrueIdFromHitId(const art::Event& event, int hit_i);
114 
115  // Get the true particle ID that contributed the most energy to the CRT track
116  int TrueIdFromTotalEnergy(const art::Event& event, const CRTTrack& track);
117 
118  // Faster function - needs Initialize() to be called first
119  int TrueIdFromTrackId(const art::Event& event, int track_i);
120 
121  private:
122 
123  art::InputTag fCRTTrueHitLabel;
124  art::InputTag fCRTDataLabel;
125  art::InputTag fCRTSimHitLabel;
126  art::InputTag fCRTTrackLabel;
127 
129  std::map<int, std::map<int, double>> fTrueHitTrueIds;
130  std::map<int, std::map<int, double>> fDataTrueIds;
131  std::map<int, std::map<int, double>> fSimHitTrueIds;
132  std::map<int, std::map<int, double>> fTrackTrueIds;
133 
134 };
135 
136 #endif
bool HitCompare(const CRTHit &hit1, const CRTHit &hit2)
std::map< int, std::map< int, double > > fTrueHitTrueIds
std::map< int, std::map< int, double > > fDataTrueIds
int TrueIdFromDataId(const art::Event &event, int data_i)
process_name use argoneut_mc_hitfinder track
int TrueIdFromTrackId(const art::Event &event, int track_i)
std::map< int, std::map< int, double > > fTrackTrueIds
bool DataCompare(const CRTData &data1, const CRTData &data2)
process_name hit
Definition: cheaterreco.fcl:51
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Single hit (self trigger) of a CRT board.
BEGIN_PROLOG vertical distance to the surface Name
bool TrackCompare(const CRTTrack &track1, const CRTTrack &track2)
int TrueIdFromHitId(const art::Event &event, int hit_i)
std::vector< int > AllTrueIds(const art::Event &event, const CRTData &data)
int TrueIdFromTotalEnergy(const art::Event &event, const CRTData &data)
CRT Hit Info.
std::map< int, std::map< int, double > > fSimHitTrueIds
process_name crt