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

TrState.h

Go to the documentation of this file.
00001 
00002 
00003 //   **************************************************************************
00004 //   *                                                                        *
00005 //   *                      ! ! ! A T T E N T I O N ! ! !                     *
00006 //   *                                                                        *
00007 //   *  This file was created automatically by GaudiObjDesc, please do not    *
00008 //   *  delete it or edit it by hand.                                         *
00009 //   *                                                                        *
00010 //   *  If you want to change this file, first change the corresponding       *
00011 //   *  xml-file and rerun the tools from GaudiObjDesc (or run make if you    *
00012 //   *  are using it from inside a Gaudi-package).                            *
00013 //   *                                                                        *
00014 //   **************************************************************************
00015 
00016 
00017 
00018 #ifndef TrEvent_TrState_H
00019 #define TrEvent_TrState_H 1
00020 
00021 // Include files
00022 #include "Kernel/CLHEPStreams.h"
00023 #include "CLHEP/Matrix/SymMatrix.h"
00024 #include "CLHEP/Matrix/Vector.h"
00025 #include "GaudiKernel/KeyedObject.h"
00026 #include "GaudiKernel/ObjectList.h"
00027 #include "GaudiKernel/ObjectVector.h"
00028 #include "CLHEP/Geometry/Point3D.h"
00029 #include "GaudiKernel/StreamBuffer.h"
00030 #include "CLHEP/Geometry/Vector3D.h"
00031 
00032 
00033 // Class ID definition
00034   static const CLID& CLID_TrState = 10004;
00035 
00036 // Namespace for locations in TDS
00037 namespace TrStateLocation {
00038   static const std::string& Default = "Rec/Tr/States";
00039 }
00040 
00041 
00051 class TrState: public KeyedObject<int>
00052 {
00053 
00054 public: 
00055 
00056   enum Type {HasMomentum,StraightLine};   
00057   enum Location {BegVelo,EndVelo,AtTT,AtT,BegRICH1,EndRICH1,BegRICH2,EndRICH2,Calo,Muon};   
00058 
00060   TrState();
00061 
00063   TrState(const Type& type);
00064 
00066   TrState(const TrState& state);
00067 
00069   virtual ~TrState() {}
00070 
00072   virtual const CLID& clID() const; 
00073   static const CLID& classID(); 
00074 
00076   unsigned int nParameters() const;
00077 
00079   void positionAndMomentum(HepPoint3D& pos, HepVector3D& mom, HepSymMatrix& cov6D);
00080 
00082   HepPoint3D position();
00083 
00085   double x() const;
00086 
00088   double y() const;
00089 
00091   double z() const;
00092 
00094   HepVector3D slopes() const;
00095 
00097   double tx() const;
00098 
00100   double ty() const;
00101 
00103   virtual double qOverP() const;
00104 
00106   virtual double p() const;
00107 
00109   virtual double pt() const;
00110 
00112   HepVector3D momentum() const;
00113 
00115   double qOverPperp() const;
00116 
00118   virtual HepSymMatrix posMomCovariance() const;
00119 
00121   HepSymMatrix errPosition() const;
00122 
00124   double errX2() const;
00125 
00127   double errY2() const;
00128 
00130   HepSymMatrix errSlopes() const;
00131 
00133   double errTx2() const;
00134 
00136   double errTy2() const;
00137 
00139   virtual double errQOverP2() const;
00140 
00142   virtual double errP2() const;
00143 
00145   HepSymMatrix errMomentum() const;
00146 
00148   virtual double errQOverPperp2() const;
00149 
00151   virtual TrState* clone();
00152 
00154   virtual void reset();
00155 
00157   void setState(const HepVector& state);
00158 
00160   virtual void setState(double x, double y, double z, double tx, double ty, double qOverP);
00161 
00163   void setState(double x, double y, double z, double tx, double ty);
00164 
00166   void setCovariance(const HepSymMatrix& value);
00167 
00169   void setX(double value);
00170 
00172   void setY(double value);
00173 
00175   void setTx(double value);
00176 
00178   void setTy(double value);
00179 
00181   virtual void setQOverP(double value);
00182 
00184   unsigned int type() const; 
00185 
00187   unsigned int location() const; 
00188 
00190   void setLocation(unsigned int value);
00191 
00193   const HepVector& state() const; 
00194 
00196   HepVector& state();
00197 
00199   const HepSymMatrix& covariance() const; 
00200 
00202   HepSymMatrix& covariance();
00203 
00205   virtual StreamBuffer& serialize(StreamBuffer& s) const;
00206 
00208   virtual StreamBuffer& serialize(StreamBuffer& s);
00209 
00211   virtual std::ostream& fillStream(std::ostream& s) const;
00212 
00213 protected: 
00214 
00215 private: 
00216 
00217   unsigned int m_type;       
00218   unsigned int m_location;   
00219   HepVector    m_state;      
00220   HepSymMatrix m_covariance; 
00221   double       m_z;          
00222 
00223 };
00224 
00225 // -----------------------------------------------------------------------------
00226 //   end of class
00227 // -----------------------------------------------------------------------------
00228 
00229 
00230 inline const CLID& TrState::clID() const 
00231 {
00232   return TrState::classID();
00233 }
00234 
00235 inline const CLID& TrState::classID()
00236 {
00237   return CLID_TrState;
00238 }
00239 
00240 inline unsigned int TrState::nParameters() const
00241 {
00242    
00243   return (unsigned int) m_state.num_row();
00244         
00245 }
00246 
00247 inline void TrState::positionAndMomentum(HepPoint3D& pos, HepVector3D& mom, HepSymMatrix& cov6D)
00248 {
00249    
00250   pos   = position();
00251   mom   = momentum();
00252   cov6D = posMomCovariance();
00253         
00254 }
00255 
00256 inline HepPoint3D TrState::position()
00257 {
00258    
00259   return HepPoint3D( m_state[0], m_state[1], m_z );
00260         
00261 }
00262 
00263 inline double TrState::x() const
00264 {
00265    
00266   return m_state[0];
00267         
00268 }
00269 
00270 inline double TrState::y() const
00271 {
00272    
00273   return m_state[1];
00274         
00275 }
00276 
00277 inline double TrState::z() const
00278 {
00279    
00280   return m_z;
00281         
00282 }
00283 
00284 inline HepVector3D TrState::slopes() const
00285 {
00286    
00287   return HepVector3D( m_state[2], m_state[3], 1.);
00288         
00289 }
00290 
00291 inline double TrState::tx() const
00292 {
00293    
00294   return m_state[2];
00295         
00296 }
00297 
00298 inline double TrState::ty() const
00299 {
00300    
00301   return m_state[3];
00302         
00303 }
00304 
00305 inline HepVector3D TrState::momentum() const
00306 {
00307    
00308   HepVector3D mom = slopes();
00309   mom *= ( p() / mom.mag() );
00310   return mom;
00311         
00312 }
00313 
00314 inline double TrState::qOverPperp() const
00315 {
00316    
00317   double tx2 = tx() * tx();
00318   return ( qOverP() * sqrt( (1.+ tx2 + ty()*ty()) / (1. + tx2 ) ) );
00319         
00320 }
00321 
00322 inline HepSymMatrix TrState::errPosition() const
00323 {
00324    
00325   return posMomCovariance().sub(1,3);
00326         
00327 }
00328 
00329 inline double TrState::errX2() const
00330 {
00331    
00332   return m_covariance.fast(1,1);
00333         
00334 }
00335 
00336 inline double TrState::errY2() const
00337 {
00338    
00339   return m_covariance.fast(2,2);
00340         
00341 }
00342 
00343 inline HepSymMatrix TrState::errSlopes() const
00344 {
00345    
00346   HepSymMatrix err = m_covariance.sub(3,5);
00347   err.fast(2,1) = 0.;
00348   err.fast(3,1) = 0.;
00349   err.fast(3,2) = 0.;
00350   err.fast(3,3) = 0.;
00351   return err;
00352         
00353 }
00354 
00355 inline double TrState::errTx2() const
00356 {
00357    
00358   return m_covariance.fast(3,3);
00359         
00360 }
00361 
00362 inline double TrState::errTy2() const
00363 {
00364    
00365   return m_covariance.fast(4,4);
00366         
00367 }
00368 
00369 inline HepSymMatrix TrState::errMomentum() const
00370 {
00371    
00372   if ( m_type == TrState::HasMomentum ) {
00373     return posMomCovariance().sub(4,6);
00374   }
00375   else {
00376     // print out an error message ...
00377     return HepSymMatrix(3,0);
00378   }
00379         
00380 }
00381 
00382 inline void TrState::setState(const HepVector& state)
00383 {
00384    
00385   m_state = state;
00386         
00387 }
00388 
00389 inline void TrState::setState(double x, double y, double z, double tx, double ty)
00390 {
00391    
00392   m_state[0] = x;
00393   m_state[1] = y;
00394   m_state[2] = tx;
00395   m_state[3] = ty;
00396   m_z        = z;
00397         
00398 }
00399 
00400 inline void TrState::setCovariance(const HepSymMatrix& value)
00401 {
00402    
00403   if ( value.num_row() == (int) nParameters() ) {
00404     m_covariance = value;
00405   }
00406   else {
00407     std::cerr << "ERROR   The dimension of the covariance matrix does not match that of the state!"
00408               << "ERROR   Using the default covariance matrix." << std::endl;
00409     int dim = nParameters();
00410     m_covariance = HepSymMatrix(dim,0);
00411   }
00412         
00413 }
00414 
00415 inline void TrState::setX(double value)
00416 {
00417    
00418   m_state[0] = value;
00419         
00420 }
00421 
00422 inline void TrState::setY(double value)
00423 {
00424    
00425   m_state[1] = value;
00426         
00427 }
00428 
00429 inline void TrState::setTx(double value)
00430 {
00431    
00432   m_state[2] = value;
00433         
00434 }
00435 
00436 inline void TrState::setTy(double value)
00437 {
00438    
00439   m_state[3] = value;
00440         
00441 }
00442 
00443 inline unsigned int TrState::type() const 
00444 {
00445   return m_type;
00446 }
00447 
00448 inline unsigned int TrState::location() const 
00449 {
00450   return m_location;
00451 }
00452 
00453 inline void TrState::setLocation(unsigned int value)
00454 {
00455   m_location = value; 
00456 }
00457 
00458 inline const HepVector& TrState::state() const 
00459 {
00460   return m_state;
00461 }
00462 
00463 inline HepVector& TrState::state()
00464 {
00465   return m_state;
00466 }
00467 
00468 inline const HepSymMatrix& TrState::covariance() const 
00469 {
00470   return m_covariance;
00471 }
00472 
00473 inline HepSymMatrix& TrState::covariance()
00474 {
00475   return m_covariance;
00476 }
00477 
00478 inline StreamBuffer& TrState::serialize(StreamBuffer& s) const 
00479 {
00480   KeyedObject<int>::serialize(s);
00481   s << m_type
00482     << m_location
00483     << m_state
00484     << m_covariance
00485     << (float)m_z;
00486   return s;
00487 }
00488 
00489 inline StreamBuffer& TrState::serialize(StreamBuffer& s)
00490 {
00491   float l_z;
00492   KeyedObject<int>::serialize(s);
00493   s >> m_type
00494     >> m_location
00495     >> m_state
00496     >> m_covariance
00497     >> l_z;
00498   m_z = l_z;
00499   return s;
00500 }
00501 
00502 inline std::ostream& TrState::fillStream(std::ostream& s) const
00503 {
00504   s << "{ "
00505     << " type:\t" << m_type << std::endl
00506     << "   location:\t" << m_location << std::endl
00507     << "   state:\t" << m_state << std::endl
00508     << "   covariance:\t" << m_covariance << std::endl
00509     << "   z:\t" << (float)m_z << " } ";
00510   return s;
00511 }
00512 
00513 //Definition of keyed container for TrState
00514 typedef KeyedContainer<TrState, Containers::HashMap> TrStates;
00515 
00516 #endif   

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