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 unsigned int nStates() const;
00142
00144 void addToStates(State* value);
00145
00147 void removeFromStates(State* value);
00148
00150 virtual State & closestState(double z);
00151
00153 virtual const State & closestState(double z) const;
00154
00156 virtual State & closestState(const HepPlane3D& plane);
00157
00159 virtual const State & closestState(const HepPlane3D& plane) const;
00160
00162 bool hasStateAt(const State::Location& value) const;
00163
00165 virtual State* stateAt(const State::Location& value);
00166
00168 virtual const State* stateAt(const State::Location& value) const;
00169
00171 double chi2() const;
00172
00174 virtual void reset();
00175
00177 virtual Track* clone() const;
00178
00180 void addToLhcbIDs(const LHCbID& value);
00181
00183 void removeFromLhcbIDs(const LHCbID& value);
00184
00186 virtual bool producedByAlgo(const HistoryFlag& value) const;
00187
00189 virtual void setProducedByAlgo(const HistoryFlag& value);
00190
00192 double chi2PerDoF() const;
00193
00195 void setChi2PerDoF(double value);
00196
00198 int nDoF() const;
00199
00201 void setNDoF(int value);
00202
00204 unsigned int flags() const;
00205
00207 void setType(const TrackType& value);
00208
00210 bool checkType(const TrackType& value) const;
00211
00213 void setFlag(const Flag& value);
00214
00216 bool checkFlag(const Flag& value) const;
00217
00219 const std::vector<LHCbID>& lhcbIDs() const;
00220
00222 std::vector<LHCbID>& lhcbIDs();
00223
00225 void setLhcbIDs(const std::vector<LHCbID>& value);
00226
00228 const State& physicsState() const;
00229
00231 State& physicsState();
00232
00234 void setPhysicsState(const State& value);
00235
00237 const std::vector<State*>& states() const;
00238
00240 std::vector<State*>& states();
00241
00243 void setStates(const std::vector<State*>& value);
00244
00245 protected:
00246
00248 enum flagsBits{typeBits = 0,
00249 historyBits = 7,
00250 flagBits = 16};
00251
00253 enum flagsMasks{typeMask = 0x7FL,
00254 historyMask = 0xFF80L,
00255 flagMask = 0xF0000L};
00256
00257
00258 double m_chi2PerDoF;
00259 int m_nDoF;
00260 unsigned int m_flags;
00261 std::vector<LHCbID> m_lhcbIDs;
00262 State m_physicsState;
00263 std::vector<State*> m_states;
00264
00265 private:
00266
00267 };
00268
00269
00270
00271
00272
00273
00274 #include "GaudiKernel/StatusCode.h"
00275 #include "CLHEP/Geometry/Point3D.h"
00276 #include "CLHEP/Geometry/Vector3D.h"
00277 #include "CLHEP/Matrix/SymMatrix.h"
00278
00279
00280 inline Track::~Track()
00281 {
00282
00283 for (std::vector<State*>::iterator iter = m_states.begin();
00284 iter != m_states.end(); iter++)
00285 delete *iter;
00286
00287 }
00288
00289 inline const CLID& Track::clID() const
00290 {
00291 return Track::classID();
00292 }
00293
00294 inline const CLID& Track::classID()
00295 {
00296 return CLID_Track;
00297 }
00298
00299 inline double Track::chi2PerDoF() const
00300 {
00301 return m_chi2PerDoF;
00302 }
00303
00304 inline void Track::setChi2PerDoF(double value)
00305 {
00306 m_chi2PerDoF = value;
00307 }
00308
00309 inline int Track::nDoF() const
00310 {
00311 return m_nDoF;
00312 }
00313
00314 inline void Track::setNDoF(int value)
00315 {
00316 m_nDoF = value;
00317 }
00318
00319 inline unsigned int Track::flags() const
00320 {
00321 return m_flags;
00322 }
00323
00324 inline void Track::setType(const TrackType& value)
00325 {
00326 unsigned int val = (unsigned int)value;
00327 m_flags &= ~typeMask;
00328 m_flags |= ((((unsigned int)val) << typeBits) & typeMask);
00329 }
00330
00331 inline bool Track::checkType(const TrackType& value) const
00332 {
00333 unsigned int val = (unsigned int)value;
00334 return 0 != ( m_flags & typeMask & ( val << typeBits ));
00335 }
00336
00337 inline void Track::setFlag(const Flag& value)
00338 {
00339 unsigned int val = (unsigned int)value;
00340 m_flags |= ((((unsigned int)val) << flagBits) & flagMask);
00341 }
00342
00343 inline bool Track::checkFlag(const Flag& value) const
00344 {
00345 unsigned int val = (unsigned int)value;
00346 return 0 != ( m_flags & flagMask & ( val << flagBits ));
00347 }
00348
00349 inline const std::vector<LHCbID>& Track::lhcbIDs() const
00350 {
00351 return m_lhcbIDs;
00352 }
00353
00354 inline std::vector<LHCbID>& Track::lhcbIDs()
00355 {
00356 return m_lhcbIDs;
00357 }
00358
00359 inline void Track::setLhcbIDs(const std::vector<LHCbID>& value)
00360 {
00361 m_lhcbIDs = value;
00362 }
00363
00364 inline const State& Track::physicsState() const
00365 {
00366 return m_physicsState;
00367 }
00368
00369 inline State& Track::physicsState()
00370 {
00371 return m_physicsState;
00372 }
00373
00374 inline void Track::setPhysicsState(const State& value)
00375 {
00376 m_physicsState = value;
00377 }
00378
00379 inline const std::vector<State*>& Track::states() const
00380 {
00381 return m_states;
00382 }
00383
00384 inline std::vector<State*>& Track::states()
00385 {
00386 return m_states;
00387 }
00388
00389 inline void Track::setStates(const std::vector<State*>& value)
00390 {
00391 m_states = value;
00392 }
00393
00394 inline int Track::charge() const
00395 {
00396
00397 double qP = m_physicsState.qOverP();
00398 return ( qP != 0. ? int(fabs(qP)/qP) : 0 );
00399
00400 }
00401
00402 inline unsigned int Track::nStates() const
00403 {
00404
00405 return m_states.size();
00406
00407 }
00408
00409 inline void Track::addToStates(State* value)
00410 {
00411
00412 m_states.push_back( value );
00413
00414 }
00415
00416 inline void Track::removeFromStates(State* value)
00417 {
00418
00419 std::vector<State*>::iterator iter =
00420 std::remove( m_states.begin(), m_states.end(), value );
00421 m_states.erase( iter, m_states.end() );
00422
00423 }
00424
00425 inline double Track::chi2() const
00426 {
00427
00428 return ( m_chi2PerDoF * double(m_nDoF) );
00429
00430 }
00431
00432 inline void Track::reset()
00433 {
00434
00435 m_chi2PerDoF = 0;
00436 m_nDoF = 0;
00437 m_flags = 0;
00438 m_physicsState.reset();
00439 m_states.clear();
00440 m_lhcbIDs.clear();
00441
00442 }
00443
00444 inline void Track::addToLhcbIDs(const LHCbID& value)
00445 {
00446
00447 m_lhcbIDs.push_back( value );
00448
00449 }
00450
00451 inline void Track::removeFromLhcbIDs(const LHCbID& value)
00452 {
00453
00454 std::vector<LHCbID>::iterator iter =
00455 std::remove( m_lhcbIDs.begin(), m_lhcbIDs.end(), value );
00456 m_lhcbIDs.erase( iter, m_lhcbIDs.end() );
00457
00458 }
00459
00460
00461 typedef KeyedContainer<Track, Containers::HashMap> Tracks;
00462
00463
00464
00465 #endif