CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DataFormats/TrackReco/src/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", 
00009                                              "iter0", "iter1", "iter2","iter3","iter4","iter5","iter6","iter7","iter8","iter9","iter10",
00010                                              "outInEcalSeededConv","inOutEcalSeededConv",
00011                                              "nuclInter",
00012                                              "standAloneMuon","globalMuon","cosmicStandAloneMuon","cosmicGlobalMuon",
00013                                              "iter1LargeD0","iter2LargeD0","iter3LargeD0","iter4LargeD0","iter5LargeD0",
00014                                              "bTagGhostTracks", 
00015                                              "beamhalo" , 
00016                                              "gsf" };
00017 
00018 std::string const TrackBase::qualityNames[] = { "loose", "tight", "highPurity", "confirmed", "goodIterative", "looseSetWithPV", "highPuritySetWithPV"};
00019 
00020 TrackBase::TrackBase() :
00021   chi2_(0), vertex_(0,0,0), momentum_(0,0,0), ndof_(0), charge_(0), algorithm_(undefAlgorithm), quality_(0), nLoops_(0) {
00022   index idx = 0;
00023   for( index i = 0; i < dimension; ++ i )
00024     for( index j = 0; j <= i; ++ j )
00025       covariance_[ idx ++ ]=0;
00026 }
00027 
00028 TrackBase::TrackBase( double chi2, double ndof, const Point & vertex, const Vector & momentum, int charge,
00029                       const CovarianceMatrix & cov,
00030                       TrackAlgorithm algorithm , TrackQuality quality,signed char nloops) :
00031   chi2_( chi2 ), vertex_( vertex ), momentum_( momentum ), ndof_( ndof ), charge_( charge ), algorithm_(algorithm), quality_(0), nLoops_(nloops) {
00032   index idx = 0;
00033   for( index i = 0; i < dimension; ++ i )
00034     for( index j = 0; j <= i; ++ j )
00035       covariance_[ idx ++ ] = cov( i, j );
00036   setQuality(quality);
00037 }
00038 
00039 TrackBase::~TrackBase() {
00040 }
00041 
00042 TrackBase::CovarianceMatrix & TrackBase::fill( CovarianceMatrix & v ) const {
00043   return fillCovariance( v, covariance_ );
00044 }
00045 
00046 TrackBase::TrackQuality TrackBase::qualityByName(const std::string &name){
00047   TrackQuality size = qualitySize;
00048   int index = std::find(qualityNames, qualityNames+size, name)-qualityNames;
00049   if(index == size) return undefQuality; // better this or throw() ?
00050 
00051   // cast
00052   return TrackQuality(index);
00053 }
00054 
00055 TrackBase::TrackAlgorithm TrackBase::algoByName(const std::string &name){
00056   TrackAlgorithm size = algoSize;
00057   int index = std::find(algoNames, algoNames+size, name)-algoNames;
00058   if(index == size) return undefAlgorithm; // better this or throw() ?
00059 
00060   // cast
00061   return TrackAlgorithm(index);
00062 }
00063 
00064