All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexWrapper.h
Go to the documentation of this file.
1 #ifndef VERTEXWRAPPER_H
2 #define VERTEXWRAPPER_H
3 
4 #include <functional>
7 
8 namespace trkf {
9  //
10  /**
11  * @file larreco/RecoAlg/VertexWrapper.h
12  * @class trkf::VertexWrapper
13  *
14  * @brief Wrapper class to facilitate vertex production.
15  *
16  * It stores the recob::Vertex being built and the references to the tracks being used in the vertex fit.
17  * Tracks are stored in a vector of std::reference_wrapper<const recob::Track>,
18  * so the wrapper does not own the pointer to the original track object.
19  *
20  * @author G. Cerati (FNAL, MicroBooNE)
21  * @date 2017
22  * @version 1.0
23  */
24 
25  // use reference_wrapper instead of pointers: we do not want ownership of the tracks
26  typedef std::vector<std::reference_wrapper<const recob::Track> > TrackRefVec;
27 
28  class VertexWrapper {
29 
30  public:
31 
33  VertexWrapper(const recob::Vertex& vtx) : vtx_(vtx) {}
34  VertexWrapper(const recob::tracking::Point_t& pos, const recob::tracking::SMatrixSym33& cov, double chi2, int ndof) { vtx_ = recob::Vertex(pos,cov,chi2,ndof); }
35  //
36  const recob::Vertex& vertex() const { return vtx_; }
37  bool isValid() const {return vtx_.isValid();}
38  const recob::tracking::Point_t& position() const { return vtx_.position(); }
40  //
41  void setVertexId(int newID) { vtx_.setID(newID); }
42  //
43  void addTrack(const recob::Track& tk) { vtxtks_.push_back(tk); }
45  double chi2, int ndof, const recob::Track& tk) {
46  vtx_ = recob::Vertex(pos, cov, vtx_.chi2()+chi2, vtx_.ndof()+ndof);
47  addTrack(tk);
48  }
49  //
50  size_t findTrack(const recob::Track& tk) const {
51  for (size_t it = 0; it!=vtxtks_.size(); ++it) {
52  if (&tk==&vtxtks_[it].get()) return it;
53  }
54  return vtxtks_.size();
55  }
56  //
57  size_t tracksSize() const { return vtxtks_.size(); }
58  const TrackRefVec& tracks() const { return vtxtks_; }
60  TrackRefVec tks = vtxtks_;
61  tks.erase(tks.begin()+element);
62  return tks;
63  }
64 
65  private:
68  };
69 }
70 
71 #endif
const recob::tracking::Point_t & position() const
Definition: VertexWrapper.h:38
TrackRefVec tracksWithoutElement(size_t element) const
Definition: VertexWrapper.h:59
const recob::tracking::SMatrixSym33 & covariance() const
Definition: VertexWrapper.h:39
bool isValid() const
Definition: VertexWrapper.h:37
Wrapper class to facilitate vertex production.
Definition: VertexWrapper.h:28
VertexWrapper(const recob::Vertex &vtx)
Definition: VertexWrapper.h:33
void addTrack(const recob::Track &tk)
Definition: VertexWrapper.h:43
void addTrackAndUpdateVertex(const recob::tracking::Point_t &pos, const recob::tracking::SMatrixSym33 &cov, double chi2, int ndof, const recob::Track &tk)
Definition: VertexWrapper.h:44
ROOT::Math::SMatrix< Double32_t, 3, 3, ROOT::Math::MatRepSym< Double32_t, 3 > > SMatrixSym33
Definition: TrackingTypes.h:84
TrackRefVec vtxtks_
Definition: VertexWrapper.h:67
void setID(int newID)
Set vertex id.
Definition: Vertex.h:82
recob::Vertex vtx_
Definition: VertexWrapper.h:66
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
double chi2() const
Definition: Vertex.h:64
size_t tracksSize() const
Definition: VertexWrapper.h:57
const TrackRefVec & tracks() const
Definition: VertexWrapper.h:58
bool isValid() const
Definition: Vertex.h:72
Provides recob::Track data product.
const SMatrixSym33 & covariance() const
Return vertex 3D covariance (be careful, the matrix may have rank=2).
Definition: Vertex.h:62
void setVertexId(int newID)
Definition: VertexWrapper.h:41
int ndof() const
Definition: Vertex.h:66
VertexWrapper(const recob::tracking::Point_t &pos, const recob::tracking::SMatrixSym33 &cov, double chi2, int ndof)
Definition: VertexWrapper.h:34
size_t findTrack(const recob::Track &tk) const
Definition: VertexWrapper.h:50
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
const Point_t & position() const
Return vertex 3D position.
Definition: Vertex.h:60
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
const recob::Vertex & vertex() const
Definition: VertexWrapper.h:36
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26