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

State.h

Go to the documentation of this file.
00001 
00002 //   **************************************************************************
00003 //   *                                                                        *
00004 //   *                      ! ! ! A T T E N T I O N ! ! !                     *
00005 //   *                                                                        *
00006 //   *  This file was created automatically by GaudiObjDesc, please do not    *
00007 //   *  delete it or edit it by hand.                                         *
00008 //   *                                                                        *
00009 //   *  If you want to change this file, first change the corresponding       *
00010 //   *  xml-file and rerun the tools from GaudiObjDesc (or run make if you    *
00011 //   *  are using it from inside a Gaudi-package).                            *
00012 //   *                                                                        *
00013 //   **************************************************************************
00014 
00015 #ifndef TrEvent_State_H
00016 #define TrEvent_State_H 1
00017 
00018 // Include files
00019 #include "Kernel/CLHEPStreams.h"
00020 #include "CLHEP/Geometry/Point3D.h"
00021 #include "CLHEP/Geometry/Vector3D.h"
00022 #include "GaudiKernel/KeyedContainer.h"
00023 #include "CLHEP/Matrix/Vector.h"
00024 #include "CLHEP/Matrix/SymMatrix.h"
00025 
00026 
00027 // Forward declarations
00028 
00029 // Class ID definition
00030 static const CLID& CLID_State = 10011;
00031 
00032 // Namespace for locations in TDS
00033 namespace StateLocation {
00034   static const std::string& Default = "Rec/Track/States";
00035 }
00036 
00037 
00047 class State
00048 {
00049 public:
00050 
00052   enum Type{ HasMomentum=1,
00053              StraightLine=2 };
00055   enum Location{ 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 };
00065 
00067   State();
00068 
00070   virtual ~State() {}
00071 
00072   // Retrieve pointer to class definition structure
00073   virtual const CLID& clID() const;
00074   static const CLID& classID();
00075 
00077   unsigned int nParameters() const;
00078 
00080   void positionAndMomentum(HepPoint3D& pos,
00081                            HepVector3D& mom,
00082                            HepSymMatrix& cov6D) const;
00083 
00085   HepPoint3D position() const;
00086 
00088   double x() const;
00089 
00091   double y() const;
00092 
00094   double z() const;
00095 
00097   HepVector3D slopes() const;
00098 
00100   double tx() const;
00101 
00103   double ty() const;
00104 
00106   virtual double qOverP() const;
00107 
00109   virtual double p() const;
00110 
00112   virtual double pt() const;
00113 
00115   HepVector3D momentum() const;
00116 
00118   double qOverPperp() const;
00119 
00121   virtual HepSymMatrix posMomCovariance() const;
00122 
00124   HepSymMatrix errPosition() const;
00125 
00127   double errX2() const;
00128 
00130   double errY2() const;
00131 
00133   HepSymMatrix errSlopes() const;
00134 
00136   double errTx2() const;
00137 
00139   double errTy2() const;
00140 
00142   virtual double errQOverP2() const;
00143 
00145   virtual double errP2() const;
00146 
00148   virtual HepSymMatrix errMomentum() const;
00149 
00151   virtual double errQOverPperp2() const;
00152 
00154   virtual State* clone() const;
00155 
00157   virtual void reset();
00158 
00160   void setState(const HepVector& state);
00161 
00163   virtual void setState(double x,
00164                         double y,
00165                         double z,
00166                         double tx,
00167                         double ty,
00168                         double qOverP);
00169 
00171   void setState(double x,
00172                 double y,
00173                 double z,
00174                 double tx,
00175                 double ty);
00176 
00178   void setCovariance(const HepSymMatrix& value);
00179 
00181   void setX(double value);
00182 
00184   void setY(double value);
00185 
00187   void setZ(double value);
00188 
00190   void setTx(double value);
00191 
00193   void setTy(double value);
00194 
00196   virtual void setQOverP(double value);
00197 
00199   unsigned int flags() const;
00200 
00202   bool checkType(const Type& value) const;
00203 
00205   void setLocation(const Location& value);
00206 
00208   bool checkLocation(const Location& value) const;
00209 
00211   const HepVector& state() const;
00212 
00214   HepVector& state();
00215 
00217   const HepSymMatrix& covariance() const;
00218 
00220   HepSymMatrix& covariance();
00221 
00222 protected:
00223 
00225   void setType(const State::Type& value);
00226 
00228   enum flagsBits{typeBits     = 0,
00229                  locationBits = 2};
00230 
00232   enum flagsMasks{typeMask     = 0x3L,
00233                   locationMask = 0xFFCL};
00234 
00235 
00236   unsigned int m_flags; 
00237 
00238 private:
00239 
00240   HepVector    m_state;      
00241   HepSymMatrix m_covariance; 
00242   double       m_z;          
00243 
00244 };
00245 
00246 // -----------------------------------------------------------------------------
00247 //   end of class
00248 // -----------------------------------------------------------------------------
00249 
00250 // Including forward declarations
00251 
00252 inline const CLID& State::clID() const
00253 {
00254   return State::classID();
00255 }
00256 
00257 inline const CLID& State::classID()
00258 {
00259   return CLID_State;
00260 }
00261 
00262 inline unsigned int State::flags() const 
00263 {
00264   return m_flags;
00265 }
00266 
00267 inline bool State::checkType(const Type& value) const
00268 {
00269   unsigned int val = (unsigned int)value;  return 0 != ( m_flags & typeMask & val );
00270 }
00271 
00272 inline void State::setLocation(const Location& value)
00273 {
00274   unsigned int val = (unsigned int)value;
00275   m_flags &= ~locationMask;
00276   m_flags |= ((((unsigned int)val) << locationBits) & locationMask);
00277 }
00278 
00279 inline bool State::checkLocation(const Location& value) const
00280 {
00281   unsigned int val = (unsigned int)value;  return 0 != ( m_flags & locationMask & val );
00282 }
00283 
00284 inline const HepVector& State::state() const 
00285 {
00286   return m_state;
00287 }
00288 
00289 inline HepVector& State::state() 
00290 {
00291   return m_state;
00292 }
00293 
00294 inline const HepSymMatrix& State::covariance() const 
00295 {
00296   return m_covariance;
00297 }
00298 
00299 inline HepSymMatrix& State::covariance() 
00300 {
00301   return m_covariance;
00302 }
00303 
00304 inline unsigned int State::nParameters() const 
00305 {
00306 
00307   return (unsigned int) m_state.num_row();
00308         
00309 }
00310 
00311 inline void State::positionAndMomentum(HepPoint3D& pos,
00312                                        HepVector3D& mom,
00313                                        HepSymMatrix& cov6D) const 
00314 {
00315 
00316   pos   = position();
00317   mom   = momentum();
00318   cov6D = posMomCovariance();
00319         
00320 }
00321 
00322 inline HepPoint3D State::position() const 
00323 {
00324 
00325   return HepPoint3D( m_state[0], m_state[1], m_z );
00326         
00327 }
00328 
00329 inline double State::x() const 
00330 {
00331 
00332   return m_state[0];
00333         
00334 }
00335 
00336 inline double State::y() const 
00337 {
00338 
00339   return m_state[1];
00340         
00341 }
00342 
00343 inline double State::z() const 
00344 {
00345 
00346   return m_z;
00347         
00348 }
00349 
00350 inline HepVector3D State::slopes() const 
00351 {
00352 
00353   return HepVector3D( m_state[2], m_state[3], 1.);
00354         
00355 }
00356 
00357 inline double State::tx() const 
00358 {
00359 
00360   return m_state[2];
00361         
00362 }
00363 
00364 inline double State::ty() const 
00365 {
00366 
00367   return m_state[3];
00368         
00369 }
00370 
00371 inline HepVector3D State::momentum() const 
00372 {
00373 
00374   HepVector3D mom = slopes();
00375   mom *= ( p() / mom.mag() );
00376   return mom;
00377         
00378 }
00379 
00380 inline double State::qOverPperp() const 
00381 {
00382 
00383   double tx2 = tx() * tx();
00384   return ( qOverP() * sqrt( (1.+ tx2 + ty()*ty()) / (1. + tx2 ) ) );
00385         
00386 }
00387 
00388 inline HepSymMatrix State::errPosition() const 
00389 {
00390 
00391   return posMomCovariance().sub(1,3);
00392         
00393 }
00394 
00395 inline double State::errX2() const 
00396 {
00397 
00398   return m_covariance.fast(1,1);
00399         
00400 }
00401 
00402 inline double State::errY2() const 
00403 {
00404 
00405   return m_covariance.fast(2,2);
00406         
00407 }
00408 
00409 inline HepSymMatrix State::errSlopes() const 
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 }
00420 
00421 inline double State::errTx2() const 
00422 {
00423 
00424   return m_covariance.fast(3,3);
00425         
00426 }
00427 
00428 inline double State::errTy2() const 
00429 {
00430 
00431   return m_covariance.fast(4,4);
00432         
00433 }
00434 
00435 inline void State::setState(const HepVector& state) 
00436 {
00437 
00438   m_state = state;
00439         
00440 }
00441 
00442 inline void State::setState(double x,
00443                             double y,
00444                             double z,
00445                             double tx,
00446                             double ty) 
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 }
00456 
00457 inline void State::setCovariance(const HepSymMatrix& value) 
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 }
00471 
00472 inline void State::setX(double value) 
00473 {
00474 
00475   m_state[0] = value;
00476         
00477 }
00478 
00479 inline void State::setY(double value) 
00480 {
00481 
00482   m_state[1] = value;
00483         
00484 }
00485 
00486 inline void State::setZ(double value) 
00487 {
00488 
00489   m_z = value;
00490         
00491 }
00492 
00493 inline void State::setTx(double value) 
00494 {
00495 
00496   m_state[2] = value;
00497         
00498 }
00499 
00500 inline void State::setTy(double value) 
00501 {
00502 
00503   m_state[3] = value;
00504         
00505 }
00506 
00507 // Definition of Keyed Container for State
00508 typedef KeyedContainer<State, Containers::HashMap> States;
00509 
00510 #endif 

Generated on Tue Dec 14 22:00:36 2004 for New Track Event Model by doxygen 1.3.5