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