All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhotonBackTrackerService.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file PhotonBackTrackerServiceService_service.cc
4 // \brief This is the LArSoft facing implimentation of the PhotonBackTracker.
5 // \author jason.stock@mines.sdsmt.edu
6 //
7 //
8 ////////////////////////////////////////////////////////////////////////
9 
11 
12 // Framework includes
13 #include "art/Framework/Services/Registry/ActivityRegistry.h"
14 #include "art/Framework/Principal/Event.h"
15 #include "messagefacility/MessageLogger/MessageLogger.h"
16 #include "fhiclcpp/ParameterSet.h"
17 
18 // LArSoft includes
19 #include "larcore/CoreUtils/ServiceUtil.h" // for provid...
20 #include "larcore/Geometry/Geometry.h" // for Geometry
21 #include "larsim/MCCheater/ParticleInventoryService.h" // for Partic...
22 
23 namespace cheat{
24 
25  //----------------------------------------------------------------------
26  PhotonBackTrackerService::PhotonBackTrackerService(fhicl::ParameterSet const& pSet, art::ActivityRegistry& reg)
28  pSet.get<fhicl::ParameterSet>("PhotonBackTracker"),
30  lar::providerFrom<geo::Geometry>()//,
31 // lar::providerFrom<detinfo::DetectorClocksService>()
32  )
33  {
34  reg.sPreProcessEvent.watch(this, &PhotonBackTrackerService::priv_PrepEvent);
35  }
36 
37  //----------------------------------------------------------------------
38  PhotonBackTrackerService::PhotonBackTrackerService(fhiclConfig const& config, art::ActivityRegistry& reg)
40  config.PhotonBackTrackerTable(),
42  lar::providerFrom<geo::Geometry>()//,
43 // lar::providerFrom<detinfo::DetectorClocksService>()
44  )
45  {
46  reg.sPreProcessEvent.watch(this, &PhotonBackTrackerService::priv_PrepEvent);
47  }
48 
49  ////////////////////////////////////////////////
50  //////////Event Rebuild Implimentation//////////
51  /// This section contains the implimentation ///
52  /// of all Prep templates from the service ///
53  /// provider. ///
54  ////////////////////////////////////////////////
55 
56 
57  //----------------------------------------------------------------------
58  void PhotonBackTrackerService::Rebuild(art::Event const& evt)
59  {
60  this->priv_PrepEvent(evt, art::ScheduleContext::invalid());
61  }
62 
63  //----------------------------------------------------------------------
64  void PhotonBackTrackerService::priv_PrepEvent( art::Event const& evt, art::ScheduleContext)
65  {
67  if( ! this->priv_CanRun(evt) ){ return; }
68  this->priv_PrepOpDetBTRs(evt);
69  this->priv_PrepOpFlashToOpHits(evt);
70  }
71 
72  //----------------------------------------------------------------------
73  bool PhotonBackTrackerService::priv_CanRun(art::Event const& evt){
74  return PhotonBackTracker::CanRun(evt);
75  }
76 
77  //----------------------------------------------------------------------
79  throw cet::exception("PhotonBackTrackerService")
80  <<"The called Prep Fucntion failed. This is most likely due "
81  <<"to a PhotonBackTracker fucntion being used on a file that "
82  <<"is real data.";
83  }
84 
85  //----------------------------------------------------------------------
87  if( !this->priv_CanRun(evt) ) {this->priv_PrepFailed(); }
88  if( this->priv_OpDetBTRsReady()){ return; }
90  //catch(...){ mf::LogWarning("PhotonBackTrackerService")//This needs to go. Catch all should not be used.
91  catch(cet::exception const&){//This needs to go. Make it specific if there is a really an exception we would like to catch.
92  mf::LogWarning("PhotonBackTrackerService")
93  <<"Rebuild failed to get the OpDetBTRs. This is expected when "
94  <<"running on a generation or simulation step.";}
95  }
96 
98  if( !this->priv_CanRun(evt) ) {this->priv_PrepFailed();}
99  if( this->priv_OpFlashToOpHitsReady()){ return; }
101  //catch(...){ //This needs to go. Catch all should not be used.
102  catch(cet::exception const&){//This needs to go. Make it specific if there is a really an exception we would like to catch.
103  mf::LogWarning("PhotonBackTrackerService")
104  <<"Rebuild failed to get the OpFlashToOpHits. This is expected when "
105  <<"running on a generation or simulation stage.";
106  }
107  }
108 
109  /////////////////////////////////////////////
110  // End of the Event Rebuild Implimentation //
111  /////////////////////////////////////////////
112 
113  ///////////////////////////////////////////////
114  /////BackTracking Functions Implimentation/////
115  // This section contains the implimentation //
116  // of all PhotonBackTrackerService end user //
117  // functionality //
118  ///////////////////////////////////////////////
119 
120 
121  //----------------------------------------------------------------------
122  const std::vector< art::Ptr< sim::OpDetBacktrackerRecord >>& PhotonBackTrackerService::OpDetBTRs()
123  {
125  }
126 
127  //----------------------------------------------------------------------
129 
130  //----------------------------------------------------------------------
131  const std::vector< const sim::SDP* > PhotonBackTrackerService::TrackIdToSimSDPs_Ps(int const& id)
132  {
134  }
135 
136  //----------------------------------------------------------------------
137  const std::vector< const sim::SDP* > PhotonBackTrackerService::TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view )
138  {
140  }
141 
142  //----------------------------------------------------------------------
143  art::Ptr< sim::OpDetBacktrackerRecord > PhotonBackTrackerService::FindOpDetBTR(int const& opDetNum)
144  {
145  return PhotonBackTracker::FindOpDetBTR(opDetNum);
146  }
147 
148  //----------------------------------------------------------------------
149  const std::vector < sim::TrackSDP > PhotonBackTrackerService::OpDetToTrackSDPs( int const& OpDetNum,
150  double const& opHit_start_time,
151  double const& opHit_end_time)
152  {
153  return PhotonBackTracker::OpDetToTrackSDPs(OpDetNum, opHit_start_time, opHit_end_time);
154  }
155 
156  //----------------------------------------------------------------------
157  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P )
158  {
159  return PhotonBackTracker::OpHitToTrackSDPs(opHit_P );
160  }
161 
162  //----------------------------------------------------------------------
163  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToTrackSDPs(recob::OpHit const& opHit)
164  {
166  }
167 
168  //----------------------------------------------------------------------
169  const std::vector < int > PhotonBackTrackerService::OpHitToTrackIds(recob::OpHit const& opHit) {
171  }
172 
173  //----------------------------------------------------------------------
174  const std::vector < int > PhotonBackTrackerService::OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit_P) {
175  return PhotonBackTracker::OpHitToTrackIds(opHit_P);
176  }
177 
178  //----------------------------------------------------------------------
179  //----------------------------------------------------------------------
180  const std::vector < int > PhotonBackTrackerService::OpHitToEveTrackIds(recob::OpHit const& opHit) {
182  }
183 
184  //----------------------------------------------------------------------
185  const std::vector < int > PhotonBackTrackerService::OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P) {
187  }
188 
189  //----------------------------------------------------------------------
190  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToEveTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P )
191  {
193  }
194 
195  //----------------------------------------------------------------------
196  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToEveTrackSDPs(recob::OpHit const& opHit)
197  {
199  }
200 
201  //----------------------------------------------------------------------
202  const std::vector<art::Ptr<recob::OpHit>> PhotonBackTrackerService::TrackIdToOpHits_Ps(int const& tkId, std::vector<art::Ptr<recob::OpHit>> const& hitsIn)
203  {
204  return PhotonBackTracker::TrackIdToOpHits_Ps(tkId, hitsIn);
205  }
206 
207  //----------------------------------------------------------------------
208  const std::vector<std::vector<art::Ptr<recob::OpHit>>> PhotonBackTrackerService::TrackIdsToOpHits_Ps(std::vector<int> const& tkIds, std::vector<art::Ptr<recob::OpHit>> const& hitsIn)
209  {
210  return PhotonBackTracker::TrackIdsToOpHits_Ps(tkIds, hitsIn);
211  }
212 
213  //----------------------------------------------------------------------
214  const std::vector< const sim::SDP* > PhotonBackTrackerService::OpHitToSimSDPs_Ps(recob::OpHit const& opHit)
215  {
217  }
218 
219  //----------------------------------------------------------------------
220  const std::vector< const sim::SDP* > PhotonBackTrackerService::OpHitToSimSDPs_Ps(art::Ptr<recob::OpHit> const& opHit_P)
221  {
222  return PhotonBackTracker::OpHitToSimSDPs_Ps(opHit_P);
223  }
224 
225  //----------------------------------------------------------------------
226  /*
227  const std::vector< sim::SDP > PhotonBackTrackerService::OpHitToChannelWeightedSimSDPs(art::Ptr<recob::OpHit> const& opHit_P)
228  {
229  return PhotonBackTracker::OpHitToChannelWeightedSimSDPs(opHit_P);
230  }*/
231 
232  //----------------------------------------------------------------------
233  const std::unordered_set< const sim::SDP* > PhotonBackTrackerService::OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit)
234  {
236  }
237 
238  //----------------------------------------------------------------------
239  const std::unordered_set< const sim::SDP* > PhotonBackTrackerService::OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit> & opHit_P)
240  {
242  }
243 
244  //----------------------------------------------------------------------
245  const std::vector< double> PhotonBackTrackerService::SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&
246  {
247  return PhotonBackTracker::SimSDPsToXYZ(sdps);
248  }
249 
250  //----------------------------------------------------------------------
251  const std::vector< double> PhotonBackTrackerService::SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps )
252  {
253  return PhotonBackTracker::SimSDPsToXYZ(sdps_Ps);
254  }
255 
256  //----------------------------------------------------------------------
257  const std::vector< double> PhotonBackTrackerService::OpHitToXYZ(recob::OpHit const& opHit)
258  {
259  return PhotonBackTracker::OpHitToXYZ(opHit);
260  }
261 
262  //----------------------------------------------------------------------
263  const std::vector< double> PhotonBackTrackerService::OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit_P)
264  {
265  return PhotonBackTracker::OpHitToXYZ(opHit_P);
266  }
267 
268  //----------------------------------------------------------------------
270  {
272  }
273 
274  //----------------------------------------------------------------------
276  {
278  }
279 
280  //----------------------------------------------------------------------
281  const std::set< int> PhotonBackTrackerService::GetSetOfEveIds(std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps)
282  {
283  return PhotonBackTracker::GetSetOfEveIds(opHits_Ps);
284  }
285  //----------------------------------------------------------------------
286  const std::set< int> PhotonBackTrackerService::GetSetOfEveIds(std::vector< recob::OpHit > const& opHits)
287  {
288  return PhotonBackTracker::GetSetOfEveIds(opHits);
289  }
290 
291  //----------------------------------------------------------------------
292  const std::set< int> PhotonBackTrackerService::GetSetOfTrackIds(std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps)
293  {
294  return PhotonBackTracker::GetSetOfTrackIds(opHits_Ps);
295  }
296  //----------------------------------------------------------------------
297  const std::set< int> PhotonBackTrackerService::GetSetOfTrackIds(std::vector< recob::OpHit > const& opHits)
298  {
300  }
301 
302  //----------------------------------------------------------------------
303  const double PhotonBackTrackerService::OpHitCollectionPurity(std::set<int> const& tkIds,
304  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps)
305  {
306  return PhotonBackTracker::OpHitCollectionPurity(tkIds, opHits_Ps);
307  }
308 
309  //----------------------------------------------------------------------
310  const double PhotonBackTrackerService::OpHitLightCollectionPurity(std::set<int> const& tkIds,
311  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps)
312  {
313  return PhotonBackTracker::OpHitLightCollectionPurity(tkIds, opHits_Ps);
314  }
315 
316 
317  //----------------------------------------------------------------------
318  const double PhotonBackTrackerService::OpHitCollectionEfficiency(std::set<int> const& tkIds,
319  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
320  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps,
321  geo::View_t const& view)
322  {
323  throw cet::exception("PhotonBackTrackerService")<<"This function is not supported. OpHits do not have type View.\n";
324  }
325 
326  //----------------------------------------------------------------------
327  const double PhotonBackTrackerService::OpHitCollectionEfficiency(std::set<int> const& tkIds,
328  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
329  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps)
330  {
331  return PhotonBackTracker::OpHitCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
332  }
333 
334  //----------------------------------------------------------------------
335  const double PhotonBackTrackerService::OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
336  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
337  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps,
338  geo::View_t const& view)
339  {
340  throw cet::exception("PhotonBackTrackerService")<<"This function is not supported. OpHits do not have type View.\n";
341  }
342 
343  //----------------------------------------------------------------------
344  const double PhotonBackTrackerService::OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
345  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
346  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps)
347  {
348  return PhotonBackTracker::OpHitLightCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
349  }
350 
351  //----------------------------------------------------------------------
352  const std::set<int> PhotonBackTrackerService::OpFlashToTrackIds(art::Ptr<recob::OpFlash>& flash_P ) const{
353  return PhotonBackTracker::OpFlashToTrackIds( flash_P);
354  }
355 
356  //----------------------------------------------------------------------
357  const std::vector < art::Ptr< recob::OpHit > > PhotonBackTrackerService::OpFlashToOpHits_Ps ( art::Ptr < recob::OpFlash > & flash_P ){
358  return PhotonBackTracker::OpFlashToOpHits_Ps( flash_P);
359  }
360 
361  //----------------------------------------------------------------------
362  const std::vector < double > PhotonBackTrackerService::OpFlashToXYZ ( art::Ptr < recob::OpFlash > & flash_P ){
363  return PhotonBackTracker::OpFlashToXYZ( flash_P );
364  }
365 
366 } // namespace
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps(recob::OpHit const &opHit)
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum)
Utilities related to art service access.
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P)
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
const double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps)
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit)
const bool CanRun(Evt const &evt)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
Definition: ServiceUtil.h:77
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps(recob::OpHit const &opHit)
const std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps) const &
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
void PrepOpFlashToOpHits(Evt const &evt)
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
bool priv_CanRun(art::Event const &evt)
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) 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)
double OpHitCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits)
const double OpHitCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps)
void priv_PrepOpDetBTRs(art::Event const &evt)
const std::vector< double > OpHitToXYZ(recob::OpHit const &opHit)
const std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
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
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBTRs()
void PrepOpDetBTRs(Evt const &evt)
const std::set< int > GetSetOfEveIds() const
void Rebuild(art::Event const &evt)
const double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn)
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P)
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
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
const double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits)
const double GetDelay()
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 double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn_Ps, geo::View_t const &view)
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P)
const double OpHitCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn_Ps, geo::View_t const &view)
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs()
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
PhotonBackTrackerService(fhicl::ParameterSet const &pSet, art::ActivityRegistry &reg)
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
void priv_PrepEvent(art::Event const &evt, art::ScheduleContext)
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit)
TCEvent evt
Definition: DataStructs.cxx:8
const std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P)
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
art framework interface to geometry description
void priv_PrepOpFlashToOpHits(art::Event const &evt)