All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vertex.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // \file lardataobj/RecoBase/Vertex.h
4 // \brief Definition of vertex object for LArSoft
5 //
6 // \author brebel@fnal.gov
7 //
8 ////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef RB_VERTEX_H
11 #define RB_VERTEX_H
12 
13 #include <iosfwd>
14 
17 
18 namespace recob {
19 
20  /**
21  * @class recob::Vertex
22  *
23  * @brief Definition of vertex object for LArSoft
24  *
25  * Vertex object, containing 3D position, position covariance (also in 3D, but the matrix rank may be = 2),
26  * vertex fit chi2 and number of degrees of freedom, plus a vertex status and a vertex id.
27  * The vertex object may be associated (via art Assn) to the recob::Track objects used in the vertex fit, possibly with
28  * a meta data, see recob::VertexAssnMeta.
29  *
30  * @author Original author: brebel@fnal.gov, updated by G. Cerati (FNAL, MicroBooNE)
31  * @date 2017
32  * @version 2.0
33  */
34 
35  class Vertex {
36 
37  public:
38 
44 
45  /// Status of the vertex. Here the convention is that when adding new enum values
46  /// all invalid go before 'Invalid', all valid go after 'Valid', and all valid with covariance go after 'ValidWithCovariance'
48 
49  /// Default constructor, initializes status to Invalid, and data members to default or kBogus values.
50  Vertex();
51 
52  /// Legacy constructor, preserved to avoid breaking code. Please try to use the new constructor.
53  explicit Vertex(double *xyz, int id=util::kBogusI);
54 
55  /// Constructor initializing all data members.
56  Vertex(const Point_t& pos, const SMatrixSym33& cov, double chi2, int ndof, int id=util::kBogusI)
57  : pos_(pos), cov_(cov), chi2_(chi2), ndof_(ndof), status_(ValidWithCovariance), id_(id) {}
58 
59  /// Return vertex 3D position.
60  const Point_t& position() const { return pos_; }
61  /// Return vertex 3D covariance (be careful, the matrix may have rank=2).
62  const SMatrixSym33& covariance() const { return cov_; }
63  // Return vertex fit chi2.
64  double chi2() const { return chi2_; }
65  // Return vertex fit ndof.
66  int ndof() const { return ndof_; }
67  // Return vertex fit chi2 per ndof.
68  double chi2PerNdof() const { return (ndof_>0. ? chi2_/ndof_ : util::kBogusD); }
69  //
70  // Return vertex status.
71  Status status() const { return status_; }
72  bool isValid() const { return status_>=Valid; }
73  bool isValidCovariance() const { return status_>=ValidWithCovariance; }
74 
75  /// Legacy method to access vertex position, preserved to avoid breaking code. Please try to use Vertex::position().
76  void XYZ(double *xyz) const;
77 
78  /// Return vertex id.
79  int ID() const;
80 
81  /// Set vertex id.
82  void setID(int newID) { id_ = newID; }
83 
84  friend bool operator < (const Vertex & a, const Vertex & b);
85  friend std::ostream& operator << (std::ostream& o, const Vertex & a);
86 
87  private:
88 
89  Point_t pos_; ///< Vertex 3D position
90  SMatrixSym33 cov_; ///< Vertex covariance matrix 3x3
91  double chi2_; ///< Vertex fit chi2
92  int ndof_; ///< Vertex fit degrees of freedom
93  Status status_; ///< Vertex status, as define in Vertex::Status enum
94  int id_; ///< id number for vertex
95 
96  };
97 }
98 
99 inline int recob::Vertex::ID() const { return id_; }
100 
101 #endif // RB_VERTEX_H
void XYZ(double *xyz) const
Legacy method to access vertex position, preserved to avoid breaking code. Please try to use Vertex::...
Definition: Vertex.cxx:36
tracking::SMatrixSym33 SMatrixSym33
Definition: Vertex.h:40
friend std::ostream & operator<<(std::ostream &o, const Vertex &a)
Definition: Vertex.cxx:48
Vertex()
Default constructor, initializes status to Invalid, and data members to default or kBogus values...
Definition: Vertex.cxx:16
ROOT::Math::SMatrix< Double32_t, 3, 3, ROOT::Math::MatRepSym< Double32_t, 3 > > SMatrixSym33
Definition: TrackingTypes.h:84
Status status() const
Definition: Vertex.h:71
constexpr int kBogusI
obviously bogus integer value
ROOT::Math::SVector< Double32_t, 3 > SVector3
Definition: TrackingTypes.h:93
void setID(int newID)
Set vertex id.
Definition: Vertex.h:82
Vertex(const Point_t &pos, const SMatrixSym33 &cov, double chi2, int ndof, int id=util::kBogusI)
Constructor initializing all data members.
Definition: Vertex.h:56
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
double chi2() const
Definition: Vertex.h:64
bool isValidCovariance() const
Definition: Vertex.h:73
process_name gaushit a
tracking::Point_t Point_t
Definition: Vertex.h:39
double chi2PerNdof() const
Definition: Vertex.h:68
Status status_
Vertex status, as define in Vertex::Status enum.
Definition: Vertex.h:93
ROOT::Math::SVector< Double32_t, 2 > SVector2
Definition: TrackingTypes.h:94
SMatrixSym33 cov_
Vertex covariance matrix 3x3.
Definition: Vertex.h:90
bool isValid() const
Definition: Vertex.h:72
int id_
id number for vertex
Definition: Vertex.h:94
const SMatrixSym33 & covariance() const
Return vertex 3D covariance (be careful, the matrix may have rank=2).
Definition: Vertex.h:62
int ndof_
Vertex fit degrees of freedom.
Definition: Vertex.h:92
tracking::SMatrixSym22 SMatrixSym22
Definition: Vertex.h:41
tracking::SVector3 SVector3
Definition: Vertex.h:42
Point_t pos_
Vertex 3D position.
Definition: Vertex.h:89
double chi2_
Vertex fit chi2.
Definition: Vertex.h:91
int ID() const
Return vertex id.
Definition: Vertex.h:99
friend bool operator<(const Vertex &a, const Vertex &b)
Definition: Vertex.cxx:61
ROOT::Math::SMatrix< Double32_t, 2, 2, ROOT::Math::MatRepSym< Double32_t, 2 > > SMatrixSym22
Definition: TrackingTypes.h:83
int ndof() const
Definition: Vertex.h:66
tracking::SVector2 SVector2
Definition: Vertex.h:43
constexpr double kBogusD
obviously bogus double value
Collection of Physical constants used in LArSoft.
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