LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PhotonBackTrackerService_service.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 //CPP includes
13 #include <map>
14 
15 // Framework includes
17 
18 // LArSoft includes
21 
22 //#include "lardata/Utilities/AssociationUtil.h"
23 //#include "lardataobj/Simulation/sim.h"
24 
25 namespace cheat{
26 
27  //----------------------------------------------------------------------
30  pSet.get<fhicl::ParameterSet>("PhotonBackTracker"),
32  lar::providerFrom<geo::Geometry>()//,
33 // lar::providerFrom<detinfo::DetectorClocksService>()
34  )
35  {
37  }
38 
39  //----------------------------------------------------------------------
42  config.PhotonBackTrackerTable(),
44  lar::providerFrom<geo::Geometry>()//,
45 // lar::providerFrom<detinfo::DetectorClocksService>()
46  )
47  {
49  }
50 
57 
58 
59  //----------------------------------------------------------------------
61  {
62  this->priv_PrepEvent(evt);
63  }
64 
65  //----------------------------------------------------------------------
67  {
69  if( ! this->priv_CanRun(evt) ){ return; }
70  this->priv_PrepOpDetBTRs(evt);
71  this->priv_PrepOpFlashToOpHits(evt);
72  }
73 
74  //----------------------------------------------------------------------
76  return PhotonBackTracker::CanRun(evt);
77  }
78 
79  //----------------------------------------------------------------------
81  throw cet::exception("PhotonBackTrackerService")
82  <<"The called Prep Fucntion failed. This is most likely due "
83  <<"to a PhotonBackTracker fucntion being used on a file that "
84  <<"is real data.";
85  }
86 
87  //----------------------------------------------------------------------
89  if( !this->priv_CanRun(evt) ) {this->priv_PrepFailed(); }
90  if( this->priv_OpDetBTRsReady()){ return; }
92  catch(...){ 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(...){
102  mf::LogWarning("PhotonBackTrackerService")
103  <<"Rebuild failed to get the OpFlashToOpHits. This is expected when "
104  <<"running on a generation or simulation stage.";
105  }
106  }
107 
109  // End of the Event Rebuild Implimentation //
111 
114  // This section contains the implimentation //
115  // of all PhotonBackTrackerService end user //
116  // functionality //
118 
119 
120  //----------------------------------------------------------------------
121  const std::vector< art::Ptr< sim::OpDetBacktrackerRecord >>& PhotonBackTrackerService::OpDetBTRs()
122  {
124  }
125 
126  //----------------------------------------------------------------------
127  const std::vector< const sim::SDP* > PhotonBackTrackerService::TrackIdToSimSDPs_Ps(int const& id)
128  {
130  }
131 
132  //----------------------------------------------------------------------
133  const std::vector< const sim::SDP* > PhotonBackTrackerService::TrackIdToSimSDPs_Ps(int const& id, geo::View_t const& view )
134  {
136  }
137 
138  //----------------------------------------------------------------------
140  {
141  return PhotonBackTracker::FindOpDetBTR(opDetNum);
142  }
143 
144  //----------------------------------------------------------------------
145  const std::vector < sim::TrackSDP > PhotonBackTrackerService::OpDetToTrackSDPs( int const& OpDetNum,
146  double const& opHit_start_time,
147  double const& opHit_end_time)
148  {
149  return PhotonBackTracker::OpDetToTrackSDPs(OpDetNum, opHit_start_time, opHit_end_time);
150  }
151 
152  //----------------------------------------------------------------------
153  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P )
154  {
155  return PhotonBackTracker::OpHitToTrackSDPs(opHit_P );
156  }
157 
158  //----------------------------------------------------------------------
159  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToTrackSDPs(recob::OpHit const& opHit)
160  {
162  }
163 
164  //----------------------------------------------------------------------
165  const std::vector < int > PhotonBackTrackerService::OpHitToTrackIds(recob::OpHit const& opHit) {
167  }
168 
169  //----------------------------------------------------------------------
170  const std::vector < int > PhotonBackTrackerService::OpHitToTrackIds(art::Ptr<recob::OpHit> const& opHit_P) {
171  return PhotonBackTracker::OpHitToTrackIds(opHit_P);
172  }
173 
174  //----------------------------------------------------------------------
175  //----------------------------------------------------------------------
176  const std::vector < int > PhotonBackTrackerService::OpHitToEveTrackIds(recob::OpHit const& opHit) {
178  }
179 
180  //----------------------------------------------------------------------
181  const std::vector < int > PhotonBackTrackerService::OpHitToEveTrackIds(art::Ptr<recob::OpHit> const& opHit_P) {
183  }
184 
185  //----------------------------------------------------------------------
186  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToEveTrackSDPs(art::Ptr<recob::OpHit> const& opHit_P )
187  {
189  }
190 
191  //----------------------------------------------------------------------
192  std::vector<sim::TrackSDP> PhotonBackTrackerService::OpHitToEveTrackSDPs(recob::OpHit const& opHit)
193  {
195  }
196 
197  //----------------------------------------------------------------------
198  const std::vector<art::Ptr<recob::OpHit>> PhotonBackTrackerService::TrackIdToOpHits_Ps(int const& tkId, std::vector<art::Ptr<recob::OpHit>> const& hitsIn)
199  {
200  return PhotonBackTracker::TrackIdToOpHits_Ps(tkId, hitsIn);
201  }
202 
203  //----------------------------------------------------------------------
204  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)
205  {
206  return PhotonBackTracker::TrackIdsToOpHits_Ps(tkIds, hitsIn);
207  }
208 
209  //----------------------------------------------------------------------
210  const std::vector< const sim::SDP* > PhotonBackTrackerService::OpHitToSimSDPs_Ps(recob::OpHit const& opHit)
211  {
213  }
214 
215  //----------------------------------------------------------------------
216  const std::vector< const sim::SDP* > PhotonBackTrackerService::OpHitToSimSDPs_Ps(art::Ptr<recob::OpHit> const& opHit_P)
217  {
218  return PhotonBackTracker::OpHitToSimSDPs_Ps(opHit_P);
219  }
220 
221  //----------------------------------------------------------------------
222  const std::unordered_set< const sim::SDP* > PhotonBackTrackerService::OpHitToEveSimSDPs_Ps(recob::OpHit const& opHit)
223  {
225  }
226 
227  //----------------------------------------------------------------------
228  const std::unordered_set< const sim::SDP* > PhotonBackTrackerService::OpHitToEveSimSDPs_Ps(art::Ptr<recob::OpHit> & opHit_P)
229  {
231  }
232 
233  //----------------------------------------------------------------------
234  const std::vector< double> PhotonBackTrackerService::SimSDPsToXYZ(std::vector<sim::SDP> const& sdps) const&
235  {
236  return PhotonBackTracker::SimSDPsToXYZ(sdps);
237  }
238 
239  //----------------------------------------------------------------------
240  const std::vector< double> PhotonBackTrackerService::SimSDPsToXYZ(std::vector<const sim::SDP*> const& sdps_Ps )
241  {
242  return PhotonBackTracker::SimSDPsToXYZ(sdps_Ps);
243  }
244 
245  //----------------------------------------------------------------------
246  const std::vector< double> PhotonBackTrackerService::OpHitToXYZ(recob::OpHit const& opHit)
247  {
248  return PhotonBackTracker::OpHitToXYZ(opHit);
249  }
250 
251  //----------------------------------------------------------------------
252  const std::vector< double> PhotonBackTrackerService::OpHitToXYZ(art::Ptr<recob::OpHit> const& opHit_P)
253  {
254  return PhotonBackTracker::OpHitToXYZ(opHit_P);
255  }
256 
257  //----------------------------------------------------------------------
259  {
261  }
262 
263  //----------------------------------------------------------------------
265  {
267  }
268 
269  //----------------------------------------------------------------------
271  {
272  return PhotonBackTracker::GetSetOfEveIds(opHits_Ps);
273  }
274  //----------------------------------------------------------------------
275  const std::set< int> PhotonBackTrackerService::GetSetOfEveIds(std::vector< recob::OpHit > const& opHits)
276  {
277  return PhotonBackTracker::GetSetOfEveIds(opHits);
278  }
279 
280  //----------------------------------------------------------------------
282  {
283  return PhotonBackTracker::GetSetOfTrackIds(opHits_Ps);
284  }
285  //----------------------------------------------------------------------
286  const std::set< int> PhotonBackTrackerService::GetSetOfTrackIds(std::vector< recob::OpHit > const& opHits)
287  {
289  }
290 
291  //----------------------------------------------------------------------
292  const double PhotonBackTrackerService::OpHitCollectionPurity(std::set<int> const& tkIds,
293  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps)
294  {
295  return PhotonBackTracker::OpHitCollectionPurity(tkIds, opHits_Ps);
296  }
297 
298  //----------------------------------------------------------------------
299  const double PhotonBackTrackerService::OpHitLightCollectionPurity(std::set<int> const& tkIds,
300  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps)
301  {
302  return PhotonBackTracker::OpHitLightCollectionPurity(tkIds, opHits_Ps);
303  }
304 
305 
306  //----------------------------------------------------------------------
307  const double PhotonBackTrackerService::OpHitCollectionEfficiency(std::set<int> const& tkIds,
308  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
309  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps,
310  geo::View_t const& view)
311  {
312  throw cet::exception("PhotonBackTrackerService")<<"This function is not supported. OpHits do not have type View.\n";
313  }
314 
315  //----------------------------------------------------------------------
316  const double PhotonBackTrackerService::OpHitCollectionEfficiency(std::set<int> const& tkIds,
317  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
318  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps)
319  {
320  return PhotonBackTracker::OpHitCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
321  }
322 
323  //----------------------------------------------------------------------
324  const double PhotonBackTrackerService::OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
325  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
326  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps,
327  geo::View_t const& view)
328  {
329  throw cet::exception("PhotonBackTrackerService")<<"This function is not supported. OpHits do not have type View.\n";
330  }
331 
332  //----------------------------------------------------------------------
333  const double PhotonBackTrackerService::OpHitLightCollectionEfficiency(std::set<int> const& tkIds,
334  std::vector< art::Ptr<recob::OpHit> > const& opHits_Ps,
335  std::vector< art::Ptr<recob::OpHit> > const& opHitsIn_Ps)
336  {
337  return PhotonBackTracker::OpHitLightCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
338  }
339 
340  //----------------------------------------------------------------------
342  return PhotonBackTracker::OpFlashToTrackIds( flash_P);
343  }
344 
345  //----------------------------------------------------------------------
347  return PhotonBackTracker::OpFlashToTrackIds( flash_P);
348  }
349 
350  //----------------------------------------------------------------------
351  const std::vector < double > PhotonBackTrackerService::OpFlashToXYZ ( art::Ptr < recob::OpFlash > & flash_P ){
352  return PhotonBackTracker::OpFlashToXYZ( flash_P );
353  }
354 
355 
357  //-------------------------------------------------------------------
358 } // namespace
359 
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum)
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::set< int > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P)
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
#define DEFINE_ART_SERVICE(svc)
Definition: ServiceMacros.h:93
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)
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)
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)
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:265
Access the description of detector geometry.
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
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::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 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)
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:26
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)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &)> sPreProcessEvent
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit)
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs()
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)
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
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void priv_PrepOpFlashToOpHits(art::Event const &evt)