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
00057 HepVector& tX = state -> state();
00058 HepSymMatrix& tC = state -> covariance();
00059
00060
00061 tX = m_F * tX;
00062 tC = tC.similarity(m_F);
00063 }
00064
00065
00066
00067
00068 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00069 double zNew,
00070 ParticleID& partId ) {
00071
00072
00073 if ( !state ) {
00074 return Error( "propagate() should be called with a pointer to a TrState !",
00075 StatusCode::FAILURE);
00076 }
00077
00078
00079 m_F = HepMatrix(5, 5, 1);
00080
00081
00082 double dz = zNew - state -> z();
00083 if ( fabs(dz) > TrGeneral::hiTolerance ) {
00084 m_F[0][2] = dz;
00085 m_F[1][3] = dz;
00086
00087 extrapolate(state);
00088 state -> setZ( zNew );
00089 }
00090
00091 return StatusCode::SUCCESS;
00092 }
00093
00094
00095
00096
00097 StatusCode TrLinearExtrapolator::propagate( TrState* state,
00098 HepPlane3D& plane,
00099 ParticleID& partId ) {
00100
00101
00102 if ( !state ) {
00103 return Error( "propagate() should be called with a pointer to a TrState !",
00104 StatusCode::FAILURE);
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
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
00138
00139 const HepMatrix& TrLinearExtrapolator::transportMatrix() const {
00140 return m_F;
00141 }