LArSoft  v07_13_02
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
39 
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::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.
51  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.
52  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};
53  };
54 
55  //----------------------------------------------------------------
56  PhotonBackTracker(fhiclConfig const& config,
57  const cheat::ParticleInventory* partInv,
58  const geo::GeometryCore* geom);//,
59 // const detinfo::DetectorClocks* detClock);
60 
61  //----------------------------------------------------------------
63  const cheat::ParticleInventory* partInv,
64  const geo::GeometryCore* geom);//,
65 // const detinfo::DetectorClocks* detClock);
66 
67  //----------------------------------------------------------------
68  PhotonBackTracker(PhotonBackTracker const&) = delete;
69 
70  //-----------------------------------------------------
71  template<typename Evt>
72  void PrepEvent( Evt const& evt);
73 
74  //-----------------------------------------------------
75  template<typename Evt>
76  const bool CanRun( Evt const& evt) ;
77 
78  //-----------------------------------------------------
79  template<typename Evt>
80  void PrepOpDetBTRs(Evt const& evt);
81 
82  //-----------------------------------------------------
83  template<typename Evt>
84  void PrepOpFlashToOpHits(Evt const& evt);
85 
86  //----------------------------------------------------- /*NEW*/
87  const std::vector< art::Ptr<recob::OpHit> > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash >& flash_P) const;
88 
89  //----------------------------------------------------- /*NEW*/
90  const std::vector<double> OpFlashToXYZ(art::Ptr<recob::OpFlash>& flash_P) const ;
91 
92  //----------------------------------------------------- /*NEW*/
93  const std::set<int> OpFlashToTrackIds(art::Ptr<recob::OpFlash>& flash_P) const;
94 
95  //-----------------------------------------------------
96  const double GetDelay();
97 
98  //-----------------------------------------------------
99  void ClearEvent();
100 
101  //-----------------------------------------------------
102  const bool BTRsReady() ;
103 
104  //-----------------------------------------------------
105  const bool OpFlashToOpHitsReady();
106 
107  //-----------------------------------------------------
108  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> const& OpDetBTRs() ;
109 
110  //-----------------------------------------------------
111  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id) ;
112 
113  //-----------------------------------------------------
114  const std::vector< const sim::SDP* > TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view) ;
115 
116  //-----------------------------------------------------
117  const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const& opDetNum) const;
118 
119  //-----------------------------------------------------
120 
121  //-----------------------------------------------------
122  const std::vector < sim::TrackSDP > OpDetToTrackSDPs(int const& OpDetNum, double const& opHit_start_time, double const& opHit_end_time) const;
123 
124  //-----------------------------------------------------
125  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const ;
126 
127  //-----------------------------------------------------
128  const std::vector< sim::TrackSDP> OpHitToTrackSDPs(recob::OpHit const& opHit) const ;
129 
130  //-----------------------------------------------------
131  const std::vector < int > OpHitToTrackIds(recob::OpHit const& opHit) const;
132 
133  //-----------------------------------------------------
134  const std::vector < int > OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit) const;
135 
136  //-----------------------------------------------------
137  const std::vector < int > OpHitToEveTrackIds(recob::OpHit const& opHit) ;
138 
139  //-----------------------------------------------------
140  const std::vector < int > OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P);
141 
142  //-----------------------------------------------------
143  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P) const;
144 
145  //-----------------------------------------------------
146  const std::vector< sim::TrackSDP> OpHitToEveTrackSDPs( recob::OpHit const& opHit) const ;
147 
148  //-----------------------------------------------------
149  const std::vector<art::Ptr<recob::OpHit>> TrackIdToOpHits_Ps( int const& tkId, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
150 
151  //-----------------------------------------------------
152  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIdsToOpHits_Ps( std::vector< int> const& tkIds, std::vector<art::Ptr<recob::OpHit>> const& hitsIn) ;
153 
154  //-----------------------------------------------------
155  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( recob::OpHit const& opHit) const ;
156 
157  //-----------------------------------------------------
158  const std::vector< const sim::SDP* > OpHitToSimSDPs_Ps( art::Ptr<recob::OpHit> const& opHit_P) const;
159  //-----------------------------------------------------
160  //
161  //-----------------------------------------------------
162  // const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( const std::vector< art::Ptr < recob::OpHit > >& opHits_Ps) ;
163  const std::vector< const sim::SDP* > OpHitsToSimSDPs_Ps( std::vector< art::Ptr < recob::OpHit > > const& opHits_Ps) const;
164 
165  //-----------------------------------------------------
166  const std::vector< double > SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&;
167 
168  //-----------------------------------------------------
169  const std::vector< double > SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps ) const&;
170 
171  //-----------------------------------------------------
172  const std::vector< double > OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit) ;
173 
174  //-----------------------------------------------------
175  const std::vector< double > OpHitToXYZ(recob::OpHit const& opHit) ;
176 
177  //-----------------------------------------------------
178  const std::vector< double > OpHitsToXYZ( std::vector < art::Ptr < recob::OpHit > > const& opHits_Ps) const; /*NEW*/
179 
180  //----------------------------------------------------- /*NEW*/
181  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit);
182 
183  //----------------------------------------------------- /*NEW*/
184  const std::unordered_set<const sim::SDP*> OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit>& opHit_P);
185 
186  //-----------------------------------------------------
187  const std::set< int> GetSetOfEveIds() const ;
188 
189  //-----------------------------------------------------
190  const std::set< int> GetSetOfTrackIds() const ;
191 
192  //-----------------------------------------------------
193  const std::set< int> GetSetOfEveIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const ;
194 
195  //----------------------------------------------------- /*NEW*/
196  const std::set< int> GetSetOfEveIds(std::vector< recob::OpHit > const& opHits) const ;
197 
198  //-----------------------------------------------------
199  const std::set< int> GetSetOfTrackIds(std::vector< art::Ptr<recob::OpHit> > const& opHits) const;
200 
201  //----------------------------------------------------- /*NEW*/
202  const std::set< int> GetSetOfTrackIds(std::vector< recob::OpHit > const& opHits) const;
203 
204  //-----------------------------------------------------
205  const double OpHitCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
206 
207  //-----------------------------------------------------
208  const double OpHitLightCollectionPurity(std::set<int> const& tkIds, std::vector< art::Ptr<recob::OpHit> > const& opHits) ;
209 
210  //-----------------------------------------------------
211  const double OpHitCollectionEfficiency(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 OpHitCollectionEfficiency(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  //-----------------------------------------------------
222  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
223  std::vector< art::Ptr< recob::OpHit > > const& opHits,
224  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn) ;
225 
226  //-----------------------------------------------------
227  const double OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
228  std::vector< art::Ptr< recob::OpHit > > const& opHits,
229  std::vector< art::Ptr< recob::OpHit > > const& opHitsIn,
230  geo::View_t const& view);
231 
232  //----------------------------------------------------- /*NEW*/
233  //std::vector<sim::TrackSDP> OpFlashToTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
234  //----------------------------------------------------- /*NEW*/
235  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(recob::OpFlash flash);
236  //----------------------------------------------------- /*NEW*/
237  //std::vector<sim::TrackSDP> OpFlashToEveTrackSDPs(art::Ptr<recob::OpFlash> flash_P);
238  //----------------------------------------------------- /*NEW*/
239  //std::vector<sim::SDP*> OpFlashToSimSDPs_Ps(art::Ptr<recob::OpFlash> flash_P);
240 
241 
242  private:
243  const cheat::ParticleInventory* fPartInv; //The constructor needs to put something in here
245  // const detinfo::DetectorClocks* fDetClocks;
246  const double fDelay;
251  mutable std::vector<art::Ptr<sim::OpDetBacktrackerRecord> > priv_OpDetBTRs;
252  std::map< art::Ptr < recob::OpFlash >, std::vector < art::Ptr < recob::OpHit > > > priv_OpFlashToOpHits;
253 
254 
255  };//Class
256 }//namespace
257 
258 #include "PhotonBackTracker.tcc"
259 
260 #endif
261 
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)
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
Utility object to perform functions of association.
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()
TCEvent evt
Definition: DataStructs.cxx:5
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P) const
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
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