00001
00002
00003
00004
00005 #include "Event/State.h"
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 State::State() {
00017 setType( State::HasMomentum );
00018 m_z = 0.;
00019 m_state = HepVector(5,0);
00020 m_covariance = HepSymMatrix(5,0);
00021 }
00022
00023
00024
00025
00026 double State::qOverP() const
00027 {
00028 return m_state[4];
00029 };
00030
00031
00032
00033
00034 double State::p() const
00035 {
00036 if ( m_state[4] != 0. ) return fabs( 1./m_state[4] );
00037 return 0.;
00038 };
00039
00040
00041
00042
00043 double State::pt() const
00044 {
00045 if ( m_state[4] != 0. ) {
00046 double txy2 = m_state[2]*m_state[2] + m_state[3]*m_state[3];
00047 return sqrt( txy2/(1.+txy2) ) / fabs( m_state[4] );
00048 }
00049 return 0.;
00050 };
00051
00052
00053
00054
00055 HepSymMatrix State::posMomCovariance() const
00056 {
00057 HepSymMatrix cov = covariance();
00058
00059
00060 return cov;
00061 };
00062
00063
00064
00065
00066 double State::errQOverP2() const
00067 {
00068 return m_covariance.fast(5,5);
00069 };
00070
00071
00072
00073
00074 double State::errP2() const
00075 {
00076 if ( m_state[4] != 0. ) return errQOverP2() / pow( m_state[4], 4. );
00077 return 0.;
00078 };
00079
00080
00081
00082
00083 HepSymMatrix State::errMomentum() const
00084 {
00085 if ( checkType( State::HasMomentum ) ) {
00086 return posMomCovariance().sub(4,6);
00087 }
00088 else {
00089 return HepSymMatrix(3,0);
00090 }
00091 };
00092
00093
00094
00095
00096 double State::errQOverPperp2() const
00097 {
00098 double tx2 = tx() * tx();
00099 double ty2 = ty() * ty();
00100 double qOverP2 = qOverP() * qOverP();
00101 double transSlope = 1. + tx2;
00102 double norm = 1 + tx2 + ty2;
00103
00104 double QOverPperpError = ( (norm/transSlope) * m_covariance[4][4] )
00105
00106 + ( qOverP2 * tx2 * ty2*ty2 * m_covariance[2][2]/
00107 (pow(transSlope,3.)*norm))
00108
00109 + ( qOverP2 * ty2 * m_covariance[3][3] / (norm*transSlope) )
00110
00111 - ( 2. * qOverP() * tx() * ty2 * m_covariance[2][4]
00112 / ( transSlope*transSlope ) )
00113
00114 + 2. * qOverP() * ty() * m_covariance[3][4] / transSlope
00115
00116 - 2. * ( qOverP2 * tx() * ty() * ty2 * m_covariance[2][3]
00117 / ( norm* transSlope*transSlope ) );
00118
00119 return QOverPperpError;
00120 };
00121
00122
00123
00124
00125 State* State::clone() const
00126 {
00127 return new State(*this);
00128 };
00129
00130
00131
00132
00133 void State::reset()
00134 {
00135 m_z = 0.;
00136 m_state = HepVector(5,0);
00137 m_covariance = HepSymMatrix(5,0);
00138 };
00139
00140
00141
00142
00143 void State::setState( double x, double y, double z,
00144 double tx, double ty,
00145 double qOverP )
00146 {
00147 m_state[0] = x;
00148 m_state[1] = y;
00149 m_state[2] = tx;
00150 m_state[3] = ty;
00151 m_z = z;
00152 if ( checkType( State::StraightLine ) ) {
00153 std::cerr
00154 << "ERROR You're trying to set the Q/P value for a state of type State::StraightLine!"
00155 << "ERROR This value will be discarded." << std::endl;
00156 }
00157 else {
00158 m_state[4] = qOverP;
00159 }
00160 };
00161
00162
00163
00164
00165 void State::setQOverP( double value )
00166 {
00167 m_state[4] = value;
00168 };
00169
00170
00171
00172
00173 void State::setType( const Type& value)
00174 {
00175 unsigned int val = (unsigned int)value;
00176 m_flags &= ~typeMask;
00177 m_flags |= ((((unsigned int)val) << typeBits) & typeMask);
00178 };
00179
00180