00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TTrack_FLAG_
00014 #define TTrack_FLAG_
00015
00016 #ifdef TRKRECO_DEBUG_DETAIL
00017 #ifndef TRKRECO_DEBUG
00018 #define TRKRECO_DEBUG
00019 #endif
00020 #endif
00021
00022
00023 #define TrackOldConformalFinder 1
00024 #define TrackFastFinder 2
00025 #define TrackSlowFinder 4
00026 #define TrackCurlFinder 8
00027 #define TrackTrackManager 16
00028 #define TrackPMCurlFinder 32
00029 #define TrackSVDAssociator 64
00030 #define TrackFinderMask 255
00031
00032
00033 #define TrackTypeUndefined 0
00034 #define TrackTypeNormal 1
00035 #define TrackTypeCurl 2
00036 #define TrackTypeCircle 4
00037 #define TrackTypeCosmic 8
00038 #define TrackTypeIncomingCosmic 8
00039 #define TrackTypeOutgoingCosmic 16
00040 #define TrackTypeKink 32
00041 #define TrackTypeSVDOnly 256
00042
00043
00044 #define TrackQualityOutsideCurler 1
00045 #define TrackQualityAfterKink 2
00046 #define TrackQualityCosmic 4
00047 #define TrackQuality2D 8
00048 #define TrackQualityShift 8
00049 #define TrackQualityMask 255
00050
00051
00052 #define TrackFitGlobal 1
00053 #define TrackFitCosmic 2
00054 #define TrackFitCdcKalman 4
00055 #define TrackFitSvdCdcKalman 8
00056 #define TrackFitShift 16
00057 #define TrackFitMask 255
00058
00059
00060 #define TrackHasMother 1
00061 #define TrackHasDaughter 2
00062 #define TrackRelationShift 24
00063 #define TrackRelationMask 255
00064
00065 #include <string>
00066
00067 #define HEP_SHORT_NAMES
00068 #include "CLHEP/Vector/ThreeVector.h"
00069
00070
00071 #include "TrackUtil/Helix.h"
00072 #include "TrkReco/TMDCUtil.h"
00073 #include "TrkReco/TTrackBase.h"
00074 #include "TrkReco/TMLink.h"
00075 #include "TrkReco/TBuilder0.h"
00076 #include "TrkReco/TBuilderCosmic.h"
00077 #include "TrkReco/TBuilderCurl.h"
00078
00079 #include "TrkReco/TPoint2D.h"
00080
00081
00082 #include "TrkReco/T3DLine.h"
00083 #include "TrkReco/TRunge.h"
00084 #include "GaudiKernel/IInterface.h"
00085 #include "GaudiKernel/Kernel.h"
00086 #include "GaudiKernel/Service.h"
00087 #include "MagneticField/IMagneticFieldSvc.h"
00088 #include "MagneticField/MagneticFieldSvc.h"
00089
00090 #include "CLHEP/Matrix/Vector.h"
00091 #include "CLHEP/Matrix/SymMatrix.h"
00092 #include "CLHEP/Vector/ThreeVector.h"
00093 #include "CLHEP/Vector/LorentzVector.h"
00094 #include "CLHEP/Geometry/Point3D.h"
00095
00096
00097 using CLHEP::Hep3Vector;
00098
00099 #ifndef CLHEP_POINT3D_H
00100 #include "CLHEP/Geometry/Point3D.h"
00101 #endif
00102 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00103 typedef HepGeom::Point3D<double> HepPoint3D;
00104 #endif
00105 using HepGeom::Point3D;
00106
00107
00108 class TrkReco;
00109 class TTrackManager;
00110 class TCircle;
00111 class TCosmicFitter;
00112 class Refit;
00113 class THelixFitter;
00114 class TBuilder;
00115
00116 class TCurlFinder;
00117
00118
00119
00120
00121
00122 class MdcRec_trk;
00123 class MdcRec_trk_add;
00124 class MdcTrk_localz;
00125 class Gen_hepevt;
00126 class Mdst_trk_fit;
00127
00129 class TTrack : public TTrackBase {
00130
00131 public:
00133 TTrack();
00134
00136 TTrack(const TCircle &);
00137
00139 TTrack(const TTrack &);
00140
00142 TTrack(const T3DLine &);
00143
00145 TTrack(const Helix &);
00146
00147 TTrack(const TRunge &);
00149 virtual ~TTrack();
00150
00151 public:
00153 const std::string & name(void) const;
00154 const std::string & name(const std::string & newName);
00155
00157 TTrack * mother(void) const;
00158 TTrack * mother(TTrack *);
00159 TTrack * daughter(void) const;
00160 TTrack * daughter(TTrack *);
00161
00163 unsigned objectType(void) const;
00164
00166 unsigned type(void) const;
00167
00169 unsigned finder(void) const;
00170 unsigned finder(unsigned finderMask);
00171 void setFinderType(unsigned);
00172 unsigned getFinderType(void)const;
00173
00175 unsigned quality(void) const;
00176 unsigned quality(unsigned qualityMask);
00177
00179 unsigned fitting(void) const;
00180 unsigned fitting(unsigned fitMask);
00181
00183 unsigned state(void) const;
00184
00186 void assign(unsigned maskForWireHit);
00187
00189 void dump(const std::string & message = std::string(""),
00190 const std::string & prefix = std::string("")) const;
00191
00192 public:
00194 double charge(void) const;
00195
00197 const Helix & helix(void) const;
00198
00200 Hep3Vector p(void) const;
00201
00203 double ptot(void) const;
00204
00206 double pt(void) const;
00207
00209 double pz(void) const;
00210
00212 double impact(void) const;
00213
00215 TPoint2D center(void) const;
00216
00218 double radius(void) const;
00219
00221 unsigned ndf(void) const;
00222
00224 double chi2(void) const;
00225
00227 double confidenceLevel(void) const;
00228
00229 public:
00231 AList<TSegment> & segments(void);
00232 const AList<TSegment> & segments(void) const;
00233
00234 public:
00236 int approach(TMLink &) const;
00237 int approach(TMLink &, bool sagCorrection) const;
00238 int approach2D(TMLink &) const;
00239
00241 int szPosition(TMLink & link) const;
00242
00244 int szPosition(const TSegment & segment, TMLink & link) const;
00245
00247 int szPosition(const HepPoint3D & p, HepPoint3D & szPosition) const;
00248
00250 #define OLD_STEREO 1
00251 #if OLD_STEREO
00252 int stereoHitForCurl(TMLink & link, AList<HepPoint3D> & arcZList) const;
00253 int stereoHitForCurl(TMLink & link, TMLink & link1) const;
00254 int stereoHitForCurl(TMLink & link, TMLink & link1, TMLink & link2) const;
00255 void deleteListForCurl(AList<HepPoint3D> &l1,
00256 AList<HepPoint3D> &l2) const;
00257 void deleteListForCurl(AList<HepPoint3D> &l1,
00258 AList<HepPoint3D> &l2,
00259 AList<HepPoint3D> &l3) const;
00260 #endif
00262 int stereoHitForCurl(AList<TMLink>&) const;
00264
00265 public:
00267 double charge(double);
00268
00270
00271
00273 int fit2D(unsigned = 0, double = 0.1, double = 0.015);
00274
00276
00277
00279 void refine2D(AList<TMLink> & list, float maxSigma);
00280
00282 void movePivot(void);
00283
00284 public:
00286
00287
00289 int HelCyl(double rhole,
00290 double rcyl,
00291 double zb,
00292 double zf,
00293 double epsl,
00294 double & phi,
00295 HepPoint3D & xp) const;
00296
00298
00299
00301
00302
00304
00305
00307
00308
00310
00311
00312
00314 const AList<TMLink> & finalHits(void) const;
00315 const AList<TMLink> & finalHits(const AList<TMLink> & hits);
00316
00318 const AList<TMLink> & associateHits(void) const;
00319 const AList<TMLink> & associateHits(const AList<TMLink> & hits);
00320
00321 private:
00323 int dxda(const TMLink & link,
00324 double dPhi,
00325 Vector & dxda,
00326 Vector & dyda,
00327 Vector & dzda) const;
00328
00329 int dxda2D(const TMLink & link,
00330 double dPhi,
00331 Vector & dxda,
00332 Vector & dyda,
00333 Vector & dzda) const;
00334
00335 int dxda2D(const TMLink & link,
00336 double dPhi,
00337 Vector & dxda,
00338 Vector & dyda) const;
00339
00340 int dxda2D(double dPhi,
00341 Vector & dxda,
00342 Vector & dyda) const;
00343
00344 unsigned defineType(void) const;
00345
00346 unsigned _findertype;
00347 private:
00348 unsigned _state;
00349 double _charge;
00350 AList<TSegment> _segments;
00351 TTrack * _mother;
00352 TTrack * _daughter;
00353
00354 AList<TMLink> _finalHits;
00355 AList<TMLink> _associateHits;
00356
00357 private:
00358
00359 static const THelixFitter _fitter;
00360 Helix * _helix;
00361 unsigned _ndf;
00362 double _chi2;
00363 std::string _name;
00364 mutable unsigned _type;
00365
00366 private:
00367
00368
00369 friend class TTrackManager;
00370 friend class TrkReco;
00371 friend class THelixFitter;
00372 friend class TCosmicFitter;
00373 friend class Refit;
00374 friend class TBuilder;
00375 friend class TBuilder0;
00376 friend class TBuilderCosmic;
00377 friend class TBuilderCurl;
00378 friend class TPMCurlFinder;
00379 friend class TCurlFinder;
00380
00381 private:
00382 mutable IMagneticFieldSvc* m_pmgnIMF;
00383
00384
00385 };
00386
00388 #if defined(__GNUG__)
00389 int
00390 SortByPt(const TTrack ** a, const TTrack ** b);
00391 #else
00392 extern "C" int
00393 SortByPt(const void* a, const void* b);
00394 #endif
00395
00397 inline std::string
00398 TrackDump(const TTrack &);
00399
00401 inline std::string
00402 TrackType(const TTrack &);
00403
00404 inline std::string
00405 TrackType(unsigned type);
00406
00408 std::string
00409 TrackStatus(const TTrack &);
00410
00411 std::string
00412 TrackStatus(const MdcRec_trk &);
00413
00414 std::string
00415 TrackStatus(const MdcRec_trk_add &);
00416
00417 std::string
00418 TrackStatus(unsigned md,
00419 unsigned mk,
00420 unsigned mq,
00421 unsigned ms,
00422 unsigned mm,
00423 unsigned ma);
00424
00425 inline std::string
00426 TrackKinematics(const TTrack &);
00427
00428 std::string
00429 TrackKinematics(const Helix &);
00430
00431 std::string
00432 TrackInformation(const TTrack &);
00433
00434 std::string
00435 TrackInformation(const MdcRec_trk &);
00436
00437 std::string
00438 TrackInformation(unsigned nA, unsigned nS, unsigned n, float chisq);
00439
00440 std::string
00441 TrackLayerUsage(const TTrack &);
00442
00444 Helix
00445 Track2Helix(const MdcRec_trk &);
00446
00447 Helix
00448 Track2Helix(const MdcTrk_localz &);
00449
00450 Helix
00451 Track2Helix(const Gen_hepevt &);
00452
00453 Helix
00454 Track2Helix(const Mdst_trk_fit &);
00455
00457 bool
00458 HelixHasNan(const Helix &);
00459
00461 bool
00462 PositiveDefinite(const Helix &);
00463
00464
00465
00466 #ifdef TTrack_NO_INLINE
00467 #define inline
00468 #else
00469 #undef inline
00470 #define TTrack_INLINE_DEFINE_HERE
00471 #endif
00472
00473 #ifdef TTrack_INLINE_DEFINE_HERE
00474
00475 inline
00476 const Helix &
00477 TTrack::helix(void) const {
00478 #ifdef TRKRECO_DEBUG
00479
00480 #endif
00481 return * _helix;
00482 }
00483
00484 inline
00485 unsigned
00486 TTrack::ndf(void) const {
00487 #ifdef TRKRECO_DEBUG
00488 if (! _fitted) std::cout << "TTrack::ndf !!! ndf not updated" << std::endl;
00489 #endif
00490 return _ndf;
00491 }
00492
00493 inline
00494 double
00495 TTrack::chi2(void) const {
00496 #ifdef TRKRECO_DEBUG
00497 if (! _fitted) std::cout << "TTrack::chi2 !!! chi2 not updated" << std::endl;
00498 #endif
00499 return _chi2;
00500 }
00501
00502 inline
00503 double
00504 TTrack::charge(void) const {
00505 return _charge;
00506 }
00507
00508 inline
00509 double
00510 TTrack::charge(double a) {
00511 return _charge = a;
00512 }
00513
00514 inline
00515 const std::string &
00516 TTrack::name(void) const {
00517 return _name;
00518 }
00519
00520 inline
00521 const std::string &
00522 TTrack::name(const std::string & a) {
00523 return _name = a;
00524 }
00525
00526 inline
00527 double
00528 TTrack::pt(void) const {
00529 return 1. / fabs(_helix->a()[2]);
00530 }
00531
00532 inline
00533 double
00534 TTrack::pz(void) const {
00535 return (1. / fabs(_helix->a()[2])) * _helix->a()[4];
00536 }
00537
00538 inline
00539 double
00540 TTrack::ptot(void) const {
00541 return (1. / fabs(_helix->a()[2])) *
00542 sqrt(1. + _helix->a()[4] * _helix->a()[4]);
00543 }
00544
00545 inline
00546 double
00547 TTrack::confidenceLevel(void) const {
00548 return chisq2confLevel((int) _ndf, _chi2);
00549 }
00550
00551 inline
00552 Hep3Vector
00553 TTrack::p(void) const {
00554 return _helix->momentum(0.);
00555 }
00556
00557 inline
00558 unsigned
00559 TTrack::objectType(void) const {
00560 return Track;
00561 }
00562
00563 inline
00564 unsigned
00565 TTrack::type(void) const {
00566 return defineType();
00567 }
00568
00569 inline
00570 double
00571 TTrack::impact(void) const {
00572 return fabs(_helix->radius()) - _helix->center().mag();
00573 }
00574
00575 inline
00576 double
00577 TTrack::radius(void) const {
00578 return _helix->radius();
00579 }
00580
00581 inline
00582 AList<TSegment> &
00583 TTrack::segments(void) {
00584 return _segments;
00585 }
00586
00587 inline
00588 const AList<TSegment> &
00589 TTrack::segments(void) const {
00590 return _segments;
00591 }
00592
00593 inline
00594 TPoint2D
00595 TTrack::center(void) const {
00596 return TPoint2D(_helix->center());
00597 }
00598
00599 inline
00600 unsigned
00601 TTrack::finder(void) const {
00602 return _state & TrackFinderMask;
00603 }
00604
00605 inline
00606 unsigned
00607 TTrack::finder(unsigned a) {
00608 _state |= (a & TrackFinderMask);
00609 return finder();
00610 }
00611
00612 inline
00613 unsigned
00614 TTrack::quality(void) const {
00615 return (_state >> TrackQualityShift) & TrackQualityMask;
00616 }
00617
00618 inline
00619 unsigned
00620 TTrack::quality(unsigned a) {
00621
00622
00623 _state = ((a & TrackQualityMask) << TrackQualityShift) |
00624 (_state & (~ (TrackQualityMask << TrackQualityShift)));
00625 return quality();
00626 }
00627
00628 inline
00629 unsigned
00630 TTrack::fitting(void) const {
00631 return (_state >> TrackFitShift) & TrackFitMask;
00632 }
00633
00634 inline
00635 unsigned
00636 TTrack::fitting(unsigned a) {
00637 _state |= ((a << TrackFitShift) & TrackFitMask);
00638 return fitting();
00639 }
00640
00641 inline
00642 TTrack *
00643 TTrack::mother(void) const {
00644 return _mother;
00645 }
00646
00647 inline
00648 TTrack *
00649 TTrack::mother(TTrack * a) {
00650 if (a) _state |= (TrackHasMother << TrackRelationShift);
00651 else _state &= (~(TrackHasMother << TrackRelationShift));
00652 return _mother = a;
00653 }
00654
00655 inline
00656 TTrack *
00657 TTrack::daughter(void) const {
00658 return _daughter;
00659 }
00660
00661 inline
00662 TTrack *
00663 TTrack::daughter(TTrack * a) {
00664 if (a) _state |= (TrackHasDaughter << TrackRelationShift);
00665 else _state &= (~(TrackHasDaughter << TrackRelationShift));
00666 return _daughter = a;
00667 }
00668
00669 inline
00670 unsigned
00671 TTrack::state(void) const {
00672 return _state;
00673 }
00674
00675 inline
00676 void TTrack::setFinderType(unsigned type){
00677 _findertype=type;
00678 }
00679 inline
00680 unsigned TTrack::getFinderType(void)const{
00681 return _findertype;
00682 }
00683 inline
00684 std::string
00685 TrackType(const TTrack & t) {
00686 return TrackType(t.type());
00687 }
00688
00689 inline
00690 std::string
00691 TrackKinematics(const TTrack & t) {
00692 return TrackKinematics(t.helix());
00693 }
00694
00695 inline
00696 std::string
00697 TrackDump(const TTrack & t) {
00698 return t.name() + " " + TrackStatus(t) + " " + TrackKinematics(t) + " " +
00699 TrackInformation(t);
00700 }
00701
00702 inline
00703 const AList<TMLink> &
00704 TTrack::finalHits(const AList<TMLink> & list) {
00705 _finalHits = list;
00706 return _finalHits;
00707 }
00708
00709 inline
00710 const AList<TMLink> &
00711 TTrack::finalHits(void) const {
00712 return _finalHits;
00713 }
00714
00715 inline
00716 const AList<TMLink> &
00717 TTrack::associateHits(const AList<TMLink> & list) {
00718 _associateHits = list;
00719 return _associateHits;
00720 }
00721
00722 inline
00723 const AList<TMLink> &
00724 TTrack::associateHits(void) const {
00725 return _associateHits;
00726 }
00727
00728
00729 #endif
00730
00731 #undef inline
00732
00733 #endif