CMS 3D CMS Logo

Vertex.cc

Go to the documentation of this file.
00001 #include "DataFormats/VertexReco/interface/Vertex.h"
00002 
00003 // $Id: Vertex.cc,v 1.15 2007/09/25 11:21:53 speer Exp $
00004 using namespace reco;
00005 using namespace std;
00006 
00007 Vertex::Vertex( const Point & p , const Error & err, double chi2, double ndof, size_t size ) :
00008   chi2_( chi2 ), ndof_( ndof ), position_( p ) {
00009   tracks_.reserve( size );
00010   index idx = 0;
00011   for( index i = 0; i < dimension; ++ i ) 
00012     for( index j = 0; j <= i; ++ j )
00013       covariance_[ idx ++ ] = err( i, j );
00014   validity_ = true;
00015 }
00016 
00017 Vertex::Vertex( const Point & p , const Error & err) :
00018   chi2_( 0.0 ), ndof_( 0 ), position_( p ) {
00019   index idx = 0;
00020   for( index i = 0; i < dimension; ++ i ) 
00021     for( index j = 0; j <= i; ++ j )
00022       covariance_[ idx ++ ] = err( i, j );
00023   validity_ = true;
00024 }
00025 
00026 void Vertex::fill( Error & err ) const {
00027   index idx = 0;
00028   for( index i = 0; i < dimension; ++ i ) 
00029     for( index j = 0; j <= i; ++ j )
00030       err( i, j ) = covariance_[ idx ++ ];
00031 }
00032 
00033 size_t Vertex::tracksSize() const
00034 {
00035   return weights_.size();
00036 }
00037 
00038 Vertex::trackRef_iterator Vertex::tracks_begin() const
00039 {
00040   return tracks_.begin();
00041 }
00042 
00043 Vertex::trackRef_iterator Vertex::tracks_end() const
00044 {
00045 //   if ( !(tracks_.size() ) ) createTracks();
00046   return tracks_.end();
00047   // return weights_.keys().end();
00048 }
00049 
00050 void Vertex::add ( const TrackBaseRef & r, float w )
00051 {
00052   tracks_.push_back ( r );
00053   weights_.push_back(w);
00054 
00055 }
00056 
00057 void Vertex::add ( const TrackBaseRef & r, const Track & refTrack, float w )
00058 {
00059   tracks_.push_back ( r );
00060   refittedTracks_.push_back ( refTrack );
00061   weights_.push_back(w);
00062 }
00063 
00064 void Vertex::removeTracks()
00065 {
00066   weights_.clear();
00067   tracks_.clear();
00068   refittedTracks_.clear();
00069 }
00070 
00071 float Vertex::trackWeight ( const TrackBaseRef & track ) const
00072 {
00073   trackRef_iterator it = find(tracks_begin(), tracks_end(), track);
00074   if (it==tracks_end()) return 0.0;
00075   size_t pos = it - tracks_begin();
00076   return weights_[pos];
00077 }
00078 
00079 float Vertex::trackWeight ( const TrackRef & track ) const
00080 {
00081   return trackWeight(TrackBaseRef(track));
00082 }
00083 
00084 
00085 TrackBaseRef Vertex::originalTrack(const Track & refTrack) const
00086 {
00087   if (refittedTracks_.empty())
00088         throw cms::Exception("Vertex") << "No refitted tracks stored in vertex\n";
00089   std::vector<Track>::const_iterator it =
00090         find_if(refittedTracks_.begin(), refittedTracks_.end(), TrackEqual(refTrack));
00091   if (it==refittedTracks_.end())
00092         throw cms::Exception("Vertex") << "Refitted track not found in list\n";
00093   size_t pos = it - refittedTracks_.begin();
00094   return tracks_[pos];
00095 }
00096 
00097 Track Vertex::refittedTrack(const TrackBaseRef & track) const
00098 {
00099   if (refittedTracks_.empty())
00100          throw cms::Exception("Vertex") << "No refitted tracks stored in vertex\n";
00101   trackRef_iterator it = find(tracks_begin(), tracks_end(), track);
00102   if (it==tracks_end()) throw cms::Exception("Vertex") << "Track not found in list\n";
00103   size_t pos = it - tracks_begin();
00104   return refittedTracks_[pos];
00105 }
00106 
00107 Track Vertex::refittedTrack(const TrackRef & track) const
00108 {
00109   return refittedTrack(TrackBaseRef(track));
00110 }

Generated on Tue Jun 9 17:31:48 2009 for CMSSW by  doxygen 1.5.4