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

Track.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_Track_H
00016 #define TrackEvent_Track_H 1
00017 
00018 // Include files
00019 #include "GaudiKernel/GaudiException.h"
00020 #include "Event/State.h"
00021 #include "Event/Measurement.h"
00022 #include "Event/Node.h"
00023 #include "Kernel/LHCbID.h"
00024 #include "CLHEP/Geometry/Plane3D.h"
00025 #include "GaudiKernel/KeyedObject.h"
00026 #include "GaudiKernel/KeyedContainer.h"
00027 #include <vector>
00028 
00029 
00030 // Forward declarations
00031 class StatusCode;
00032 class Point3D;
00033 class Vector3D;
00034 class SymMatrix;
00035 
00036 
00037 // Class ID definition
00038 static const CLID& CLID_Track = 10010;
00039 
00040 // Namespace for locations in TDS
00041 namespace TrackLocation {
00042   static const std::string& Default = "Rec/Track/Best";
00043   static const std::string& Ideal = "Rec/Track/Ideal";
00044   static const std::string& Velo = "Rec/Track/Velo";
00045   static const std::string& Seed = "Rec/Track/Seed";
00046   static const std::string& Match = "Rec/Track/Match";
00047   static const std::string& Forward = "Rec/Track/Forward";
00048   static const std::string& Follow = "Rec/Track/Follow";
00049   static const std::string& VeloTT = "Rec/Track/VeloTT";
00050   static const std::string& KsTrack = "Rec/Track/KsTrack";
00051 }
00052 
00053 
00063 class Track: public KeyedObject<int>
00064 {
00065 public:
00066 
00068   Track(int key) : KeyedObject<int>( key ),
00069                    m_chi2PerDoF(0.0),
00070                    m_nDoF(0),
00071                    m_flags(0),
00072                    m_lhcbIDs(),
00073                    m_states(),
00074                    m_measurements(),
00075                    m_nodes(),
00076                    m_ancestors() {}
00077 
00079   Track() : m_chi2PerDoF(0.0),
00080             m_nDoF(0),
00081             m_flags(0),
00082             m_lhcbIDs(),
00083             m_states(),
00084             m_measurements(),
00085             m_nodes(),
00086             m_ancestors() {}
00087 
00089   ~Track();
00090 
00091   // Retrieve pointer to class definition structure
00092   virtual const CLID& clID() const;
00093   static const CLID& classID();
00094 
00096   StatusCode positionAndMomentum(HepPoint3D& pos,
00097                                  HepVector3D& mom,
00098                                  HepSymMatrix& cov6D) const;
00099 
00101   StatusCode positionAndMomentum(HepPoint3D& pos,
00102                                  HepVector3D& mom) const;
00103 
00105   StatusCode position(HepPoint3D& pos,
00106                       HepSymMatrix& errPos) const;
00107 
00109   StatusCode slopes(HepVector3D& slopes,
00110                     HepSymMatrix& errSlopes) const;
00111 
00113   double p() const;
00114 
00116   double pt() const;
00117 
00119   StatusCode momentum(HepVector3D& mom,
00120                       HepSymMatrix& errMom) const;
00121 
00123   StatusCode posMomCovariance(HepSymMatrix& cov6D) const;
00124 
00126   State & physicsState() const;
00127 
00129   int charge() const;
00130 
00132   double chi2() const;
00133 
00135   unsigned int nStates() const;
00136 
00138   void addToStates(State*  state,
00139                    bool inOrder = true);
00140 
00142   void addToStates(const State&  state,
00143                    bool inOrder = true);
00144 
00146   void removeFromStates(State* value);
00147 
00149   State & closestState(double z);
00150 
00152   const State & closestState(double z) const;
00153 
00155   State & closestState(const HepPlane3D& plane);
00156 
00158   const State & closestState(const HepPlane3D& plane) const;
00159 
00161   bool hasStateAt(unsigned int location) const;
00162 
00164   State & stateAt(unsigned int location);
00165 
00167   const State & stateAt(unsigned int location) const;
00168 
00170   unsigned int nMeasurements() const;
00171 
00173   void addToMeasurements(Measurement*  meas,
00174                          bool inOrder = true);
00175 
00177   void addToMeasurements(const Measurement& meas,
00178                          bool inOrder = true);
00179 
00181   void removeFromMeasurements(Measurement* value);
00182 
00184   void addToNodes(Node* node);
00185 
00187   void removeFromNodes(Node* value);
00188 
00190   void addToLhcbIDs(const LHCbID& value);
00191 
00193   void removeFromLhcbIDs(const LHCbID& value);
00194 
00196   void addToAncestors(Track & ancestor);
00197 
00199   void removeFromAncestors(const Track& value);
00200 
00202   virtual void reset();
00203 
00205   virtual Track* clone() const;
00206 
00208   bool checkType(unsigned int value) const;
00209 
00211   bool checkHistory(unsigned int value) const;
00212 
00214   bool checkHistoryFit(unsigned int value) const;
00215 
00217   void setFlag(unsigned int flag,
00218                bool ok);
00219 
00221   bool checkFlag(unsigned int flag) const;
00222 
00224   double chi2PerDoF() const;
00225 
00227   void setChi2PerDoF(double value);
00228 
00230   int nDoF() const;
00231 
00233   void setNDoF(int value);
00234 
00236   unsigned int flags() const;
00237 
00239   void setFlags(unsigned int value);
00240 
00242   unsigned int type() const;
00243 
00245   void setType(unsigned int value);
00246 
00248   unsigned int history() const;
00249 
00251   void setHistory(unsigned int value);
00252 
00254   unsigned int historyFit() const;
00255 
00257   void setHistoryFit(unsigned int value);
00258 
00260   unsigned int status() const;
00261 
00263   void setStatus(unsigned int value);
00264 
00266   unsigned int flag() const;
00267 
00269   unsigned int specific() const;
00270 
00272   void setSpecific(unsigned int value);
00273 
00275   const std::vector<LHCbID>& lhcbIDs() const;
00276 
00278   std::vector<LHCbID>& lhcbIDs();
00279 
00281   void setLhcbIDs(const std::vector<LHCbID>& value);
00282 
00284   const std::vector<State*>& states() const;
00285 
00287   std::vector<State*>& states();
00288 
00290   const std::vector<Measurement*>& measurements() const;
00291 
00293   std::vector<Measurement*>& measurements();
00294 
00296   const std::vector<Node*>& nodes() const;
00297 
00299   std::vector<Node*>& nodes();
00300 
00302   const std::vector<Track*>& ancestors() const;
00303 
00305   std::vector<Track*>& ancestors();
00306 
00307 protected:
00308 
00310   enum flagsBits{typeBits       = 0,
00311                  historyBits    = 5,
00312                  historyFitBits = 10,
00313                  statusBits     = 15,
00314                  flagBits       = 18,
00315                  specificBits   = 28};
00316 
00318   enum flagsMasks{typeMask       = 0x1FL,
00319                   historyMask    = 0x3E0L,
00320                   historyFitMask = 0x7C00L,
00321                   statusMask     = 0x38000L,
00322                   flagMask       = 0xFFC0000L,
00323                   specificMask   = 0xF0000000L};
00324 
00325 
00326   double                    m_chi2PerDoF;   
00327   int                       m_nDoF;         
00328   unsigned int              m_flags;        
00329   std::vector<LHCbID>       m_lhcbIDs;      
00330   std::vector<State*>       m_states;       
00331   std::vector<Measurement*> m_measurements; 
00332   std::vector<Node*>        m_nodes;        
00333   std::vector<Track*>       m_ancestors;    
00334 
00335 private:
00336 
00337 };
00338 
00339 // -----------------------------------------------------------------------------
00340 //   end of class
00341 // -----------------------------------------------------------------------------
00342 
00343 // Including forward declarations
00344 #include "GaudiKernel/StatusCode.h"
00345 #include "CLHEP/Geometry/Point3D.h"
00346 #include "CLHEP/Geometry/Vector3D.h"
00347 #include "CLHEP/Matrix/SymMatrix.h"
00348 
00349 
00350 inline Track::~Track() 
00351 {
00352 
00353   reset();
00354         
00355 }
00356 
00357 inline const CLID& Track::clID() const
00358 {
00359   return Track::classID();
00360 }
00361 
00362 inline const CLID& Track::classID()
00363 {
00364   return CLID_Track;
00365 }
00366 
00367 inline double Track::chi2PerDoF() const 
00368 {
00369   return m_chi2PerDoF;
00370 }
00371 
00372 inline void Track::setChi2PerDoF(double value) 
00373 {
00374   m_chi2PerDoF = value;
00375 }
00376 
00377 inline int Track::nDoF() const 
00378 {
00379   return m_nDoF;
00380 }
00381 
00382 inline void Track::setNDoF(int value) 
00383 {
00384   m_nDoF = value;
00385 }
00386 
00387 inline unsigned int Track::flags() const 
00388 {
00389   return m_flags;
00390 }
00391 
00392 inline void Track::setFlags(unsigned int value) 
00393 {
00394   m_flags = value;
00395 }
00396 
00397 inline unsigned int Track::type() const
00398 {
00399   return (unsigned int)((m_flags & typeMask) >> typeBits);
00400 }
00401 
00402 inline void Track::setType(unsigned int value)
00403 {
00404   unsigned int val = (unsigned int)value;
00405   m_flags &= ~typeMask;
00406   m_flags |= ((((unsigned int)val) << typeBits) & typeMask);
00407 }
00408 
00409 inline unsigned int Track::history() const
00410 {
00411   return (unsigned int)((m_flags & historyMask) >> historyBits);
00412 }
00413 
00414 inline void Track::setHistory(unsigned int value)
00415 {
00416   unsigned int val = (unsigned int)value;
00417   m_flags &= ~historyMask;
00418   m_flags |= ((((unsigned int)val) << historyBits) & historyMask);
00419 }
00420 
00421 inline unsigned int Track::historyFit() const
00422 {
00423   return (unsigned int)((m_flags & historyFitMask) >> historyFitBits);
00424 }
00425 
00426 inline void Track::setHistoryFit(unsigned int value)
00427 {
00428   unsigned int val = (unsigned int)value;
00429   m_flags &= ~historyFitMask;
00430   m_flags |= ((((unsigned int)val) << historyFitBits) & historyFitMask);
00431 }
00432 
00433 inline unsigned int Track::status() const
00434 {
00435   return (unsigned int)((m_flags & statusMask) >> statusBits);
00436 }
00437 
00438 inline void Track::setStatus(unsigned int value)
00439 {
00440   unsigned int val = (unsigned int)value;
00441   m_flags &= ~statusMask;
00442   m_flags |= ((((unsigned int)val) << statusBits) & statusMask);
00443 }
00444 
00445 inline unsigned int Track::flag() const
00446 {
00447   return (unsigned int)((m_flags & flagMask) >> flagBits);
00448 }
00449 
00450 inline unsigned int Track::specific() const
00451 {
00452   return (unsigned int)((m_flags & specificMask) >> specificBits);
00453 }
00454 
00455 inline void Track::setSpecific(unsigned int value)
00456 {
00457   unsigned int val = (unsigned int)value;
00458   m_flags &= ~specificMask;
00459   m_flags |= ((((unsigned int)val) << specificBits) & specificMask);
00460 }
00461 
00462 inline const std::vector<LHCbID>& Track::lhcbIDs() const 
00463 {
00464   return m_lhcbIDs;
00465 }
00466 
00467 inline std::vector<LHCbID>& Track::lhcbIDs() 
00468 {
00469   return m_lhcbIDs;
00470 }
00471 
00472 inline void Track::setLhcbIDs(const std::vector<LHCbID>& value) 
00473 {
00474   m_lhcbIDs = value;
00475 }
00476 
00477 inline const std::vector<State*>& Track::states() const 
00478 {
00479   return m_states;
00480 }
00481 
00482 inline std::vector<State*>& Track::states() 
00483 {
00484   return m_states;
00485 }
00486 
00487 inline const std::vector<Measurement*>& Track::measurements() const 
00488 {
00489   return m_measurements;
00490 }
00491 
00492 inline std::vector<Measurement*>& Track::measurements() 
00493 {
00494   return m_measurements;
00495 }
00496 
00497 inline const std::vector<Node*>& Track::nodes() const 
00498 {
00499   return m_nodes;
00500 }
00501 
00502 inline std::vector<Node*>& Track::nodes() 
00503 {
00504   return m_nodes;
00505 }
00506 
00507 inline const std::vector<Track*>& Track::ancestors() const 
00508 {
00509   return m_ancestors;
00510 }
00511 
00512 inline std::vector<Track*>& Track::ancestors() 
00513 {
00514   return m_ancestors;
00515 }
00516 
00517 inline State & Track::physicsState() const 
00518 {
00519 
00520   // check at least the "physics state" exists
00521   if ( NULL == m_states[0] )
00522     throw GaudiException( "Physics state not defined!",
00523                           "Track.h",
00524                           StatusCode::FAILURE );
00525   return *m_states[0];
00526         
00527 }
00528 
00529 inline int Track::charge() const 
00530 {
00531 
00532   double qP = physicsState().qOverP();
00533   return ( qP != 0. ? int(fabs(qP)/qP) : 0 );
00534         
00535 }
00536 
00537 inline double Track::chi2() const 
00538 {
00539 
00540   return ( m_chi2PerDoF * double(m_nDoF) );
00541         
00542 }
00543 
00544 inline unsigned int Track::nStates() const 
00545 {
00546 
00547   return m_states.size();
00548         
00549 }
00550 
00551 inline void Track::addToStates(const State&  state,
00552                                bool inOrder ) 
00553 {
00554 
00555           addToStates(state.clone(),inOrder);
00556         
00557 }
00558 
00559 inline void Track::removeFromStates(State* value) 
00560 {
00561 
00562   std::vector<State*>::iterator iter =
00563     std::remove( m_states.begin(), m_states.end(), value );
00564   delete *iter;
00565   m_states.erase( iter, m_states.end() );
00566         
00567 }
00568 
00569 inline unsigned int Track::nMeasurements() const 
00570 {
00571 
00572   unsigned int n = m_measurements.size();
00573   if (n == 0) n = m_lhcbIDs.size();
00574   return n;
00575         
00576 }
00577 
00578 inline void Track::addToMeasurements(const Measurement& meas,
00579                                      bool inOrder ) 
00580 {
00581 
00582           addToMeasurements(meas.clone(),inOrder);
00583         
00584 }
00585 
00586 inline void Track::removeFromMeasurements(Measurement* value) 
00587 {
00588 
00589   std::vector<Measurement*>::iterator iter =
00590     std::remove( m_measurements.begin(), m_measurements.end(), value );
00591   delete *iter;
00592   m_measurements.erase( iter, m_measurements.end() );
00593         
00594 }
00595 
00596 inline void Track::addToNodes(Node* node) 
00597 {
00598 
00599   m_nodes.push_back( node );
00600         
00601 }
00602 
00603 inline void Track::removeFromNodes(Node* value) 
00604 {
00605 
00606   std::vector<Node*>::iterator iter =
00607     std::remove( m_nodes.begin(), m_nodes.end(), value );
00608   delete *iter;
00609   m_nodes.erase( iter, m_nodes.end() );
00610         
00611 }
00612 
00613 inline void Track::addToLhcbIDs(const LHCbID& value) 
00614 {
00615 
00616   m_lhcbIDs.push_back( value );
00617         
00618 }
00619 
00620 inline void Track::removeFromLhcbIDs(const LHCbID& value) 
00621 {
00622 
00623   std::vector<LHCbID>::iterator iter =
00624     std::remove( m_lhcbIDs.begin(), m_lhcbIDs.end(), value );
00625   m_lhcbIDs.erase( iter, m_lhcbIDs.end() );
00626         
00627 }
00628 
00629 inline void Track::addToAncestors(Track & ancestor) 
00630 {
00631 
00632   m_ancestors.push_back( (Track*) &ancestor );
00633         
00634 }
00635 
00636 inline void Track::removeFromAncestors(const Track& value) 
00637 {
00638 
00639   std::vector<Track*>::iterator iter =
00640     std::remove( m_ancestors.begin(), m_ancestors.end(), &value );
00641   m_ancestors.erase( iter, m_ancestors.end() );
00642         
00643 }
00644 
00645 inline bool Track::checkType(unsigned int value) const 
00646 {
00647 
00648   return type() == value;
00649         
00650 }
00651 
00652 inline bool Track::checkHistory(unsigned int value) const 
00653 {
00654 
00655   return history() == value;
00656         
00657 }
00658 
00659 inline bool Track::checkHistoryFit(unsigned int value) const 
00660 {
00661 
00662   return historyFit() == value;
00663         
00664 }
00665 
00666 inline void Track::setFlag(unsigned int flag,
00667                            bool ok) 
00668 {
00669 
00670   unsigned int val = (((unsigned int) flag) << flagBits) & flagMask;
00671   if (ok) m_flags |= val;
00672   else m_flags &= ~val;
00673         
00674 }
00675 
00676 inline bool Track::checkFlag(unsigned int flag) const 
00677 {
00678 
00679   unsigned int val = ((unsigned int) flag << flagBits);  
00680   bool ok = (0 != ( m_flags & flagMask & val ));
00681   return ok;
00682         
00683 }
00684 
00685 // Definition of Keyed Container for Track
00686 typedef KeyedContainer<Track, Containers::HashMap> Tracks;
00687 
00688 
00689 
00690 #endif 

Generated on Thu May 12 12:28:05 2005 for New Track Event Model by doxygen 1.4.1