00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TrEvent_TrState_H
00019 #define TrEvent_TrState_H 1
00020
00021
00022 #include "Kernel/CLHEPStreams.h"
00023 #include "CLHEP/Matrix/SymMatrix.h"
00024 #include "CLHEP/Matrix/Vector.h"
00025 #include "GaudiKernel/KeyedObject.h"
00026 #include "GaudiKernel/ObjectList.h"
00027 #include "GaudiKernel/ObjectVector.h"
00028 #include "GaudiKernel/StreamBuffer.h"
00029
00030
00031
00032 static const CLID& CLID_TrState = 10004;
00033
00034
00035 namespace TrStateLocation {
00036 static const std::string& Default = "Rec/Tr/States";
00037 }
00038
00039
00049 class TrState: public KeyedObject<int>
00050 {
00051
00052 public:
00053
00054 enum Type {HasMomentum,StraightLine};
00055 enum ReferenceLocation {NotDefined=0,ClosestToBeam,AtFirstMeasurement,BeforeRICH1,AfterRICH1,BeforeRICH2,AfterRICH2};
00056
00058 TrState(const TrState& state)
00059 {
00060
00061 m_type = state.type();
00062 m_state = state.state();
00063 m_stateCovariance = state.stateCovariance();
00064 m_z = state.z();
00065
00066 }
00067
00069 TrState()
00070 : m_type(0),
00071 m_state(),
00072 m_stateCovariance(),
00073 m_z(0.0) {}
00074
00076 virtual ~TrState() {}
00077
00079 virtual const CLID& clID() const;
00080 static const CLID& classID();
00081
00083 virtual void positionAndMomentum(const HepPoint3D& pos, const HepVector3D& mom, const HepSymMatrix& cov6D) const;
00084
00086 virtual HepPoint3D position() const;
00087
00089 virtual double x() const;
00090
00092 virtual double y() const;
00093
00095 virtual double z() const;
00096
00098 virtual HepVector3D slopes() const;
00099
00101 virtual double tx() const;
00102
00104 virtual double ty() const;
00105
00107 virtual double qOverP() const;
00108
00110 virtual double p() const;
00111
00113 virtual double pt() const;
00114
00116 virtual HepVector3D momentum() const;
00117
00119 virtual HepSymMatrix posMomCovariance() const;
00120
00122 virtual std::vector errPosition() const;
00123
00125 virtual double errX2() const;
00126
00128 virtual double errY2() const;
00129
00131 virtual std::vector errSlopes() const;
00132
00134 virtual double errTx2() const;
00135
00137 virtual double errTy2() const;
00138
00140 virtual double errQOverP2() const;
00141
00143 virtual double errP2() const;
00144
00146 virtual std::vector errMomentum() const;
00147
00149 virtual TrState* clone() const;
00150
00152 virtual void setState(const HepVector& state);
00153
00155 virtual void setState(double x, double y, double z, double tx, double ty, double qOverP);
00156
00158 virtual void setState(double x, double y, double z, double tx, double ty);
00159
00161 virtual void setX(double value);
00162
00164 virtual void setY(double value);
00165
00167 virtual void setTx(double value);
00168
00170 virtual void setTy(double value);
00171
00173 virtual void setQOverP(double value);
00174
00176 virtual void setErrX2(double value);
00177
00179 virtual void setErrY2(double value);
00180
00182 virtual void setErrTx2(double value);
00183
00185 virtual void setErrTy2(double value);
00186
00188 virtual void setErrQOverP2(double value);
00189
00191 int type() const;
00192
00194 void setType(int value);
00195
00197 const HepVector& state() const;
00198
00200 HepVector& state();
00201
00203 const HepSymMatrix& stateCovariance() const;
00204
00206 HepSymMatrix& stateCovariance();
00207
00209 void setStateCovariance(const HepSymMatrix& value);
00210
00212 double z() const;
00213
00215 void setZ(double value);
00216
00218 virtual StreamBuffer& serialize(StreamBuffer& s) const;
00219
00221 virtual StreamBuffer& serialize(StreamBuffer& s);
00222
00224 virtual std::ostream& fillStream(std::ostream& s) const;
00225
00226 protected:
00227
00228 private:
00229
00230 int m_type;
00231 HepVector m_state;
00232 HepSymMatrix m_stateCovariance;
00233 double m_z;
00234
00235 };
00236
00237
00238
00239
00240
00241
00242 inline const CLID& TrState::clID() const
00243 {
00244 return TrState::classID();
00245 }
00246
00247 inline const CLID& TrState::classID()
00248 {
00249 return CLID_TrState;
00250 }
00251
00252 inline void TrState::positionAndMomentum(const HepPoint3D& pos, const HepVector3D& mom, const HepSymMatrix& cov6D) const
00253 {
00254
00255 HepPoint3D pos = state.position();
00256
00257 }
00258
00259 inline HepPoint3D TrState::position() const
00260 {
00261
00262 return HepPoint3D( m_state[0], m_state[1], m_z );
00263
00264 }
00265
00266 inline double TrState::x() const
00267 {
00268
00269 return m_state[0];
00270
00271 }
00272
00273 inline double TrState::y() const
00274 {
00275
00276 return m_state[1];
00277
00278 }
00279
00280 inline double TrState::z() const
00281 {
00282
00283 return m_z;
00284
00285 }
00286
00287 inline double TrState::tx() const
00288 {
00289
00290 return m_state[2];
00291
00292 }
00293
00294 inline double TrState::ty() const
00295 {
00296
00297 return m_state[3];
00298
00299 }
00300
00301 inline double TrState::qOverP() const
00302 {
00303
00304 return m_state[4];
00305
00306 }
00307
00308 inline double TrState::p() const
00309 {
00310
00311 if ( m_state.type() == TrState::StraightLine ) return 0.;
00312 return fabs( 1./m_state[4] );
00313
00314 }
00315
00316 inline double TrState::errX2() const
00317 {
00318
00319 return m_covariance.fast(1,1);
00320
00321 }
00322
00323 inline double TrState::errY2() const
00324 {
00325
00326 return m_covariance.fast(2,2);
00327
00328 }
00329
00330 inline double TrState::errTx2() const
00331 {
00332
00333 return m_covariance.fast(3,3);
00334
00335 }
00336
00337 inline double TrState::errTy2() const
00338 {
00339
00340 return m_covariance.fast(4,4);
00341
00342 }
00343
00344 inline void TrState::setState(double x, double y, double z, double tx, double ty, double qOverP)
00345 {
00346
00347 m_state[0] = x;
00348 m_state[1] = y;
00349 m_state[2] = tx;
00350 m_state[3] = ty;
00351 m_state[4] = qOverP;
00352 m_z = z;
00353
00354 }
00355
00356 inline void TrState::setState(double x, double y, double z, double tx, double ty)
00357 {
00358
00359 m_state[0] = x;
00360 m_state[1] = y;
00361 m_state[2] = tx;
00362 m_state[3] = ty;
00363 m_z = z;
00364
00365 }
00366
00367 inline void TrState::setX(double value)
00368 {
00369
00370 m_state[0] = value;
00371
00372 }
00373
00374 inline void TrState::setY(double value)
00375 {
00376
00377 m_state[1] = value;
00378
00379 }
00380
00381 inline void TrState::setTx(double value)
00382 {
00383
00384 m_state[2] = value;
00385
00386 }
00387
00388 inline void TrState::setTy(double value)
00389 {
00390
00391 m_state[3] = value;
00392
00393 }
00394
00395 inline void TrState::setQOverP(double value)
00396 {
00397
00398 if ( m_state.type() == TrState::HasMomentum ) m_state[4] = value;
00399
00400 }
00401
00402 inline void TrState::setErrX2(double value)
00403 {
00404
00405 m_covariance(1,1) = value;
00406
00407 }
00408
00409 inline void TrState::setErrY2(double value)
00410 {
00411
00412 m_covariance(2,2) = value;
00413
00414 }
00415
00416 inline void TrState::setErrTx2(double value)
00417 {
00418
00419 m_covariance(3,3) = value;
00420
00421 }
00422
00423 inline void TrState::setErrTy2(double value)
00424 {
00425
00426 m_covariance(4,4) = value;
00427
00428 }
00429
00430 inline void TrState::setErrQOverP2(double value)
00431 {
00432
00433 if ( m_state.type() == TrState::HasMomentum ) m_covariance(5,5) = value;
00434
00435 }
00436
00437 inline int TrState::type() const
00438 {
00439 return m_type;
00440 }
00441
00442 inline void TrState::setType(int value)
00443 {
00444 m_type = value;
00445 }
00446
00447 inline const HepVector& TrState::state() const
00448 {
00449 return m_state;
00450 }
00451
00452 inline HepVector& TrState::state()
00453 {
00454 return m_state;
00455 }
00456
00457 inline const HepSymMatrix& TrState::stateCovariance() const
00458 {
00459 return m_stateCovariance;
00460 }
00461
00462 inline HepSymMatrix& TrState::stateCovariance()
00463 {
00464 return m_stateCovariance;
00465 }
00466
00467 inline void TrState::setStateCovariance(const HepSymMatrix& value)
00468 {
00469 m_stateCovariance = value;
00470 }
00471
00472 inline double TrState::z() const
00473 {
00474 return m_z;
00475 }
00476
00477 inline void TrState::setZ(double value)
00478 {
00479 m_z = value;
00480 }
00481
00482 inline StreamBuffer& TrState::serialize(StreamBuffer& s) const
00483 {
00484 KeyedObject<int>::serialize(s);
00485 s << m_type
00486 << m_state
00487 << m_stateCovariance
00488 << (float)m_z;
00489 return s;
00490 }
00491
00492 inline StreamBuffer& TrState::serialize(StreamBuffer& s)
00493 {
00494 float l_z;
00495 KeyedObject<int>::serialize(s);
00496 s >> m_type
00497 >> m_state
00498 >> m_stateCovariance
00499 >> l_z;
00500 m_z = l_z;
00501 return s;
00502 }
00503
00504 inline std::ostream& TrState::fillStream(std::ostream& s) const
00505 {
00506 s << "{ "
00507 << " type:\t" << m_type << std::endl
00508 << " state:\t" << m_state << std::endl
00509 << " stateCovariance:\t" << m_stateCovariance << std::endl
00510 << " z:\t" << (float)m_z << " } ";
00511 return s;
00512 }
00513
00514
00515 typedef KeyedContainer<TrState, Containers::HashMap> TrStates;
00516
00517 #endif