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 {
00056   // get reference to the TrState vector and covariance
00057   HepVector& tX = state -> state();
00058   HepSymMatrix& tC = state -> covariance();
00059 
00060   // calculate new state
00061   tX = m_F * tX; // X*F  (can this be done more efficiently?)
00062   tC = tC.similarity(m_F); // F*C*F.T()
00063 }
00064 
00065 //=============================================================================
00066 // Propagate a TrState to a given z-position
00067 //=============================================================================
00068 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00069                                             double zNew,
00070                                             ParticleID& partId ) {
00071 
00072   // check for state
00073   if ( !state ) {
00074      return Error( "propagate() should be called with a pointer to a TrState !",
00075                    StatusCode::FAILURE);
00076   }
00077 
00078   // create transport matrix
00079   m_F = HepMatrix(5, 5, 1);
00080 
00081   // check current z-position
00082   double dz = zNew - state -> z();
00083   if ( fabs(dz) > TrGeneral::hiTolerance ) {
00084     m_F[0][2] = dz; // tx*dz
00085     m_F[1][3] = dz; // ty*dz
00086     // extrapolate
00087     extrapolate(state);
00088     state -> setZ( zNew );
00089   }
00090   
00091   return StatusCode::SUCCESS;
00092 }
00093 
00094 //=============================================================================
00095 // Propagate a TrState to the intersection point with a given plane
00096 //=============================================================================
00097 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00098                                             HepPlane3D& plane,
00099                                             ParticleID& partId ) {
00100 
00101   // check the state
00102   if ( !state ) {
00103      return Error( "propagate() should be called with a pointer to a TrState !",
00104                    StatusCode::FAILURE);
00105   }
00106 
00107   // calculation of the z-position by linear extrapolation to the plane
00108   // ------------------------------------------------------------------
00109   // given the plane defined by (a,b,c,d) and the input state of
00110   // position (x0,y0,z0) and slopes (Tx,Ty),
00111   // the (x,y,z) of the intersection point verify the set of equations
00112   //    a*x + b*y + c*z + d = 0
00113   //    x = x0 + (z-z0)*Tx
00114   //    x = y0 + (z-z0)*Ty
00115   HepNormal3D nVec   = plane -> normal();
00116   HepPoint3D  posVec = state -> position();
00117   HepVector3D slpVec = state -> slopes();
00118 
00119   double den = nVec.dot( slpVec );
00120 
00121   if ( den != 0 ) {
00122     slpVec *= ( state -> z() );
00123     posVec -= slpVec;
00124 
00125     double nom = - ( nVec.dot( posVec ) + plane -> d() );
00126 
00127     double zNew = nom / den;
00128 
00129     return propagate( state, zNew, partId );
00130   {
00131   else {
00132     return StatusCode::FAILURE;
00133   }
00134 }
00135 
00136 //=============================================================================
00137 // Get reference to last used transport matrix.
00138 //=============================================================================
00139 const HepMatrix& TrLinearExtrapolator::transportMatrix() const {
00140   return m_F;
00141 }

Generated on Tue Dec 7 10:30:18 2004 for New Track Event Model by doxygen 1.2.14 written by Dimitri van Heesch, © 1997-2002