test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Vertex.h
Go to the documentation of this file.
1 #ifndef VertexReco_Vertex_h
2 #define VertexReco_Vertex_h
3 
20 #include <Rtypes.h>
26 #include <Math/GenVector/PxPyPzE4D.h>
27 #include <Math/GenVector/PxPyPzM4D.h>
29 
30 namespace reco {
31 
32  class Track;
33 
34  class Vertex {
35  public:
37  typedef std::vector<TrackBaseRef >::const_iterator trackRef_iterator;
41  enum { dimension = 3 };
47  enum { size = dimension * ( dimension + 1 ) / 2 };
49  typedef unsigned int index;
53  Vertex(): chi2_( 0.0 ), ndof_( 0 ), position_(0.,0.,0. ) { validity_ = false; for(int i = 0; i < size; ++ i ) covariance_[i]=0.;
54 }
56  Vertex( const Point &, const Error &);
58  Vertex( const Point &, const Error &, double chi2, double ndof, size_t size );
60  bool isValid() const {return validity_;}
64  bool isFake() const {return (chi2_==0 && ndof_==0 && tracks_.empty());}
66  void add( const TrackBaseRef & r, float w=1.0 );
68  void add( const TrackBaseRef & r, const Track & refTrack, float w=1.0 );
69  void removeTracks();
70 
71 #ifndef CMS_NOCXX11
72  template<typename TREF>
74  float trackWeight ( const TREF & r ) const {
75  int i=0;
76  for(auto const & t : tracks_) {
77  if ( (r.id()==t.id()) & (t.key()==r.key()) ) return weights_[i]/255.f;
78  ++i;
79  }
80  return 0;
81  }
82 #else
83  float trackWeight ( const TrackBaseRef & r ) const;
86  float trackWeight ( const TrackRef & r ) const;
87 #endif
93  size_t tracksSize() const;
95  double chi2() const { return chi2_; }
102  double ndof() const { return ndof_; }
104  double normalizedChi2() const { return ndof_ != 0 ? chi2_ / ndof_ : chi2_ * 1e6; }
106  const Point & position() const { return position_; }
108  double x() const { return position_.X(); }
110  double y() const { return position_.Y(); }
112  double z() const { return position_.Z(); }
114  double xError() const { return sqrt( covariance(0, 0) ); }
116  double yError() const { return sqrt( covariance(1, 1) ); }
118  double zError() const { return sqrt( covariance(2, 2) ); }
120  // Note that:
121  // double error( int i, int j ) const
122  // is OBSOLETE, use covariance(i, j)
123  double covariance( int i, int j ) const {
124  return covariance_[ idx( i, j ) ];
125  }
127  CovarianceMatrix covariance() const { Error m; fill( m ); return m; }
129  Error error() const { Error m; fill( m ); return m; }
131  void fill( CovarianceMatrix & v ) const;
132 
134  bool hasRefittedTracks() const {return !refittedTracks_.empty();}
135 
138  TrackBaseRef originalTrack(const Track & refTrack) const;
139 
142  Track refittedTrack(const TrackBaseRef & track) const;
143 
146  Track refittedTrack(const TrackRef & track) const;
147 
149  const std::vector<Track> & refittedTracks() const { return refittedTracks_;}
150 
152  math::XYZTLorentzVectorD p4(float mass=0.13957018,float minWeight=0.5) const;
153 
155  unsigned int nTracks(float minWeight=0.5) const;
156 
157  class TrackEqual {
158  public:
159  TrackEqual( const Track & t) : track_( t ) { }
160  bool operator()( const Track & t ) const { return t.pt()==track_.pt();}
161  private:
162  const Track & track_;
163  };
164 
165  private:
167  float chi2_;
169  float ndof_;
173  float covariance_[ size ];
175  std::vector<TrackBaseRef > tracks_;
177  std::vector<Track> refittedTracks_;
178  std::vector<uint8_t> weights_;
180  bool validity_;
181 
182 
184  index idx( index i, index j ) const {
185  int a = ( i <= j ? i : j ), b = ( i <= j ? j : i );
186  return b * ( b + 1 ) / 2 + a;
187  }
188  };
189 
190 }
191 
192 #endif
int i
Definition: DBlmapReader.cc:9
std::vector< TrackBaseRef > tracks_
reference to tracks
Definition: Vertex.h:175
float chi2_
chi-sqared
Definition: Vertex.h:167
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
const double w
Definition: UKUtility.cc:23
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
double zError() const
error on z
Definition: Vertex.h:118
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:86
Track refittedTrack(const TrackBaseRef &track) const
double y() const
y coordinate
Definition: Vertex.h:110
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:60
std::vector< Track > refittedTracks_
The vector of refitted tracks.
Definition: Vertex.h:177
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:134
fixed size error matrix
Definition: Error.h:38
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
void fill(CovarianceMatrix &v) const
fill SMatrix
Definition: Vertex.cc:27
ErrorD< N >::type type
Definition: Error.h:39
unsigned int index
index type
Definition: Vertex.h:49
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:123
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
Definition: Vertex.h:149
const Point & position() const
position
Definition: Vertex.h:106
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
Definition: Vertex.h:45
TrackEqual(const Track &t)
Definition: Vertex.h:159
const Track & track_
Definition: Vertex.h:162
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:32
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:608
math::XYZPoint Point
double chi2() const
chi-squares
Definition: Vertex.h:95
int j
Definition: DBlmapReader.cc:9
double z() const
y coordinate
Definition: Vertex.h:112
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double ndof() const
Definition: Vertex.h:102
CovarianceMatrix covariance() const
return SMatrix
Definition: Vertex.h:127
void add(const TrackBaseRef &r, float w=1.0)
add a reference to a Track
double x() const
x coordinate
Definition: Vertex.h:108
double xError() const
error on x
Definition: Vertex.h:114
bool isFake() const
Definition: Vertex.h:64
unsigned int nTracks(float minWeight=0.5) const
Returns the number of tracks in the vertex with weight above minWeight.
Definition: Vertex.cc:147
Point position_
position
Definition: Vertex.h:171
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products...
Definition: Vertex.cc:113
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
double b
Definition: hdecay.h:120
Error error() const
return SMatrix
Definition: Vertex.h:129
bool operator()(const Track &t) const
Definition: Vertex.h:160
double a
Definition: hdecay.h:121
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
double normalizedChi2() const
chi-squared divided by n.d.o.f.
Definition: Vertex.h:104
void removeTracks()
Definition: Vertex.cc:64
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
float covariance_[size]
covariance matrix (3x3) as vector
Definition: Vertex.h:173
index idx(index i, index j) const
position index
Definition: Vertex.h:184
double yError() const
error on y
Definition: Vertex.h:116
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:34
float ndof_
number of degrees of freedom
Definition: Vertex.h:169
bool validity_
tells wether the vertex is really valid.
Definition: Vertex.h:180
std::vector< uint8_t > weights_
Definition: Vertex.h:178