00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef TrackEvent_Track_H
00016 #define TrackEvent_Track_H 1
00017
00018
00019 #include "Event/State.h"
00020 #include "Kernel/LHCbID.h"
00021 #include "CLHEP/Geometry/Plane3D.h"
00022 #include "GaudiKernel/KeyedObject.h"
00023 #include "GaudiKernel/KeyedContainer.h"
00024 #include <vector>
00025
00026
00027
00028 class StatusCode;
00029 class Point3D;
00030 class Vector3D;
00031 class SymMatrix;
00032
00033
00034
00035 static const CLID& CLID_Track = 10010;
00036
00037
00038 namespace TrackLocation {
00039 static const std::string& Default = "Rec/Track/Best";
00040 static const std::string& Velo = "Rec/Track/Velo";
00041 static const std::string& Seed = "Rec/Track/Seed";
00042 static const std::string& Match = "Rec/Track/Match";
00043 static const std::string& Forward = "Rec/Track/Forward";
00044 static const std::string& Follow = "Rec/Track/Follow";
00045 static const std::string& VeloTT = "Rec/Track/VeloTT";
00046 static const std::string& KsTrack = "Rec/Track/KsTrack";
00047 }
00048
00049
00059 class Track: public KeyedObject<int>
00060 {
00061 public:
00062
00064 enum TrackType{ Velo=1,
00065 VeloR=2,
00066 Backward=4,
00067 Long=8,
00068 Upstream=16,
00069 Downstream=32,
00070 Ttrack=64 };
00072 enum HistoryFlag{ LongTrack=1,
00073 Seeding=2,
00074 TrKshort=4,
00075 TrMatching=8,
00076 VeloTrack=16,
00077 VeloTT=32,
00078 TrgForward=64,
00079 TrgVelo=128,
00080 TrgVeloTT=256 };
00082 enum Flag{ Valid=1,
00083 Unique=2,
00084 IPSelected=4,
00085 MuSelected=8 };
00086
00088 Track(int key) : KeyedObject<int>( key ),
00089 m_chi2PerDoF(0.0),
00090 m_nDoF(0),
00091 m_flags(0),
00092 m_lhcbIDs(),
00093 m_physicsState(),
00094 m_states() {}
00095
00097 Track() : m_chi2PerDoF(0.0),
00098 m_nDoF(0),
00099 m_flags(0),
00100 m_lhcbIDs(),
00101 m_physicsState(),
00102 m_states() {}
00103
00105 ~Track();
00106
00107
00108 virtual const CLID& clID() const;
00109 static const CLID& classID();
00110
00112 StatusCode positionAndMomentum(HepPoint3D& pos,
00113 HepVector3D& mom,
00114 HepSymMatrix& cov6D) const;
00115
00117 StatusCode position(HepPoint3D& pos,
00118 HepSymMatrix& errPos) const;
00119
00121 StatusCode slopes(HepVector3D& slopes,
00122 HepSymMatrix& errSlopes) const;
00123
00125 double p() const;
00126
00128 double pt() const;
00129
00131 StatusCode momentum(HepVector3D& mom,
00132 HepSymMatrix& errMom) const;
00133
00135 StatusCode posMomCovariance(HepSymMatrix& cov6D) const;
00136
00138 int charge() const;
00139
00141 virtual unsigned int nMeasurements() const;
00142
00144 unsigned int nStates() const;
00145
00147 void addToStates(State* value);
00148
00150 void removeFromStates(State* value);
00151
00153 virtual State & closestState(double z);
00154
00156 virtual const State & closestState(double z) const;
00157
00159 virtual State & closestState(const HepPlane3D& plane);
00160
00162 virtual const State & closestState(const HepPlane3D& plane) const;
00163
00165 bool hasStateAt(const State::Location& value) const;
00166
00168 virtual State* stateAt(const State::Location& value);
00169
00171 virtual const State* stateAt(const State::Location& value) const;
00172
00174 double chi2() const;
00175
00177 virtual void reset();
00178
00180 virtual Track* clone() const;
00181
00183 void addToLhcbIDs(const LHCbID& value);
00184
00186 void removeFromLhcbIDs(const LHCbID& value);
00187
00189 virtual bool producedByAlgo(const HistoryFlag& value) const;
00190
00192 virtual void setProducedByAlgo(const HistoryFlag& value);
00193
00195 double chi2PerDoF() const;
00196
00198 void setChi2PerDoF(double value);
00199
00201 int nDoF() const;
00202
00204 void setNDoF(int value);
00205
00207 unsigned int flags() const;
00208
00210 void setType(const TrackType& value);
00211
00213 bool checkType(const TrackType& value) const;
00214
00216 void setFlag(const Flag& value);
00217
00219 bool checkFlag(const Flag& value) const;
00220
00222 const std::vector<LHCbID>& lhcbIDs() const;
00223
00225 std::vector<LHCbID>& lhcbIDs();
00226
00228 void setLhcbIDs(const std::vector<LHCbID>& value);
00229
00231 const State& physicsState() const;
00232
00234 State& physicsState();
00235
00237 void setPhysicsState(const State& value);
00238
00240 const std::vector<State*>& states() const;
00241
00243 std::vector<State*>& states();
00244
00246 void setStates(const std::vector<State*>& value);
00247
00248 protected:
00249
00251 enum flagsBits{typeBits = 0,
00252 historyBits = 7,
00253 flagBits = 16};
00254
00256 enum flagsMasks{typeMask = 0x7FL,
00257 historyMask = 0xFF80L,
00258 flagMask = 0xF0000L};
00259
00260
00261 double m_chi2PerDoF;
00262 int m_nDoF;
00263 unsigned int m_flags;
00264 std::vector<LHCbID> m_lhcbIDs;
00265 State m_physicsState;
00266 std::vector<State*> m_states;
00267
00268 private:
00269
00270 };
00271
00272
00273
00274
00275
00276
00277 #include "GaudiKernel/StatusCode.h"
00278 #include "CLHEP/Geometry/Point3D.h"
00279 #include "CLHEP/Geometry/Vector3D.h"
00280 #include "CLHEP/Matrix/SymMatrix.h"
00281
00282
00283 inline Track::~Track()
00284 {
00285
00286 for (std::vector<State*>::iterator iter = m_states.begin();
00287 iter != m_states.end(); iter++)
00288 delete *iter;
00289
00290 }
00291
00292 inline const CLID& Track::clID() const
00293 {
00294 return Track::classID();
00295 }
00296
00297 inline const CLID& Track::classID()
00298 {
00299 return CLID_Track;
00300 }
00301
00302 inline double Track::chi2PerDoF() const
00303 {
00304 return m_chi2PerDoF;
00305 }
00306
00307 inline void Track::setChi2PerDoF(double value)
00308 {
00309 m_chi2PerDoF = value;
00310 }
00311
00312 inline int Track::nDoF() const
00313 {
00314 return m_nDoF;
00315 }
00316
00317 inline void Track::setNDoF(int value)
00318 {
00319 m_nDoF = value;
00320 }
00321
00322 inline unsigned int Track::flags() const
00323 {
00324 return m_flags;
00325 }
00326
00327 inline void Track::setType(const TrackType& value)
00328 {
00329 unsigned int val = (unsigned int)value;
00330 m_flags &= ~typeMask;
00331 m_flags |= ((((unsigned int)val) << typeBits) & typeMask);
00332 }
00333
00334 inline bool Track::checkType(const TrackType& value) const
00335 {
00336 unsigned int val = (unsigned int)value;
00337 return 0 != ( m_flags & typeMask & ( val << typeBits ));
00338 }
00339
00340 inline void Track::setFlag(const Flag& value)
00341 {
00342 unsigned int val = (unsigned int)value;
00343 m_flags |= ((((unsigned int)val) << flagBits) & flagMask);
00344 }
00345
00346 inline bool Track::checkFlag(const Flag& value) const
00347 {
00348 unsigned int val = (unsigned int)value;
00349 return 0 != ( m_flags & flagMask & ( val << flagBits ));
00350 }
00351
00352 inline const std::vector<LHCbID>& Track::lhcbIDs() const
00353 {
00354 return m_lhcbIDs;
00355 }
00356
00357 inline std::vector<LHCbID>& Track::lhcbIDs()
00358 {
00359 return m_lhcbIDs;
00360 }
00361
00362 inline void Track::setLhcbIDs(const std::vector<LHCbID>& value)
00363 {
00364 m_lhcbIDs = value;
00365 }
00366
00367 inline const State& Track::physicsState() const
00368 {
00369 return m_physicsState;
00370 }
00371
00372 inline State& Track::physicsState()
00373 {
00374 return m_physicsState;
00375 }
00376
00377 inline void Track::setPhysicsState(const State& value)
00378 {
00379 m_physicsState = value;
00380 }
00381
00382 inline const std::vector<State*>& Track::states() const
00383 {
00384 return m_states;
00385 }
00386
00387 inline std::vector<State*>& Track::states()
00388 {
00389 return m_states;
00390 }
00391
00392 inline void Track::setStates(const std::vector<State*>& value)
00393 {
00394 m_states = value;
00395 }
00396
00397 inline int Track::charge() const
00398 {
00399
00400 double qP = m_physicsState.qOverP();
00401 return ( qP != 0. ? int(fabs(qP)/qP) : 0 );
00402
00403 }
00404
00405 inline unsigned int Track::nMeasurements() const
00406 {
00407
00408 return m_lhcbIDs.size();
00409
00410 }
00411
00412 inline unsigned int Track::nStates() const
00413 {
00414
00415 return m_states.size();
00416
00417 }
00418
00419 inline void Track::addToStates(State* value)
00420 {
00421
00422 m_states.push_back( value );
00423
00424 }
00425
00426 inline void Track::removeFromStates(State* value)
00427 {
00428
00429 std::vector<State*>::iterator iter =
00430 std::remove( m_states.begin(), m_states.end(), value );
00431 m_states.erase( iter, m_states.end() );
00432
00433 }
00434
00435 inline double Track::chi2() const
00436 {
00437
00438 return ( m_chi2PerDoF * double(m_nDoF) );
00439
00440 }
00441
00442 inline void Track::reset()
00443 {
00444
00445 m_chi2PerDoF = 0;
00446 m_nDoF = 0;
00447 m_flags = 0;
00448 m_physicsState.reset();
00449 m_states.clear();
00450 m_lhcbIDs.clear();
00451
00452 }
00453
00454 inline void Track::addToLhcbIDs(const LHCbID& value)
00455 {
00456
00457 m_lhcbIDs.push_back( value );
00458
00459 }
00460
00461 inline void Track::removeFromLhcbIDs(const LHCbID& value)
00462 {
00463
00464 std::vector<LHCbID>::iterator iter =
00465 std::remove( m_lhcbIDs.begin(), m_lhcbIDs.end(), value );
00466 m_lhcbIDs.erase( iter, m_lhcbIDs.end() );
00467
00468 }
00469
00470
00471 typedef KeyedContainer<Track, Containers::HashMap> Tracks;
00472
00473
00474
00475 #endif