LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PhotonBackTrackerService.cc
Go to the documentation of this file.
1 //
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 //
9 
11 
12 // Framework includes
15 #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  //----------------------------------------------------------------------
28  : PhotonBackTracker(pSet.get<fhicl::ParameterSet>("PhotonBackTracker"),
30  lar::providerFrom<geo::Geometry>() //,
31  // lar::providerFrom<detinfo::DetectorClocksService>()
32  )
33  {
35  }
36 
37  //----------------------------------------------------------------------
40  : PhotonBackTracker(config.PhotonBackTrackerTable(),
42  lar::providerFrom<geo::Geometry>() //,
43  // lar::providerFrom<detinfo::DetectorClocksService>()
44  )
45  {
47  }
48 
55 
56  //----------------------------------------------------------------------
58  {
60  }
61 
62  //----------------------------------------------------------------------
64  {
66  if (!this->priv_CanRun(evt)) { return; }
67  this->priv_PrepOpDetBTRs(evt);
68  this->priv_PrepOpFlashToOpHits(evt);
69  }
70 
71  //----------------------------------------------------------------------
73  {
74  return PhotonBackTracker::CanRun(evt);
75  }
76 
77  //----------------------------------------------------------------------
79  {
80  throw cet::exception("PhotonBackTrackerService")
81  << "The called Prep Fucntion failed. This is most likely due "
82  << "to a PhotonBackTracker fucntion being used on a file that "
83  << "is real data.";
84  }
85 
86  //----------------------------------------------------------------------
88  {
89  if (!this->priv_CanRun(evt)) { this->priv_PrepFailed(); }
90  if (this->priv_OpDetBTRsReady()) { return; }
91  try {
93  }
94  //catch(...){ mf::LogWarning("PhotonBackTrackerService")//This needs to go. Catch all should not be used.
95  catch (
96  cet::
97  exception const&) { //This needs to go. Make it specific if there is a really an exception we would like to catch.
98  mf::LogWarning("PhotonBackTrackerService")
99  << "Rebuild failed to get the OpDetBTRs. This is expected when "
100  << "running on a generation or simulation step.";
101  }
102  }
103 
105  {
106  if (!this->priv_CanRun(evt)) { this->priv_PrepFailed(); }
107  if (this->priv_OpFlashToOpHitsReady()) { return; }
108  try {
110  }
111  //catch(...){ //This needs to go. Catch all should not be used.
112  catch (
113  cet::
114  exception const&) { //This needs to go. Make it specific if there is a really an exception we would like to catch.
115  mf::LogWarning("PhotonBackTrackerService")
116  << "Rebuild failed to get the OpFlashToOpHits. This is expected when "
117  << "running on a generation or simulation stage.";
118  }
119  }
120 
122  // End of the Event Rebuild Implimentation //
124 
127  // This section contains the implimentation //
128  // of all PhotonBackTrackerService end user //
129  // functionality //
131 
132  //----------------------------------------------------------------------
133  const std::vector<art::Ptr<sim::OpDetBacktrackerRecord>>& PhotonBackTrackerService::OpDetBTRs()
134  {
136  }
137 
138  //----------------------------------------------------------------------
140  {
142  }
143 
144  //----------------------------------------------------------------------
145  const std::vector<const sim::SDP*> PhotonBackTrackerService::TrackIdToSimSDPs_Ps(int const& id)
146  {
148  }
149 
150  //----------------------------------------------------------------------
151  const std::vector<const sim::SDP*> PhotonBackTrackerService::TrackIdToSimSDPs_Ps(
152  int const& id,
153  geo::View_t const& view)
154  {
156  }
157 
158  //----------------------------------------------------------------------
160  {
161  return PhotonBackTracker::FindOpDetBTR(opDetNum);
162  }
163 
164  //----------------------------------------------------------------------
165  const std::vector<sim::TrackSDP> PhotonBackTrackerService::OpDetToTrackSDPs(
166  int const& OpDetNum,
167  double const& opHit_start_time,
168  double const& opHit_end_time)
169  {
170  return PhotonBackTracker::OpDetToTrackSDPs(OpDetNum, opHit_start_time, opHit_end_time);
171  }
172 
173  //----------------------------------------------------------------------
174  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToTrackSDPs(
175  art::Ptr<recob::OpHit> const& opHit_P)
176  {
177  return PhotonBackTracker::OpHitToTrackSDPs(opHit_P);
178  }
179 
180  //----------------------------------------------------------------------
181  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToTrackSDPs(recob::OpHit const& opHit)
182  {
184  }
185 
186  //----------------------------------------------------------------------
187  const std::vector<int> PhotonBackTrackerService::OpHitToTrackIds(recob::OpHit const& opHit)
188  {
190  }
191 
192  //----------------------------------------------------------------------
194  art::Ptr<recob::OpHit> const& opHit_P)
195  {
196  return PhotonBackTracker::OpHitToTrackIds(opHit_P);
197  }
198 
199  //----------------------------------------------------------------------
200  //----------------------------------------------------------------------
201  const std::vector<int> PhotonBackTrackerService::OpHitToEveTrackIds(recob::OpHit const& opHit)
202  {
204  }
205 
206  //----------------------------------------------------------------------
208  art::Ptr<recob::OpHit> const& opHit_P)
209  {
211  }
212 
213  //----------------------------------------------------------------------
215  art::Ptr<recob::OpHit> const& opHit_P)
216  {
218  }
219 
220  //----------------------------------------------------------------------
222  recob::OpHit const& opHit)
223  {
225  }
226 
227  //----------------------------------------------------------------------
228  const std::vector<art::Ptr<recob::OpHit>> PhotonBackTrackerService::TrackIdToOpHits_Ps(
229  int const& tkId,
230  std::vector<art::Ptr<recob::OpHit>> const& hitsIn)
231  {
232  return PhotonBackTracker::TrackIdToOpHits_Ps(tkId, hitsIn);
233  }
234 
235  //----------------------------------------------------------------------
236  const std::vector<std::vector<art::Ptr<recob::OpHit>>>
237  PhotonBackTrackerService::TrackIdsToOpHits_Ps(std::vector<int> const& tkIds,
238  std::vector<art::Ptr<recob::OpHit>> const& hitsIn)
239  {
240  return PhotonBackTracker::TrackIdsToOpHits_Ps(tkIds, hitsIn);
241  }
242 
243  //----------------------------------------------------------------------
244  const std::vector<const sim::SDP*> PhotonBackTrackerService::OpHitToSimSDPs_Ps(
245  recob::OpHit const& opHit)
246  {
248  }
249 
250  //----------------------------------------------------------------------
251  const std::vector<const sim::SDP*> PhotonBackTrackerService::OpHitToSimSDPs_Ps(
252  art::Ptr<recob::OpHit> const& opHit_P)
253  {
254  return PhotonBackTracker::OpHitToSimSDPs_Ps(opHit_P);
255  }
256 
257  //----------------------------------------------------------------------
258  /*
259  const std::vector< sim::SDP > PhotonBackTrackerService::OpHitToChannelWeightedSimSDPs(art::Ptr<recob::OpHit> const& opHit_P)
260  {
261  return PhotonBackTracker::OpHitToChannelWeightedSimSDPs(opHit_P);
262  }*/
263 
264  //----------------------------------------------------------------------
265  const std::unordered_set<const sim::SDP*> PhotonBackTrackerService::OpHitToEveSimSDPs_Ps(
266  recob::OpHit const& opHit)
267  {
269  }
270 
271  //----------------------------------------------------------------------
272  const std::unordered_set<const sim::SDP*> PhotonBackTrackerService::OpHitToEveSimSDPs_Ps(
273  art::Ptr<recob::OpHit>& opHit_P)
274  {
276  }
277 
278  //----------------------------------------------------------------------
279  const std::vector<double> PhotonBackTrackerService::SimSDPsToXYZ(
280  std::vector<sim::SDP> const& sdps) const&
281  {
282  return PhotonBackTracker::SimSDPsToXYZ(sdps);
283  }
284 
285  //----------------------------------------------------------------------
286  const std::vector<double> PhotonBackTrackerService::SimSDPsToXYZ(
287  std::vector<const sim::SDP*> const& sdps_Ps)
288  {
289  return PhotonBackTracker::SimSDPsToXYZ(sdps_Ps);
290  }
291 
292  //----------------------------------------------------------------------
293  const std::vector<double> PhotonBackTrackerService::OpHitToXYZ(recob::OpHit const& opHit)
294  {
295  return PhotonBackTracker::OpHitToXYZ(opHit);
296  }
297 
298  //----------------------------------------------------------------------
299  const std::vector<double> PhotonBackTrackerService::OpHitToXYZ(
300  art::Ptr<recob::OpHit> const& opHit_P)
301  {
302  return PhotonBackTracker::OpHitToXYZ(opHit_P);
303  }
304 
305  //----------------------------------------------------------------------
307  {
309  }
310 
311  //----------------------------------------------------------------------
313  {
315  }
316 
317  //----------------------------------------------------------------------
319  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps)
320  {
321  return PhotonBackTracker::GetSetOfEveIds(opHits_Ps);
322  }
323  //----------------------------------------------------------------------
325  std::vector<recob::OpHit> const& opHits)
326  {
327  return PhotonBackTracker::GetSetOfEveIds(opHits);
328  }
329 
330  //----------------------------------------------------------------------
332  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps)
333  {
334  return PhotonBackTracker::GetSetOfTrackIds(opHits_Ps);
335  }
336  //----------------------------------------------------------------------
338  std::vector<recob::OpHit> const& opHits)
339  {
341  }
342 
343  //----------------------------------------------------------------------
345  std::set<int> const& tkIds,
346  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps)
347  {
348  return PhotonBackTracker::OpHitCollectionPurity(tkIds, opHits_Ps);
349  }
350 
351  //----------------------------------------------------------------------
353  std::set<int> const& tkIds,
354  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps)
355  {
356  return PhotonBackTracker::OpHitLightCollectionPurity(tkIds, opHits_Ps);
357  }
358 
359  //----------------------------------------------------------------------
361  std::set<int> const& tkIds,
362  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps,
363  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn_Ps,
364  geo::View_t const& view)
365  {
366  throw cet::exception("PhotonBackTrackerService")
367  << "This function is not supported. OpHits do not have type View.\n";
368  }
369 
370  //----------------------------------------------------------------------
372  std::set<int> const& tkIds,
373  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps,
374  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn_Ps)
375  {
376  return PhotonBackTracker::OpHitCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
377  }
378 
379  //----------------------------------------------------------------------
381  std::set<int> const& tkIds,
382  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps,
383  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn_Ps,
384  geo::View_t const& view)
385  {
386  throw cet::exception("PhotonBackTrackerService")
387  << "This function is not supported. OpHits do not have type View.\n";
388  }
389 
390  //----------------------------------------------------------------------
392  std::set<int> const& tkIds,
393  std::vector<art::Ptr<recob::OpHit>> const& opHits_Ps,
394  std::vector<art::Ptr<recob::OpHit>> const& opHitsIn_Ps)
395  {
396  return PhotonBackTracker::OpHitLightCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
397  }
398 
399  //----------------------------------------------------------------------
401  art::Ptr<recob::OpFlash>& flash_P) const
402  {
403  return PhotonBackTracker::OpFlashToTrackIds(flash_P);
404  }
405 
406  //----------------------------------------------------------------------
407  const std::vector<art::Ptr<recob::OpHit>> PhotonBackTrackerService::OpFlashToOpHits_Ps(
408  art::Ptr<recob::OpFlash>& flash_P)
409  {
411  }
412 
413  //----------------------------------------------------------------------
414  const std::vector<double> PhotonBackTrackerService::OpFlashToXYZ(
415  art::Ptr<recob::OpFlash>& flash_P)
416  {
417  return PhotonBackTracker::OpFlashToXYZ(flash_P);
418  }
419 
420 } // namespace
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)
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 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:75
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 double OpHitCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
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)
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)
void PrepOpFlashToOpHits(Evt const &evt)
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
bool priv_CanRun(art::Event const &evt)
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
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 priv_PrepOpDetBTRs(art::Event const &evt)
const double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
const std::vector< double > OpHitToXYZ(recob::OpHit const &opHit)
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBTRs()
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)
parameter set interface
void Rebuild(art::Event const &evt)
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P)
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time)
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P)
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:22
const std::set< int > GetSetOfTrackIds() const
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
LArSoft-specific namespace.
PhotonBackTrackerService(fhicl::ParameterSet const &pSet, art::ActivityRegistry &reg)
double OpHitCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits)
static ScheduleContext invalid()
const double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
double OpHitCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
void priv_PrepEvent(art::Event const &evt, art::ScheduleContext)
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit)
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs()
TCEvent evt
Definition: DataStructs.cxx:8
const std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P) const
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_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)
Namespace collecting geometry-related classes utilities.
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
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
void priv_PrepOpFlashToOpHits(art::Event const &evt)
const double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits)