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 <vector>
00023 #include "Kernel/CLHEPStreams.h"
00024 #include "GaudiKernel/KeyedObject.h"
00025 #include "Kernel/LHCbID.h"
00026 #include "GaudiKernel/ObjectList.h"
00027 #include "GaudiKernel/ObjectVector.h"
00028 #include "CLHEP/Geometry/Plane3D.h"
00029 #include "GaudiKernel/StreamBuffer.h"
00030 #include "Event/TrState.h"
00031
00032
00033
00034 static const CLID& CLID_TrTrack = 10003;
00035
00036
00037 namespace TrTrackLocation {
00038 static const std::string& Default = "Rec/Tr/Best";
00039 static const std::string& Velo = "Rec/Tr/Velo";
00040 static const std::string& Seed = "Rec/Tr/Seed";
00041 static const std::string& Match = "Rec/Tr/Match";
00042 static const std::string& Forward = "Rec/Tr/Forward";
00043 static const std::string& Follow = "Rec/Tr/Follow";
00044 static const std::string& VeloTT = "Rec/Tr/VeloTT";
00045 static const std::string& KsTrack = "Rec/Tr/KsTrack";
00046 }
00047
00048
00058 class TrTrack: public KeyedObject<int>
00059 {
00060
00061 public:
00062
00063 enum TrackType {Long,Velotrack,Backward,Ttrack,Upstream,Downstream,L1Long,L1RZVelo,L1SpaceVelo,L1VeloTT,L1MuonMatched,L1KShort,L1Downstream,HLTRZVelo,HLTSpaceVelo,HLTVeloTT};
00064 enum HistoryFlag {LongTrack,Seeding,TrKshort,TrMatching,VeloTrack,VeloTT,TrgForward,TrgVelo,TrgVeloTT};
00065
00067 TrTrack()
00068 : m_chi2PerDoF(0.0),
00069 m_nDoF(0),
00070 m_flags(0),
00071 m_lhcbids(),
00072 m_physicsState(),
00073 m_states() {}
00074
00076 virtual ~TrTrack() {}
00077
00079 virtual const CLID& clID() const;
00080 static const CLID& classID();
00081
00083 StatusCode positionAndMomentum(HepPoint3D& pos, HepVector3D& mom, HepSymMatrix& cov6D) const;
00084
00086 StatusCode position(HepPoint3D& pos, HepSymMatrix& errPos) const;
00087
00089 StatusCode slopes(HepVector3D& slopes, HepSymMatrix& errSlopes) const;
00090
00092 double p() const;
00093
00095 double pt() const;
00096
00098 StatusCode momentum(HepVector3D& mom, HepSymMatrix& errMom) const;
00099
00101 StatusCode posMomCovariance(HepSymMatrix& cov6D) const;
00102
00104 int charge() const;
00105
00107 unsigned int nStates() const;
00108
00110 void addToStates(TrState* value);
00111
00113 void removeFromStates(const TrState& value);
00114
00116 virtual TrState* closestState(double z);
00117
00119 virtual const TrState* closestState(double z) const;
00120
00122 virtual TrState* closestState(HepPlane3D& plane);
00123
00125 virtual const TrState* closestState(HepPlane3D& plane) const;
00126
00128 double chi2() const;
00129
00131 virtual void reset();
00132
00134 virtual TrTrack* clone() const;
00135
00137 std::vector<LHCbID> & LHCbIDs();
00138
00140 const std::vector<LHCbID> & LHCbIDs() const;
00141
00143 void setLHCbIDs(const std::vector<LHCbID>& value);
00144
00146 void addToLHCbIDs(const LHCbID& value);
00147
00149 void removeFromLHCbIDs(const LHCbID& value);
00150
00152 bool type(unsigned value) const;
00153
00155 void setType(unsigned value);
00156
00158 bool history(unsigned value) const;
00159
00161 void setHistory(unsigned value);
00162
00164 virtual bool producedByAlgo(const TrTrack::HistoryFlag& flag) const;
00165
00167 bool flag(unsigned value) const;
00168
00170 void setFlag(unsigned value);
00171
00173 double chi2PerDoF() const;
00174
00176 void setChi2PerDoF(double value);
00177
00179 int nDoF() const;
00180
00182 void setNDoF(int value);
00183
00185 unsigned flags() const;
00186
00188 void setFlags(unsigned value);
00189
00191 void setValid(bool value);
00192
00194 bool valid() const;
00195
00197 const TrState& physicsState() const;
00198
00200 TrState& physicsState();
00201
00203 void setPhysicsState(const TrState& value);
00204
00206 const std::vector<TrState*>& states() const;
00207
00209 std::vector<TrState*>& states();
00210
00212 void setStates(const std::vector<TrState*>& value);
00213
00215 virtual StreamBuffer& serialize(StreamBuffer& s) const;
00216
00218 virtual StreamBuffer& serialize(StreamBuffer& s);
00219
00221 virtual std::ostream& fillStream(std::ostream& s) const;
00222
00223 protected:
00224
00225 private:
00226
00227 enum flagsBits {validBits = 0};
00228 enum flagsMasks {validMask = 0x00000001};
00229
00230 double m_chi2PerDoF;
00231 int m_nDoF;
00232 unsigned m_flags;
00233 std::vector<LHCbID> m_lhcbids;
00234 TrState m_physicsState;
00235 std::vector<TrState*> m_states;
00236
00237 };
00238
00239
00240
00241
00242
00243
00244 inline const CLID& TrTrack::clID() const
00245 {
00246 return TrTrack::classID();
00247 }
00248
00249 inline const CLID& TrTrack::classID()
00250 {
00251 return CLID_TrTrack;
00252 }
00253
00254 inline unsigned int TrTrack::nStates() const
00255 {
00256
00257 return m_states.size();
00258
00259 }
00260
00261 inline void TrTrack::addToStates(TrState* value)
00262 {
00263
00264 m_states.push_back( value );
00265
00266 }
00267
00268 inline void TrTrack::removeFromStates(const TrState& value)
00269 {
00270
00271 std::vector<TrState*>::iterator iter =
00272 std::remove( m_states.begin(), m_states.end(), value );
00273 m_states.erase( iter, m_states.end() );
00274
00275 }
00276
00277 inline double TrTrack::chi2() const
00278 {
00279
00280 return ( m_chi2PerDoF * double(m_nDoF) );
00281
00282 }
00283
00284 inline void TrTrack::reset()
00285 {
00286
00287 m_type = 0;
00288 m_chi2PerDoF = 0;
00289 m_nDoF = 0;
00290 m_historyFlag = 0;
00291 m_physicsState = 0;
00292 m_states.clear();
00293
00294 }
00295
00296 inline std::vector<LHCbID> & TrTrack::LHCbIDs()
00297 {
00298
00299 return m_lhcbids;
00300
00301 }
00302
00303 inline const std::vector<LHCbID> & TrTrack::LHCbIDs() const
00304 {
00305
00306 return m_lhcbids;
00307
00308 }
00309
00310 inline void TrTrack::setLHCbIDs(const std::vector<LHCbID>& value)
00311 {
00312
00313 m_lhcbids = value;
00314
00315 }
00316
00317 inline void TrTrack::addToLHCbIDs(const LHCbID& value)
00318 {
00319
00320 m_lhcbids.push_back( value );
00321
00322 }
00323
00324 inline void TrTrack::removeFromLHCbIDs(const LHCbID& value)
00325 {
00326
00327 std::vector<LHCbID>::iterator iter =
00328 std::remove( m_lhcbids.begin(), m_lhcbids.end(), value );
00329 m_lhcbids.erase( iter, m_lhcbids.end() );
00330
00331 }
00332
00333 inline double TrTrack::chi2PerDoF() const
00334 {
00335 return m_chi2PerDoF;
00336 }
00337
00338 inline void TrTrack::setChi2PerDoF(double value)
00339 {
00340 m_chi2PerDoF = value;
00341 }
00342
00343 inline int TrTrack::nDoF() const
00344 {
00345 return m_nDoF;
00346 }
00347
00348 inline void TrTrack::setNDoF(int value)
00349 {
00350 m_nDoF = value;
00351 }
00352
00353 inline unsigned TrTrack::flags() const
00354 {
00355 return m_flags;
00356 }
00357
00358 inline void TrTrack::setFlags(unsigned value)
00359 {
00360 m_flags = value;
00361 }
00362
00363 inline void TrTrack::setValid(bool value)
00364 {
00365 unsigned val = (unsigned)value;
00366 m_flags &= ~validMask;
00367 m_flags |= ((((unsigned)val) << validBits) & validMask);
00368 }
00369
00370 inline bool TrTrack::valid() const
00371 {
00372 return (bool)((m_flags & validMask) >> validBits);
00373 }
00374
00375 inline const TrState& TrTrack::physicsState() const
00376 {
00377 return m_physicsState;
00378 }
00379
00380 inline TrState& TrTrack::physicsState()
00381 {
00382 return m_physicsState;
00383 }
00384
00385 inline void TrTrack::setPhysicsState(const TrState& value)
00386 {
00387 m_physicsState = value;
00388 }
00389
00390 inline const std::vector<TrState*>& TrTrack::states() const
00391 {
00392 return m_states;
00393 }
00394
00395 inline std::vector<TrState*>& TrTrack::states()
00396 {
00397 return m_states;
00398 }
00399
00400 inline void TrTrack::setStates(const std::vector<TrState*>& value)
00401 {
00402 m_states = value;
00403 }
00404
00405 inline StreamBuffer& TrTrack::serialize(StreamBuffer& s) const
00406 {
00407 KeyedObject<int>::serialize(s);
00408 s << (float)m_chi2PerDoF
00409 << m_nDoF
00410 << m_flags
00411 << m_physicsState;
00412 return s;
00413 }
00414
00415 inline StreamBuffer& TrTrack::serialize(StreamBuffer& s)
00416 {
00417 float l_chi2PerDoF;
00418 KeyedObject<int>::serialize(s);
00419 s >> l_chi2PerDoF
00420 >> m_nDoF
00421 >> m_flags
00422 >> m_physicsState;
00423 m_chi2PerDoF = l_chi2PerDoF;
00424 return s;
00425 }
00426
00427 inline std::ostream& TrTrack::fillStream(std::ostream& s) const
00428 {
00429 s << "{ "
00430 << " chi2PerDoF:\t" << (float)m_chi2PerDoF << std::endl
00431 << " nDoF:\t" << m_nDoF << std::endl
00432 << " flags:\t" << m_flags << std::endl
00433 << " valid:\t" << valid() << std::endl
00434 << " lhcbids:\t" << m_lhcbids << std::endl
00435 << " physicsState:\t" << m_physicsState << std::endl
00436 << " states:\t" << m_states << " } ";
00437 return s;
00438 }
00439
00440
00441 typedef KeyedContainer<TrTrack, Containers::HashMap> TrTracks;
00442
00443 #endif