CMS 3D CMS Logo

TrackBase.cc

Go to the documentation of this file.
00001 #include "Rtypes.h" 
00002 #include "DataFormats/TrackReco/interface/TrackBase.h"
00003 #include "DataFormats/TrackReco/interface/fillCovariance.h"
00004 #include <algorithm>
00005 using namespace reco;
00006 
00007 // To be kept in synch with the enumerator definitions in TrackBase.h file
00008 std::string const TrackBase::algoNames[] = { "undefAlgorithm", "ctf", "rs", "cosmics", "beamhalo",
00009                                              "iter1", "iter2","iter3","iter4","iter5","iter6","iter7","iter8","iter9","iter10",
00010                                              "conversion","nuclInter"};
00011 std::string const TrackBase::qualityNames[] = { "loose", "tight", "highPurity", "confirmed", "goodIterative"};
00012 
00013 TrackBase::TrackBase() :
00014   chi2_(0), ndof_(0), vertex_(0,0,0), momentum_(0,0,0), charge_(0), algorithm_(undefAlgorithm), quality_(0) {
00015   index idx = 0;
00016   for( index i = 0; i < dimension; ++ i )
00017     for( index j = 0; j <= i; ++ j )
00018       covariance_[ idx ++ ]=0;
00019 }
00020 
00021 TrackBase::TrackBase( double chi2, double ndof, const Point & vertex, const Vector & momentum, int charge,
00022                       const CovarianceMatrix & cov,
00023                       TrackAlgorithm algorithm , TrackQuality quality) :
00024   chi2_( chi2 ), ndof_( ndof ), vertex_( vertex ), momentum_( momentum ), charge_( charge ), algorithm_(algorithm), quality_(0) {
00025   index idx = 0;
00026   for( index i = 0; i < dimension; ++ i )
00027     for( index j = 0; j <= i; ++ j )
00028       covariance_[ idx ++ ] = cov( i, j );
00029   setQuality(quality);
00030 }
00031 
00032 TrackBase::~TrackBase() {
00033 }
00034 
00035 TrackBase::CovarianceMatrix & TrackBase::fill( CovarianceMatrix & v ) const {
00036   return fillCovariance( v, covariance_ );
00037 }
00038 
00039 TrackBase::TrackQuality TrackBase::qualityByName(const std::string &name){
00040   TrackQuality size = qualitySize;
00041   int index = std::find(qualityNames, qualityNames+size, name)-qualityNames;
00042   if(index == size) return undefQuality; // better this or throw() ?
00043 
00044   // cast
00045   return TrackQuality(index);
00046 }
00047 
00048 TrackBase::TrackAlgorithm TrackBase::algoByName(const std::string &name){
00049   TrackAlgorithm size = algoSize;
00050   int index = std::find(algoNames, algoNames+size, name)-algoNames;
00051   if(index == size) return undefAlgorithm; // better this or throw() ?
00052 
00053   // cast
00054   return TrackAlgorithm(index);
00055 }
00056 
00057 

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