LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
BackTracker.tcc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 // \author jason.stock@mines.sdsmt.edu
3 //
4 // Based on the original BackTracker by brebel@fnal.gov
5 //
6 ////////////////////////////////////////////////////////////////////////////
7 
8 #include "canvas/Persistency/Common/FindManyP.h"
9 #include "lardataobj/RecoBase/SpacePoint.h"
10 
11 namespace cheat {
12 
13  //--------------------------------------------------------------------
14  template <typename Evt> // DO NOT USE THIS FUNCTION FROM WITHIN ART! The
15  // BackTrackerService is designed to impliment these
16  // methods as cleanly as possible within the art
17  // framework. This is intended for gallery users.
18  void BackTracker::PrepEvent(const Evt& evt)
19  {
20  if (!(this->CanRun(evt))) {
21  throw cet::exception("BackTracker") << "BackTracker cannot function. "
22  << "Is this file real data?";
23  }
24  fSimChannels.clear();
25  this->PrepSimChannels(evt);
26  //this->PrepAllHitList ( evt ); //This line temporarily commented out until I figure out how I want PrepAllHitList to work.
27  }
28 
29  //--------------------------------------------------------------------
30  template <typename Evt>
31  void BackTracker::PrepSimChannels(const Evt& evt)
32  {
33  if (this->SimChannelsReady()) { return; }
34  // The SimChannels list needs to be built.
35  const auto& simChannelsHandle =
36  evt.template getValidHandle<std::vector<sim::SimChannel>>(fSimChannelModuleLabel);
37 
38  art::fill_ptr_vector(fSimChannels, simChannelsHandle);
39 
40  auto comparesclambda = [](art::Ptr<sim::SimChannel> a, art::Ptr<sim::SimChannel> b) {
41  return (a->Channel() < b->Channel());
42  };
43  if (!std::is_sorted(fSimChannels.begin(), fSimChannels.end(), comparesclambda))
44  std::sort(fSimChannels.begin(), fSimChannels.end(), comparesclambda);
45  }
46 
47  //--------------------------------------------------------------------
48  /* template<typename Evt>
49  void BackTracker::PrepAllHitList( const Evt& evt){
50  if(this->AllHitListReady()){return;}
51  const auto& allHitsHandle = evt.template
52  getValidHandle<std::vector<recob::Hit>>(fHitLabel);
53  art::fill_ptr_vector(fAllHitList, allHitsHandle);
54  }
55  */
56  //--------------------------------------------------------------------
57  template <typename Evt>
58  std::vector<art::Ptr<recob::Hit>> BackTracker::SpacePointToHits_Ps(
59  art::Ptr<recob::SpacePoint> const& spt,
60  const Evt& evt) const
61  {
62  std::vector<art::Ptr<recob::SpacePoint>>
63  spv; // This method needs to be rethought. For now I am directly
64  // implimenting it as found in the previous backtracker.
65  spv.push_back(spt);
66  art::FindManyP<recob::Hit> fmh(spv, evt, fHitLabel);
67  std::vector<art::Ptr<recob::Hit>> hitv = fmh.at(0);
68  return hitv;
69  }
70 
71  //--------------------------------------------------------------------
72  template <typename Evt>
73  std::vector<double> BackTracker::SpacePointToXYZ(detinfo::DetectorClocksData const& clockData,
74  art::Ptr<recob::SpacePoint> const& spt,
75  const Evt& evt) const
76  {
77  std::vector<art::Ptr<recob::Hit>> hits = this->SpacePointToHits_Ps(spt, evt);
78  return this->SpacePointHitsToWeightedXYZ(clockData, hits);
79  }
80 
81 } // end namespace
82 
83 // Local variables:
84 // mode: c++
85 // End: