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

FitTrack.cpp

Go to the documentation of this file.
00001 // $Id: FitTrack.cpp,v 1.1.1.1 2005/04/07 20:24:28 erodrigu Exp $
00002 // Include files
00003 // -------------
00004 
00005 // local
00006 #include "Event/FitTrack.h"
00007 #include "Event/MeasurementFunctor.h"
00008 
00009 //-----------------------------------------------------------------------------
00010 // Implementation file for class : FitTrack
00011 //
00012 // 2005-04-05 : Eduardo Rodrigues
00013 //-----------------------------------------------------------------------------
00014 
00015 //=============================================================================
00016 // Sort the measurements by increasing z
00017 //=============================================================================
00018 void FitTrack::sortMeasurements() {
00019   std::sort( m_measurements.begin(),
00020              m_measurements.end(),
00021              MeasurementFunctor::increasingByZ() );
00022 };
00023 
00024 //=============================================================================
00025 // Retrieve the reference to the state closest to the given z-position
00026 //=============================================================================
00027 State & FitTrack::closestState( double z )
00028 {
00029   double minDist = 999999999.;
00030   State* best = 0;
00031   for ( std::vector<State*>::iterator it = m_states.begin() ;
00032         m_states.end() != it; it++ ) {
00033     if ( minDist > fabs( z - (*it)->z() ) ) {
00034       minDist = fabs( z-(*it)->z() );
00035       best    = *it;
00036     }
00037   }
00038   if ( fabs(z - m_physicsState.z()) < minDist ) return m_physicsState;
00039   return *best;
00040 };
00041 
00042 //=============================================================================
00043 // Retrieve the (const) reference to the state closest to the given z-position
00044 //=============================================================================
00045 const State & FitTrack::closestState( double z ) const
00046 {
00047   double minDist = 999999999.;
00048   State* best = 0;
00049   for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00050         m_states.end() != it; it++ ) {
00051     if ( minDist > fabs( z - (*it)->z() ) ) {
00052       minDist = fabs( z-(*it)->z() );
00053       best    = *it;
00054     }
00055   }
00056   if ( fabs(z - m_physicsState.z()) < minDist ) return m_physicsState;
00057   return *best;
00058 };
00059 
00060 //=============================================================================
00061 // Retrieve the reference to the state closest to the given plane
00062 //=============================================================================
00063 State & FitTrack::closestState( const HepPlane3D &plane )
00064 {
00065   double minDist = 999999999.;
00066   double dist;
00067   State* best = 0;
00068   for ( std::vector<State*>::iterator it = m_states.begin() ;
00069         m_states.end() != it; it++ ) {
00070     dist = plane.distance( ((*it) -> position()) );
00071     if ( minDist > dist ) {
00072       minDist = dist;
00073       best    = *it;
00074     }
00075   }
00076   if ( fabs( plane.distance(m_physicsState.position())) < minDist ) return m_physicsState;
00077   return *best;
00078 };
00079 
00080 //=============================================================================
00081 // Retrieve the (const) reference to the state closest to the given plane
00082 //=============================================================================
00083 const State & FitTrack::closestState( const HepPlane3D &plane ) const
00084 {
00085   double minDist = 999999999.;
00086   double dist;
00087   State* best = 0;
00088   for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00089         m_states.end() != it; it++ ) {
00090     dist = plane.distance( ((*it) -> position()) );
00091     if ( minDist > dist ) {
00092       minDist = dist;
00093       best    = *it;
00094     }
00095   }
00096   if ( fabs( plane.distance(m_physicsState.position()) ) < minDist )
00097     return m_physicsState;
00098 
00099   return *best;
00100 };
00101 
00102 //=============================================================================
00103 // check the existence of a state at a certain predefined location
00104 //=============================================================================
00105 bool FitTrack::hasStateAt( const State::Location& value ) const
00106 {
00107   if ( NULL != stateAt(value) ) return true;
00108   return false;
00109 };
00110 
00111 //=============================================================================
00112 // Retrieve the pointer to the state closest to the given plane
00113 //=============================================================================
00114 State* FitTrack::stateAt( const State::Location& value )
00115 {
00116   for ( std::vector<State*>::iterator it = m_states.begin() ;
00117         m_states.end() != it; it++ ) {
00118     if ( (*it) -> checkLocation( value ) ) return (*it);
00119   }
00120   if  (m_physicsState.checkLocation(value)) return &m_physicsState;
00121   return NULL;
00122 };
00123 
00124 //=============================================================================
00125 // Retrieve the (const) pointer to the state at a given location
00126 //=============================================================================
00127 const State* FitTrack::stateAt( const State::Location& value ) const
00128 {
00129   for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00130         m_states.end() != it; it++ ) {
00131     if ( (*it) -> checkLocation( value ) ) return (*it);
00132   }
00133   if  (m_physicsState.checkLocation(value)) return &m_physicsState;
00134   return NULL;
00135 };
00136 
00137 //=============================================================================
00138 // Clone the track
00139 //=============================================================================
00140 FitTrack* FitTrack::clone() const
00141 {
00142 
00143 };
00144 
00145 //=============================================================================
00146 // Check whether the track was produced by a given algorithm
00147 //=============================================================================
00148 bool FitTrack::producedByAlgo( const HistoryFlag& value ) const
00149 {
00150   unsigned int val = (unsigned int)value;
00151   return 0 != ( m_flags & historyMask & val );
00152 };
00153 
00154 //=============================================================================
00155 // Update the name of the algorithm that produced the track
00156 //=============================================================================
00157 void FitTrack::setProducedByAlgo( const HistoryFlag& value )
00158 {
00159   unsigned int val = (unsigned int)value;
00160   m_flags &= ~historyMask;
00161   m_flags |= ((((unsigned int)val) << historyBits) & historyMask);
00162 };
00163 
00164 //=============================================================================

Generated on Thu Apr 7 22:43:26 2005 for New Track Event Model by doxygen 1.4.1