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 "CLHEP/Geometry/Point3D.h"
00020 #include "CLHEP/Geometry/Vector3D.h"
00021 #include "GaudiKernel/KeyedContainer.h"
00022 #include "CLHEP/Matrix/Vector.h"
00023 #include "CLHEP/Matrix/SymMatrix.h"
00024 
00025 
00026 // Forward declarations
00027 
00028 // Class ID definition
00029 static const CLID& CLID_State = 10011;
00030 
00031 // Namespace for locations in TDS
00032 namespace StateLocation {
00033   static const std::string& Default = "Rec/Track/States";
00034 }
00035 
00036 
00046 class State
00047 {
00048 public:
00049 
00051   enum Type{ HasMomentum=1,
00052              StraightLine=2 };
00054   enum Location{ Unknown=1,
00055                  ClosestToBeam=2,
00056                  FirstMeasurement=4,
00057                  EndVelo=8,
00058                  AtTT=16,
00059                  AtT=32,
00060                  BegRich1=64,
00061                  EndRich1=128,
00062                  BegRich2=256,
00063                  EndRich2=512,
00064                  Calo=1024,
00065                  Muon=2048 };
00066 
00068   State();
00069 
00071   virtual ~State() {}
00072 
00073   // Retrieve pointer to class definition structure
00074   virtual const CLID& clID() const;
00075   static const CLID& classID();
00076 
00078   unsigned int nParameters() const;
00079 
00081   void positionAndMomentum(HepPoint3D& pos,
00082                            HepVector3D& mom,
00083                            HepSymMatrix& cov6D) const;
00084 
00086   HepPoint3D position() const;
00087 
00089   double x() const;
00090 
00092   double y() const;
00093 
00095   double z() const;
00096 
00098   HepVector3D slopes() const;
00099 
00101   double tx() const;
00102 
00104   double ty() const;
00105 
00107   virtual double qOverP() const;
00108 
00110   virtual double p() const;
00111 
00113   virtual double pt() const;
00114 
00116   HepVector3D momentum() const;
00117 
00119   double qOverPperp() const;
00120 
00122   virtual HepSymMatrix posMomCovariance() const;
00123 
00125   HepSymMatrix errPosition() const;
00126 
00128   double errX2() const;
00129 
00131   double errY2() const;
00132 
00134   HepSymMatrix errSlopes() const;
00135 
00137   double errTx2() const;
00138 
00140   double errTy2() const;
00141 
00143   virtual double errQOverP2() const;
00144 
00146   virtual double errP2() const;
00147 
00149   virtual HepSymMatrix errMomentum() const;
00150 
00152   virtual double errQOverPperp2() const;
00153 
00155   virtual State* clone() const;
00156 
00158   virtual void reset();
00159 
00161   void setState(const HepVector& state);
00162 
00164   virtual void setState(double x,
00165                         double y,
00166                         double z,
00167                         double tx,
00168                         double ty,
00169                         double qOverP);
00170 
00172   void setState(double x,
00173                 double y,
00174                 double z,
00175                 double tx,
00176                 double ty);
00177 
00179   void setCovariance(const HepSymMatrix& value);
00180 
00182   void setX(double value);
00183 
00185   void setY(double value);
00186 
00188   void setZ(double value);
00189 
00191   void setTx(double value);
00192 
00194   void setTy(double value);
00195 
00197   virtual void setQOverP(double value);
00198 
00200   unsigned int flags() const;
00201 
00203   bool checkType(const Type& value) const;
00204 
00206   void setLocation(const Location& value);
00207 
00209   bool checkLocation(const Location& value) const;
00210 
00212   const HepVector& state() const;
00213 
00215   HepVector& state();
00216 
00218   const HepSymMatrix& covariance() const;
00219 
00221   HepSymMatrix& covariance();
00222 
00223 protected:
00224 
00226   void setType(const State::Type& value);
00227 
00229   enum flagsBits{typeBits     = 0,
00230                  locationBits = 2};
00231 
00233   enum flagsMasks{typeMask     = 0x3L,
00234                   locationMask = 0xFFCL};
00235 
00236 
00237   unsigned int m_flags;      
00238   HepVector    m_state;      
00239   HepSymMatrix m_covariance; 
00240   double       m_z;          
00241 
00242 private:
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;
00270   return 0 != ( m_flags & typeMask & ( val << typeBits ));
00271 }
00272 
00273 inline void State::setLocation(const Location& value)
00274 {
00275   unsigned int val = (unsigned int)value;
00276   m_flags &= ~locationMask;
00277   m_flags |= ((((unsigned int)val) << locationBits) & locationMask);
00278 }
00279 
00280 inline bool State::checkLocation(const Location& value) const
00281 {
00282   unsigned int val = (unsigned int)value;
00283   return 0 != ( m_flags & locationMask & ( val << locationBits ));
00284 }
00285 
00286 inline const HepVector& State::state() const 
00287 {
00288   return m_state;
00289 }
00290 
00291 inline HepVector& State::state() 
00292 {
00293   return m_state;
00294 }
00295 
00296 inline const HepSymMatrix& State::covariance() const 
00297 {
00298   return m_covariance;
00299 }
00300 
00301 inline HepSymMatrix& State::covariance() 
00302 {
00303   return m_covariance;
00304 }
00305 
00306 inline unsigned int State::nParameters() const 
00307 {
00308 
00309   return (unsigned int) m_state.num_row();
00310         
00311 }
00312 
00313 inline void State::positionAndMomentum(HepPoint3D& pos,
00314                                        HepVector3D& mom,
00315                                        HepSymMatrix& cov6D) const 
00316 {
00317 
00318   pos   = position();
00319   mom   = momentum();
00320   cov6D = posMomCovariance();
00321         
00322 }
00323 
00324 inline HepPoint3D State::position() const 
00325 {
00326 
00327   return HepPoint3D( m_state[0], m_state[1], m_z );
00328         
00329 }
00330 
00331 inline double State::x() const 
00332 {
00333 
00334   return m_state[0];
00335         
00336 }
00337 
00338 inline double State::y() const 
00339 {
00340 
00341   return m_state[1];
00342         
00343 }
00344 
00345 inline double State::z() const 
00346 {
00347 
00348   return m_z;
00349         
00350 }
00351 
00352 inline HepVector3D State::slopes() const 
00353 {
00354 
00355   return HepVector3D( m_state[2], m_state[3], 1.);
00356         
00357 }
00358 
00359 inline double State::tx() const 
00360 {
00361 
00362   return m_state[2];
00363         
00364 }
00365 
00366 inline double State::ty() const 
00367 {
00368 
00369   return m_state[3];
00370         
00371 }
00372 
00373 inline HepVector3D State::momentum() const 
00374 {
00375 
00376   HepVector3D mom = slopes();
00377   mom *= ( p() / mom.mag() );
00378   return mom;
00379         
00380 }
00381 
00382 inline double State::qOverPperp() const 
00383 {
00384 
00385   double tx2 = tx() * tx();
00386   return ( qOverP() * sqrt( (1.+ tx2 + ty()*ty()) / (1. + tx2 ) ) );
00387         
00388 }
00389 
00390 inline HepSymMatrix State::errPosition() const 
00391 {
00392 
00393   const HepSymMatrix temp = posMomCovariance();
00394   return temp.sub(1,3);
00395         
00396 }
00397 
00398 inline double State::errX2() const 
00399 {
00400 
00401   return m_covariance.fast(1,1);
00402         
00403 }
00404 
00405 inline double State::errY2() const 
00406 {
00407 
00408   return m_covariance.fast(2,2);
00409         
00410 }
00411 
00412 inline HepSymMatrix State::errSlopes() const 
00413 {
00414 
00415   const HepSymMatrix temp = m_covariance;
00416   HepSymMatrix err = temp.sub(3,5);
00417   err.fast(2,1) = 0.;
00418   err.fast(3,1) = 0.;
00419   err.fast(3,2) = 0.;
00420   err.fast(3,3) = 0.;
00421   return err;
00422         
00423 }
00424 
00425 inline double State::errTx2() const 
00426 {
00427 
00428   return m_covariance.fast(3,3);
00429         
00430 }
00431 
00432 inline double State::errTy2() const 
00433 {
00434 
00435   return m_covariance.fast(4,4);
00436         
00437 }
00438 
00439 inline void State::setState(const HepVector& state) 
00440 {
00441 
00442   m_state = state;
00443         
00444 }
00445 
00446 inline void State::setState(double x,
00447                             double y,
00448                             double z,
00449                             double tx,
00450                             double ty) 
00451 {
00452 
00453   m_state[0] = x;
00454   m_state[1] = y;
00455   m_state[2] = tx;
00456   m_state[3] = ty;
00457   m_z        = z;
00458         
00459 }
00460 
00461 inline void State::setCovariance(const HepSymMatrix& value) 
00462 {
00463 
00464   if ( value.num_row() == (int) nParameters() ) {
00465     m_covariance = value;
00466   }
00467   else {
00468     std::cerr << "ERROR   The dimension of the covariance matrix does not match that of the state!"
00469               << "ERROR   Using the default covariance matrix." << std::endl;
00470     int dim = nParameters();
00471     m_covariance = HepSymMatrix(dim,0);
00472   }
00473         
00474 }
00475 
00476 inline void State::setX(double value) 
00477 {
00478 
00479   m_state[0] = value;
00480         
00481 }
00482 
00483 inline void State::setY(double value) 
00484 {
00485 
00486   m_state[1] = value;
00487         
00488 }
00489 
00490 inline void State::setZ(double value) 
00491 {
00492 
00493   m_z = value;
00494         
00495 }
00496 
00497 inline void State::setTx(double value) 
00498 {
00499 
00500   m_state[2] = value;
00501         
00502 }
00503 
00504 inline void State::setTy(double value) 
00505 {
00506 
00507   m_state[3] = value;
00508         
00509 }
00510 
00511 // Definition of Keyed Container for State
00512 typedef KeyedContainer<State, Containers::HashMap> States;
00513 
00514 
00515 
00516 #endif 

Generated on Thu Apr 7 22:43:27 2005 for New Track Event Model by doxygen 1.4.1