LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TrackMaker.h
Go to the documentation of this file.
1 #ifndef TRACKMAKER_H
2 #define TRACKMAKER_H
3 
12 
13 namespace trkmkr {
14 
33  public:
35  void setTrackFitHitInfo(recob::TrackFitHitInfo&& aTrackFitHitInfo) { trackFitHitInfo = std::make_unique< recob::TrackFitHitInfo >(aTrackFitHitInfo); }
36  void setTrackFitHitInfo(const recob::TrackFitHitInfo& aTrackFitHitInfo) { trackFitHitInfo = std::make_unique< recob::TrackFitHitInfo >(aTrackFitHitInfo); }
38  bool isTrackFitInfoSet() { return bool(trackFitHitInfo); }
41  //
43  void setSpacePoint(recob::SpacePoint&& aSpacePoint) { spacePoint = std::make_unique< recob::SpacePoint >(aSpacePoint); }
44  void setSpacePoint(const recob::SpacePoint& aSpacePoint) { spacePoint = std::make_unique< recob::SpacePoint >(aSpacePoint); }
46  bool isSpacePointSet() { return bool(spacePoint); }
48  recob::SpacePoint getSpacePoint() { auto tmp = *spacePoint; spacePoint.reset(); return tmp; }
49  private:
50  std::unique_ptr< recob::TrackFitHitInfo > trackFitHitInfo;
51  std::unique_ptr<recob::SpacePoint> spacePoint;
52  };
53 
73  struct OptionalOutputs {
74  public:
75  typedef std::pair<recob::SpacePoint, art::Ptr<recob::Hit> > SpHitPair;
76 
79  if (isTrackFitInfosInit() && ope.isTrackFitInfoSet()) {
80  outTrackFitHitInfos->push_back( ope.getTrackFitHitInfo() );
81  }
82  }
85  if (isSpacePointsInit() && ope.isSpacePointSet()) {
86  outSpacePointHitPairs->emplace_back(ope.getSpacePoint(), hptr);
87  }
88  addPoint(ope);
89  }
91  void reset() {
92  if (isTrackFitInfosInit()) {
93  outTrackFitHitInfos.reset();
94  initTrackFitInfos();
95  }
96  if (isSpacePointsInit()) {
97  outSpacePointHitPairs.reset();
98  initSpacePoints();
99  }
100  }
103  outTrackFitHitInfos = std::make_unique< std::vector<recob::TrackFitHitInfo> >();
104  }
107  outSpacePointHitPairs = std::make_unique< std::vector<SpHitPair> >();
108  }
110  bool isTrackFitInfosInit() { return bool(outTrackFitHitInfos); }
112  bool isSpacePointsInit() { return bool(outSpacePointHitPairs); }
114  std::vector<recob::TrackFitHitInfo> trackFitHitInfos() {
115  if (!isTrackFitInfosInit()) throw std::logic_error("outTrackFitHitInfos is not available (any more?).");
116  auto tmp = *outTrackFitHitInfos; outTrackFitHitInfos.reset(); return tmp;
117  }
119  std::vector<SpHitPair> spacePointHitPairs() {
120  if (!isSpacePointsInit()) throw std::logic_error("outSpacePointHitPairs is not available (any more?).");
121  auto tmp = *outSpacePointHitPairs; outSpacePointHitPairs.reset(); return tmp;
122  }
123  private:
124  std::unique_ptr< std::vector<recob::TrackFitHitInfo> > outTrackFitHitInfos;
125  std::unique_ptr< std::vector<SpHitPair> > outSpacePointHitPairs;
126  };
127 
153  class TrackMaker {
154  public:
155  virtual ~TrackMaker() noexcept = default;
156 
158  virtual void initEvent(const art::Event& e) { return; }
159 
161  virtual bool makeTrack(const recob::Trajectory& traj, const std::vector<recob::TrajectoryPointFlags>& flags,
163  const int tkID, const std::vector<art::Ptr<recob::Hit> >& inHits,
164  recob::Track& outTrack, std::vector<art::Ptr<recob::Hit> >& outHits, OptionalOutputs& optionals) const
165  {
166  return makeTrack(recob::TrackTrajectory(traj,recob::TrackTrajectory::Flags_t(traj.NPoints())), tkID, inHits, outTrack, outHits, optionals);
167  }
168  virtual bool makeTrack(const art::Ptr<recob::Trajectory> traj, const std::vector<recob::TrajectoryPointFlags>& flags,
169  const std::vector<art::Ptr<recob::Hit> >& inHits,
170  recob::Track& outTrack, std::vector<art::Ptr<recob::Hit> >& outHits, OptionalOutputs& optionals) const
171  {
172  return makeTrack(recob::TrackTrajectory(*traj,recob::TrackTrajectory::Flags_t(traj->NPoints())), traj.key(), inHits, outTrack, outHits, optionals);
173  }
175 
178  recob::Track& outTrack, std::vector<art::Ptr<recob::Hit> >& outHits, OptionalOutputs& optionals) const
179  {
180  return makeTrack(*ttraj, ttraj.key(), inHits, outTrack, outHits, optionals);
181  }
182 
184  virtual bool makeTrack(const recob::TrackTrajectory& ttraj, const int tkID, const std::vector<art::Ptr<recob::Hit> >& inHits,
185  recob::Track& outTrack, std::vector<art::Ptr<recob::Hit> >& outHits, OptionalOutputs& optionals) const = 0;
186 
188  virtual bool makeTrack(const art::Ptr<recob::Track> track, const std::vector<art::Ptr<recob::Hit> >& inHits,
190  recob::Track& outTrack, std::vector<art::Ptr<recob::Hit> >& outHits, OptionalOutputs& optionals) const
191  {
192  return makeTrack(track->Trajectory(), track.key(), inHits, outTrack, outHits, optionals);
193  }
194 
195  virtual bool makeTrack(const recob::Track& track, const std::vector<art::Ptr<recob::Hit> >& inHits,
196  recob::Track& outTrack, std::vector<art::Ptr<recob::Hit> >& outHits, OptionalOutputs& optionals) const
197  {
198  return makeTrack(track.Trajectory(), track.ID(), inHits, outTrack, outHits, optionals);
199  }
201  };
202 }
203 
204 #endif
key_type key() const
Definition: Ptr.h:356
bool isTrackFitInfoSet()
check if the recob::TrackFitHitInfo unique_ptr is set
Definition: TrackMaker.h:38
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
Definition: TrackMaker.h:102
void setTrackFitHitInfo(const recob::TrackFitHitInfo &aTrackFitHitInfo)
Definition: TrackMaker.h:36
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:101
recob::TrackFitHitInfo getTrackFitHitInfo()
get the recob::TrackFitHitInfo object, and reset the unique_ptr
Definition: TrackMaker.h:40
bool isSpacePointSet()
check if the recob::SpacePoint unique_ptr is set
Definition: TrackMaker.h:46
Declaration of signal hit object.
std::unique_ptr< recob::SpacePoint > spacePoint
Definition: TrackMaker.h:51
virtual bool makeTrack(const art::Ptr< recob::Trajectory > traj, const std::vector< recob::TrajectoryPointFlags > &flags, const std::vector< art::Ptr< recob::Hit > > &inHits, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit > > &outHits, OptionalOutputs &optionals) const
makeTrack functions with recob::Trajectory as argument; calls the version with recob::TrackTrajectory...
Definition: TrackMaker.h:168
Float_t tmp
Definition: plot.C:37
Base abstract class for tools used to fit tracks.
Definition: TrackMaker.h:153
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::unique_ptr< std::vector< SpHitPair > > outSpacePointHitPairs
Definition: TrackMaker.h:125
Provides recob::Track data product.
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:173
A trajectory in space reconstructed from hits.
Object storing per-hit information from a track fit.
Struct holding point-by-point elements used in OptionalOutputs.
Definition: TrackMaker.h:32
void setSpacePoint(const recob::SpacePoint &aSpacePoint)
Definition: TrackMaker.h:44
std::vector< PointFlags_t > Flags_t
Type of point flag list.
void addPoint(OptionalPointElement &ope, art::Ptr< recob::Hit > hptr)
add one OptionalPointElement and the corresponding hit
Definition: TrackMaker.h:84
std::vector< SpHitPair > spacePointHitPairs()
get the output vector of SpHitPair by releasing and moving
Definition: TrackMaker.h:119
void reset()
reset the stored vectors
Definition: TrackMaker.h:91
A trajectory in space reconstructed from hits.
Definition: Trajectory.h:73
int ID() const
Definition: Track.h:201
virtual void initEvent(const art::Event &e)
per-event initialization; concrete classes may override this function to retrieve other products or a...
Definition: TrackMaker.h:158
recob::SpacePoint getSpacePoint()
get the recob::SpacePoint object, and release the unique_ptr
Definition: TrackMaker.h:48
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
Definition: TrackMaker.h:114
std::pair< recob::SpacePoint, art::Ptr< recob::Hit > > SpHitPair
Definition: TrackMaker.h:75
void addPoint(OptionalPointElement &ope)
add one OptionalPointElement
Definition: TrackMaker.h:78
bool isTrackFitInfosInit()
check initialization of the output vector of TrackFitHitInfos
Definition: TrackMaker.h:110
void setSpacePoint(recob::SpacePoint &&aSpacePoint)
set the recob::SpacePoint unique_ptr
Definition: TrackMaker.h:43
virtual bool makeTrack(const art::Ptr< recob::TrackTrajectory > ttraj, const std::vector< art::Ptr< recob::Hit > > &inHits, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit > > &outHits, OptionalOutputs &optionals) const
makeTrack functions with art::Ptr<recob::TrackTrajectory>; calls the purely virtual version with cons...
Definition: TrackMaker.h:177
virtual bool makeTrack(const recob::Track &track, const std::vector< art::Ptr< recob::Hit > > &inHits, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit > > &outHits, OptionalOutputs &optionals) const
makeTrack functions with recob::Track as argument; calls the version with recob::TrackTrajectory.
Definition: TrackMaker.h:195
void setTrackFitHitInfo(recob::TrackFitHitInfo &&aTrackFitHitInfo)
set the recob::TrackFitHitInfo unique_ptr
Definition: TrackMaker.h:35
std::unique_ptr< recob::TrackFitHitInfo > trackFitHitInfo
Definition: TrackMaker.h:50
Float_t e
Definition: plot.C:34
Float_t track
Definition: plot.C:34
std::unique_ptr< std::vector< recob::TrackFitHitInfo > > outTrackFitHitInfos
Definition: TrackMaker.h:124
void initSpacePoints()
initialize the output vector of SpHitPair
Definition: TrackMaker.h:106
Struct holding optional TrackMaker outputs.
Definition: TrackMaker.h:73
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:52
bool isSpacePointsInit()
check initialization of the output vector of SpHitPair
Definition: TrackMaker.h:112