00001
00002
00003
00004 #include "Event/Track.h"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00028
00029 StatusCode Track::positionAndMomentum( HepPoint3D &pos,
00030 HepVector3D &mom ) const
00031 {
00032 m_physicsState.positionAndMomentum( pos, mom );
00033
00034 return StatusCode::SUCCESS;
00035 };
00036
00037
00038
00039
00040 StatusCode Track::position( HepPoint3D &pos,
00041 HepSymMatrix &errPos ) const
00042 {
00043 pos = m_physicsState.position();
00044 errPos = m_physicsState.errPosition();
00045
00046 return StatusCode::SUCCESS;
00047 };
00048
00049
00050
00051
00052 StatusCode Track::slopes( HepVector3D &slopes,
00053 HepSymMatrix &errSlopes ) const
00054 {
00055 slopes = m_physicsState.slopes();
00056 errSlopes = m_physicsState.errSlopes();
00057
00058 return StatusCode::SUCCESS;
00059 };
00060
00061
00062
00063
00064 double Track::p() const
00065 {
00066 return m_physicsState.p();
00067 };
00068
00069
00070
00071
00072 double Track::pt() const
00073 {
00074 return m_physicsState.pt();
00075 };
00076
00077
00078
00079
00080 StatusCode Track::momentum( HepVector3D &mom,
00081 HepSymMatrix &errMom ) const
00082 {
00083 mom = m_physicsState.momentum();
00084 errMom = m_physicsState.errMomentum();
00085
00086 return StatusCode::SUCCESS;
00087 };
00088
00089
00090
00091
00092 StatusCode Track::posMomCovariance( HepSymMatrix &cov6D ) const
00093 {
00094 cov6D = m_physicsState.posMomCovariance();
00095
00096 return StatusCode::SUCCESS;
00097 };
00098
00099
00100
00101
00102 State & Track::closestState( double z )
00103 {
00104 double minDist = 999999999.;
00105 State* best = 0;
00106 for ( std::vector<State*>::iterator it = m_states.begin() ;
00107 m_states.end() != it; it++ ) {
00108 if ( minDist > fabs( z - (*it)->z() ) ) {
00109 minDist = fabs( z-(*it)->z() );
00110 best = *it;
00111 }
00112 }
00113 if ( fabs(z - m_physicsState.z()) < minDist ) return m_physicsState;
00114 return *best;
00115 };
00116
00117
00118
00119
00120 const State & Track::closestState( double z ) const
00121 {
00122 double minDist = 999999999.;
00123 State* best = 0;
00124 for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00125 m_states.end() != it; it++ ) {
00126 if ( minDist > fabs( z - (*it)->z() ) ) {
00127 minDist = fabs( z-(*it)->z() );
00128 best = *it;
00129 }
00130 }
00131 if ( fabs(z - m_physicsState.z()) < minDist ) return m_physicsState;
00132 return *best;
00133 };
00134
00135
00136
00137
00138 State & Track::closestState( const HepPlane3D &plane )
00139 {
00140 double minDist = 999999999.;
00141 double dist;
00142 State* best = 0;
00143 for ( std::vector<State*>::iterator it = m_states.begin() ;
00144 m_states.end() != it; it++ ) {
00145 dist = plane.distance( ((*it) -> position()) );
00146 if ( minDist > dist ) {
00147 minDist = dist;
00148 best = *it;
00149 }
00150 }
00151 if ( fabs( plane.distance(m_physicsState.position())) < minDist ) return m_physicsState;
00152 return *best;
00153 };
00154
00155
00156
00157
00158 const State & Track::closestState( const HepPlane3D &plane ) const
00159 {
00160 double minDist = 999999999.;
00161 double dist;
00162 State* best = 0;
00163 for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00164 m_states.end() != it; it++ ) {
00165 dist = plane.distance( ((*it) -> position()) );
00166 if ( minDist > dist ) {
00167 minDist = dist;
00168 best = *it;
00169 }
00170 }
00171 if ( fabs( plane.distance(m_physicsState.position()) ) < minDist )
00172 return m_physicsState;
00173
00174 return *best;
00175 };
00176
00177
00178
00179
00180 bool Track::hasStateAt( const State::Location& value ) const
00181 {
00182 if ( NULL != stateAt(value) ) return true;
00183 return false;
00184 };
00185
00186
00187
00188
00189 State* Track::stateAt( const State::Location& value )
00190 {
00191 for ( std::vector<State*>::iterator it = m_states.begin() ;
00192 m_states.end() != it; it++ ) {
00193 if ( (*it) -> checkLocation( value ) ) return (*it);
00194 }
00195 if (m_physicsState.checkLocation(value)) return &m_physicsState;
00196 return NULL;
00197 };
00198
00199
00200
00201
00202 const State* Track::stateAt( const State::Location& value ) const
00203 {
00204 for ( std::vector<State*>::const_iterator it = m_states.begin() ;
00205 m_states.end() != it; it++ ) {
00206 if ( (*it) -> checkLocation( value ) ) return (*it);
00207 }
00208 if (m_physicsState.checkLocation(value)) return &m_physicsState;
00209 return NULL;
00210 };
00211
00212
00213
00214
00215 void Track::reset()
00216 {
00217
00218 m_chi2PerDoF = 0;
00219 m_nDoF = 0;
00220 m_flags = 0;
00221 m_physicsState.reset();
00222 m_lhcbIDs.clear();
00223 for (std::vector<State*>::iterator it = m_states.begin();
00224 it != m_states.end(); it++) delete *it;
00225 for (std::vector<Measurement*>::iterator it2 = m_measurements.begin();
00226 it2 != m_measurements.end(); it2++) delete *it2;
00227 for (std::vector<Node*>::iterator it3 = m_nodes.begin();
00228 it3 != m_nodes.end(); it3++) delete *it3;
00229 m_states.clear();
00230 m_measurements.clear();
00231 m_nodes.clear();
00232 m_ancestors.clear();
00233 };
00234
00235
00236
00237
00238 Track* Track::clone() const
00239 {
00240 Track* tr = new Track();
00241 tr->setChi2PerDoF(chi2PerDoF());
00242 tr->setNDoF(nDoF());
00243 tr->setFlags(flags());
00244 tr->setPhysicsState(physicsState());
00245 tr->setLhcbIDs(lhcbIDs());
00246 for (std::vector<State*>::const_iterator it = m_states.begin();
00247 it != m_states.end(); it++) tr->addToStates(*(*it));
00248 for (std::vector<Measurement*>::const_iterator it2 = m_measurements.begin();
00249 it2 != m_measurements.end(); it2++) tr->addToMeasurements(*(*it2));
00250 for (std::vector<Node*>::const_iterator it3 = m_nodes.begin();
00251 it3 != m_nodes.end(); it3++) tr->addToNodes( (*it3)->clone());
00252 for (std::vector<Track*>::const_iterator it4 = m_ancestors.begin();
00253 it4 != m_ancestors.end(); it4++) tr->addToAncestors( *(*it4) );
00254 return tr;
00255 };
00256
00257
00258
00259
00260 void Track::setHistory(unsigned int key )
00261 {
00262 m_flags &= ~historyMask;
00263 m_flags |= ((((unsigned int) key ) << historyBits) & historyMask);
00264 };
00265
00266 unsigned int Track::history() const
00267 {
00268 unsigned int val = ( m_flags & historyMask) >> historyBits;
00269 return val;
00270 };
00271
00272 void Track::setHistoryFit(unsigned int key )
00273 {
00274 m_flags &= ~historyFitMask;
00275 m_flags |= ((((unsigned int) key) << historyFitBits) & historyFitMask);
00276 };
00277
00278 unsigned int Track::historyFit() const
00279 {
00280 unsigned int val = ( m_flags & historyFitMask) >> historyFitBits;
00281 return val;
00282 };
00283
00284 void Track::setType(unsigned int key)
00285 {
00286 m_flags &= ~typeMask;
00287 m_flags |= ((((unsigned int) key) << typeBits) & typeMask);
00288 };
00289
00290 unsigned int Track::type() const
00291 {
00292 unsigned int val = ( m_flags & typeMask) >> typeBits;
00293 return val;
00294 }
00295
00296 void Track::setStatus(unsigned int key)
00297 {
00298 m_flags &= ~statusMask;
00299 m_flags |= ((((unsigned int) key) << statusBits) & statusMask);
00300 };
00301
00302 unsigned int Track::status() const
00303 {
00304 unsigned int val = ( m_flags & statusMask) >> statusBits;
00305 return val;
00306 }
00307
00308 void Track::setFlag(unsigned int flag, bool ok)
00309 {
00310 unsigned int val = (((unsigned int) flag) << flagBits) & flagMask;
00311 if (ok) m_flags |= val;
00312 else m_flags &= ~val;
00313 }
00314
00315 bool Track::checkFlag(unsigned int flag) const
00316 {
00317 unsigned int val = ((unsigned int) flag << flagBits);
00318 bool ok = (0 != ( m_flags & flagMask & val ));
00319 return ok;
00320 }
00321