TrackCreationBookKeeper.h
Go to the documentation of this file.
1 #ifndef TRACKCREATIONBOOKKEEPER_H
2 #define TRACKCREATIONBOOKKEEPER_H
3 
8 
9 namespace trkmkr {
10 
11  /**
12  * @file larreco/RecoAlg/TrackCreationBookKeeper.h
13  * @class trkmkr::TrackCreationBookKeeper
14  *
15  * @brief Helper class to aid the creation of a recob::Track, keeping data vectors in sync.
16  *
17  * Helper class to aid the creation of a recob::Track, keeping output data (vectors of recob::tracking::Point_t, recob::tracking::Vector_t, recob::TrackTrajectory::PointFlags_t, recob::Hit, and trkmkr::OptionalOutputs struct) in sync.
18  * It internally stores and uses a trkmkr::TrackTrajectoryCreationBookKeeper object. Elements of those vectors are added sequentially using the addPoint functions.
19  * Once all points have been added a call to the function finalizeTrack, builds the track moving the content of the vectors.
20  *
21  * @author G. Cerati (FNAL, MicroBooNE)
22  * @date 2017
23  * @version 1.0
24  */
25 
26  using namespace recob;
30 
32  public:
33  /// Constructor: needs reference to output hit vector, optional outputs struct, and other parameters needed when creating the track object
34  TrackCreationBookKeeper(std::vector<art::Ptr<Hit> >& outhits, OptionalOutputs& optionals, int tkID, int pdgHyp, bool hasMomenta, int nfitpars = 4)
35  : ttcbk_(outhits, hasMomenta), tkID_(tkID), pdgHyp_(pdgHyp), totChi2_(0), opts(&optionals), nfittedpars(nfitpars)
36  {
37  opts->reset();
38  }
39  //
40  //@{
41  /// Avoid copies of this object
44  TrackCreationBookKeeper& operator=(const TrackCreationBookKeeper&) = delete;
45  TrackCreationBookKeeper& operator=(TrackCreationBookKeeper&& ) = delete;
46  //@}
47  //
48  //@{
49  /// Add a single point; different version of the functions are provided using const references or rvalue references, with and without an OptionalPointElement argument.
50  void addPoint(const Point_t& point, const Vector_t& vect, art::Ptr<Hit> hit, const PointFlags_t& flag, double chi2) {
51  ttcbk_.addPoint(point, vect, hit, flag);
52  if (chi2>=0) {
53  chi2v.push_back(chi2);
54  totChi2_+=chi2;
55  }
56  }
57  void addPoint(const Point_t& point, const Vector_t& vect, art::Ptr<Hit> hit, const PointFlags_t& flag, double chi2, OptionalPointElement& ope) {
58  addPoint(point, vect, hit, flag, chi2);
59  opts->addPoint(ope);
60  }
61  void addPoint(Point_t&& point, Vector_t&& vect, art::Ptr<Hit> hit, PointFlags_t&& flag, double chi2) {
62  ttcbk_.addPoint(std::move(point), std::move(vect), hit, std::move(flag));
63  if (chi2>=0) {
64  chi2v.push_back(chi2);
65  totChi2_+=chi2;
66  }
67  }
68  void addPoint(Point_t&& point, Vector_t&& vect, art::Ptr<Hit> hit, PointFlags_t&& flag, double chi2, OptionalPointElement& ope) {
69  addPoint(std::move(point), std::move(vect), hit, std::move(flag), chi2);
70  opts->addPoint(ope);
71  }
72  //@}
73  //
74  /// Set the total chi2 value
75  void setTotChi2(double totChi2) { totChi2_ = totChi2; }
76  //
77  //@{
78  /// Get the finalized recob::Track; needs the start and end covariance matrices.
80  return Track(ttcbk_.finalizeTrackTrajectory(),pdgHyp_,totChi2_,int(chi2v.size())-nfittedpars,
81  tracking::SMatrixSym55(covStart),tracking::SMatrixSym55(covEnd),tkID_);
82  }
84  return Track(ttcbk_.finalizeTrackTrajectory(),pdgHyp_,totChi2_,int(chi2v.size())-nfittedpars,
85  std::move(covStart),std::move(covEnd),tkID_);
86  }
87  //@}
88  private:
90  int tkID_;
91  int pdgHyp_;
92  double totChi2_;
94  std::vector<double> chi2v;
95  int nfittedpars; // hits are 1D measurement, i.e. each hit is one d.o.f.; no B field: 4 fitted parameters by default
96  //
97  };
98 
99 }
100 #endif
recob::TrajectoryPointFlags PointFlags_t
Type for flags of a point/hit.
tracking::Point_t Point_t
void setTotChi2(double totChi2)
Set the total chi2 value.
Reconstruction base classes.
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Definition: TrackingTypes.h:85
struct vector vector
trkmkr::TrackTrajectoryCreationBookKeeper ttcbk_
void addPoint(Point_t &&point, Vector_t &&vect, art::Ptr< Hit > hit, PointFlags_t &&flag, double chi2)
void addPoint(const Point_t &point, const Vector_t &vect, art::Ptr< Hit > hit, const PointFlags_t &flag, double chi2)
Add a single point; different version of the functions are provided using const references or rvalue ...
tracking::Vector_t Vector_t
Track finalizeTrack(const tracking::SMatrixSym55 &covStart, const tracking::SMatrixSym55 &covEnd)
Get the finalized recob::Track; needs the start and end covariance matrices.
void addPoint(Point_t &&point, Vector_t &&vect, art::Ptr< Hit > hit, PointFlags_t &&flag, double chi2, OptionalPointElement &ope)
TrackCreationBookKeeper(std::vector< art::Ptr< Hit > > &outhits, OptionalOutputs &optionals, int tkID, int pdgHyp, bool hasMomenta, int nfitpars=4)
Constructor: needs reference to output hit vector, optional outputs struct, and other parameters need...
Helper class to aid the creation of a recob::TrackTrajectory, keeping data vectors in sync...
Struct holding point-by-point elements used in OptionalOutputs.
Definition: TrackMaker.h:36
def move(depos, offset)
Definition: depos.py:107
Track finalizeTrack(tracking::SMatrixSym55 &&covStart, tracking::SMatrixSym55 &&covEnd)
Detector simulation of raw signals on wires.
void addPoint(const Point_t &point, const Vector_t &vect, art::Ptr< Hit > hit, const PointFlags_t &flag, double chi2, OptionalPointElement &ope)
recob::tracking::SMatrixSym55 SMatrixSym55
opts
Definition: ECLAPI.py:241
Provides recob::Track data product.
Helper class to aid the creation of a recob::Track, keeping data vectors in sync. ...
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
recob::tracking::Vector_t Vector_t
Definition: fwd.h:31
Struct holding optional TrackMaker outputs.
Definition: TrackMaker.h:114
Set of flags pertaining a point of the track.
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:49