00001 // $Id: Track.cpp,v 1.2 2005/02/10 19:33:50 erodrigu Exp $ // Include files 00002 00003 // local 00004 #include "Event/Track.h" 00005 00006 //----------------------------------------------------------------------------- 00007 // Implementation file for class : Track 00008 // 00009 // 2004-12-14 : Jose Hernando, Eduardo Rodrigues 00010 //----------------------------------------------------------------------------- 00011 00012 00013 //============================================================================= 00014 // Retrieve the position and momentum vectors and the corresponding 00015 // 6D covariance matrix (pos:1->3,mom:4-6) at the physics state 00016 //============================================================================= 00017 StatusCode Track::positionAndMomentum( HepPoint3D &pos, 00018 HepVector3D &mom, 00019 HepSymMatrix &cov6D ) const 00020 { 00021 m_physicsState.positionAndMomentum( pos, mom, cov6D ); 00022 00023 return StatusCode::SUCCESS; 00024 }; 00025 00026 //============================================================================= 00027 // Retrieve the 3D-position (+ errors) at the physics state 00028 //============================================================================= 00029 StatusCode Track::position( HepPoint3D &pos, 00030 HepSymMatrix &errPos ) const 00031 { 00032 pos = m_physicsState.position(); 00033 errPos = m_physicsState.errPosition(); 00034 00035 return StatusCode::SUCCESS; 00036 }; 00037 00038 //============================================================================= 00039 // Retrieve the slopes (dx/dz,dy/dz,1) at the physics state 00040 //============================================================================= 00041 StatusCode Track::slopes( HepVector3D &slopes, 00042 HepSymMatrix &errSlopes ) const 00043 { 00044 slopes = m_physicsState.slopes(); 00045 errSlopes = m_physicsState.errSlopes(); 00046 00047 return StatusCode::SUCCESS; 00048 }; 00049 00050 //============================================================================= 00051 // Retrieve the momentum at the physics state 00052 //============================================================================= 00053 double Track::p() const 00054 { 00055 return m_physicsState.p(); 00056 }; 00057 00058 //============================================================================= 00059 // Retrieve the transverse momentum at the physics state 00060 //============================================================================= 00061 double Track::pt() const 00062 { 00063 return m_physicsState.pt(); 00064 }; 00065 00066 //============================================================================= 00067 // Retrieve the momentum vector (+ errors) at the physics state 00068 //============================================================================= 00069 StatusCode Track::momentum( HepVector3D &mom, 00070 HepSymMatrix &errMom ) const 00071 { 00072 mom = m_physicsState.momentum(); 00073 errMom = m_physicsState.errMomentum(); 00074 00075 return StatusCode::SUCCESS; 00076 }; 00077 00078 //============================================================================= 00079 // Retrieve the 6D covariance matrix (x,y,z,px,py,pz) at the physics state 00080 //============================================================================= 00081 StatusCode Track::posMomCovariance( HepSymMatrix &cov6D ) const 00082 { 00083 cov6D = m_physicsState.posMomCovariance(); 00084 00085 return StatusCode::SUCCESS; 00086 }; 00087 00088 //============================================================================= 00089 // Retrieve the reference to the state closest to the given z-position 00090 //============================================================================= 00091 State & Track::closestState( double z ) 00092 { 00093 double minDist = 999999999.; 00094 State* best = 0; 00095 for ( std::vector<State*>::iterator it = m_states.begin() ; 00096 m_states.end() != it; it++ ) { 00097 if ( minDist > fabs( z - (*it)->z() ) ) { 00098 minDist = fabs( z-(*it)->z() ); 00099 best = *it; 00100 } 00101 } 00102 if ( fabs(z - m_physicsState.z()) < minDist ) return m_physicsState; 00103 return *best; 00104 }; 00105 00106 //============================================================================= 00107 // Retrieve the (const) reference to the state closest to the given z-position 00108 //============================================================================= 00109 const State & Track::closestState( double z ) const 00110 { 00111 double minDist = 999999999.; 00112 State* best = 0; 00113 for ( std::vector<State*>::const_iterator it = m_states.begin() ; 00114 m_states.end() != it; it++ ) { 00115 if ( minDist > fabs( z - (*it)->z() ) ) { 00116 minDist = fabs( z-(*it)->z() ); 00117 best = *it; 00118 } 00119 } 00120 if ( fabs(z - m_physicsState.z()) < minDist ) return m_physicsState; 00121 return *best; 00122 }; 00123 00124 //============================================================================= 00125 // Retrieve the reference to the state closest to the given plane 00126 //============================================================================= 00127 State & Track::closestState( const HepPlane3D &plane ) 00128 { 00129 double minDist = 999999999.; 00130 double dist; 00131 State* best = 0; 00132 for ( std::vector<State*>::iterator it = m_states.begin() ; 00133 m_states.end() != it; it++ ) { 00134 dist = plane.distance( ((*it) -> position()) ); 00135 if ( minDist > dist ) { 00136 minDist = dist; 00137 best = *it; 00138 } 00139 } 00140 if ( fabs( plane.distance(m_physicsState.position())) < minDist ) return m_physicsState; 00141 return *best; 00142 }; 00143 00144 //============================================================================= 00145 // Retrieve the (const) reference to the state closest to the given plane 00146 //============================================================================= 00147 const State & Track::closestState( const HepPlane3D &plane ) const 00148 { 00149 double minDist = 999999999.; 00150 double dist; 00151 State* best = 0; 00152 for ( std::vector<State*>::const_iterator it = m_states.begin() ; 00153 m_states.end() != it; it++ ) { 00154 dist = plane.distance( ((*it) -> position()) ); 00155 if ( minDist > dist ) { 00156 minDist = dist; 00157 best = *it; 00158 } 00159 } 00160 if ( fabs( plane.distance(m_physicsState.position()) ) < minDist ) 00161 return m_physicsState; 00162 00163 return *best; 00164 }; 00165 00166 //============================================================================= 00167 // check the existence of a state at a certain predefined location 00168 //============================================================================= 00169 bool Track::hasStateAt( const State::Location& value ) const 00170 { 00171 if ( NULL != stateAt(value) ) return true; 00172 return false; 00173 }; 00174 00175 //============================================================================= 00176 // Retrieve the pointer to the state closest to the given plane 00177 //============================================================================= 00178 State* Track::stateAt( const State::Location& value ) 00179 { 00180 for ( std::vector<State*>::iterator it = m_states.begin() ; 00181 m_states.end() != it; it++ ) { 00182 if ( (*it) -> checkLocation( value ) ) return (*it); 00183 } 00184 if (m_physicsState.checkLocation(value)) return &m_physicsState; 00185 return NULL; 00186 }; 00187 00188 //============================================================================= 00189 // Retrieve the (const) pointer to the state at a given location 00190 //============================================================================= 00191 const State* Track::stateAt( const State::Location& value ) const 00192 { 00193 for ( std::vector<State*>::const_iterator it = m_states.begin() ; 00194 m_states.end() != it; it++ ) { 00195 if ( (*it) -> checkLocation( value ) ) return (*it); 00196 } 00197 if (m_physicsState.checkLocation(value)) return &m_physicsState; 00198 return NULL; 00199 }; 00200 00201 //============================================================================= 00202 // Clone the track 00203 //============================================================================= 00204 Track* Track::clone() const 00205 { 00206 Track* tk = new Track(); 00207 *tk = *this; 00208 return tk; 00209 }; 00210 00211 //============================================================================= 00212 // Check whether the track was produced by a given algorithm 00213 //============================================================================= 00214 bool Track::producedByAlgo( const HistoryFlag& value ) const 00215 { 00216 unsigned int val = (unsigned int)value; 00217 return 0 != ( m_flags & historyMask & val ); 00218 }; 00219 00220 //============================================================================= 00221 // Update the name of the algorithm that produced the track 00222 //============================================================================= 00223 void Track::setProducedByAlgo( const HistoryFlag& value ) 00224 { 00225 unsigned int val = (unsigned int)value; 00226 m_flags &= ~historyMask; 00227 m_flags |= ((((unsigned int)val) << historyBits) & historyMask); 00228 }; 00229 00230 //============================================================================= 00231