00001
00002
00003
00004
00005
00006 #include "GaudiKernel/ToolFactory.h"
00007
00008
00009 #include "Event/TrackParameters.h"
00010 #include "Event/State.h"
00011
00012
00013 #include "CLHEP/Units/PhysicalConstants.h"
00014
00015
00016 #include "TrackPtKick.h"
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 static const ToolFactory<TrackPtKick> s_factory ;
00027 const IToolFactory& TrackPtKickFactory = s_factory ;
00028
00029
00030
00031
00032
00033 TrackPtKick::TrackPtKick( const std::string& type,
00034 const std::string& name,
00035 const IInterface* parent )
00036 : GaudiTool ( type, name , parent )
00037 , m_bIntegrator(0)
00038 , m_FieldPolarity(1)
00039
00040 {
00041 declareInterface<ITrackPtKick>(this);
00042
00043 declareProperty( "MomentumError", m_MomentumError = 0.01);
00044 declareProperty( "ParabolicCorrection", m_ParabolicCorrection );
00045 declareProperty( "ConstantCorrection", m_Constant = 0.*MeV );
00046
00047 m_ParabolicCorrection.push_back( -0.0092 );
00048 m_ParabolicCorrection.push_back( 0.0 );
00049 m_ParabolicCorrection.push_back( -0.112 );
00050
00051 }
00052
00053
00054
00055 TrackPtKick::~TrackPtKick() {};
00056
00057
00058
00059
00060 StatusCode TrackPtKick::initialize()
00061 {
00062 StatusCode sc = GaudiTool::initialize();
00063 if (sc.isFailure()) return sc;
00064
00065 m_bIntegrator = tool<IBIntegrator>( "IBIntegrator" );
00066
00067 info() << " Pt kick parameters(" << m_ParabolicCorrection.size()
00068 << ") ==" <<m_ParabolicCorrection[0] << " + "
00069 << m_ParabolicCorrection[1]<<" tx + "
00070 << m_ParabolicCorrection[2] <<" tx^2 " <<endreq;
00071
00072 determineFieldPolarity();
00073
00074 return StatusCode::SUCCESS;
00075 }
00076
00077
00078
00079
00080 StatusCode TrackPtKick::calculate( State* state ) const
00081 {
00082
00083
00084
00085 StatusCode sc = StatusCode::SUCCESS;
00086
00087
00088 HepPoint3D begin( 0., 0., 0. );
00089 HepPoint3D end( state->x(), state->y(), state->z() );
00090 HepVector3D bdl;
00091 double zCenter;
00092
00093 m_bIntegrator -> calculateBdlAndCenter( begin, end, state->tx(),
00094 state->ty(), zCenter, bdl );
00095 double q = 0.;
00096 double p = 1e6 * MeV;
00097
00098 if ( fabs(bdl[0]) > TrackParameters::hiTolerance ) {
00099
00100
00101
00102 double tX = state -> tx();
00103 double xCenter = state -> x() + tX * ( zCenter - state->z() );
00104
00105 double zeta_trk = -tX / sqrt( 1.0 + tX*tX );
00106 double tx_vtx = xCenter / zCenter;
00107 double zeta_vtx = -tx_vtx/ sqrt( 1.0 + tx_vtx*tx_vtx );
00108
00109
00110 double curv = ( zeta_trk - zeta_vtx );
00111
00112
00113 int sign = 1;
00114 if(curv< TrackParameters::hiTolerance ) {
00115 sign *= -1;
00116 }
00117 if ( bdl[0] < TrackParameters::hiTolerance ) {
00118 sign *= -1;
00119 }
00120 q = -1. * m_FieldPolarity*sign;
00121
00122
00123 p = eplus * c_light *fabs(bdl[0])
00124 * sqrt((1.0 +tX*tX+pow(state->ty(),2.))
00125 /(1.0 +pow(tX,2.)))/fabs(curv);
00126
00127
00128 if ( m_ParabolicCorrection.size() == 3 ) {
00129 double tx = (float) state -> tx();
00130
00131 p+= m_Constant;
00132 p*= ( 1 - ( m_ParabolicCorrection[0]
00133 + m_ParabolicCorrection[1] * fabs(tx)
00134 + m_ParabolicCorrection[2] * tx * tx ) );
00135 }
00136
00137 }
00138 else {
00139
00140 error() << "B integral is 0!" << endreq;
00141 sc = StatusCode::FAILURE;
00142 }
00143
00144
00145 state -> setQOverP( q / p );
00146
00147 HepSymMatrix& cov = state -> covariance();
00148 double errQOverP = m_MomentumError / p;
00149 cov.fast(5,5) = errQOverP * errQOverP;
00150
00151 return sc;
00152 }
00153
00154
00155
00156
00157 void TrackPtKick::determineFieldPolarity()
00158 {
00159
00160 HepPoint3D begin( 0., 0., 0. );
00161 HepPoint3D end( 0., 0., 100. );
00162 HepVector3D bdl;
00163 double z;
00164
00165 m_bIntegrator -> calculateBdlAndCenter( begin, end, 0., 0., z, bdl );
00166
00167 if ( bdl[0] > 0.0 ) {
00168 m_FieldPolarity = 1;
00169 }
00170 else {
00171 m_FieldPolarity = -1;
00172 }
00173
00174 }
00175
00176