Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | File Members

Track.cpp

Go to the documentation of this file.
00001 // $Id: $ // 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) of a track closest to the beam-line
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) of a track closest to the beam-line
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) of a track closest to the beam-line
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 of a track closest to the beam-line
00052 //=============================================================================
00053 double Track::p() const
00054 {
00055   return m_physicsState.p();
00056 };
00057 
00058 //=============================================================================
00059 // Retrieve the transverse momentum of a track closest to the beam-line
00060 //=============================================================================
00061 double Track::pt() const
00062 {
00063   return m_physicsState.pt();
00064 };
00065 
00066 //=============================================================================
00067 // Retrieve the momentum vector (+ errors) of a track closest to the beam-line
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)
00080 // of a track closest to the beam-line
00081 //=============================================================================
00082 StatusCode Track::posMomCovariance( HepSymMatrix &cov6D ) const
00083 {
00084   cov6D = m_physicsState.posMomCovariance();
00085 
00086   return StatusCode::SUCCESS;
00087 };
00088 
00089 //=============================================================================
00090 // Retrieve the pointer to the state closest to the given z-position
00091 //=============================================================================
00092 State* Track::closestState( double z )
00093 {
00094   double minDist = 999999999.;
00095   State* best = 0;
00096   for ( std::vector<State*>::iterator it = m_states.begin() ;
00097         m_states.end() != it; it++ ) {
00098     if ( minDist > fabs( z - (*it)->z() ) ) {
00099       minDist = fabs( z-(*it)->z() );
00100       best    = *it;
00101     }
00102   }
00103   return best;
00104 };
00105 
00106 //=============================================================================
00107 // Retrieve the (constant) pointer 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   return best;
00121 };
00122 
00123 //=============================================================================
00124 // Retrieve the pointer to the state closest to the given plane
00125 //=============================================================================
00126 State* Track::closestState( HepPlane3D &plane )
00127 {
00128   double minDist = 999999999.;
00129   double dist;
00130   State* best = 0;
00131   for ( std::vector<State*>::iterator it = m_states.begin() ;
00132         m_states.end() != it; it++ ) {
00133     dist = plane.distance( ((*it) -> position()) );
00134     if ( minDist > dist ) {
00135       minDist = dist;
00136       best    = *it;
00137     }
00138   }
00139   return best;
00140 };
00141 
00142 //=============================================================================
00143 // Retrieve the (constant) pointer to the state closest to the given plane
00144 //=============================================================================
00145 const State* Track::closestState( HepPlane3D &plane ) const
00146 {
00147   double minDist = 999999999.;
00148   double dist;
00149   State* best = 0;
00150   for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00151         m_states.end() != it; it++ ) {
00152     dist = plane.distance( ((*it) -> position()) );
00153     if ( minDist > dist ) {
00154       minDist = dist;
00155       best    = *it;
00156     }
00157   }
00158   return best;
00159 };
00160 
00161 //=============================================================================
00162 // Retrieve the pointer to the state closest to the given plane
00163 //=============================================================================
00164 State* Track::stateAt( const State::Location& value )
00165 {
00166   for ( std::vector<State*>::iterator it = m_states.begin() ;
00167         m_states.end() != it; it++ ) {
00168     if ( (*it) -> checkLocation( value ) ) return (*it);
00169   }
00170   return NULL;
00171 };
00172 
00173 //=============================================================================
00174 // Retrieve the (constant) pointer to the state closest to the given plane
00175 //=============================================================================
00176 const State* Track::stateAt( const State::Location& value ) const
00177 {
00178   for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00179         m_states.end() != it; it++ ) {
00180     if ( (*it) -> checkLocation( value ) ) return (*it);
00181   }
00182   return NULL;
00183 };
00184 
00185 //=============================================================================
00186 // Clone the track
00187 //=============================================================================
00188 Track* Track::clone() const
00189 {
00190   Track* tk = new Track();
00191   *tk = *this;
00192   return tk;
00193 };
00194 
00195 //=============================================================================
00196 // Check whether the track was produced by a given algorithm
00197 //=============================================================================
00198 bool Track::producedByAlgo( const HistoryFlag& value ) const
00199 {
00200   unsigned int val = (unsigned int)value;
00201   return 0 != ( m_flags & historyMask & val );
00202 };
00203 
00204 //=============================================================================
00205 // Update the name of the algorithm that produced the track
00206 //=============================================================================
00207 void Track::setProducedByAlgo( const HistoryFlag& value )
00208 {
00209   unsigned int val = (unsigned int)value;
00210   m_flags &= ~historyMask;
00211   m_flags |= ((((unsigned int)val) << historyBits) & historyMask);
00212 };
00213 
00214 //=============================================================================
00215 

Generated on Tue Dec 14 22:00:36 2004 for New Track Event Model by doxygen 1.3.5