Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TrState.cpp

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

Generated on Mon Nov 1 17:29:45 2004 for New Track Event Model by doxygen 1.2.14 written by Dimitri van Heesch, © 1997-2002