CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
reco::Vertex Class Reference

#include <Vertex.h>

Inheritance diagram for reco::Vertex:
reco::PFDisplacedVertex

Classes

class  TrackEqual
 

Public Types

enum  { dimension = 3 }
 error matrix dimension More...
 
enum  { size = dimension * ( dimension + 1 ) / 2 }
 matix size More...
 
typedef math::Error< dimension >
::type 
CovarianceMatrix
 covariance error matrix (3x3) More...
 
typedef math::Error< dimension >
::type 
Error
 covariance error matrix (3x3) More...
 
typedef unsigned int index
 index type More...
 
typedef math::XYZPoint Point
 point in the space More...
 
typedef std::vector
< TrackBaseRef >
::const_iterator 
trackRef_iterator
 The iteratator for the vector<TrackRef> More...
 

Public Member Functions

void add (const TrackBaseRef &r, float w=1.0)
 add a reference to a Track More...
 
void add (const TrackBaseRef &r, const Track &refTrack, float w=1.0)
 add the original a Track(reference) and the smoothed Track More...
 
double chi2 () const
 chi-squares More...
 
double covariance (int i, int j) const
 (i, j)-th element of error matrix, i, j = 0, ... 2 More...
 
CovarianceMatrix covariance () const
 return SMatrix More...
 
Error error () const
 return SMatrix More...
 
void fill (CovarianceMatrix &v) const
 fill SMatrix More...
 
bool hasRefittedTracks () const
 Checks whether refitted tracks are stored. More...
 
bool isFake () const
 
bool isValid () const
 Tells whether the vertex is valid. More...
 
double ndof () const
 
double normalizedChi2 () const
 chi-squared divided by n.d.o.f. More...
 
unsigned int nTracks (float minWeight=0.5) const
 Returns the number of tracks in the vertex with weight above minWeight. More...
 
TrackBaseRef originalTrack (const Track &refTrack) const
 
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. More...
 
const Pointposition () const
 position More...
 
Track refittedTrack (const TrackBaseRef &track) const
 
Track refittedTrack (const TrackRef &track) const
 
const std::vector< Track > & refittedTracks () const
 Returns the container of refitted tracks. More...
 
void removeTracks ()
 
trackRef_iterator tracks_begin () const
 first iterator over tracks More...
 
trackRef_iterator tracks_end () const
 last iterator over tracks More...
 
size_t tracksSize () const
 number of tracks More...
 
template<typename TREF >
float trackWeight (const TREF &r) const
 returns the weight with which a Track has contributed to the vertex-fit. More...
 
 Vertex ()
 
 Vertex (const Point &, const Error &)
 Constructor for a fake vertex. More...
 
 Vertex (const Point &, const Error &, double chi2, double ndof, size_t size)
 constructor for a valid vertex, with all data More...
 
double x () const
 x coordinate More...
 
double xError () const
 error on x More...
 
double y () const
 y coordinate More...
 
double yError () const
 error on y More...
 
double z () const
 y coordinate More...
 
double zError () const
 error on z More...
 

Private Member Functions

index idx (index i, index j) const
 position index More...
 

Private Attributes

float chi2_
 chi-sqared More...
 
float covariance_ [size]
 covariance matrix (3x3) as vector More...
 
float ndof_
 number of degrees of freedom More...
 
Point position_
 position More...
 
std::vector< TrackrefittedTracks_
 The vector of refitted tracks. More...
 
std::vector< TrackBaseReftracks_
 reference to tracks More...
 
bool validity_
 tells wether the vertex is really valid. More...
 
std::vector< uint8_t > weights_
 

Detailed Description

A reconstructed Vertex providing position, error, chi2, ndof and reconstrudted tracks. The vertex can be valid, fake, or invalid. A valid vertex is one which has been obtained from a vertex fit of tracks, and all data is meaningful A fake vertex is a vertex which was not made out of a proper fit with tracks, but still has a position and error (chi2 and ndof are null). For a primary vertex, it could simply be the beam line. A fake vertex is considered valid. An invalid vertex has no meaningful data.

Author
Luca Lista, INFN

Definition at line 34 of file Vertex.h.

Member Typedef Documentation

covariance error matrix (3x3)

Definition at line 45 of file Vertex.h.

covariance error matrix (3x3)

Definition at line 43 of file Vertex.h.

typedef unsigned int reco::Vertex::index

index type

Definition at line 49 of file Vertex.h.

point in the space

Definition at line 39 of file Vertex.h.

typedef std::vector<TrackBaseRef >::const_iterator reco::Vertex::trackRef_iterator

The iteratator for the vector<TrackRef>

Definition at line 37 of file Vertex.h.

Member Enumeration Documentation

anonymous enum

error matrix dimension

Enumerator
dimension 

Definition at line 41 of file Vertex.h.

anonymous enum

matix size

Enumerator
size 

Definition at line 47 of file Vertex.h.

Constructor & Destructor Documentation

reco::Vertex::Vertex ( )
inline

default constructor - The vertex will not be valid. Position, error, chi2, ndof will have random entries, and the vectors of tracks will be empty Use the isValid method to check that your vertex is valid.

Definition at line 53 of file Vertex.h.

Vertex::Vertex ( const Point p,
const Error err 
)

Constructor for a fake vertex.

Definition at line 18 of file Vertex.cc.

References covariance_, dimension, i, idx(), j, and validity_.

18  :
19  chi2_( 0.0 ), ndof_( 0 ), position_( p ) {
20  index idx = 0;
21  for( index i = 0; i < dimension; ++ i )
22  for( index j = 0; j <= i; ++ j )
23  covariance_[ idx ++ ] = err( i, j );
24  validity_ = true;
25 }
int i
Definition: DBlmapReader.cc:9
float chi2_
chi-sqared
Definition: Vertex.h:160
unsigned int index
index type
Definition: Vertex.h:49
int j
Definition: DBlmapReader.cc:9
Point position_
position
Definition: Vertex.h:164
float covariance_[size]
covariance matrix (3x3) as vector
Definition: Vertex.h:166
index idx(index i, index j) const
position index
Definition: Vertex.h:177
float ndof_
number of degrees of freedom
Definition: Vertex.h:162
bool validity_
tells wether the vertex is really valid.
Definition: Vertex.h:173
Vertex::Vertex ( const Point p,
const Error err,
double  chi2,
double  ndof,
size_t  size 
)

constructor for a valid vertex, with all data

Definition at line 8 of file Vertex.cc.

References covariance_, dimension, i, idx(), j, tracks_, and validity_.

8  :
9  chi2_( chi2 ), ndof_( ndof ), position_( p ) {
10  tracks_.reserve( size );
11  index idx = 0;
12  for( index i = 0; i < dimension; ++ i )
13  for( index j = 0; j <= i; ++ j )
14  covariance_[ idx ++ ] = err( i, j );
15  validity_ = true;
16 }
int i
Definition: DBlmapReader.cc:9
std::vector< TrackBaseRef > tracks_
reference to tracks
Definition: Vertex.h:168
float chi2_
chi-sqared
Definition: Vertex.h:160
unsigned int index
index type
Definition: Vertex.h:49
double chi2() const
chi-squares
Definition: Vertex.h:88
int j
Definition: DBlmapReader.cc:9
double ndof() const
Definition: Vertex.h:95
Point position_
position
Definition: Vertex.h:164
float covariance_[size]
covariance matrix (3x3) as vector
Definition: Vertex.h:166
index idx(index i, index j) const
position index
Definition: Vertex.h:177
float ndof_
number of degrees of freedom
Definition: Vertex.h:162
bool validity_
tells wether the vertex is really valid.
Definition: Vertex.h:173

Member Function Documentation

void reco::Vertex::add ( const TrackBaseRef r,
float  w = 1.0 
)
void reco::Vertex::add ( const TrackBaseRef r,
const Track refTrack,
float  w = 1.0 
)

add the original a Track(reference) and the smoothed Track

Referenced by counter.Counter::register().

double reco::Vertex::chi2 ( void  ) const
inline
double reco::Vertex::covariance ( int  i,
int  j 
) const
inline
CovarianceMatrix reco::Vertex::covariance ( void  ) const
inline

return SMatrix

Definition at line 120 of file Vertex.h.

Error reco::Vertex::error ( ) const
inline
void Vertex::fill ( CovarianceMatrix v) const

fill SMatrix

Definition at line 27 of file Vertex.cc.

References covariance_, dimension, i, idx(), and j.

Referenced by CandCommonVertexFitterBase::set(), and PFCandCommonVertexFitterBase::set().

27  {
28  index idx = 0;
29  for( index i = 0; i < dimension; ++ i )
30  for( index j = 0; j <= i; ++ j )
31  err( i, j ) = covariance_[ idx ++ ];
32 }
int i
Definition: DBlmapReader.cc:9
unsigned int index
index type
Definition: Vertex.h:49
int j
Definition: DBlmapReader.cc:9
float covariance_[size]
covariance matrix (3x3) as vector
Definition: Vertex.h:166
index idx(index i, index j) const
position index
Definition: Vertex.h:177
bool reco::Vertex::hasRefittedTracks ( ) const
inline

Checks whether refitted tracks are stored.

Definition at line 127 of file Vertex.h.

Referenced by nTracks(), p4(), and reco::TrackKinematics::TrackKinematics().

index reco::Vertex::idx ( index  i,
index  j 
) const
inlineprivate

position index

Definition at line 177 of file Vertex.h.

Referenced by fill(), and Vertex().

bool reco::Vertex::isFake ( ) const
inline

Tells whether a Vertex is fake, i.e. not a vertex made out of a proper fit with tracks. For a primary vertex, it could simply be the beam line.

Definition at line 64 of file Vertex.h.

Referenced by BVertexFilterT< VTX >::filter(), HLTVertexFilter::hltFilter(), PVObjectSelector::operator()(), EventVtxInfoNtupleDumper::produce(), and PFchsMETcorrInputProducer::produce().

bool reco::Vertex::isValid ( void  ) const
inline

Tells whether the vertex is valid.

Definition at line 60 of file Vertex.h.

Referenced by NuclearLikelihood::calculate(), HLTVertexFilter::hltFilter(), and core.AutoHandle.AutoHandle::ReallyLoad().

double reco::Vertex::ndof ( ) const
inline

Number of degrees of freedom Meant to be Double32_t for soft-assignment fitters: tracks may contribute to the vertex with fractional weights. The ndof is then = to the sum of the track weights. see e.g. CMS NOTE-2006/032, CMS NOTE-2004/002

Definition at line 95 of file Vertex.h.

Referenced by CMSDAS11DijetTestAnalyzer::analyze(), HLTVertexFilter::hltFilter(), PVObjectSelector::operator()(), EventVtxInfoNtupleDumper::produce(), pat::PATVertexSlimmer::produce(), pat::PATSecondaryVertexSlimmer::produce(), ConeIsolation::produce(), PFchsMETcorrInputProducer::produce(), pat::PATConversionProducer::produce(), CandCommonVertexFitterBase::set(), and PFCandCommonVertexFitterBase::set().

double reco::Vertex::normalizedChi2 ( ) const
inline

chi-squared divided by n.d.o.f.

Definition at line 97 of file Vertex.h.

unsigned int Vertex::nTracks ( float  minWeight = 0.5) const

Returns the number of tracks in the vertex with weight above minWeight.

Definition at line 132 of file Vertex.cc.

References hasRefittedTracks(), gen::n, originalTrack(), refittedTracks_, tracks_begin(), tracks_end(), and trackWeight().

Referenced by nTracks().

133 {
134  int n=0;
135  if(hasRefittedTracks()) {
136  for(std::vector<Track>::const_iterator iter = refittedTracks_.begin(); iter != refittedTracks_.end(); ++iter)
137  if (trackWeight(originalTrack(*iter)) >=minWeight)
138  n++;
139  }
140  else
141  {
142  for(std::vector<reco::TrackBaseRef>::const_iterator iter = tracks_begin(); iter != tracks_end(); iter++)
143  if (trackWeight(*iter) >=minWeight)
144  n++;
145  }
146  return n;
147 }
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:71
std::vector< Track > refittedTracks_
The vector of refitted tracks.
Definition: Vertex.h:170
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:127
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:73
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
TrackBaseRef Vertex::originalTrack ( const Track refTrack) const

Returns the original track which corresponds to a particular refitted Track Throws an exception if now refitted tracks are stored ot the track is not found in the list

Definition at line 71 of file Vertex.cc.

References refittedTracks_, and tracks_.

Referenced by nTracks(), and p4().

72 {
73  if (refittedTracks_.empty())
74  throw cms::Exception("Vertex") << "No refitted tracks stored in vertex\n";
75  std::vector<Track>::const_iterator it =
76  find_if(refittedTracks_.begin(), refittedTracks_.end(), TrackEqual(refTrack));
77  if (it==refittedTracks_.end())
78  throw cms::Exception("Vertex") << "Refitted track not found in list\n";
79  size_t pos = it - refittedTracks_.begin();
80  return tracks_[pos];
81 }
std::vector< TrackBaseRef > tracks_
reference to tracks
Definition: Vertex.h:168
std::vector< Track > refittedTracks_
The vector of refitted tracks.
Definition: Vertex.h:170
math::XYZTLorentzVectorD Vertex::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 at line 98 of file Vertex.cc.

References hasRefittedTracks(), originalTrack(), refittedTracks_, tracks_begin(), tracks_end(), and trackWeight().

Referenced by Tau.Tau::dxy_approx(), Tau.Tau::dz(), Lepton.Lepton::p4WithFSR(), and pat::PATSecondaryVertexSlimmer::produce().

99 {
100 
102  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
103 
104  if(hasRefittedTracks()) {
105  for(std::vector<Track>::const_iterator iter = refittedTracks_.begin();
106  iter != refittedTracks_.end(); ++iter) {
107  if (trackWeight(originalTrack(*iter)) >=minWeight) {
108  vec.SetPx(iter->px());
109  vec.SetPy(iter->py());
110  vec.SetPz(iter->pz());
111  vec.SetM(mass);
112  sum += vec;
113  }
114  }
115  }
116  else
117  {
118  for(std::vector<reco::TrackBaseRef>::const_iterator iter = tracks_begin();
119  iter != tracks_end(); iter++) {
120  if (trackWeight(*iter) >=minWeight) {
121  vec.SetPx((*iter)->px());
122  vec.SetPy((*iter)->py());
123  vec.SetPz((*iter)->pz());
124  vec.SetM(mass);
125  sum += vec;
126  }
127  }
128  }
129  return sum;
130 }
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:71
std::vector< Track > refittedTracks_
The vector of refitted tracks.
Definition: Vertex.h:170
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:127
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:73
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
const Point& reco::Vertex::position ( ) const
inline
Track reco::Vertex::refittedTrack ( const TrackBaseRef track) const

Returns the refitted track which corresponds to a particular original Track Throws an exception if now refitted tracks are stored ot the track is not found in the list

Referenced by refittedTrack(), and reco::TrackKinematics::TrackKinematics().

Track Vertex::refittedTrack ( const TrackRef track) const

Returns the refitted track which corresponds to a particular original Track Throws an exception if now refitted tracks are stored ot the track is not found in the list

Definition at line 93 of file Vertex.cc.

References refittedTrack().

94 {
95  return refittedTrack(TrackBaseRef(track));
96 }
Track refittedTrack(const TrackBaseRef &track) const
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:32
const std::vector<Track>& reco::Vertex::refittedTracks ( ) const
inline

Returns the container of refitted tracks.

Definition at line 142 of file Vertex.h.

void Vertex::removeTracks ( )

Definition at line 64 of file Vertex.cc.

References refittedTracks_, tracks_, and weights_.

65 {
66  weights_.clear();
67  tracks_.clear();
68  refittedTracks_.clear();
69 }
std::vector< TrackBaseRef > tracks_
reference to tracks
Definition: Vertex.h:168
std::vector< Track > refittedTracks_
The vector of refitted tracks.
Definition: Vertex.h:170
std::vector< uint8_t > weights_
Definition: Vertex.h:171
Vertex::trackRef_iterator Vertex::tracks_begin ( ) const
Vertex::trackRef_iterator Vertex::tracks_end ( ) const
size_t Vertex::tracksSize ( ) const
template<typename TREF >
float reco::Vertex::trackWeight ( const TREF &  r) const
inline

returns the weight with which a Track has contributed to the vertex-fit.

Definition at line 73 of file Vertex.h.

Referenced by vertexTools::computeSharedTracks(), computeSharedTracks(), nTracks(), p4(), pat::PATSecondaryVertexSlimmer::produce(), and reco::TrackKinematics::TrackKinematics().

double reco::Vertex::x ( ) const
inline
double reco::Vertex::xError ( ) const
inline

error on x

Definition at line 107 of file Vertex.h.

Referenced by PatVertexAnalyzer::analyze(), and pf2pat::IPCutPFCandidateSelectorDefinition::select().

double reco::Vertex::y ( ) const
inline
double reco::Vertex::yError ( ) const
inline

error on y

Definition at line 109 of file Vertex.h.

Referenced by PatVertexAnalyzer::analyze(), and pf2pat::IPCutPFCandidateSelectorDefinition::select().

double reco::Vertex::z ( ) const
inline
double reco::Vertex::zError ( ) const
inline

Member Data Documentation

float reco::Vertex::chi2_
private

chi-sqared

Definition at line 160 of file Vertex.h.

float reco::Vertex::covariance_[size]
private

covariance matrix (3x3) as vector

Definition at line 166 of file Vertex.h.

Referenced by fill(), and Vertex().

float reco::Vertex::ndof_
private

number of degrees of freedom

Definition at line 162 of file Vertex.h.

Point reco::Vertex::position_
private

position

Definition at line 164 of file Vertex.h.

std::vector<Track> reco::Vertex::refittedTracks_
private

The vector of refitted tracks.

Definition at line 170 of file Vertex.h.

Referenced by nTracks(), originalTrack(), p4(), and removeTracks().

std::vector<TrackBaseRef > reco::Vertex::tracks_
private

reference to tracks

Definition at line 168 of file Vertex.h.

Referenced by originalTrack(), removeTracks(), tracks_begin(), tracks_end(), and Vertex().

bool reco::Vertex::validity_
private

tells wether the vertex is really valid.

Definition at line 173 of file Vertex.h.

Referenced by Vertex().

std::vector<uint8_t> reco::Vertex::weights_
private

Definition at line 171 of file Vertex.h.

Referenced by removeTracks(), and tracksSize().