LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 <vector>
20 
21 //Framework
22 #include "fhiclcpp/types/Atom.h"
23 #include "fhiclcpp/types/Table.h"
24 
25 //LArSoft
34 
35 
36 
37 namespace cheat{
38  class PhotonBackTracker
39  {
40  public:
41 
42  struct fhiclConfig{
43  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};
44  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"};
45  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.
46  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.
47  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};
48  };
49 
50  //----------------------------------------------------------------
51  PhotonBackTracker(fhiclConfig const& config,
52  const cheat::ParticleInventory* partInv,
53  const geo::GeometryCore* geom);//,
54 // const detinfo::DetectorClocks* detClock);
55 
56  //----------------------------------------------------------------
58  const cheat::ParticleInventory* partInv,
59  const geo::GeometryCore* geom);//,
60 // const detinfo::DetectorClocks* detClock);
61 
62  //----------------------------------------------------------------
63  PhotonBackTracker(PhotonBackTracker const&) = delete;
64 
65  //-----------------------------------------------------
66  template<typename Evt>
67  void PrepEvent( Evt const& evt);
68 
69  //-----------------------------------------------------
70  template<typename Evt>
71  const bool CanRun( Evt const& evt) ;
72 
73  //-----------------------------------------------------
74  template<typename Evt>
75  void PrepOpDetBTRs(Evt const& evt);
76 
77  //-----------------------------------------------------
78  template<typename Evt>
79  void PrepOpFlashToOpHits(Evt const& evt);
80 
81  //----------------------------------------------------- /*NEW*/
82  const std::vector<art::Ptr<recob::OpHit>> OpFlashToOpHits_Ps(art::Ptr<recob::OpFlash>& flash_P) const;
83 
84  //----------------------------------------------------- /*NEW*/
85  const std::vector<double> OpFlashToXYZ(art::Ptr<recob::OpFlash>& flash_P) const ;
86 
87  //----------------------------------------------------- /*NEW*/
88  const std::set<int> OpFlashToTrackIds(art::Ptr<recob::OpFlash>& flash_P) const;
89 
90  //-----------------------------------------------------
91  void ClearEvent();
92 
93  //-----------------------------------------------------
94  const bool BTRsReady() ;
95 
96  //-----------------------------------------------------
97  const bool OpFlashToOpHitsReady();
98 
99  //-----------------------------------------------------
100  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> const& OpDetBTRs() ;
101 
102  //-----------------------------------------------------
103  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id) ;
104 
105  //-----------------------------------------------------
106  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view) ;
107 
108  //-----------------------------------------------------
109  const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const& opDetNum) const;
110 
111  //-----------------------------------------------------
112  const std::vector < sim::TrackSDP > OpDetToTrackSDPs(int const& OpDetNum, double const& opHit_start_time, double const& opHit_end_time) const;
113 
114  //-----------------------------------------------------
115  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const ;
116 
117  //-----------------------------------------------------
118  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(recob::OpHit const& opHit) const ;
119 
120  //-----------------------------------------------------
121  const std::vector < int > OpHitToTrackIds(recob::OpHit const& opHit) const;
122 
123  //-----------------------------------------------------
124  const std::vector < int > OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit) const;
125 
126  //-----------------------------------------------------
127  const std::vector < int > OpHitToEveTrackIds(recob::OpHit const& opHit) ;
128 
129  //-----------------------------------------------------
130  const std::vector < int > OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P);
131 
132  //-----------------------------------------------------
133  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const;
134 
135  //-----------------------------------------------------
136  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs( recob::OpHit const& opHit) const ;
137 
138  //-----------------------------------------------------
139  const std::vector<art::Ptr<recob::OpHit>> TrackIdToOpHits_Ps( int const& tkId, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
140 
141  //-----------------------------------------------------
142  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIdsToOpHits_Ps( std::vector< int> const& tkIds, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
143 
144  //-----------------------------------------------------
145  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( recob::OpHit const& opHit) const ;
146 
147  //-----------------------------------------------------
148  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( art::Ptr<recob::OpHit> const& opHit_P) const;
149  //
150  //-----------------------------------------------------
151  // const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( const std::vector< art::Ptr < recob::OpHit > >& opHits_Ps) ;
152  const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( std::vector< art::Ptr < recob::OpHit > > const& opHits_Ps) const;
153 
154  //-----------------------------------------------------
155  const std::vector< double > SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&;
156 
157  //-----------------------------------------------------
158  const std::vector< double > SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps ) const&;
159 
160  //-----------------------------------------------------
161  const std::vector< double > OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit) ;
162 
163  //-----------------------------------------------------
164  const std::vector< double > OpHitToXYZ(recob::OpHit const& opHit) ;
165 
166  //-----------------------------------------------------
167  const std::vector< double > OpHitsToXYZ( std::vector < art::Ptr < recob::OpHit > > const& opHits_Ps) const; /*NEW*/
168 
169  //----------------------------------------------------- /*NEW*/
170  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit);
171 
172  //----------------------------------------------------- /*NEW*/
173  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit>& opHit_P);
174 
175  //-----------------------------------------------------
176  const std::set< int> GetSetOfEveIds() const ;
177 
178  //-----------------------------------------------------
179  const std::set< int> GetSetOfTrackIds() const ;
180 
181  //-----------------------------------------------------
182  const std::set< int> GetSetOfEveIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const ;
183 
184  //----------------------------------------------------- /*NEW*/
185  const std::set< int> GetSetOfEveIds(std::vector< recob::OpHit > const& opHits) const ;
186 
187  //-----------------------------------------------------
188  const std::set< int> GetSetOfTrackIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const;
189 
190  //----------------------------------------------------- /*NEW*/
191  const std::set< int> GetSetOfTrackIds(std::vector< recob::OpHit > const& opHits) const;
192 
193  //-----------------------------------------------------
194  const double OpHitCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
195 
196  //-----------------------------------------------------
197  const double OpHitLightCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
198 
199  //-----------------------------------------------------
200  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
201  std::vector< art::Ptr< recob::OpHit > > const& opHits,
202  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
203 
204  //-----------------------------------------------------
205  const double OpHitCollectionEfficiency(std::set<int> const& tkIds,
206  std::vector< art::Ptr< recob::OpHit > > const& opHits,
207  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
208  geo::View_t const& view) ;
209 
210  //-----------------------------------------------------
211  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
212  std::vector< art::Ptr< recob::OpHit > > const& opHits,
213  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
214 
215  //-----------------------------------------------------
216  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
217  std::vector< art::Ptr< recob::OpHit > > const& opHits,
218  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
219  geo::View_t const& view);
220 
221  //----------------------------------------------------- /*NEW*/
222  //std::vector<sim::TrackSDP> OpFlashToTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
223  //----------------------------------------------------- /*NEW*/
224  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(recob::OpFlash flash);
225  //----------------------------------------------------- /*NEW*/
226  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
227  //----------------------------------------------------- /*NEW*/
228  //std::vector<sim::SDP*> OpFlashToSimSDPs_Ps(art::Ptr<recob::OpFlash> flash_P);
229 
230 
231  private:
232  const cheat::ParticleInventory* fPartInv; //The constructor needs to put something in here
234 // const detinfo::DetectorClocks* fDetClocks;
235  const double fDelay;
240  mutable std::vector<art::Ptr<sim::OpDetBacktrackerRecord> > priv_OpDetBTRs;
241  std::map< art::Ptr < recob::OpFlash >, std::vector < art::Ptr < recob::OpHit > > > fOpFlashToOpHits;
242 
243 
244  };//Class
245 }//namespace
246 
247 #include "PhotonBackTracker.tcc"
248 
249 #endif
250 
fhicl::Atom< art::InputTag > G4ModuleLabel
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
fhicl::Atom< art::InputTag > OpHitLabel
const double fMinOpHitEnergyFraction
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps(recob::OpHit const &opHit)
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > fOpFlashToOpHits
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
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< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
double OpHitCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits)
pure virtual base interface for detector clocks
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
fhicl::Atom< art::InputTag > OpFlashLabel
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Access the description of detector geometry.
const std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
const std::set< int > GetSetOfEveIds() const
const std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
void PrepOpDetBTRs(Evt const &evt)
const cheat::ParticleInventory * fPartInv
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
const geo::GeometryCore * fGeom
const double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn)
double OpHitCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits, std::vector< art::Ptr< recob::OpHit > > const &allhits)
const double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits)
Description of geometry of one entire detector.
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)
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:26
const std::set< int > GetSetOfTrackIds() const
geo::GeometryCore const * geom
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
const std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps(std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
const std::vector< double > OpHitsToXYZ(std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
Header for the ParticleInvenotry Service Provider.
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
const art::InputTag fOpHitLabel
Data structure containing constant pointers to classes.
void PrepEvent(Evt const &evt)
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs()
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const