BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/TrkReco/TrkReco/TMLink.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TMLink.h,v 1.17 2012/05/28 05:16:29 maoh Exp $
3//-----------------------------------------------------------------------------
4// Filename : TMLink.h
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to relate TMDCWireHit and TTrack objects.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#ifndef TMLink_FLAG_
14#define TMLink_FLAG_
15
16#include <iostream>
17
18#ifdef TRKRECO_DEBUG_DETAIL
19#ifndef TRKRECO_DEBUG
20#define TRKRECO_DEBUG
21#endif
22#endif
23#define HEP_SHORT_NAMES
24#include <string>
25#ifndef CLHEP_POINT3D_H
26#include "CLHEP/Geometry/Point3D.h"
27#endif
28#ifndef ENABLE_BACKWARDS_COMPATIBILITY
30#endif
31
32#include "CLHEP/Alist/ConstAList.h"
33#include "TrkReco/TMDCWire.h"
34#include "TrkReco/TMDCWireHit.h"
35//#include "TrkReco/TMDCWire.h"
36//#include "TrkReco/TMDCClust.h"
37
38class TTrackHEP;
39
40class TTrack;
41
42/// A class to relate TMDCWireHit and TTrack objects.
43class TMLink {
44
45 public:
46 /// Constructor.
47/* TMLink(TTrack * track = 0,
48 const TMDCWireHit * hit = 0,
49 const HepPoint3D & position = HepPoint3D());*/
50 TMLink(TTrack * track = 0,
51 const TMDCWireHit * hit = 0,
52 const HepPoint3D & position = HepPoint3D(),
54 const double = 0.0);
55
56 /// Copy constructor.
57 TMLink(const TMLink &);
58
59 /// Destructor
60 virtual ~TMLink();
61
62 public:// Selectors
63 /// dumps debug information.
64 void dump(const std::string & message = std::string(""),
65 const std::string & prefix = std::string("")) const;
66
67 /// returns a pointer to a hit.
68 const TMDCWireHit * hit(void) const;
69
70 /// returns a pointer to a wire.
71 const TMDCWire * const wire(void) const;
72
73 /// returns a pointer to a track.
74 TTrack * track(void) const;
75
76 /// returns pull.
77 double pull(void) const;
78
79 /// returns middle position of a wire. z componet is 0.
80 const HepPoint3D & xyPosition(void) const;
81
82 /// returns the closest point on wire to a track.
83 const HepPoint3D & positionOnWire(void) const;
84
85 /// returns the closest point on track to wire.
86 const HepPoint3D & positionOnTrack(void) const;
87
88 /// returns dPhi to the closest point.
89 double dPhi(void) const;
90
91 /// returns left-right. 0:left, 1:right, 2:wire
92 unsigned leftRight(void) const;
93
94 /// returns stauts of stereo hit
95 int zStatus(void) const;
96
97 /// returns id\# of the pair, if zStatus == 20 (2 consective hits).
98 int zPair(void) const;
99
100 /// returns position.
101 const HepPoint3D & position(void) const;
102 const HepPoint3D & positionD(void) const;
103
104
105 /// returns distance between point on wire and on track.
106 double distance(void) const;
107
108 double distance(double);
109
110 double distancenew(void)const;
111
112 /// returns neighbor TMLink.
113 TMLink * neighbor(unsigned int) const;
114
115 /// returns a pointer to a TMLink.
116 TMLink * link(void) const;
117
118// S.Suzuki added
119 /// returns UseCathode flag
120 // int usecathode(void) const;
121
122 /// returns pointer to the cluster to be fit
123 // TMDCClust * getmclust(void) const;
124// end S.Suzuki
125
126 /// returns arc and Z for the curl finder.
127 const HepPoint3D & arcZ(const unsigned = 0) const;
128
129 public:// tmp
130// const HepPoint3D & conf(void) const;
131 const HepPoint3D & conf(const HepPoint3D & conf);
132
133 public:// Modifiers
134 /// sets results of fitting.
135 void update(const HepPoint3D & onTrack,
136 const HepPoint3D & onWire,
137 unsigned leftRight,
138 double pull);
139
140 /// sets a pointer to a hit.
141 const TMDCWireHit * hit(const TMDCWireHit *);
142
143 /// sets a pointer to a track.
144 TTrack * track(TTrack *);
145
146 /// sets and returns the closest point on wire to a track.
147 const HepPoint3D & positionOnWire(const HepPoint3D &);
148 const HepPoint3D & positionOnWire(double p[3]);
149
150 /// sets and returns the closest point on track to wire.
151 const HepPoint3D & positionOnTrack(const HepPoint3D &);
152 const HepPoint3D & positionOnTrack(double p[3]);
153
154 /// sets and returns dPhi to the closest point.
155 double dPhi(double);
156
157 /// sets and returns position.
158 const HepPoint3D & position(const HepPoint3D &);
159 const HepPoint3D & positionD(const HepPoint3D &);
160
161 /// sets neighbor TMLink.
162 void neighbor(unsigned int, TMLink *);
163
164 /// sets a pointer to a TMLink.
165 TMLink * link(TMLink *);
166
167 /// sets left-right. 0:left, 1:right, 2:wire
168 unsigned leftRight(unsigned);
169
170 /// sets pull.
171 double pull(double);
172
173 /// sets stereo Hit status
174 int zStatus(int);
175
176 /// sets id\# of the pair
177 int zPair(int);
178
179// S.Suzuki added
180
181 /// sets usecathode flag
182 // void setusecathode(int);
183
184 /// sets pointer to the cluster to be fit
185 // void setmclust(TMDCClust *);
186
187 /// sets z(phi) before cathode fit
188 // void setZphiBeforeCathode(float);
189
190// end S.Suzuki
191
192 /// sets and returns arc and Z for the curl finder.
193 const HepPoint3D & arcZ(const HepPoint3D &, const unsigned = 0);
194 const unsigned fit2D(const unsigned &);
195 unsigned fit2D(void);
196
197 public:// Drift distance
198 /// returns/sets drift distance.
199 float drift(void) const;
200 float drift(unsigned) const;
201 float drift(float, unsigned);
202 double cDrift(void) const;
203 double cDrift(unsigned) const;
204 double cDrift(double, unsigned);
205
206 /// returns/sets drift distance error.
207 float dDrift(void) const;
208 float dDrift(unsigned) const;
209 float dDrift(float, unsigned);
210
211 /// return tsfTag of links
212 unsigned tsfTag(void) const;
213 unsigned tsfTag(unsigned);
214
215 /// return time of flight
216 double tof(void) const;
217 double tof(double);
218
219 /// add by jialk returns timeDrift after prop correction
220 void setDriftTime(double);
221 double getDriftTime(void);
222
223 /// returs drift time
224 double DriftTime(double,double) const;
225 private:
226 TTrack * _track;
227 const TMDCWireHit * _hit;
228 HepPoint3D _onTrack;
229 HepPoint3D _onWire;
230 HepPoint3D _position;
231 HepPoint3D _positionD;
232 double _dPhi;
233 unsigned _leftRight;
234 float _drift[2];
235 float _dDrift[2];
236
237 double _cDrift[2];
238
239 int _zStatus;
240 int _zPair;
241 double _pull;
242 double _distance;
243 TMLink * _neighbor[6];
244 TMLink * _link;
245
246 //...tmp...
247 HepPoint3D _conf;
248
249 double _tof;
250 double _drifttime;
251
252 //-- S. Suzuki added -------
253 // int _usecathode;
254 // float _ZphiBeforeCathode;
255 // TMDCClust * _mclust;
256 //-- S. Suzuki added end ---
257
258 HepPoint3D _arcZ[4];
259 unsigned _fit2D;
260 unsigned _tsfTag;
261};
262
263// Utility functions
264
265/// returns TTrackHEP
266const TTrackHEP &
267Links2HEP(const AList<TMLink> & links);
268
269/// returns \# of layers.
270unsigned
271NSuperLayers(const AList<TMLink> & links);
272
273unsigned
274NSuperLayers(const AList<TMLink> & links, unsigned minNHits);
275
276unsigned
278
279/// returns \# of layers.
280unsigned
281NLayers(const AList<TMLink> & links);
282
283/// returns \# of hits per layer.
284void
285NHits(const AList<TMLink> & links, unsigned nHits[50]);
286
287/// returns \# of hits per super layer.
288void
289NHitsSuperLayer(const AList<TMLink> & links, unsigned nHits[11]);
290
291/// returns axial hits.
293AxialHits(const AList<TMLink> & links);
294
295/// returns stereo hits.
297StereoHits(const AList<TMLink> & links);
298
299/// returns \# of axial hits.
300unsigned
301NAxialHits(const AList<TMLink> & links);
302
303/// returns \# of stereo hits.
304unsigned
305NStereoHits(const AList<TMLink> & links);
306
307/// returns width(wire cell unit) of given AList<TMLink>. This function assumes that all TMLink's are in the same super layer.
308unsigned
309Width(const AList<TMLink> &);
310
311/// returns links which are edges. This function assumes that all TMLink's are in the same super layer.
313Edges(const AList<TMLink> &);
314
315/// returns links which are in the same layer as 'a' or 'id'.
317SameLayer(const AList<TMLink> & list, const TMLink & a);
319SameLayer(const AList<TMLink> & list, unsigned id);
320
321/// returns links which are in the same super layer as 'a' or 'id'.
323SameSuperLayer(const AList<TMLink> & list, const TMLink & a);
325SameSuperLayer(const AList<TMLink> & list, unsigned id);
326
327/// returns super layer pattern.
328unsigned
329SuperLayer(const AList<TMLink> & list);
330unsigned
331SuperLayer(const AList<TMLink> & list, unsigned minNHits);
332
333/// returns the inner(outer)-most link.
334TMLink *
335InnerMost(const AList<TMLink> & links);
336TMLink *
337OuterMost(const AList<TMLink> & links);
338
339/// returns links which are in the inner most and outer most layer. This function assumes that all TMLink's are in the same super layer.
341InOut(const AList<TMLink> &);
342
343template <class T> class CAList;
344
345/// separate cores and non-cores.
346void
347SeparateCores(const AList<TMLink> & input,
348 AList<TMLink> & cores,
349 AList<TMLink> & nonCores);
350
352Cores(const AList<TMLink> & input);
353
354/// dumps TMLinks.
355void
356Dump(const CAList<TMLink> & links,
357 const std::string & message = std::string(""),
358 const std::string & prefix = std::string(""));
359void
360Dump(const TMLink & link,
361 const std::string & message = std::string(""),
362 const std::string & prefix = std::string(""));
363
364/// Sorter
365#if defined(__GNUG__)
366int
367SortByWireId(const TMLink ** a, const TMLink ** b);
368int
369SortByX(const TMLink ** a, const TMLink ** b);
370#else
371extern "C" int
372SortByWireId(const void* a, const void* b);
373extern "C" int
374SortByX(const void* a, const void* b);
375#endif
376
377//-----------------------------------------------------------------------------
378
379#ifdef TMLink_NO_INLINE
380#define inline
381#else
382#undef inline
383#define TMLink_INLINE_DEFINE_HERE
384#endif
385
386#ifdef TMLink_INLINE_DEFINE_HERE
387
388inline
389const TMDCWireHit *
390TMLink::hit(void) const {
391 return _hit;
392}
393
394inline
395TTrack *
396TMLink::track(void) const {
397 return _track;
398}
399
400inline
401const TMDCWireHit *
403 return _hit = a;
404}
405
406inline
407TTrack *
409 return _track = a;
410}
411
412inline
413void
415 const HepPoint3D & onWire,
416 unsigned leftRight,
417 double pull) {
418 _onTrack = onTrack;
419 _onWire = onWire;
420 _leftRight = leftRight;
421 _pull = pull;
422}
423
424inline
425double
426TMLink::pull(void) const {
427 return _pull;
428}
429
430inline
431double
432TMLink::pull(double a) {
433 return _pull = a;
434}
435
436inline
437const HepPoint3D &
439 return _onWire;
440}
441
442inline
443const HepPoint3D &
445 return _onTrack;
446}
447
448inline
449const HepPoint3D &
451 return _onWire = a;
452}
453
454inline
455const HepPoint3D &
457 _onWire.setX(p[0]);
458 _onWire.setY(p[1]);
459 _onWire.setZ(p[2]);
460 return _onWire;
461}
462
463inline
464const HepPoint3D &
466 return _onTrack = a;
467}
468
469inline
470const HepPoint3D &
472 _onTrack.setX(p[0]);
473 _onTrack.setY(p[1]);
474 _onTrack.setZ(p[2]);
475 return _onTrack;
476}
477
478inline
479unsigned
480TMLink::leftRight(void) const {
481 return _leftRight;
482}
483
484inline
485unsigned
486TMLink::leftRight(unsigned a) {
487 return _leftRight = a;
488}
489
490inline
491double
492TMLink::dPhi(void) const {
493 return _dPhi;
494}
495
496inline
497double
498TMLink::dPhi(double a) {
499 return _dPhi = a;
500}
501
502inline
503const HepPoint3D &
504TMLink::position(void) const {
505 return _position;
506}
507
508inline
509const HepPoint3D &
511 return _position = a;
512}
513
514inline
515const HepPoint3D &
516TMLink::positionD(void) const {
517 return _positionD;
518}
519
520inline
521const HepPoint3D &
523 return _positionD = a;
524}
525
526// inline
527// const HepPoint3D &
528// TMLink::conf(void) const {
529// return _conf;
530// }
531
532inline
533const HepPoint3D &
535 return _conf = a;
536}
537
538inline
539void
540TMLink::neighbor(unsigned n, TMLink * neighbor){
541 if(n <= 6)
542 _neighbor[n] = neighbor;
543}
544
545inline
546TMLink *
547TMLink::neighbor(unsigned n) const {
548 if(n <= 6)
549 return _neighbor[n];
550 return NULL;
551}
552
553inline
554TMLink *
555TMLink::link(void) const {
556 return _link;
557}
558
559inline
560TMLink *
562 return _link = a;
563}
564
565inline
566double
567TMLink::distance(void) const {
568
569 return (_onTrack-_onWire).mag() ;
570}
571inline
572double
574
575
576 return _distance;
577
578}
579
580inline
581double
583
584 _distance=a ;
585}
586//inline
587//const TMDCWire * const
588//TMLink::wire(void) const {
589// if (_hit) return _hit->wire();
590// return NULL;
591//}
592
593//zangsl 040518 move the following two fun. to TMLink.cxx file
594/*
595inline
596const TMDCWire * const
597TMLink::wire(void) const {
598 if (_hit) return _hit->wire();
599 return NULL;
600}
601
602inline
603const HepPoint3D &
604TMLink::xyPosition(void) const {
605 return _hit->wire()->xyPosition();
606}
607*/
608
609inline
610int
611TMLink::zStatus(void) const {
612 return _zStatus;
613}
614
615inline
616int
618 return _zStatus = a;
619}
620
621inline
622int
623TMLink::zPair(void) const {
624 return _zPair;
625}
626
627inline
628int
630 return _zPair = a;
631}
632
633/*
634//-- S. Suzuki added -------
635inline
636int
637TMLink::usecathode(void) const {
638 return _usecathode;
639}
640
641inline
642void
643TMLink::setusecathode(int a) {
644 _usecathode = a ;
645}
646
647inline
648TMDCClust *
649TMLink::getmclust(void) const {
650 return _mclust;
651}
652
653inline
654void
655TMLink::setmclust(TMDCClust * a) {
656 _mclust = a ;
657}
658
659//-- S. Suzuki added end ----
660*/
661
662inline
663const HepPoint3D &
664TMLink::arcZ(const unsigned i) const {
665 if(i < 4)return _arcZ[i];
666 std::cerr << "Error!! Please stop!!.....arcZ of TMLink!!! in TrkReco." << std::endl;
667 return _arcZ[0];
668}
669
670inline
671const HepPoint3D &
672TMLink::arcZ(const HepPoint3D &az, const unsigned i){
673 if(i < 4)return _arcZ[i] = az;
674 std::cerr << "Error!! Please stop!!.....arcZ of TMLink!!! in TrkReco." << std::endl;
675 return _arcZ[0];
676}
677
678//inline
679//void
680//TMLink::setZphiBeforeCathode(float a) {
681// _ZphiBeforeCathode = a;
682//}
683
684inline
685const unsigned
686TMLink::fit2D(const unsigned &f) {
687 return _fit2D = f;
688}
689
690inline
691unsigned
693 return _fit2D;
694}
695
696inline
697float
698TMLink::drift(unsigned a) const {
699 return _drift[a];
700}
701
702inline
703float
704TMLink::drift(float b, unsigned a) {
705 return _drift[a] = b;
706}
707
708inline
709double
710TMLink::cDrift(unsigned a) const {
711 return _cDrift[a];
712}
713
714inline
715double
716TMLink::cDrift(double b, unsigned a) {
717 return _cDrift[a] = b;
718}
719
720inline
721float
722TMLink::dDrift(unsigned a) const {
723 return _dDrift[a];
724}
725
726inline
727float
728TMLink::dDrift(float b, unsigned a) {
729 return _dDrift[a] = b;
730}
731
732inline
733float
734TMLink::drift(void) const {
735 return (_drift[0] + _drift[1]) / 2.;
736}
737
738inline
739double
740TMLink::cDrift(void) const {
741 return (_cDrift[0] + _cDrift[1]) / 2.;
742}
743
744inline
745float
746TMLink::dDrift(void) const {
747 return (_dDrift[0] + _dDrift[1]) / 2.;
748}
749
750inline
751unsigned
752TMLink::tsfTag(void) const {
753 return _tsfTag;
754}
755
756inline
757unsigned
758TMLink::tsfTag(unsigned a) {
759 return _tsfTag = a;
760}
761
762inline
763double
764TMLink::tof(void) const {
765 return _tof;
766}
767
768inline
769double
770TMLink::tof(double a) {
771 return _tof = a;
772}
773
774inline
775double
777 return _drifttime;
778}
779
780inline
781void
783_drifttime = time;
784
785 }
786#endif
787
788#undef inline
789
790#endif /* TMLink_FLAG_ */
const Int_t n
Double_t time
A class to represent a wire in MDC.
A class to represent a GEN_HEPEVT particle in tracking.
A class to represent a track in tracking.