PhotonBackTracker.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////
2 //
3 // \file PhotonBackTracker.h
4 // \brief The functions needed for the PhotonBackTracker class needed by the PhotonBackTrackerService in order to connect truth information with reconstruction.
5 // \author jason.stock@mines.sdsmt.edu
6 //
7 // Based on the original BackTracker by brebel@fnal.gov
8 //
9 ///////////////////////////////////////////////////////////////////
10 //
11 //TODO: Impliment alternate backtracking scheme developed by T. Usher
12 //
13 ///////////////////////////////////////////////////////////////////
14 #ifndef CHEAT_PHOTONBACKTRACKER_H
15 #define CHEAT_PHOTONBACKTRACKER_H
16 
17 //CPP
18 #include <map>
19 #include <unordered_set>
20 #include <vector>
21 
22 //Framework
25 #include "fhiclcpp/types/Atom.h"
26 
27 //LArSoft
32 
33 namespace cheat { class ParticleInventory; }
34 namespace fhicl { class ParameterSet; }
35 namespace geo { class GeometryCore; }
36 namespace sim {
37  struct SDP;
38  struct TrackSDP;
39 }
40 
41 namespace cheat{
42  class PhotonBackTracker
43  {
44  public:
45 
46  struct fhiclConfig{
47  fhicl::Atom<double> Delay{fhicl::Name("Delay"), fhicl::Comment("The delay time needed to correctly account for the optical simulation and optical systems simulation. (The time between when a g4partcile was made, and when the simulation write out says a signal was recorded)."), 0};
48  fhicl::Atom<art::InputTag> G4ModuleLabel{fhicl::Name("G4ModuleLabel"), fhicl::Comment("The label of the LArG4 module used to produce the art file we will be using."), "largeant"};
49  fhicl::Atom<art::InputTag> OpHitLabel{fhicl::Name("OpHitLabel"), fhicl::Comment("The default label for the module to use when grabbing OpHits"), "ophit"}; //This should be removed and replaced with some way to access the OpHitLabel given by the user in their own analysis module to avoid differing definitions.
50  fhicl::Atom<art::InputTag> OpFlashLabel{fhicl::Name("OpFlashLabel"), fhicl::Comment("The default label for the module to use when grabbing OpFlash"), "opflash"}; //This should be removed and replaced with some way to access the OpFlashLabel given by the user in their own analysis module to avoid differing definitions.
51  fhicl::Atom<double> MinOpHitEnergyFraction{fhicl::Name("MinOpHitEnergyFraction"), fhicl::Comment("The minimum contribution an energy deposit must make to a Hit to be considered part of that hit."),0.010};
52  };
53 
54  //----------------------------------------------------------------
56  const cheat::ParticleInventory* partInv,
57  const geo::GeometryCore* geom);//,
58 // const detinfo::DetectorClocks* detClock);
59 
60  //----------------------------------------------------------------
62  const cheat::ParticleInventory* partInv,
63  const geo::GeometryCore* geom);//,
64 // const detinfo::DetectorClocks* detClock);
65 
66  //----------------------------------------------------------------
67  PhotonBackTracker(PhotonBackTracker const&) = delete;
68 
69  //-----------------------------------------------------
70  template<typename Evt>
71  void PrepEvent( Evt const& evt);
72 
73  //-----------------------------------------------------
74  template<typename Evt>
75  const bool CanRun( Evt const& evt) ;
76 
77  //-----------------------------------------------------
78  template<typename Evt>
79  void PrepOpDetBTRs(Evt const& evt);
80 
81  //-----------------------------------------------------
82  template<typename Evt>
83  void PrepOpFlashToOpHits(Evt const& evt);
84 
85  //----------------------------------------------------- /*NEW*/
86  const std::vector< art::Ptr<recob::OpHit> > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash >& flash_P) const;
87 
88  //----------------------------------------------------- /*NEW*/
89  const std::vector<double> OpFlashToXYZ(art::Ptr<recob::OpFlash>& flash_P) const ;
90 
91  //----------------------------------------------------- /*NEW*/
92  const std::set<int> OpFlashToTrackIds(art::Ptr<recob::OpFlash>& flash_P) const;
93 
94  //-----------------------------------------------------
95  const double GetDelay();
96 
97  //-----------------------------------------------------
98  void ClearEvent();
99 
100  //-----------------------------------------------------
101  const bool BTRsReady() ;
102 
103  //-----------------------------------------------------
104  const bool OpFlashToOpHitsReady();
105 
106  //-----------------------------------------------------
107  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> const& OpDetBTRs() ;
108 
109  //-----------------------------------------------------
110  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id) ;
111 
112  //-----------------------------------------------------
113  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view) ;
114 
115  //-----------------------------------------------------
116  const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const& opDetNum) const;
117 
118  //-----------------------------------------------------
119 
120  //-----------------------------------------------------
121  const std::vector < sim::TrackSDP > OpDetToTrackSDPs(int const& OpDetNum, double const& opHit_start_time, double const& opHit_end_time) const;
122 
123  //-----------------------------------------------------
124  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const ;
125 
126  //-----------------------------------------------------
127  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(recob::OpHit const& opHit) const ;
128 
129  //-----------------------------------------------------
130  const std::vector < int > OpHitToTrackIds(recob::OpHit const& opHit) const;
131 
132  //-----------------------------------------------------
133  const std::vector < int > OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit) const;
134 
135  //-----------------------------------------------------
136  const std::vector < int > OpHitToEveTrackIds(recob::OpHit const& opHit) ;
137 
138  //-----------------------------------------------------
139  const std::vector < int > OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P);
140 
141  //-----------------------------------------------------
142  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const;
143 
144  //-----------------------------------------------------
145  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs( recob::OpHit const& opHit) const ;
146 
147  //-----------------------------------------------------
148  const std::vector<art::Ptr<recob::OpHit>> TrackIdToOpHits_Ps( int const& tkId, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
149 
150  //-----------------------------------------------------
151  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIdsToOpHits_Ps( std::vector< int> const& tkIds, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
152 
153  //-----------------------------------------------------
154  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( recob::OpHit const& opHit) const ;
155 
156  //-----------------------------------------------------
157  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( art::Ptr<recob::OpHit> const& opHit_P) const;
158  //-----------------------------------------------------
159  //
160  //-----------------------------------------------------
161  // const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( const std::vector< art::Ptr < recob::OpHit > >& opHits_Ps) ;
162  const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( std::vector< art::Ptr < recob::OpHit > > const& opHits_Ps) const;
163 
164  //-----------------------------------------------------
165  const std::vector< double > SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&;
166 
167  //-----------------------------------------------------
168  const std::vector< double > SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps ) const&;
169 
170  //-----------------------------------------------------
171  const std::vector< double > OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit) ;
172 
173  //-----------------------------------------------------
174  const std::vector< double > OpHitToXYZ(recob::OpHit const& opHit) ;
175 
176  //-----------------------------------------------------
177  const std::vector< double > OpHitsToXYZ( std::vector < art::Ptr < recob::OpHit > > const& opHits_Ps) const; /*NEW*/
178 
179  //----------------------------------------------------- /*NEW*/
180  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit);
181 
182  //----------------------------------------------------- /*NEW*/
183  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit>& opHit_P);
184 
185  //-----------------------------------------------------
186  const std::set< int> GetSetOfEveIds() const ;
187 
188  //-----------------------------------------------------
189  const std::set< int> GetSetOfTrackIds() const ;
190 
191  //-----------------------------------------------------
192  const std::set< int> GetSetOfEveIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const ;
193 
194  //----------------------------------------------------- /*NEW*/
195  const std::set< int> GetSetOfEveIds(std::vector< recob::OpHit > const& opHits) const ;
196 
197  //-----------------------------------------------------
198  const std::set< int> GetSetOfTrackIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const;
199 
200  //----------------------------------------------------- /*NEW*/
201  const std::set< int> GetSetOfTrackIds(std::vector< recob::OpHit > const& opHits) const;
202 
203  //-----------------------------------------------------
204  const double OpHitCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
205 
206  //-----------------------------------------------------
207  const double OpHitLightCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
208 
209  //-----------------------------------------------------
210  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
211  std::vector< art::Ptr< recob::OpHit > > const& opHits,
212  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
213 
214  //-----------------------------------------------------
215  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
216  std::vector< art::Ptr< recob::OpHit > > const& opHits,
217  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
218  geo::View_t const& view) ;
219 
220  //-----------------------------------------------------
221  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
222  std::vector< art::Ptr< recob::OpHit > > const& opHits,
223  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
224 
225  //-----------------------------------------------------
226  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
227  std::vector< art::Ptr< recob::OpHit > > const& opHits,
228  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
229  geo::View_t const& view);
230 
231  //----------------------------------------------------- /*NEW*/
232  //std::vector<sim::TrackSDP> OpFlashToTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
233  //----------------------------------------------------- /*NEW*/
234  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(recob::OpFlash flash);
235  //----------------------------------------------------- /*NEW*/
236  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
237  //----------------------------------------------------- /*NEW*/
238  //std::vector<sim::SDP*> OpFlashToSimSDPs_Ps(art::Ptr<recob::OpFlash> flash_P);
239 
240 
241  private:
242  const cheat::ParticleInventory* fPartInv; //The constructor needs to put something in here
244  // const detinfo::DetectorClocks* fDetClocks;
245  const double fDelay;
250  mutable std::vector<art::Ptr<sim::OpDetBacktrackerRecord> > priv_OpDetBTRs;
251  std::map< art::Ptr < recob::OpFlash >, std::vector < art::Ptr < recob::OpHit > > > priv_OpFlashToOpHits;
252 
253 
254  };//Class
255 }//namespace
256 
257 #include "PhotonBackTracker.tcc"
258 
259 #endif
const double fMinOpHitEnergyFraction
const art::InputTag fG4ModuleLabel
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
struct vector vector
ChannelGroupService::Name Name
const cheat::ParticleInventory * fPartInv
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
static Config * config
Definition: config.cpp:1054
const geo::GeometryCore * fGeom
Description of geometry of one entire detector.
Code to link reconstructed objects back to the MC truth information.
Definition of data types for geometry description.
const art::InputTag fOpFlashLabel
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:22
#define Comment
const art::InputTag fOpHitLabel
TCEvent evt
Definition: DataStructs.cxx:7
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits