00001
00002
00003 #include "GaudiKernel/ToolFactory.h"
00004
00005
00006 #include "Event/TrState.h"
00007 #include "Event/TrGeneral.h"
00008
00009
00010 #include "TrLinearExtrapolator.h"
00011
00012
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
00039 m_F = HepMatrix(5, 5, 1);
00040
00041 }
00042
00043
00044
00045
00046 TrLinearExtrapolator::~TrLinearExtrapolator()
00047 {
00048 }
00049
00050
00051
00052
00053
00054 void TrLinearExtrapolator::extrapolate(TrState* state) const {
00055
00056 HepVector& tX = state -> state();
00057 HepSymMatrix& tC = state -> covariance();
00058
00059
00060 tX = m_F * tX;
00061 tC = tC.similarity(m_F);
00062 }
00063
00064
00065
00066
00067 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00068 ParticleID partId ) {
00069
00070
00071 if ( !state ) {
00072 return Error( "propagate() should be called with a pointer to a TrState !",
00073 StatusCode::FAILURE);
00074 }
00075
00076
00077
00078
00079 HepVector stateVec = state -> state();
00080 double zNew = state -> z();
00081
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
00091
00092 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00093 double zNew,
00094 ParticleID partId ) {
00095
00096
00097 if ( !state ) {
00098 return Error( "propagate() should be called with a pointer to a TrState !",
00099 StatusCode::FAILURE);
00100 }
00101
00102
00103 m_F = HepMatrix(5, 5, 1);
00104
00105
00106 double dz = zNew - state -> z();
00107 if ( fabs(dz) > TrGeneral::hiTolerance ) {
00108 m_F[0][2] = dz;
00109 m_F[1][3] = dz;
00110
00111 extrapolate(state);
00112 state -> setZ( zNew );
00113 }
00114
00115 return StatusCode::SUCCESS;
00116 }
00117
00118
00119
00120
00121 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00122 HepPlane3D plane,
00123 ParticleID partId ) {
00124
00125
00126 if ( !state ) {
00127 return Error( "propagate() should be called with a pointer to a TrState !",
00128 StatusCode::FAILURE);
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
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
00161
00162 const HepMatrix& TrLinearExtrapolator::transportMatrix() const {
00163 return m_F;
00164 }