Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | File Members

State Class Reference

#include <State.h>

List of all members.

Public Types

enum  Type { HasMomentum = 1, StraightLine = 2 }
 enumeration for the state type More...

enum  Location {
  MostUpstream = 1, FirstMeasurement = 2, AtTT = 4, AtT = 8,
  BegRich1 = 16, EndRich1 = 32, BegRich2 = 64, EndRich2 = 128,
  Calo = 256, Muon = 512
}
 enumeration for the location of the state More...


Public Member Functions

 State ()
 Default constructor. State defined to be of type State::HasMomentum.

virtual ~State ()
 Default Destructor.

virtual const CLID & clID () const
unsigned int nParameters () const
 Retrieve the number of state parameters.

void positionAndMomentum (HepPoint3D &pos, HepVector3D &mom, HepSymMatrix &cov6D) const
 Retrieve the position and momentum vectors and the corresponding 6D covariance matrix (pos:1->3,mom:4-6) of the state.

HepPoint3D position () const
 Retrieve the 3D-position vector of the state.

double x () const
 Retrieve the x-position of the state.

double y () const
 Retrieve the y-position of the state.

double z () const
 Retrieve the z-position of the state.

HepVector3D slopes () const
 Retrieve the slopes (Tx=dx/dz,Ty=dy/dz,1.) of the state.

double tx () const
 Retrieve the Tx=dx/dz slope of the state.

double ty () const
 Retrieve the Ty=dy/dz slope of the state.

virtual double qOverP () const
 Retrieve the charge-over-momentum Q/P of the state.

virtual double p () const
 Retrieve the momentum of the state.

virtual double pt () const
 Retrieve the transverse momentum of the state.

HepVector3D momentum () const
 Retrieve the momentum vector of the state.

double qOverPperp () const
 Retrieve the Q/Pperp (ratio of the charge to the component of the momentum transverse to the magnetic field) of the state.

virtual HepSymMatrix posMomCovariance () const
 Retrieve the 6D covariance matrix (x,y,z,px,py,pz) of the state.

HepSymMatrix errPosition () const
 Retrieve the errors on the 3D-position vector of the state.

double errX2 () const
 Retrieve the squared error on the x-position of the state.

double errY2 () const
 Retrieve the squared error on the y-position of the state.

HepSymMatrix errSlopes () const
 Retrieve the errors on the slopes of the state.

double errTx2 () const
 Retrieve the squared error on the x-slope Tx=dx/dz of the state.

double errTy2 () const
 Retrieve the squared error on the y-slope Ty=dy/dz of the state.

virtual double errQOverP2 () const
 Retrieve the squared error on the charge-over-momentum Q/P of the state.

virtual double errP2 () const
 Retrieve the squared error on the momentum of the state.

virtual HepSymMatrix errMomentum () const
 Retrieve the errors on the momentum vector of the stateRetrieve the errors on the momentum vector of the state.

virtual double errQOverPperp2 () const
 Retrieve the squared error on the Q/Pperp of the state.

virtual Stateclone () const
 Clone the state.

virtual void reset ()
 Clear the state before re-using it.

void setState (const HepVector &state)
 Update the state vector.

virtual void setState (double x, double y, double z, double tx, double ty, double qOverP)
 Update the state vector (presumably of type State::HasMomentum).

void setState (double x, double y, double z, double tx, double ty)
 Update the state vector (presumably of type State::StraightLine).

void setCovariance (const HepSymMatrix &value)
 Update the state covariance.

void setX (double value)
 Update the x-position of the state.

void setY (double value)
 Update the y-position of the state.

void setZ (double value)
 Update the z-position of the state.

void setTx (double value)
 Update the Tx slope of the state.

void setTy (double value)
 Update the Ty slope of the state.

virtual void setQOverP (double value)
 Update the Q/P value of the state.

unsigned int flags () const
 Retrieve const the variety of state flags.

bool checkType (const Type &value) const
 Check state type.

void setLocation (const Location &value)
 Update state location.

bool checkLocation (const Location &value) const
 Check state location.

const HepVector & state () const
 Retrieve const the state vector.

HepVector & state ()
 Retrieve the state vector.

const HepSymMatrix & covariance () const
 Retrieve const the state covariance matrix (indexes 1,...,5 for x, y, tx, ty, Q/p).

HepSymMatrix & covariance ()
 Retrieve the state covariance matrix (indexes 1,...,5 for x, y, tx, ty, Q/p).


Static Public Member Functions

const CLID & classID ()

Protected Types

enum  flagsBits { typeBits = 0, locationBits = 2 }
 Offsets of bitfield flags. More...

enum  flagsMasks { typeMask = 0x3L, locationMask = 0xFFCL }
 Bitmasks for bitfield flags. More...


Protected Member Functions

void setType (const State::Type &value)
 Update the type of the state.


Protected Attributes

unsigned int m_flags
 the variety of state flags


Private Attributes

HepVector m_state
 the state vector

HepSymMatrix m_covariance
 the state covariance matrix (indexes 1,...,5 for x, y, tx, ty, Q/p)

double m_z
 the z-position of the state


Detailed Description

State is the base class of offline and online track states.

Author:
Jose Hernando, Eduardo Rodrigues created Tue Dec 14 20:58:18 2004

Definition at line 47 of file State.h.


Member Enumeration Documentation

enum State::flagsBits [protected]
 

Offsets of bitfield flags.

Enumeration values:
typeBits 
locationBits 

Definition at line 228 of file State.h.

00228                 {typeBits     = 0,
00229                  locationBits = 2};

enum State::flagsMasks [protected]
 

Bitmasks for bitfield flags.

Enumeration values:
typeMask 
locationMask 

Definition at line 232 of file State.h.

00232                  {typeMask     = 0x3L,
00233                   locationMask = 0xFFCL};

enum State::Location
 

enumeration for the location of the state

Enumeration values:
MostUpstream 
FirstMeasurement 
AtTT 
AtT 
BegRich1 
EndRich1 
BegRich2 
EndRich2 
Calo 
Muon 

Definition at line 55 of file State.h.

00055                { MostUpstream=1,
00056                  FirstMeasurement=2,
00057                  AtTT=4,
00058                  AtT=8,
00059                  BegRich1=16,
00060                  EndRich1=32,
00061                  BegRich2=64,
00062                  EndRich2=128,
00063                  Calo=256,
00064                  Muon=512 };

enum State::Type
 

enumeration for the state type

Enumeration values:
HasMomentum 
StraightLine 

Definition at line 52 of file State.h.

00052            { HasMomentum=1,
00053              StraightLine=2 };


Constructor & Destructor Documentation

State::State  ) 
 

Default constructor. State defined to be of type State::HasMomentum.

Definition at line 16 of file State.cpp.

References HasMomentum, m_covariance, m_state, m_z, and setType().

Referenced by clone().

00016              {
00017   setType( State::HasMomentum );
00018   m_z          = 0.;
00019   m_state      = HepVector(5,0);
00020   m_covariance = HepSymMatrix(5,0);
00021 }

virtual State::~State  )  [inline, virtual]
 

Default Destructor.

Definition at line 70 of file State.h.

00070 {}


Member Function Documentation

bool State::checkLocation const Location value  )  const [inline]
 

Check state location.

Definition at line 279 of file State.h.

References locationMask, and m_flags.

00280 {
00281   unsigned int val = (unsigned int)value;  return 0 != ( m_flags & locationMask & val );
00282 }

bool State::checkType const Type value  )  const [inline]
 

Check state type.

Definition at line 267 of file State.h.

References m_flags, and typeMask.

Referenced by errMomentum(), and setState().

00268 {
00269   unsigned int val = (unsigned int)value;  return 0 != ( m_flags & typeMask & val );
00270 }

const CLID & State::classID  )  [inline, static]
 

Definition at line 257 of file State.h.

References CLID_State.

Referenced by clID().

00258 {
00259   return CLID_State;
00260 }

const CLID & State::clID  )  const [inline, virtual]
 

Definition at line 252 of file State.h.

References classID().

00253 {
00254   return State::classID();
00255 }

State * State::clone  )  const [virtual]
 

Clone the state.

Definition at line 125 of file State.cpp.

References State().

00126 {
00127   return new State(*this);
00128 };

HepSymMatrix & State::covariance  )  [inline]
 

Retrieve the state covariance matrix (indexes 1,...,5 for x, y, tx, ty, Q/p).

Definition at line 299 of file State.h.

References m_covariance.

00300 {
00301   return m_covariance;
00302 }

const HepSymMatrix & State::covariance  )  const [inline]
 

Retrieve const the state covariance matrix (indexes 1,...,5 for x, y, tx, ty, Q/p).

Definition at line 294 of file State.h.

References m_covariance.

Referenced by posMomCovariance().

00295 {
00296   return m_covariance;
00297 }

HepSymMatrix State::errMomentum  )  const [virtual]
 

Retrieve the errors on the momentum vector of the stateRetrieve the errors on the momentum vector of the state.

Definition at line 83 of file State.cpp.

References checkType(), HasMomentum, and posMomCovariance().

Referenced by Track::momentum().

00084 {
00085   if ( checkType( State::HasMomentum ) ) {
00086     return posMomCovariance().sub(4,6);
00087   }
00088   else {
00089     return HepSymMatrix(3,0);
00090   }
00091 };

double State::errP2  )  const [virtual]
 

Retrieve the squared error on the momentum of the state.

Definition at line 74 of file State.cpp.

References errQOverP2(), and m_state.

00075 {
00076   if ( m_state[4] != 0. ) return errQOverP2() / pow( m_state[4], 4. );
00077   return 0.;
00078 };

HepSymMatrix State::errPosition  )  const [inline]
 

Retrieve the errors on the 3D-position vector of the state.

Definition at line 388 of file State.h.

References posMomCovariance().

Referenced by Track::position().

00389 {
00390 
00391   return posMomCovariance().sub(1,3);
00392         
00393 }

double State::errQOverP2  )  const [virtual]
 

Retrieve the squared error on the charge-over-momentum Q/P of the state.

Definition at line 66 of file State.cpp.

References m_covariance.

Referenced by errP2().

00067 {
00068   return m_covariance.fast(5,5);
00069 };

double State::errQOverPperp2  )  const [virtual]
 

Retrieve the squared error on the Q/Pperp of the state.

Definition at line 96 of file State.cpp.

References m_covariance, qOverP(), tx(), and ty().

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 };

HepSymMatrix State::errSlopes  )  const [inline]
 

Retrieve the errors on the slopes of the state.

Definition at line 409 of file State.h.

References m_covariance.

Referenced by Track::slopes().

00410 {
00411 
00412   HepSymMatrix err = m_covariance.sub(3,5);
00413   err.fast(2,1) = 0.;
00414   err.fast(3,1) = 0.;
00415   err.fast(3,2) = 0.;
00416   err.fast(3,3) = 0.;
00417   return err;
00418         
00419 }

double State::errTx2  )  const [inline]
 

Retrieve the squared error on the x-slope Tx=dx/dz of the state.

Definition at line 421 of file State.h.

References m_covariance.

00422 {
00423 
00424   return m_covariance.fast(3,3);
00425         
00426 }

double State::errTy2  )  const [inline]
 

Retrieve the squared error on the y-slope Ty=dy/dz of the state.

Definition at line 428 of file State.h.

References m_covariance.

00429 {
00430 
00431   return m_covariance.fast(4,4);
00432         
00433 }

double State::errX2  )  const [inline]
 

Retrieve the squared error on the x-position of the state.

Definition at line 395 of file State.h.

References m_covariance.

00396 {
00397 
00398   return m_covariance.fast(1,1);
00399         
00400 }

double State::errY2  )  const [inline]
 

Retrieve the squared error on the y-position of the state.

Definition at line 402 of file State.h.

References m_covariance.

00403 {
00404 
00405   return m_covariance.fast(2,2);
00406         
00407 }

unsigned int State::flags  )  const [inline]
 

Retrieve const the variety of state flags.

Definition at line 262 of file State.h.

References m_flags.

00263 {
00264   return m_flags;
00265 }

HepVector3D State::momentum  )  const [inline]
 

Retrieve the momentum vector of the state.

Definition at line 371 of file State.h.

References p(), and slopes().

Referenced by Track::momentum(), and positionAndMomentum().

00372 {
00373 
00374   HepVector3D mom = slopes();
00375   mom *= ( p() / mom.mag() );
00376   return mom;
00377         
00378 }

unsigned int State::nParameters  )  const [inline]
 

Retrieve the number of state parameters.

Definition at line 304 of file State.h.

References m_state.

Referenced by setCovariance().

00305 {
00306 
00307   return (unsigned int) m_state.num_row();
00308         
00309 }

double State::p  )  const [virtual]
 

Retrieve the momentum of the state.

Definition at line 34 of file State.cpp.

References m_state.

Referenced by momentum(), and Track::p().

00035 {
00036   if ( m_state[4] != 0. ) return fabs( 1./m_state[4] );
00037   return 0.;
00038 };

HepPoint3D State::position  )  const [inline]
 

Retrieve the 3D-position vector of the state.

Definition at line 322 of file State.h.

References m_state, and m_z.

Referenced by Track::position(), and positionAndMomentum().

00323 {
00324 
00325   return HepPoint3D( m_state[0], m_state[1], m_z );
00326         
00327 }

void State::positionAndMomentum HepPoint3D &  pos,
HepVector3D &  mom,
HepSymMatrix &  cov6D
const [inline]
 

Retrieve the position and momentum vectors and the corresponding 6D covariance matrix (pos:1->3,mom:4-6) of the state.

Definition at line 311 of file State.h.

References momentum(), position(), and posMomCovariance().

Referenced by Track::positionAndMomentum().

00314 {
00315 
00316   pos   = position();
00317   mom   = momentum();
00318   cov6D = posMomCovariance();
00319         
00320 }

HepSymMatrix State::posMomCovariance  )  const [virtual]
 

Retrieve the 6D covariance matrix (x,y,z,px,py,pz) of the state.

Definition at line 55 of file State.cpp.

References covariance().

Referenced by errMomentum(), errPosition(), positionAndMomentum(), and Track::posMomCovariance().

00056 {
00057   HepSymMatrix cov = covariance();
00058   // to be written ...
00059 
00060   return cov;  
00061 };

double State::pt  )  const [virtual]
 

Retrieve the transverse momentum of the state.

Definition at line 43 of file State.cpp.

References m_state.

Referenced by Track::pt().

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 };

double State::qOverP  )  const [virtual]
 

Retrieve the charge-over-momentum Q/P of the state.

Definition at line 26 of file State.cpp.

References m_state.

Referenced by Track::charge(), errQOverPperp2(), and qOverPperp().

00027 {
00028   return m_state[4];
00029 };

double State::qOverPperp  )  const [inline]
 

Retrieve the Q/Pperp (ratio of the charge to the component of the momentum transverse to the magnetic field) of the state.

Definition at line 380 of file State.h.

References qOverP(), tx(), and ty().

00381 {
00382 
00383   double tx2 = tx() * tx();
00384   return ( qOverP() * sqrt( (1.+ tx2 + ty()*ty()) / (1. + tx2 ) ) );
00385         
00386 }

void State::reset  )  [virtual]
 

Clear the state before re-using it.

Definition at line 133 of file State.cpp.

References m_covariance, m_state, and m_z.

Referenced by Track::reset().

00134 {
00135   m_z          = 0.;
00136   m_state      = HepVector(5,0);
00137   m_covariance = HepSymMatrix(5,0);
00138 };

void State::setCovariance const HepSymMatrix &  value  )  [inline]
 

Update the state covariance.

Definition at line 457 of file State.h.

References m_covariance, and nParameters().

00458 {
00459 
00460   if ( value.num_row() == (int) nParameters() ) {
00461     m_covariance = value;
00462   }
00463   else {
00464     std::cerr << "ERROR   The dimension of the covariance matrix does not match that of the state!"
00465               << "ERROR   Using the default covariance matrix." << std::endl;
00466     int dim = nParameters();
00467     m_covariance = HepSymMatrix(dim,0);
00468   }
00469         
00470 }

void State::setLocation const Location value  )  [inline]
 

Update state location.

Definition at line 272 of file State.h.

References locationBits, locationMask, and m_flags.

00273 {
00274   unsigned int val = (unsigned int)value;
00275   m_flags &= ~locationMask;
00276   m_flags |= ((((unsigned int)val) << locationBits) & locationMask);
00277 }

void State::setQOverP double  value  )  [virtual]
 

Update the Q/P value of the state.

Definition at line 165 of file State.cpp.

References m_state.

00166 {
00167   m_state[4] = value;
00168 };

void State::setState double  x,
double  y,
double  z,
double  tx,
double  ty
[inline]
 

Update the state vector (presumably of type State::StraightLine).

Definition at line 442 of file State.h.

References m_state, and m_z.

00447 {
00448 
00449   m_state[0] = x;
00450   m_state[1] = y;
00451   m_state[2] = tx;
00452   m_state[3] = ty;
00453   m_z        = z;
00454         
00455 }

void State::setState double  x,
double  y,
double  z,
double  tx,
double  ty,
double  qOverP
[virtual]
 

Update the state vector (presumably of type State::HasMomentum).

Definition at line 143 of file State.cpp.

References checkType(), m_state, m_z, and StraightLine.

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 };

void State::setState const HepVector &  state  )  [inline]
 

Update the state vector.

Definition at line 435 of file State.h.

References m_state.

00436 {
00437 
00438   m_state = state;
00439         
00440 }

void State::setTx double  value  )  [inline]
 

Update the Tx slope of the state.

Definition at line 493 of file State.h.

References m_state.

00494 {
00495 
00496   m_state[2] = value;
00497         
00498 }

void State::setTy double  value  )  [inline]
 

Update the Ty slope of the state.

Definition at line 500 of file State.h.

References m_state.

00501 {
00502 
00503   m_state[3] = value;
00504         
00505 }

void State::setType const State::Type value  )  [protected]
 

Update the type of the state.

Definition at line 173 of file State.cpp.

References m_flags, typeBits, and typeMask.

Referenced by State().

00174 {
00175   unsigned int val = (unsigned int)value;
00176   m_flags &= ~typeMask;
00177   m_flags |= ((((unsigned int)val) << typeBits) & typeMask);
00178 };

void State::setX double  value  )  [inline]
 

Update the x-position of the state.

Definition at line 472 of file State.h.

References m_state.

00473 {
00474 
00475   m_state[0] = value;
00476         
00477 }

void State::setY double  value  )  [inline]
 

Update the y-position of the state.

Definition at line 479 of file State.h.

References m_state.

00480 {
00481 
00482   m_state[1] = value;
00483         
00484 }

void State::setZ double  value  )  [inline]
 

Update the z-position of the state.

Definition at line 486 of file State.h.

References m_z.

00487 {
00488 
00489   m_z = value;
00490         
00491 }

HepVector3D State::slopes  )  const [inline]
 

Retrieve the slopes (Tx=dx/dz,Ty=dy/dz,1.) of the state.

Definition at line 350 of file State.h.

References m_state.

Referenced by momentum(), and Track::slopes().

00351 {
00352 
00353   return HepVector3D( m_state[2], m_state[3], 1.);
00354         
00355 }

HepVector & State::state  )  [inline]
 

Retrieve the state vector.

Definition at line 289 of file State.h.

References m_state.

00290 {
00291   return m_state;
00292 }

const HepVector & State::state  )  const [inline]
 

Retrieve const the state vector.

Definition at line 284 of file State.h.

References m_state.

00285 {
00286   return m_state;
00287 }

double State::tx  )  const [inline]
 

Retrieve the Tx=dx/dz slope of the state.

Definition at line 357 of file State.h.

References m_state.

Referenced by errQOverPperp2(), and qOverPperp().

00358 {
00359 
00360   return m_state[2];
00361         
00362 }

double State::ty  )  const [inline]
 

Retrieve the Ty=dy/dz slope of the state.

Definition at line 364 of file State.h.

References m_state.

Referenced by errQOverPperp2(), and qOverPperp().

00365 {
00366 
00367   return m_state[3];
00368         
00369 }

double State::x  )  const [inline]
 

Retrieve the x-position of the state.

Definition at line 329 of file State.h.

References m_state.

00330 {
00331 
00332   return m_state[0];
00333         
00334 }

double State::y  )  const [inline]
 

Retrieve the y-position of the state.

Definition at line 336 of file State.h.

References m_state.

00337 {
00338 
00339   return m_state[1];
00340         
00341 }

double State::z  )  const [inline]
 

Retrieve the z-position of the state.

Definition at line 343 of file State.h.

References m_z.

00344 {
00345 
00346   return m_z;
00347         
00348 }


Member Data Documentation

HepSymMatrix State::m_covariance [private]
 

the state covariance matrix (indexes 1,...,5 for x, y, tx, ty, Q/p)

Definition at line 241 of file State.h.

Referenced by covariance(), errQOverP2(), errQOverPperp2(), errSlopes(), errTx2(), errTy2(), errX2(), errY2(), reset(), setCovariance(), and State().

unsigned int State::m_flags [protected]
 

the variety of state flags

Definition at line 236 of file State.h.

Referenced by checkLocation(), checkType(), flags(), setLocation(), and setType().

HepVector State::m_state [private]
 

the state vector

Definition at line 240 of file State.h.

Referenced by errP2(), nParameters(), p(), position(), pt(), qOverP(), reset(), setQOverP(), setState(), setTx(), setTy(), setX(), setY(), slopes(), state(), State(), tx(), ty(), x(), and y().

double State::m_z [private]
 

the z-position of the state

Definition at line 242 of file State.h.

Referenced by position(), reset(), setState(), setZ(), State(), and z().


The documentation for this class was generated from the following files:
Generated on Tue Dec 14 22:00:36 2004 for New Track Event Model by doxygen 1.3.5