Main Page | Namespace List | Class Hierarchy | Class List | Directories | 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 TrackEvent_State_H
00016 #define TrackEvent_State_H 1
00017 
00018 // Include files
00019 #include "GaudiKernel/GaudiException.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   State();
00053 
00055   virtual ~State() {}
00056 
00057   // Retrieve pointer to class definition structure
00058   virtual const CLID& clID() const;
00059   static const CLID& classID();
00060 
00062   unsigned int nParameters() const;
00063 
00065   void positionAndMomentum(HepPoint3D& pos,
00066                            HepVector3D& mom,
00067                            HepSymMatrix& cov6D) const;
00068 
00070   void positionAndMomentum(HepPoint3D& pos,
00071                            HepVector3D& mom) const;
00072 
00074   HepPoint3D position() const;
00075 
00077   double x() const;
00078 
00080   double y() const;
00081 
00083   double z() const;
00084 
00086   HepVector3D slopes() const;
00087 
00089   double tx() const;
00090 
00092   double ty() const;
00093 
00095   virtual double qOverP() const;
00096 
00098   virtual double p() const;
00099 
00101   virtual double pt() const;
00102 
00104   HepVector3D momentum() const;
00105 
00107   double qOverPperp() const;
00108 
00110   virtual HepSymMatrix posMomCovariance() const;
00111 
00113   HepSymMatrix errPosition() const;
00114 
00116   double errX2() const;
00117 
00119   double errY2() const;
00120 
00122   HepSymMatrix errSlopes() const;
00123 
00125   double errTx2() const;
00126 
00128   double errTy2() const;
00129 
00131   virtual double errQOverP2() const;
00132 
00134   virtual double errP2() const;
00135 
00137   virtual HepSymMatrix errMomentum() const;
00138 
00140   virtual double errQOverPperp2() const;
00141 
00143   virtual State* clone() const;
00144 
00146   void setState(const HepVector& state);
00147 
00149   virtual void setState(double x,
00150                         double y,
00151                         double z,
00152                         double tx,
00153                         double ty,
00154                         double qOverP);
00155 
00157   void setCovariance(const HepSymMatrix& value);
00158 
00160   void setX(double value);
00161 
00163   void setY(double value);
00164 
00166   void setZ(double value);
00167 
00169   void setTx(double value);
00170 
00172   void setTy(double value);
00173 
00175   virtual void setQOverP(double value);
00176 
00178   bool checkLocation(unsigned int value) const;
00179 
00181   unsigned int flags() const;
00182 
00184   void setFlags(unsigned int value);
00185 
00187   unsigned int location() const;
00188 
00190   void setLocation(unsigned int value);
00191 
00193   const HepVector& stateVector() const;
00194 
00196   HepVector& stateVector();
00197 
00199   const HepSymMatrix& covariance() const;
00200 
00202   HepSymMatrix& covariance();
00203 
00204 protected:
00205 
00207   enum flagsBits{locationBits = 0};
00208 
00210   enum flagsMasks{locationMask = 0xFFFFL};
00211 
00212 
00213   unsigned int m_flags;       
00214   HepVector    m_stateVector; 
00215   HepSymMatrix m_covariance;  
00216   double       m_z;           
00217 
00218 private:
00219 
00220 };
00221 
00222 // -----------------------------------------------------------------------------
00223 //   end of class
00224 // -----------------------------------------------------------------------------
00225 
00226 // Including forward declarations
00227 
00228 inline const CLID& State::clID() const
00229 {
00230   return State::classID();
00231 }
00232 
00233 inline const CLID& State::classID()
00234 {
00235   return CLID_State;
00236 }
00237 
00238 inline unsigned int State::flags() const 
00239 {
00240   return m_flags;
00241 }
00242 
00243 inline void State::setFlags(unsigned int value) 
00244 {
00245   m_flags = value;
00246 }
00247 
00248 inline unsigned int State::location() const
00249 {
00250   return (unsigned int)((m_flags & locationMask) >> locationBits);
00251 }
00252 
00253 inline void State::setLocation(unsigned int value)
00254 {
00255   unsigned int val = (unsigned int)value;
00256   m_flags &= ~locationMask;
00257   m_flags |= ((((unsigned int)val) << locationBits) & locationMask);
00258 }
00259 
00260 inline const HepVector& State::stateVector() const 
00261 {
00262   return m_stateVector;
00263 }
00264 
00265 inline HepVector& State::stateVector() 
00266 {
00267   return m_stateVector;
00268 }
00269 
00270 inline const HepSymMatrix& State::covariance() const 
00271 {
00272   return m_covariance;
00273 }
00274 
00275 inline HepSymMatrix& State::covariance() 
00276 {
00277   return m_covariance;
00278 }
00279 
00280 inline unsigned int State::nParameters() const 
00281 {
00282 
00283   return (unsigned int) m_stateVector.num_row();
00284         
00285 }
00286 
00287 inline void State::positionAndMomentum(HepPoint3D& pos,
00288                                        HepVector3D& mom,
00289                                        HepSymMatrix& cov6D) const 
00290 {
00291 
00292   pos   = position();
00293   mom   = momentum();
00294   cov6D = posMomCovariance();
00295         
00296 }
00297 
00298 inline void State::positionAndMomentum(HepPoint3D& pos,
00299                                        HepVector3D& mom) const 
00300 {
00301 
00302   pos   = position();
00303   mom   = momentum();
00304         
00305 }
00306 
00307 inline HepPoint3D State::position() const 
00308 {
00309 
00310   return HepPoint3D( m_stateVector[0], m_stateVector[1], m_z );
00311         
00312 }
00313 
00314 inline double State::x() const 
00315 {
00316 
00317   return m_stateVector[0];
00318         
00319 }
00320 
00321 inline double State::y() const 
00322 {
00323 
00324   return m_stateVector[1];
00325         
00326 }
00327 
00328 inline double State::z() const 
00329 {
00330 
00331   return m_z;
00332         
00333 }
00334 
00335 inline HepVector3D State::slopes() const 
00336 {
00337 
00338   return HepVector3D( m_stateVector[2], m_stateVector[3], 1.);
00339         
00340 }
00341 
00342 inline double State::tx() const 
00343 {
00344 
00345   return m_stateVector[2];
00346         
00347 }
00348 
00349 inline double State::ty() const 
00350 {
00351 
00352   return m_stateVector[3];
00353         
00354 }
00355 
00356 inline HepVector3D State::momentum() const 
00357 {
00358 
00359   HepVector3D mom = slopes();
00360   mom *= ( p() / mom.mag() );
00361   return mom;
00362         
00363 }
00364 
00365 inline double State::qOverPperp() const 
00366 {
00367 
00368   double tx2 = tx() * tx();
00369   return ( qOverP() * sqrt( (1.+ tx2 + ty()*ty()) / (1. + tx2 ) ) );
00370         
00371 }
00372 
00373 inline HepSymMatrix State::errPosition() const 
00374 {
00375 
00376   const HepSymMatrix temp = posMomCovariance();
00377   return temp.sub(1,3);
00378         
00379 }
00380 
00381 inline double State::errX2() const 
00382 {
00383 
00384   return m_covariance.fast(1,1);
00385         
00386 }
00387 
00388 inline double State::errY2() const 
00389 {
00390 
00391   return m_covariance.fast(2,2);
00392         
00393 }
00394 
00395 inline HepSymMatrix State::errSlopes() const 
00396 {
00397 
00398   const HepSymMatrix temp = m_covariance;
00399   HepSymMatrix err = temp.sub(3,5);
00400   err.fast(2,1) = 0.;
00401   err.fast(3,1) = 0.;
00402   err.fast(3,2) = 0.;
00403   err.fast(3,3) = 0.;
00404   return err;
00405         
00406 }
00407 
00408 inline double State::errTx2() const 
00409 {
00410 
00411   return m_covariance.fast(3,3);
00412         
00413 }
00414 
00415 inline double State::errTy2() const 
00416 {
00417 
00418   return m_covariance.fast(4,4);
00419         
00420 }
00421 
00422 inline void State::setState(const HepVector& state) 
00423 {
00424 
00425   m_stateVector = state;
00426         
00427 }
00428 
00429 inline void State::setCovariance(const HepSymMatrix& value) 
00430 {
00431 
00432   if ( value.num_row() != (int) nParameters() )
00433     throw GaudiException( "The dimension of the covariance matrix does not match that of the State!",
00434                           "State.h",
00435                           StatusCode::FAILURE );
00436   m_covariance = value;
00437         
00438 }
00439 
00440 inline void State::setX(double value) 
00441 {
00442 
00443   m_stateVector[0] = value;
00444         
00445 }
00446 
00447 inline void State::setY(double value) 
00448 {
00449 
00450   m_stateVector[1] = value;
00451         
00452 }
00453 
00454 inline void State::setZ(double value) 
00455 {
00456 
00457   m_z = value;
00458         
00459 }
00460 
00461 inline void State::setTx(double value) 
00462 {
00463 
00464   m_stateVector[2] = value;
00465         
00466 }
00467 
00468 inline void State::setTy(double value) 
00469 {
00470 
00471   m_stateVector[3] = value;
00472         
00473 }
00474 
00475 inline bool State::checkLocation(unsigned int value) const 
00476 {
00477 
00478   return location() == value;
00479         
00480 }
00481 
00482 // Definition of Keyed Container for State
00483 typedef KeyedContainer<State, Containers::HashMap> States;
00484 
00485 
00486 
00487 #endif 

Generated on Fri May 27 13:59:37 2005 for New Track Event Model by doxygen 1.4.1