LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PhotonBackTracker.h
Go to the documentation of this file.
1 //
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 //
10 //
11 //TODO: Impliment alternate backtracking scheme developed by T. Usher
12 //
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"
27 
28 //LArSoft
33 
34 namespace cheat {
35  class ParticleInventory;
36 }
37 namespace fhicl {
38  class ParameterSet;
39 }
40 namespace geo {
41  class GeometryCore;
42 }
43 namespace sim {
44  struct SDP;
45  struct TrackSDP;
46 }
47 
48 namespace cheat {
49  class PhotonBackTracker {
50  public:
51  struct fhiclConfig {
53  fhicl::Name("Delay"),
54  fhicl::Comment("The delay time needed to correctly account for the optical simulation and "
55  "optical systems simulation. (The time between when a g4partcile was made, "
56  "and when the simulation write out says a signal was recorded)."),
57  0};
59  fhicl::Name("G4ModuleLabel"),
61  "The label of the LArG4 module used to produce the art file we will be using."),
62  "largeant"};
64  fhicl::Name("G4ModuleLabels"),
66  "The labels of the LArG4 modules used to produce the art file we will be using."),
69  fhicl::Name("OpHitLabel"),
70  fhicl::Comment("The default label for the module to use when grabbing OpHits"),
71  "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.
73  fhicl::Name("OpFlashLabel"),
74  fhicl::Comment("The default label for the module to use when grabbing OpFlash"),
75  "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.
76  fhicl::Atom<double> MinOpHitEnergyFraction{
77  fhicl::Name("MinOpHitEnergyFraction"),
78  fhicl::Comment("The minimum contribution an energy deposit must make to a Hit to be "
79  "considered part of that hit."),
80  0.010};
81  };
82 
83  //----------------------------------------------------------------
84  PhotonBackTracker(fhiclConfig const& config,
85  const cheat::ParticleInventory* partInv,
86  const geo::GeometryCore* geom); //,
87  // const detinfo::DetectorClocks* detClock);
88 
89  //----------------------------------------------------------------
91  const cheat::ParticleInventory* partInv,
92  const geo::GeometryCore* geom); //,
93  // const detinfo::DetectorClocks* detClock);
94 
95  //----------------------------------------------------------------
96  PhotonBackTracker(PhotonBackTracker const&) = delete;
97 
98  //-----------------------------------------------------
99  template <typename Evt>
100  void PrepEvent(Evt const& evt);
101 
102  //-----------------------------------------------------
103  template <typename Evt>
104  const bool CanRun(Evt const& evt);
105 
106  //-----------------------------------------------------
107  template <typename Evt>
108  void PrepOpDetBTRs(Evt const& evt);
109 
110  //-----------------------------------------------------
111  template <typename Evt>
112  void PrepOpFlashToOpHits(Evt const& evt);
113 
114  //----------------------------------------------------- /*NEW*/
115  const std::vector<art::Ptr<recob::OpHit>> OpFlashToOpHits_Ps(
116  art::Ptr<recob::OpFlash>& flash_P) const;
117 
118  //----------------------------------------------------- /*NEW*/
119  const std::vector<double> OpFlashToXYZ(art::Ptr<recob::OpFlash>& flash_P) const;
120 
121  //----------------------------------------------------- /*NEW*/
122  const std::set<int> OpFlashToTrackIds(art::Ptr<recob::OpFlash>& flash_P) const;
123 
124  //-----------------------------------------------------
125  const double GetDelay();
126 
127  //-----------------------------------------------------
128  void ClearEvent();
129 
130  //-----------------------------------------------------
131  const bool BTRsReady();
132 
133  //-----------------------------------------------------
134  const bool OpFlashToOpHitsReady();
135 
136  //-----------------------------------------------------
137  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> const& OpDetBTRs();
138 
139  //-----------------------------------------------------
140  const std::vector<const sim::SDP*> TrackIdToSimSDPs_Ps(int const& id);
141 
142  //-----------------------------------------------------
143  const std::vector<const sim::SDP*> TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view);
144 
145  //-----------------------------------------------------
146  const art::Ptr<sim::OpDetBacktrackerRecord> FindOpDetBTR(int const& opDetNum) const;
147 
148  //-----------------------------------------------------
149 
150  //-----------------------------------------------------
151  const std::vector<sim::TrackSDP> OpDetToTrackSDPs(int const& OpDetNum,
152  double const& opHit_start_time,
153  double const& opHit_end_time) const;
154 
155  //-----------------------------------------------------
156  const std::vector<sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const;
157 
158  //-----------------------------------------------------
159  const std::vector<sim::TrackSDP> OpHitToTrackSDPs(recob::OpHit const& opHit) const;
160 
161  //-----------------------------------------------------
162  const std::vector<int> OpHitToTrackIds(recob::OpHit const& opHit) const;
163 
164  //-----------------------------------------------------
165  const std::vector<int> OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit) const;
166 
167  //-----------------------------------------------------
168  const std::vector<int> OpHitToEveTrackIds(recob::OpHit const& opHit);
169 
170  //-----------------------------------------------------
171  const std::vector<int> OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P);
172 
173  //-----------------------------------------------------
174  const std::vector<sim::TrackSDP> OpHitToEveTrackSDPs(
175  art::Ptr<recob::OpHit> const& opHit_P) const;
176 
177  //-----------------------------------------------------
178  const std::vector<sim::TrackSDP> OpHitToEveTrackSDPs(recob::OpHit const& opHit) const;
179 
180  //-----------------------------------------------------
181  const std::vector<art::Ptr<recob::OpHit>> TrackIdToOpHits_Ps(
182  int const& tkId,
183  std::vector<art::Ptr<recob::OpHit>> const& hitsIn);
184 
185  //-----------------------------------------------------
186  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIdsToOpHits_Ps(
187  std::vector<int> const& tkIds,
188  std::vector<art::Ptr<recob::OpHit>> const& hitsIn);
189 
190  //-----------------------------------------------------
191  const std::vector<const sim::SDP*> OpHitToSimSDPs_Ps(recob::OpHit const& opHit) const;
192 
193  //-----------------------------------------------------
194  const std::vector<const sim::SDP*> OpHitToSimSDPs_Ps(
195  art::Ptr<recob::OpHit> const& opHit_P) const;
196  //-----------------------------------------------------
197  //
198  //-----------------------------------------------------
199  // const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( const std::vector< art::Ptr < recob::OpHit > >& opHits_Ps) ;
200  const std::vector<const sim::SDP*> OpHitsToSimSDPs_Ps(
201  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps) const;
202 
203  //-----------------------------------------------------
204  const std::vector<double> SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&;
205 
206  //-----------------------------------------------------
207  const std::vector<double> SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps) const&;
208 
209  //-----------------------------------------------------
210  const std::vector<double> OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit);
211 
212  //-----------------------------------------------------
213  const std::vector<double> OpHitToXYZ(recob::OpHit const& opHit);
214 
215  //-----------------------------------------------------
216  const std::vector<double> OpHitsToXYZ(
217  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps) const; /*NEW*/
218 
219  //----------------------------------------------------- /*NEW*/
220  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit);
221 
222  //----------------------------------------------------- /*NEW*/
223  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit>& opHit_P);
224 
225  //-----------------------------------------------------
226  const std::set<int> GetSetOfEveIds() const;
227 
228  //-----------------------------------------------------
229  const std::set<int> GetSetOfTrackIds() const;
230 
231  //-----------------------------------------------------
232  const std::set<int> GetSetOfEveIds(std::vector<art::Ptr<recob::OpHit>> const& opHits) const;
233 
234  //----------------------------------------------------- /*NEW*/
235  const std::set<int> GetSetOfEveIds(std::vector<recob::OpHit> const& opHits) const;
236 
237  //-----------------------------------------------------
238  const std::set<int> GetSetOfTrackIds(std::vector<art::Ptr<recob::OpHit>> const& opHits) const;
239 
240  //----------------------------------------------------- /*NEW*/
241  const std::set<int> GetSetOfTrackIds(std::vector<recob::OpHit> const& opHits) const;
242 
243  //-----------------------------------------------------
244  const double OpHitCollectionPurity(std::set<int> const& tkIds,
245  std::vector<art::Ptr<recob::OpHit>> const& opHits);
246 
247  //-----------------------------------------------------
248  const double OpHitLightCollectionPurity(std::set<int> const& tkIds,
249  std::vector<art::Ptr<recob::OpHit>> const& opHits);
250 
251  //-----------------------------------------------------
252  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
253  std::vector<art::Ptr<recob::OpHit>> const& opHits,
254  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn);
255 
256  //-----------------------------------------------------
257  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
258  std::vector<art::Ptr<recob::OpHit>> const& opHits,
259  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn,
260  geo::View_t const& view);
261 
262  //-----------------------------------------------------
263  const double OpHitLightCollectionEfficiency(
264  std::set<int> const& tkIds,
265  std::vector<art::Ptr<recob::OpHit>> const& opHits,
266  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn);
267 
268  //-----------------------------------------------------
269  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
270  std::vector<art::Ptr<recob::OpHit>> const& opHits,
271  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn,
272  geo::View_t const& view);
273 
274  //----------------------------------------------------- /*NEW*/
275  //std::vector<sim::TrackSDP> OpFlashToTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
276  //----------------------------------------------------- /*NEW*/
277  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(recob::OpFlash flash);
278  //----------------------------------------------------- /*NEW*/
279  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
280  //----------------------------------------------------- /*NEW*/
281  //std::vector<sim::SDP*> OpFlashToSimSDPs_Ps(art::Ptr<recob::OpFlash> flash_P);
282 
283  private:
284  const cheat::ParticleInventory* fPartInv; //The constructor needs to put something in here
286  // const detinfo::DetectorClocks* fDetClocks;
287  const double fDelay;
289  const std::vector<art::InputTag> fG4ModuleLabels;
293  mutable std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> priv_OpDetBTRs;
294  std::map<art::Ptr<recob::OpFlash>, std::vector<art::Ptr<recob::OpHit>>> priv_OpFlashToOpHits;
295 
296  }; //Class
297 } //namespace
298 
299 #include "PhotonBackTracker.tcc"
300 
301 #endif
const double fMinOpHitEnergyFraction
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
const art::InputTag fG4ModuleLabel
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
const cheat::ParticleInventory * fPartInv
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
parameter set interface
const geo::GeometryCore * fGeom
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
Monte Carlo Simulation.
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
const std::vector< art::InputTag > fG4ModuleLabels
const art::InputTag fOpHitLabel
TCEvent evt
Definition: DataStructs.cxx:8
Namespace collecting geometry-related classes utilities.