00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TrEvent_TrTrack_H
00019 #define TrEvent_TrTrack_H 1
00020
00021
00022 #include <algorithm>
00023 #include "Kernel/CLHEPStreams.h"
00024 #include "TrKernel/ITrExtrapolator.h"
00025 #include "GaudiKernel/KeyedObject.h"
00026 #include "Kernel/LHCbID.h"
00027 #include "GaudiKernel/ObjectList.h"
00028 #include "GaudiKernel/ObjectVector.h"
00029 #include "Kernel/ParticleID.h"
00030 #include "CLHEP/Geometry/Plane3D.h"
00031 #include "GaudiKernel/SmartRef.h"
00032 #include "GaudiKernel/SmartRefVector.h"
00033 #include "GaudiKernel/StreamBuffer.h"
00034 #include "Event/TrNode.h"
00035 #include "Event/TrState.h"
00036
00037
00038
00039 static const CLID& CLID_TrTrack = 10003;
00040
00041
00042 namespace TrTrackLocation {
00043 static const std::string& Default = "Rec/Tr/Best";
00044 static const std::string& Velo = "Rec/Tr/Velo";
00045 static const std::string& Seed = "Rec/Tr/Seed";
00046 static const std::string& Match = "Rec/Tr/Match";
00047 static const std::string& Forward = "Rec/Tr/Forward";
00048 static const std::string& Follow = "Rec/Tr/Follow";
00049 static const std::string& VeloTT = "Rec/Tr/VeloTT";
00050 static const std::string& KsTrack = "Rec/Tr/KsTrack";
00051 }
00052
00053
00063 class TrTrack: public KeyedObject<int>
00064 {
00065
00066 public:
00067
00068 enum TrackType {Long,Velotrack,Backward,Ttrack,Upstream,Downstream,L1Long,L1RZVelo,L1SpaceVelo,L1VeloTT,L1MuonMatched,L1Tracks,L1KShort,L1Downstream,HLTLong,HLTRZVelo,HLTSpaceVelo,HLTVeloTT};
00069 enum HistoryFlag {LongTrack,Seeding,TrKshort,TrMatching,VeloTrack,VeloTT,TrgForward,TrgVelo,TrgVeloTT};
00070
00072 TrTrack(const TrTrack& track);
00073
00075 TrTrack()
00076 : m_type(0),
00077 m_chi2PerDoF(0.0),
00078 m_nDoF(0),
00079 m_historyFlag(0),
00080 m_flags(0) {}
00081
00083 virtual ~TrTrack() {}
00084
00086 virtual const CLID& clID() const;
00087 static const CLID& classID();
00088
00090 StatusCode positionAndMomentum(HepPoint3D& pos, HepVector3D& mom, HepSymMatrix& cov6D);
00091
00093 StatusCode positionAndMomentum(double z, ITrExtrapolator* extrapolator, ParticleID& pid, HepPoint3D& pos, HepVector3D& mom, HepSymMatrix& cov6D);
00094
00096 StatusCode positionAndMomentum(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, HepPoint3D& pos, HepVector3D& mom, HepSymMatrix& cov6D);
00097
00099 StatusCode position(HepPoint3D& pos, HepSymMatrix& errPos);
00100
00102 StatusCode position(double z, ITrExtrapolator* extrapolator, ParticleID& pid, HepPoint3D& pos, HepSymMatrix& errPos);
00103
00105 StatusCode position(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, HepPoint3D& pos, HepSymMatrix& errPos);
00106
00108 StatusCode slopes(HepVector3D& slopes, HepSymMatrix& errSlopes);
00109
00111 StatusCode slopes(double z, ITrExtrapolator* extrapolator, ParticleID& pid, HepVector3D& slopes, HepSymMatrix& errSlopes);
00112
00114 StatusCode slopes(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, HepVector3D& slopes, HepSymMatrix& errSlopes);
00115
00117 double p();
00118
00120 StatusCode p(double z, ITrExtrapolator* extrapolator, ParticleID& pid, double p);
00121
00123 StatusCode p(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, double p);
00124
00126 double pt();
00127
00129 StatusCode pt(double z, ITrExtrapolator* extrapolator, ParticleID& pid, double pt);
00130
00132 StatusCode pt(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, double pt);
00133
00135 StatusCode momentum(HepVector3D& mom, HepSymMatrix& errMom);
00136
00138 StatusCode momentum(double z, ITrExtrapolator* extrapolator, ParticleID& pid, HepVector3D& mom, HepSymMatrix& errMom);
00139
00141 StatusCode momentum(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, HepVector3D& mom, HepSymMatrix& errMom);
00142
00144 StatusCode posMomCovariance(HepSymMatrix& cov6D);
00145
00147 StatusCode posMomCovariance(double z, ITrExtrapolator* extrapolator, ParticleID& pid, HepSymMatrix& cov6D);
00148
00150 StatusCode posMomCovariance(HepPlane3D& plane, ITrExtrapolator* extrapolator, ParticleID& pid, HepSymMatrix& cov6D);
00151
00153 virtual bool producedByAlgo(const TrTrack::HistoryFlag& flag);
00154
00156 int charge() const;
00157
00159 unsigned int nStates() const;
00160
00162 virtual TrState* closestState(double z);
00163
00165 virtual TrState* closestState(HepPlane3D& plane);
00166
00168 double chi2() const;
00169
00171 virtual void reset();
00172
00174 virtual TrTrack* clone();
00175
00177 int type() const;
00178
00180 void setType(int value);
00181
00183 double chi2PerDoF() const;
00184
00186 void setChi2PerDoF(double value);
00187
00189 int nDoF() const;
00190
00192 void setNDoF(int value);
00193
00195 unsigned flags() const;
00196
00198 void setFlags(unsigned value);
00199
00201 void setValid(bool value);
00202
00204 bool valid() const;
00205
00207 const SmartRefVector<LHCbID>& lhcbIDs() const;
00208
00210 SmartRefVector<LHCbID>& lhcbIDs();
00211
00213 void setLhcbIDs(const SmartRefVector<LHCbID>& value);
00214
00216 void addToLhcbIDs(const SmartRef<LHCbID>& value);
00217
00219 void removeFromLhcbIDs(const SmartRef<LHCbID>& value);
00220
00222 void clearLhcbIDs();
00223
00225 const TrState* closestState() const;
00226
00228 TrState* closestState();
00229
00231 void setClosestState(const SmartRef<TrState>& value);
00232
00234 const SmartRefVector<TrState>& states() const;
00235
00237 SmartRefVector<TrState>& states();
00238
00240 void setStates(const SmartRefVector<TrState>& value);
00241
00243 void addToStates(const SmartRef<TrState>& value);
00244
00246 void removeFromStates(const SmartRef<TrState>& value);
00247
00249 void clearStates();
00250
00252 virtual StreamBuffer& serialize(StreamBuffer& s) const;
00253
00255 virtual StreamBuffer& serialize(StreamBuffer& s);
00256
00258 virtual std::ostream& fillStream(std::ostream& s) const;
00259
00260 protected:
00261
00262 private:
00263
00264 enum flagsBits {validBits = 0};
00265 enum flagsMasks {validMask = 0x00000001};
00266
00267 int m_type;
00268 double m_chi2PerDoF;
00269 int m_nDoF;
00270 int m_historyFlag;
00271 unsigned m_flags;
00272 SmartRefVector<LHCbID> m_lhcbIDs;
00273 SmartRef<TrState> m_closestState;
00274 SmartRefVector<TrState> m_states;
00275
00276 };
00277
00278
00279
00280
00281
00282
00283 inline const CLID& TrTrack::clID() const
00284 {
00285 return TrTrack::classID();
00286 }
00287
00288 inline const CLID& TrTrack::classID()
00289 {
00290 return CLID_TrTrack;
00291 }
00292
00293 inline int TrTrack::charge() const
00294 {
00295
00296 return ( ( m_closestState->qOverP() > 0. ) ? 1 : -1 );
00297
00298 }
00299
00300 inline unsigned int TrTrack::nStates() const
00301 {
00302
00303 return m_states.size();
00304
00305 }
00306
00307 inline double TrTrack::chi2() const
00308 {
00309
00310 return ( m_chi2PerDoF * double(m_nDoF) );
00311
00312 }
00313
00314 inline void TrTrack::reset()
00315 {
00316
00317 m_type = 0;
00318 m_chi2PerDoF = 0;
00319 m_nDoF = 0;
00320 m_historyFlag = 0;
00321
00322 }
00323
00324 inline int TrTrack::type() const
00325 {
00326 return m_type;
00327 }
00328
00329 inline void TrTrack::setType(int value)
00330 {
00331 m_type = value;
00332 }
00333
00334 inline double TrTrack::chi2PerDoF() const
00335 {
00336 return m_chi2PerDoF;
00337 }
00338
00339 inline void TrTrack::setChi2PerDoF(double value)
00340 {
00341 m_chi2PerDoF = value;
00342 }
00343
00344 inline int TrTrack::nDoF() const
00345 {
00346 return m_nDoF;
00347 }
00348
00349 inline void TrTrack::setNDoF(int value)
00350 {
00351 m_nDoF = value;
00352 }
00353
00354 inline unsigned TrTrack::flags() const
00355 {
00356 return m_flags;
00357 }
00358
00359 inline void TrTrack::setFlags(unsigned value)
00360 {
00361 m_flags = value;
00362 }
00363
00364 inline void TrTrack::setValid(bool value)
00365 {
00366 unsigned val = (unsigned)value;
00367 m_flags &= ~validMask;
00368 m_flags |= ((((unsigned)val) << validBits) & validMask);
00369 }
00370
00371 inline bool TrTrack::valid() const
00372 {
00373 return (bool)((m_flags & validMask) >> validBits);
00374 }
00375
00376 inline const SmartRefVector<LHCbID>& TrTrack::lhcbIDs() const
00377 {
00378 return m_lhcbIDs;
00379 }
00380
00381 inline SmartRefVector<LHCbID>& TrTrack::lhcbIDs()
00382 {
00383 return m_lhcbIDs;
00384 }
00385
00386 inline void TrTrack::setLhcbIDs(const SmartRefVector<LHCbID>& value)
00387 {
00388 m_lhcbIDs = value;
00389 }
00390
00391 inline void TrTrack::addToLhcbIDs(const SmartRef<LHCbID>& value)
00392 {
00393 m_lhcbIDs.push_back(value);
00394 }
00395
00396 inline void TrTrack::removeFromLhcbIDs(const SmartRef<LHCbID>& value)
00397 {
00398 SmartRefVector<LHCbID>::iterator iter =
00399 std::remove(m_lhcbIDs.begin(), m_lhcbIDs.end(), value);
00400 m_lhcbIDs.erase(iter, m_lhcbIDs.end());
00401 }
00402
00403 inline void TrTrack::clearLhcbIDs()
00404 {
00405 m_lhcbIDs.clear();
00406 }
00407
00408 inline const TrState* TrTrack::closestState() const
00409 {
00410 return m_closestState;
00411 }
00412
00413 inline TrState* TrTrack::closestState()
00414 {
00415 return m_closestState;
00416 }
00417
00418 inline void TrTrack::setClosestState(const SmartRef<TrState>& value)
00419 {
00420 m_closestState = value;
00421 }
00422
00423 inline const SmartRefVector<TrState>& TrTrack::states() const
00424 {
00425 return m_states;
00426 }
00427
00428 inline SmartRefVector<TrState>& TrTrack::states()
00429 {
00430 return m_states;
00431 }
00432
00433 inline void TrTrack::setStates(const SmartRefVector<TrState>& value)
00434 {
00435 m_states = value;
00436 }
00437
00438 inline void TrTrack::addToStates(const SmartRef<TrState>& value)
00439 {
00440 m_states.push_back(value);
00441 }
00442
00443 inline void TrTrack::removeFromStates(const SmartRef<TrState>& value)
00444 {
00445 SmartRefVector<TrState>::iterator iter =
00446 std::remove(m_states.begin(), m_states.end(), value);
00447 m_states.erase(iter, m_states.end());
00448 }
00449
00450 inline void TrTrack::clearStates()
00451 {
00452 m_states.clear();
00453 }
00454
00455 inline StreamBuffer& TrTrack::serialize(StreamBuffer& s) const
00456 {
00457 KeyedObject<int>::serialize(s);
00458 s << m_type
00459 << (float)m_chi2PerDoF
00460 << m_nDoF
00461 << m_historyFlag
00462 << m_flags
00463 << m_lhcbIDs(this)
00464 << m_closestState(this);
00465 return s;
00466 }
00467
00468 inline StreamBuffer& TrTrack::serialize(StreamBuffer& s)
00469 {
00470 float l_chi2PerDoF;
00471 KeyedObject<int>::serialize(s);
00472 s >> m_type
00473 >> l_chi2PerDoF
00474 >> m_nDoF
00475 >> m_historyFlag
00476 >> m_flags
00477 >> m_lhcbIDs(this)
00478 >> m_closestState(this);
00479 m_chi2PerDoF = l_chi2PerDoF;
00480 return s;
00481 }
00482
00483 inline std::ostream& TrTrack::fillStream(std::ostream& s) const
00484 {
00485 s << "{ "
00486 << " type:\t" << m_type << std::endl
00487 << " chi2PerDoF:\t" << (float)m_chi2PerDoF << std::endl
00488 << " nDoF:\t" << m_nDoF << std::endl
00489 << " historyFlag:\t" << m_historyFlag << std::endl
00490 << " flags:\t" << m_flags << std::endl
00491 << " valid:\t" << valid() << " } ";
00492 return s;
00493 }
00494
00495
00496 typedef KeyedContainer<TrTrack, Containers::HashMap> TrTracks;
00497
00498 #endif