00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TMLink_FLAG_
00014 #define TMLink_FLAG_
00015
00016 #include <iostream>
00017
00018 #ifdef TRKRECO_DEBUG_DETAIL
00019 #ifndef TRKRECO_DEBUG
00020 #define TRKRECO_DEBUG
00021 #endif
00022 #endif
00023 #define HEP_SHORT_NAMES
00024 #include <string>
00025 #ifndef CLHEP_POINT3D_H
00026 #include "CLHEP/Geometry/Point3D.h"
00027 #endif
00028 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00029 typedef HepGeom::Point3D<double> HepPoint3D;
00030 #endif
00031
00032 #include "CLHEP/Alist/ConstAList.h"
00033 #include "TrkReco/TMDCWire.h"
00034 #include "TrkReco/TMDCWireHit.h"
00035
00036
00037
00038 class TTrackHEP;
00039
00040 class TTrack;
00041
00043 class TMLink {
00044
00045 public:
00047
00048
00049
00050 TMLink(TTrack * track = 0,
00051 const TMDCWireHit * hit = 0,
00052 const HepPoint3D & position = HepPoint3D(),
00053 const HepPoint3D & positionD = HepPoint3D(),
00054 const double = 0.0);
00055
00057 TMLink(const TMLink &);
00058
00060 virtual ~TMLink();
00061
00062 public:
00064 void dump(const std::string & message = std::string(""),
00065 const std::string & prefix = std::string("")) const;
00066
00068 const TMDCWireHit * hit(void) const;
00069
00071 const TMDCWire * const wire(void) const;
00072
00074 TTrack * track(void) const;
00075
00077 double pull(void) const;
00078
00080 const HepPoint3D & xyPosition(void) const;
00081
00083 const HepPoint3D & positionOnWire(void) const;
00084
00086 const HepPoint3D & positionOnTrack(void) const;
00087
00089 double dPhi(void) const;
00090
00092 unsigned leftRight(void) const;
00093
00095 int zStatus(void) const;
00096
00098 int zPair(void) const;
00099
00101 const HepPoint3D & position(void) const;
00102 const HepPoint3D & positionD(void) const;
00103
00104
00106 double distance(void) const;
00107
00109 TMLink * neighbor(unsigned int) const;
00110
00112 TMLink * link(void) const;
00113
00114
00116
00117
00119
00120
00121
00123 const HepPoint3D & arcZ(const unsigned = 0) const;
00124
00125 public:
00126
00127 const HepPoint3D & conf(const HepPoint3D & conf);
00128
00129 public:
00131 void update(const HepPoint3D & onTrack,
00132 const HepPoint3D & onWire,
00133 unsigned leftRight,
00134 double pull);
00135
00137 const TMDCWireHit * hit(const TMDCWireHit *);
00138
00140 TTrack * track(TTrack *);
00141
00143 const HepPoint3D & positionOnWire(const HepPoint3D &);
00144 const HepPoint3D & positionOnWire(double p[3]);
00145
00147 const HepPoint3D & positionOnTrack(const HepPoint3D &);
00148 const HepPoint3D & positionOnTrack(double p[3]);
00149
00151 double dPhi(double);
00152
00154 const HepPoint3D & position(const HepPoint3D &);
00155 const HepPoint3D & positionD(const HepPoint3D &);
00156
00158 void neighbor(unsigned int, TMLink *);
00159
00161 TMLink * link(TMLink *);
00162
00164 unsigned leftRight(unsigned);
00165
00167 double pull(double);
00168
00170 int zStatus(int);
00171
00173 int zPair(int);
00174
00175
00176
00178
00179
00181
00182
00184
00185
00186
00187
00189 const HepPoint3D & arcZ(const HepPoint3D &, const unsigned = 0);
00190 const unsigned fit2D(const unsigned &);
00191 unsigned fit2D(void);
00192
00193 public:
00195 float drift(void) const;
00196 float drift(unsigned) const;
00197 float drift(float, unsigned);
00198 double cDrift(void) const;
00199 double cDrift(unsigned) const;
00200 double cDrift(double, unsigned);
00201
00203 float dDrift(void) const;
00204 float dDrift(unsigned) const;
00205 float dDrift(float, unsigned);
00206
00208 unsigned tsfTag(void) const;
00209 unsigned tsfTag(unsigned);
00210
00212 double tof(void) const;
00213 double tof(double);
00214
00216 void setDriftTime(double);
00217 double getDriftTime(void);
00218
00220 double DriftTime(double,double) const;
00221 private:
00222 TTrack * _track;
00223 const TMDCWireHit * _hit;
00224 HepPoint3D _onTrack;
00225 HepPoint3D _onWire;
00226 HepPoint3D _position;
00227 HepPoint3D _positionD;
00228 double _dPhi;
00229 unsigned _leftRight;
00230 float _drift[2];
00231 float _dDrift[2];
00232
00233 double _cDrift[2];
00234
00235 int _zStatus;
00236 int _zPair;
00237 double _pull;
00238 TMLink * _neighbor[6];
00239 TMLink * _link;
00240
00241
00242 HepPoint3D _conf;
00243
00244 double _tof;
00245 double _drifttime;
00246
00247
00248
00249
00250
00251
00252
00253 HepPoint3D _arcZ[4];
00254 unsigned _fit2D;
00255 unsigned _tsfTag;
00256 };
00257
00258
00259
00261 const TTrackHEP &
00262 Links2HEP(const AList<TMLink> & links);
00263
00265 unsigned
00266 NSuperLayers(const AList<TMLink> & links);
00267
00268 unsigned
00269 NSuperLayers(const AList<TMLink> & links, unsigned minNHits);
00270
00271 unsigned
00272 NMissingAxialSuperLayers(const AList<TMLink> & links);
00273
00275 unsigned
00276 NLayers(const AList<TMLink> & links);
00277
00279 void
00280 NHits(const AList<TMLink> & links, unsigned nHits[50]);
00281
00283 void
00284 NHitsSuperLayer(const AList<TMLink> & links, unsigned nHits[11]);
00285
00287 AList<TMLink>
00288 AxialHits(const AList<TMLink> & links);
00289
00291 AList<TMLink>
00292 StereoHits(const AList<TMLink> & links);
00293
00295 unsigned
00296 NAxialHits(const AList<TMLink> & links);
00297
00299 unsigned
00300 NStereoHits(const AList<TMLink> & links);
00301
00303 unsigned
00304 Width(const AList<TMLink> &);
00305
00307 AList<TMLink>
00308 Edges(const AList<TMLink> &);
00309
00311 AList<TMLink>
00312 SameLayer(const AList<TMLink> & list, const TMLink & a);
00313 AList<TMLink>
00314 SameLayer(const AList<TMLink> & list, unsigned id);
00315
00317 AList<TMLink>
00318 SameSuperLayer(const AList<TMLink> & list, const TMLink & a);
00319 AList<TMLink>
00320 SameSuperLayer(const AList<TMLink> & list, unsigned id);
00321
00323 unsigned
00324 SuperLayer(const AList<TMLink> & list);
00325 unsigned
00326 SuperLayer(const AList<TMLink> & list, unsigned minNHits);
00327
00329 TMLink *
00330 InnerMost(const AList<TMLink> & links);
00331 TMLink *
00332 OuterMost(const AList<TMLink> & links);
00333
00335 AList<TMLink>
00336 InOut(const AList<TMLink> &);
00337
00338 template <class T> class CAList;
00339
00341 void
00342 SeparateCores(const AList<TMLink> & input,
00343 AList<TMLink> & cores,
00344 AList<TMLink> & nonCores);
00345
00346 AList<TMLink>
00347 Cores(const AList<TMLink> & input);
00348
00350 void
00351 Dump(const CAList<TMLink> & links,
00352 const std::string & message = std::string(""),
00353 const std::string & prefix = std::string(""));
00354 void
00355 Dump(const TMLink & link,
00356 const std::string & message = std::string(""),
00357 const std::string & prefix = std::string(""));
00358
00360 #if defined(__GNUG__)
00361 int
00362 SortByWireId(const TMLink ** a, const TMLink ** b);
00363 int
00364 SortByX(const TMLink ** a, const TMLink ** b);
00365 #else
00366 extern "C" int
00367 SortByWireId(const void* a, const void* b);
00368 extern "C" int
00369 SortByX(const void* a, const void* b);
00370 #endif
00371
00372
00373
00374 #ifdef TMLink_NO_INLINE
00375 #define inline
00376 #else
00377 #undef inline
00378 #define TMLink_INLINE_DEFINE_HERE
00379 #endif
00380
00381 #ifdef TMLink_INLINE_DEFINE_HERE
00382
00383 inline
00384 const TMDCWireHit *
00385 TMLink::hit(void) const {
00386 return _hit;
00387 }
00388
00389 inline
00390 TTrack *
00391 TMLink::track(void) const {
00392 return _track;
00393 }
00394
00395 inline
00396 const TMDCWireHit *
00397 TMLink::hit(const TMDCWireHit * a) {
00398 return _hit = a;
00399 }
00400
00401 inline
00402 TTrack *
00403 TMLink::track(TTrack * a) {
00404 return _track = a;
00405 }
00406
00407 inline
00408 void
00409 TMLink::update(const HepPoint3D & onTrack,
00410 const HepPoint3D & onWire,
00411 unsigned leftRight,
00412 double pull) {
00413 _onTrack = onTrack;
00414 _onWire = onWire;
00415 _leftRight = leftRight;
00416 _pull = pull;
00417 }
00418
00419 inline
00420 double
00421 TMLink::pull(void) const {
00422 return _pull;
00423 }
00424
00425 inline
00426 double
00427 TMLink::pull(double a) {
00428 return _pull = a;
00429 }
00430
00431 inline
00432 const HepPoint3D &
00433 TMLink::positionOnWire(void) const {
00434 return _onWire;
00435 }
00436
00437 inline
00438 const HepPoint3D &
00439 TMLink::positionOnTrack(void) const {
00440 return _onTrack;
00441 }
00442
00443 inline
00444 const HepPoint3D &
00445 TMLink::positionOnWire(const HepPoint3D & a) {
00446 return _onWire = a;
00447 }
00448
00449 inline
00450 const HepPoint3D &
00451 TMLink::positionOnWire(double p[3]) {
00452 _onWire.setX(p[0]);
00453 _onWire.setY(p[1]);
00454 _onWire.setZ(p[2]);
00455 return _onWire;
00456 }
00457
00458 inline
00459 const HepPoint3D &
00460 TMLink::positionOnTrack(const HepPoint3D & a) {
00461 return _onTrack = a;
00462 }
00463
00464 inline
00465 const HepPoint3D &
00466 TMLink::positionOnTrack(double p[3]) {
00467 _onTrack.setX(p[0]);
00468 _onTrack.setY(p[1]);
00469 _onTrack.setZ(p[2]);
00470 return _onTrack;
00471 }
00472
00473 inline
00474 unsigned
00475 TMLink::leftRight(void) const {
00476 return _leftRight;
00477 }
00478
00479 inline
00480 unsigned
00481 TMLink::leftRight(unsigned a) {
00482 return _leftRight = a;
00483 }
00484
00485 inline
00486 double
00487 TMLink::dPhi(void) const {
00488 return _dPhi;
00489 }
00490
00491 inline
00492 double
00493 TMLink::dPhi(double a) {
00494 return _dPhi = a;
00495 }
00496
00497 inline
00498 const HepPoint3D &
00499 TMLink::position(void) const {
00500 return _position;
00501 }
00502
00503 inline
00504 const HepPoint3D &
00505 TMLink::position(const HepPoint3D & a) {
00506 return _position = a;
00507 }
00508
00509 inline
00510 const HepPoint3D &
00511 TMLink::positionD(void) const {
00512 return _positionD;
00513 }
00514
00515 inline
00516 const HepPoint3D &
00517 TMLink::positionD(const HepPoint3D & a) {
00518 return _positionD = a;
00519 }
00520
00521
00522
00523
00524
00525
00526
00527 inline
00528 const HepPoint3D &
00529 TMLink::conf(const HepPoint3D & a) {
00530 return _conf = a;
00531 }
00532
00533 inline
00534 void
00535 TMLink::neighbor(unsigned n, TMLink * neighbor){
00536 if(n <= 6)
00537 _neighbor[n] = neighbor;
00538 }
00539
00540 inline
00541 TMLink *
00542 TMLink::neighbor(unsigned n) const {
00543 if(n <= 6)
00544 return _neighbor[n];
00545 return NULL;
00546 }
00547
00548 inline
00549 TMLink *
00550 TMLink::link(void) const {
00551 return _link;
00552 }
00553
00554 inline
00555 TMLink *
00556 TMLink::link(TMLink * a) {
00557 return _link = a;
00558 }
00559
00560 inline
00561 double
00562 TMLink::distance(void) const {
00563 return (_onTrack - _onWire).mag();
00564 }
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 inline
00590 int
00591 TMLink::zStatus(void) const {
00592 return _zStatus;
00593 }
00594
00595 inline
00596 int
00597 TMLink::zStatus(int a) {
00598 return _zStatus = a;
00599 }
00600
00601 inline
00602 int
00603 TMLink::zPair(void) const {
00604 return _zPair;
00605 }
00606
00607 inline
00608 int
00609 TMLink::zPair(int a) {
00610 return _zPair = a;
00611 }
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 inline
00643 const HepPoint3D &
00644 TMLink::arcZ(const unsigned i) const {
00645 if(i < 4)return _arcZ[i];
00646 std::cerr << "Error!! Please stop!!.....arcZ of TMLink!!! in TrkReco." << std::endl;
00647 return _arcZ[0];
00648 }
00649
00650 inline
00651 const HepPoint3D &
00652 TMLink::arcZ(const HepPoint3D &az, const unsigned i){
00653 if(i < 4)return _arcZ[i] = az;
00654 std::cerr << "Error!! Please stop!!.....arcZ of TMLink!!! in TrkReco." << std::endl;
00655 return _arcZ[0];
00656 }
00657
00658
00659
00660
00661
00662
00663
00664 inline
00665 const unsigned
00666 TMLink::fit2D(const unsigned &f) {
00667 return _fit2D = f;
00668 }
00669
00670 inline
00671 unsigned
00672 TMLink::fit2D(void) {
00673 return _fit2D;
00674 }
00675
00676 inline
00677 float
00678 TMLink::drift(unsigned a) const {
00679 return _drift[a];
00680 }
00681
00682 inline
00683 float
00684 TMLink::drift(float b, unsigned a) {
00685 return _drift[a] = b;
00686 }
00687
00688 inline
00689 double
00690 TMLink::cDrift(unsigned a) const {
00691 return _cDrift[a];
00692 }
00693
00694 inline
00695 double
00696 TMLink::cDrift(double b, unsigned a) {
00697 return _cDrift[a] = b;
00698 }
00699
00700 inline
00701 float
00702 TMLink::dDrift(unsigned a) const {
00703 return _dDrift[a];
00704 }
00705
00706 inline
00707 float
00708 TMLink::dDrift(float b, unsigned a) {
00709 return _dDrift[a] = b;
00710 }
00711
00712 inline
00713 float
00714 TMLink::drift(void) const {
00715 return (_drift[0] + _drift[1]) / 2.;
00716 }
00717
00718 inline
00719 double
00720 TMLink::cDrift(void) const {
00721 return (_cDrift[0] + _cDrift[1]) / 2.;
00722 }
00723
00724 inline
00725 float
00726 TMLink::dDrift(void) const {
00727 return (_dDrift[0] + _dDrift[1]) / 2.;
00728 }
00729
00730 inline
00731 unsigned
00732 TMLink::tsfTag(void) const {
00733 return _tsfTag;
00734 }
00735
00736 inline
00737 unsigned
00738 TMLink::tsfTag(unsigned a) {
00739 return _tsfTag = a;
00740 }
00741
00742 inline
00743 double
00744 TMLink::tof(void) const {
00745 return _tof;
00746 }
00747
00748 inline
00749 double
00750 TMLink::tof(double a) {
00751 return _tof = a;
00752 }
00753
00754 inline
00755 double
00756 TMLink::getDriftTime(void) {
00757 return _drifttime;
00758 }
00759
00760 inline
00761 void
00762 TMLink::setDriftTime(double time){
00763 _drifttime = time;
00764
00765 }
00766 #endif
00767
00768 #undef inline
00769
00770 #endif