Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TrLinearExtrapolator.cpp

Go to the documentation of this file.
00001 
00002 // Gaudi
00003 #include "GaudiKernel/ToolFactory.h"
00004 
00005 // TrEvent
00006 #include "Event/TrState.h"
00007 #include "Event/TrGeneral.h"
00008 
00009 // local
00010 #include "TrLinearExtrapolator.h"
00011 
00012 // Needed for the creation of TrLinearExtrapolator objects.
00013 static const ToolFactory<TrLinearExtrapolator> s_factory;
00014 const IToolFactory& TrLinearExtrapolatorFactory = s_factory;
00015 
00029 
00030 TrLinearExtrapolator::TrLinearExtrapolator(const std::string& type,
00031                                            const std::string& name,
00032                                            const IInterface* parent):
00033   GaudiTool(type, name, parent),
00034   m_F()
00035 {
00036   declareInterface<ITrExtrapolator>( this );
00037 
00038   // create transport matrix
00039   m_F = HepMatrix(5, 5, 1);
00040 
00041 }
00042 
00043 //=============================================================================
00044 // TrLinearExtrapolator destructor.
00045 //=============================================================================
00046 TrLinearExtrapolator::~TrLinearExtrapolator()
00047 {
00048 }
00049 
00050 //=============================================================================
00051 // Extrapolate the TrState to z=zNew using the transport matrix  m_F
00052 // (i.e. it performs the mathematical calculation)
00053 //=============================================================================
00054 void TrLinearExtrapolator::extrapolate(TrState* state) const {
00055   // get reference to the TrState vector and covariance
00056   HepVector& tX = state -> state();
00057   HepSymMatrix& tC = state -> covariance();
00058 
00059   // calculate new state
00060   tX = m_F * tX; // X*F  (can this be done more efficient?)
00061   tC = tC.similarity(m_F); // F*C*F.T()
00062 }
00063 
00064 //=============================================================================
00065 // Propagate a TrState closest to the beam-line
00066 //=============================================================================
00067 StatusCode TrLinearExtrapolator::propagate( TrState* state, 
00068                                             ParticleID partId ) {
00069 
00070   // check for state
00071   if ( !state ) {
00072      return Error( "propagate() should be called with a pointer to a TrState !",
00073                    StatusCode::FAILURE);
00074   }
00075 
00076 // to a linear approximation the z-position of the closest approach
00077 // to the beam line is given by:
00078 //   zNew = state -> z() - ( x*tx + y*ty ) / ( tx*tx + ty*ty );
00079   HepVector stateVec = state -> state();
00080   double zNew = state -> z();
00081   // the zNew is unchanged if the track is parallel to the beam-line!
00082   if ( (stateVec[2] != 0) || (stateVec[3] != 0) ) {
00083     zNew -=   ( stateVec[0]*stateVec[2] + stateVec[1]*stateVec[3] )
00084             / ( stateVec[2]*stateVec[2] + stateVec[3]*stateVec[3] );
00085   }
00086   return propagate( state, zNew, partId );
00087 }
00088 
00089 //=============================================================================
00090 // Propagate a TrState to a given z-position
00091 //=============================================================================
00092 StatusCode TrLinearExtrapolator::propagate( TrState* state, 
00093                                             double zNew,
00094                                             ParticleID partId ) {
00095 
00096   // check for state
00097   if ( !state ) {
00098      return Error( "propagate() should be called with a pointer to a TrState !",
00099                    StatusCode::FAILURE);
00100   }
00101 
00102   // create transport matrix
00103   m_F = HepMatrix(5, 5, 1);
00104 
00105   // check current z-position
00106   double dz = zNew - state -> z();
00107   if ( fabs(dz) > TrGeneral::hiTolerance ) {
00108     m_F[0][2] = dz; // tx*dz
00109     m_F[1][3] = dz; // ty*dz
00110     // extrapolate
00111     extrapolate(state);
00112     state -> setZ( zNew );
00113   }
00114   
00115   return StatusCode::SUCCESS;
00116 }
00117 
00118 //=============================================================================
00119 // Propagate a TrState to the intersection point with a given plane
00120 //=============================================================================
00121 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00122                                             HepPlane3D plane,
00123                                             ParticleID partId ) {
00124 
00125   // check for state
00126   if ( !state ) {
00127      return Error( "propagate() should be called with a pointer to a TrState !",
00128                    StatusCode::FAILURE);
00129   }
00130 
00131   // calculation of the z-position by linear extrapolation to the plane
00132   // ------------------------------------------------------------------
00133   // given the plane defined by (a,b,c,d) and the input state of position (x0,y0,z0)
00134   // and slopes (Tx,Ty), the (x,y,z) of the intersection point verify the set of equations
00135   //    a*x + b*y + c*z + d = 0
00136   //    x = x0 + (z-z0)*Tx
00137   //    x = y0 + (z-z0)*Ty
00138   HepNormal3D nVec   = plane -> normal();
00139   HepPoint3D  posVec = state -> position();
00140   HepVector3D slpVec = state -> slopes();
00141 
00142   double den = nVec.dot( slpVec );
00143 
00144   if ( den != 0 ) {
00145     slpVec *= ( state -> z() );
00146     posVec -= slpVec;
00147 
00148     double nom = - ( nVec.dot( posVec ) + plane -> d() );
00149 
00150     double zNew = nom / den;
00151 
00152     return propagate( state, zNew, partId );
00153   {
00154   else {
00155     return StatusCode::FAILURE;
00156   }
00157 }
00158 
00159 //=============================================================================
00160 // Get reference to last used transport matrix.
00161 //=============================================================================
00162 const HepMatrix& TrLinearExtrapolator::transportMatrix() const {
00163   return m_F;
00164 }

Generated on Mon Nov 1 17:29:45 2004 for New Track Event Model by doxygen 1.2.14 written by Dimitri van Heesch, © 1997-2002