All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
23 #include "canvas/Persistency/Common/Ptr.h"
24 #include "canvas/Utilities/InputTag.h"
25 #include "fhiclcpp/types/Atom.h"
26 #include "fhiclcpp/types/Sequence.h"
27 
28 //LArSoft
33 
34 namespace cheat { class ParticleInventory; }
35 namespace fhicl { class ParameterSet; }
36 namespace geo { class GeometryCore; }
37 namespace sim {
38  struct SDP;
39  struct TrackSDP;
40 }
41 
42 namespace cheat{
43  class PhotonBackTracker
44  {
45  public:
46 
47  struct fhiclConfig{
48  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};
49  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"};
50  fhicl::Sequence<art::InputTag> G4ModuleLabels{fhicl::Name("G4ModuleLabels"), fhicl::Comment("The labels of the LArG4 modules used to produce the art file we will be using."), fhicl::Sequence<art::InputTag>::default_type{}};
51  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.
52  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.
53  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};
54  };
55 
56  //----------------------------------------------------------------
57  PhotonBackTracker(fhiclConfig const& config,
58  const cheat::ParticleInventory* partInv,
59  const geo::GeometryCore* geom);//,
60 // const detinfo::DetectorClocks* detClock);
61 
62  //----------------------------------------------------------------
63  PhotonBackTracker( fhicl::ParameterSet const& pSet,
64  const cheat::ParticleInventory* partInv,
65  const geo::GeometryCore* geom);//,
66 // const detinfo::DetectorClocks* detClock);
67 
68  //----------------------------------------------------------------
69  PhotonBackTracker(PhotonBackTracker const&) = delete;
70 
71  //-----------------------------------------------------
72  template<typename Evt>
73  void PrepEvent( Evt const& evt);
74 
75  //-----------------------------------------------------
76  template<typename Evt>
77  const bool CanRun( Evt const& evt) ;
78 
79  //-----------------------------------------------------
80  template<typename Evt>
81  void PrepOpDetBTRs(Evt const& evt);
82 
83  //-----------------------------------------------------
84  template<typename Evt>
85  void PrepOpFlashToOpHits(Evt const& evt);
86 
87  //----------------------------------------------------- /*NEW*/
88  const std::vector< art::Ptr<recob::OpHit> > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash >& flash_P) const;
89 
90  //----------------------------------------------------- /*NEW*/
91  const std::vector<double> OpFlashToXYZ(art::Ptr<recob::OpFlash>& flash_P) const ;
92 
93  //----------------------------------------------------- /*NEW*/
94  const std::set<int> OpFlashToTrackIds(art::Ptr<recob::OpFlash>& flash_P) const;
95 
96  //-----------------------------------------------------
97  const double GetDelay();
98 
99  //-----------------------------------------------------
100  void ClearEvent();
101 
102  //-----------------------------------------------------
103  const bool BTRsReady() ;
104 
105  //-----------------------------------------------------
106  const bool OpFlashToOpHitsReady();
107 
108  //-----------------------------------------------------
109  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> const& OpDetBTRs() ;
110 
111  //-----------------------------------------------------
112  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id) ;
113 
114  //-----------------------------------------------------
115  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view) ;
116 
117  //-----------------------------------------------------
118  const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const& opDetNum) const;
119 
120  //-----------------------------------------------------
121 
122  //-----------------------------------------------------
123  const std::vector < sim::TrackSDP > OpDetToTrackSDPs(int const& OpDetNum, double const& opHit_start_time, double const& opHit_end_time) const;
124 
125  //-----------------------------------------------------
126  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const ;
127 
128  //-----------------------------------------------------
129  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(recob::OpHit const& opHit) const ;
130 
131  //-----------------------------------------------------
132  const std::vector < int > OpHitToTrackIds(recob::OpHit const& opHit) const;
133 
134  //-----------------------------------------------------
135  const std::vector < int > OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit) const;
136 
137  //-----------------------------------------------------
138  const std::vector < int > OpHitToEveTrackIds(recob::OpHit const& opHit) ;
139 
140  //-----------------------------------------------------
141  const std::vector < int > OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P);
142 
143  //-----------------------------------------------------
144  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const;
145 
146  //-----------------------------------------------------
147  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs( recob::OpHit const& opHit) const ;
148 
149  //-----------------------------------------------------
150  const std::vector<art::Ptr<recob::OpHit>> TrackIdToOpHits_Ps( int const& tkId, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
151 
152  //-----------------------------------------------------
153  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIdsToOpHits_Ps( std::vector< int> const& tkIds, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
154 
155  //-----------------------------------------------------
156  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( recob::OpHit const& opHit) const ;
157 
158  //-----------------------------------------------------
159  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( art::Ptr<recob::OpHit> const& opHit_P) const;
160  //-----------------------------------------------------
161  //
162  //-----------------------------------------------------
163  // const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( const std::vector< art::Ptr < recob::OpHit > >& opHits_Ps) ;
164  const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( std::vector< art::Ptr < recob::OpHit > > const& opHits_Ps) const;
165 
166  //-----------------------------------------------------
167  const std::vector< double > SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&;
168 
169  //-----------------------------------------------------
170  const std::vector< double > SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps ) const&;
171 
172  //-----------------------------------------------------
173  const std::vector< double > OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit) ;
174 
175  //-----------------------------------------------------
176  const std::vector< double > OpHitToXYZ(recob::OpHit const& opHit) ;
177 
178  //-----------------------------------------------------
179  const std::vector< double > OpHitsToXYZ( std::vector < art::Ptr < recob::OpHit > > const& opHits_Ps) const; /*NEW*/
180 
181  //----------------------------------------------------- /*NEW*/
182  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit);
183 
184  //----------------------------------------------------- /*NEW*/
185  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit>& opHit_P);
186 
187  //-----------------------------------------------------
188  const std::set< int> GetSetOfEveIds() const ;
189 
190  //-----------------------------------------------------
191  const std::set< int> GetSetOfTrackIds() const ;
192 
193  //-----------------------------------------------------
194  const std::set< int> GetSetOfEveIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const ;
195 
196  //----------------------------------------------------- /*NEW*/
197  const std::set< int> GetSetOfEveIds(std::vector< recob::OpHit > const& opHits) const ;
198 
199  //-----------------------------------------------------
200  const std::set< int> GetSetOfTrackIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const;
201 
202  //----------------------------------------------------- /*NEW*/
203  const std::set< int> GetSetOfTrackIds(std::vector< recob::OpHit > const& opHits) const;
204 
205  //-----------------------------------------------------
206  const double OpHitCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
207 
208  //-----------------------------------------------------
209  const double OpHitLightCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
210 
211  //-----------------------------------------------------
212  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
213  std::vector< art::Ptr< recob::OpHit > > const& opHits,
214  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
215 
216  //-----------------------------------------------------
217  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
218  std::vector< art::Ptr< recob::OpHit > > const& opHits,
219  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
220  geo::View_t const& view) ;
221 
222  //-----------------------------------------------------
223  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
224  std::vector< art::Ptr< recob::OpHit > > const& opHits,
225  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
226 
227  //-----------------------------------------------------
228  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
229  std::vector< art::Ptr< recob::OpHit > > const& opHits,
230  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
231  geo::View_t const& view);
232 
233  //----------------------------------------------------- /*NEW*/
234  //std::vector<sim::TrackSDP> OpFlashToTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
235  //----------------------------------------------------- /*NEW*/
236  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(recob::OpFlash flash);
237  //----------------------------------------------------- /*NEW*/
238  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
239  //----------------------------------------------------- /*NEW*/
240  //std::vector<sim::SDP*> OpFlashToSimSDPs_Ps(art::Ptr<recob::OpFlash> flash_P);
241 
242 
243  private:
244  const cheat::ParticleInventory* fPartInv; //The constructor needs to put something in here
246  // const detinfo::DetectorClocks* fDetClocks;
247  const double fDelay;
248  const art::InputTag fG4ModuleLabel;
249  const std::vector<art::InputTag> fG4ModuleLabels;
250  const art::InputTag fOpHitLabel;
251  const art::InputTag fOpFlashLabel;
253  mutable std::vector<art::Ptr<sim::OpDetBacktrackerRecord> > priv_OpDetBTRs;
254  std::map< art::Ptr < recob::OpFlash >, std::vector < art::Ptr < recob::OpHit > > > priv_OpFlashToOpHits;
255 
256 
257  };//Class
258 }//namespace
259 
260 #include "PhotonBackTracker.tcc"
261 
262 #endif
fhicl::Atom< art::InputTag > G4ModuleLabel
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps(recob::OpHit const &opHit)
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
fhicl::Atom< art::InputTag > OpHitLabel
const std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps(std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
const double fMinOpHitEnergyFraction
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
const bool CanRun(Evt const &evt)
const art::InputTag fG4ModuleLabel
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
void PrepOpFlashToOpHits(Evt const &evt)
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
double OpHitCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits)
const std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
fhicl::Atom< art::InputTag > OpFlashLabel
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void PrepOpDetBTRs(Evt const &evt)
const cheat::ParticleInventory * fPartInv
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
const geo::GeometryCore * fGeom
const std::set< int > GetSetOfEveIds() const
const double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn)
fhicl::Sequence< art::InputTag > G4ModuleLabels
double OpHitCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits, std::vector< art::Ptr< recob::OpHit > > const &allhits)
const std::set< int > GetSetOfTrackIds() const
BEGIN_PROLOG vertical distance to the surface Name
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
const double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits)
Description of geometry of one entire detector.
const double GetDelay()
Definition of data types for geometry description.
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
const art::InputTag fOpFlashLabel
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
fhicl::Atom< double > MinOpHitEnergyFraction
PhotonBackTracker(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
const std::vector< art::InputTag > fG4ModuleLabels
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs()
geo::GeometryCore const * geom
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
const std::vector< double > OpHitsToXYZ(std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
const art::InputTag fOpHitLabel
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
void PrepEvent(Evt const &evt)
TCEvent evt
Definition: DataStructs.cxx:8
const bool OpFlashToOpHitsReady()
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
const std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const