00001 // $Id: TrackLinearExtrapolator.cpp,v 1.3 2005/04/08 11:53:09 hernando Exp $ 00002 // Include files 00003 00004 // from Gaudi 00005 #include "GaudiKernel/ToolFactory.h" 00006 00007 // from TrEvent 00008 #include "Event/Track.h" 00009 #include "Event/State.h" 00010 #include "Event/TrackParameters.h" 00011 00012 // local 00013 #include "TrackLinearExtrapolator.h" 00014 00015 //----------------------------------------------------------------------------- 00016 // Implementation file for class : TrackLinearExtrapolator 00017 // 00018 // 2004-12-17 : Eduardo Rodrigues 00019 //----------------------------------------------------------------------------- 00020 00021 // Declaration of the Tool Factory 00022 static const ToolFactory<TrackLinearExtrapolator> s_factory ; 00023 const IToolFactory& TrackLinearExtrapolatorFactory = s_factory ; 00024 00025 //============================================================================= 00026 // Extrapolate the State to z=zNew using the transport matrix m_F 00027 // (i.e. it performs the mathematical calculation) 00028 //============================================================================= 00029 /* 00030 void TrackLinearExtrapolator::extrapolate( State* state ) const 00031 { 00032 // get reference to the State vector and covariance 00033 HepVector& tX = state -> state(); 00034 HepSymMatrix& tC = state -> covariance(); 00035 00036 // calculate new state 00037 tX = m_F * tX; // X * F 00038 tC = tC.similarity(m_F); // F * C *F.T() 00039 } 00040 */ 00041 00042 //============================================================================= 00043 // Propagate a State to a given z-position 00044 //============================================================================= 00045 StatusCode TrackLinearExtrapolator::propagate( State& state, 00046 double zNew, 00047 ParticleID pid ) 00048 { 00049 // create transport matrix 00050 unsigned int ndim = state.nParameters(); 00051 00052 m_F = HepMatrix(ndim, ndim, 1); 00053 00054 // check current z-position 00055 double dz = zNew - state.z(); 00056 // if ( fabs(dz) < TrackParameters::hiTolerance ) dz = 0.; 00057 m_F[0][2] = dz; // tx*dz 00058 m_F[1][3] = dz; // ty*dz 00059 info() << " F " << m_F << endreq; 00060 00061 // extrapolate 00062 //extrapolate(state); 00063 //state -> setZ( zNew ); 00064 updateState( state, zNew ); 00065 00066 debug() << " z propagation " << zNew 00067 << " propagated state " << state.state() 00068 << " propagated cov " << state.covariance() 00069 << " of particle pid " << pid.pid() << endreq; 00070 00071 return StatusCode::SUCCESS; 00072 } 00073 00074 //============================================================================= 00075 // Propagate a State to the intersection point with a given plane 00076 //============================================================================= 00077 StatusCode TrackLinearExtrapolator::propagate( State& state, 00078 HepPlane3D& plane, 00079 ParticleID pid ) 00080 { 00081 // calculation of the z-position by linear extrapolation to the plane 00082 // ------------------------------------------------------------------ 00083 // given the plane defined by (a,b,c,d) and the input state of 00084 // position (x0,y0,z0) and slopes (Tx,Ty), 00085 // the (x,y,z) of the intersection point verify the set of equations 00086 // a*x + b*y + c*z + d = 0 00087 // x = x0 + (z-z0)*Tx 00088 // x = y0 + (z-z0)*Ty 00089 HepNormal3D nVec = plane.normal(); 00090 HepPoint3D posVec = state.position(); 00091 HepVector3D slpVec = state.slopes(); 00092 00093 double den = nVec.dot( slpVec ); 00094 00095 if ( den < TrackParameters::looseTolerance ) return StatusCode::FAILURE; 00096 00097 slpVec *= ( state.z() ); 00098 posVec -= slpVec; 00099 00100 double nom = - ( nVec.dot( posVec ) + plane.d() ); 00101 00102 double zNew = nom / den; 00103 00104 debug() << " z propagation " << zNew 00105 << " of particle pid " << pid.pid() << endreq; 00106 00107 return propagate( state, zNew, pid ); 00108 } 00109 00110 //============================================================================= 00111 // Standard constructor, initializes variables 00112 //============================================================================= 00113 TrackLinearExtrapolator::TrackLinearExtrapolator(const std::string& type, 00114 const std::string& name, 00115 const IInterface* parent ) 00116 : TrackExtrapolator ( type, name, parent ) 00117 { 00118 //declareInterface<ITrackExtrapolator>( this ); 00119 } 00120 00121 //============================================================================= 00122 // Destructor 00123 //============================================================================= 00124 TrackLinearExtrapolator::~TrackLinearExtrapolator() {};