BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/TrkReco/TrkReco/TTrack.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TTrack.h,v 1.21 2012/05/28 05:16:29 maoh Exp $
3//-----------------------------------------------------------------------------
4// Filename : TTrack.h
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A class to represent a track in tracking.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#ifndef TTrack_FLAG_
14#define TTrack_FLAG_
15
16#ifdef TRKRECO_DEBUG_DETAIL
17#ifndef TRKRECO_DEBUG
18#define TRKRECO_DEBUG
19#endif
20#endif
21
22//...Definition of finder/manager...
23#define TrackOldConformalFinder 1
24#define TrackFastFinder 2
25#define TrackSlowFinder 4
26#define TrackCurlFinder 8
27#define TrackTrackManager 16
28#define TrackPMCurlFinder 32
29#define TrackSVDAssociator 64
30#define TrackFinderMask 255
31
32//...Definition of type/kind...
33#define TrackTypeUndefined 0
34#define TrackTypeNormal 1
35#define TrackTypeCurl 2
36#define TrackTypeCircle 4
37#define TrackTypeCosmic 8
38#define TrackTypeIncomingCosmic 8
39#define TrackTypeOutgoingCosmic 16
40#define TrackTypeKink 32
41#define TrackTypeSVDOnly 256
42
43//...Definition of quality...
44#define TrackQualityOutsideCurler 1
45#define TrackQualityAfterKink 2
46#define TrackQualityCosmic 4
47#define TrackQuality2D 8
48#define TrackQualityShift 8
49#define TrackQualityMask 255
50
51//...Definition of fitting status...
52#define TrackFitGlobal 1
53#define TrackFitCosmic 2
54#define TrackFitCdcKalman 4
55#define TrackFitSvdCdcKalman 8
56#define TrackFitShift 16
57#define TrackFitMask 255
58
59//...Definition of relation...
60#define TrackHasMother 1
61#define TrackHasDaughter 2
62#define TrackRelationShift 24
63#define TrackRelationMask 255
64
65#include <string>
66
67#define HEP_SHORT_NAMES
68#include "CLHEP/Vector/ThreeVector.h"
69//#include "helix/Helix.h"
70//#include "TrkReco/Helix.h"
71#include "TrackUtil/Helix.h"
72#include "TrkReco/TMDCUtil.h"
73#include "TrkReco/TTrackBase.h"
74#include "TrkReco/TMLink.h"
75#include "TrkReco/TBuilder0.h"
76#include "TrkReco/TBuilderCosmic.h"
77#include "TrkReco/TBuilderCurl.h"
78//#include "TrkReco/TMDCCatHit.h"
79#include "TrkReco/TPoint2D.h"
80//#include "TrkReco/TSvdHit.h"
81
82#include "TrkReco/T3DLine.h"
83#include "TrkReco/TRunge.h"
84#include "GaudiKernel/IInterface.h"
85#include "GaudiKernel/Kernel.h"
86#include "GaudiKernel/Service.h"
87#include "MagneticField/IMagneticFieldSvc.h"
88#include "MagneticField/MagneticFieldSvc.h"
89
90#include "CLHEP/Matrix/Vector.h"
91#include "CLHEP/Matrix/SymMatrix.h"
92#include "CLHEP/Vector/ThreeVector.h"
93#include "CLHEP/Vector/LorentzVector.h"
94#include "CLHEP/Geometry/Point3D.h"
95
96
97using CLHEP::Hep3Vector;
98
99#ifndef CLHEP_POINT3D_H
100#include "CLHEP/Geometry/Point3D.h"
101#endif
102#ifndef ENABLE_BACKWARDS_COMPATIBILITY
104#endif
105using HepGeom::Point3D;
106
107//class HepPoint3D;
108class TrkReco;
109class TTrackManager;
110class TCircle;
111class TCosmicFitter;
112class Refit;
113class THelixFitter;
114class TBuilder;
115//class TPMCurlFinder;
116class TCurlFinder;
117//struct reccdc_trk;
118//struct reccdc_trk_add;
119//struct rectrk_localz;
120//struct gen_hepevt;
121//struct mdst_trk_fit;
122class MdcRec_trk;
123class MdcRec_trk_add;
124class MdcTrk_localz;
125class Gen_hepevt;
126class Mdst_trk_fit;
127
128/// A class to represent a track in tracking.
129class TTrack : public TTrackBase {
130
131 public:
132 /// Default constructor
133 TTrack();
134
135 /// Constructor
136 TTrack(const TCircle &);
137
138 /// Copy constructor
139 TTrack(const TTrack &);
140
141 /// Constructor
142 TTrack(const T3DLine &);
143
144 /// Constructor
145 TTrack(const Helix &);
146
147 TTrack(const TRunge &);
148 /// Destructor
149 virtual ~TTrack();
150
151 public:// General information
152 /// returns/sets name.
153 const std::string & name(void) const;
154 const std::string & name(const std::string & newName);
155
156 /// sets/returns mother/daughter.
157 TTrack * mother(void) const;
158 TTrack * mother(TTrack *);
159 TTrack * daughter(void) const;
161
162 /// returns type.
163 unsigned objectType(void) const;
164
165 /// returns type. Definition is depending on an object type.
166 unsigned type(void) const;
167
168 /// sets/returns finder.
169 unsigned finder(void) const;
170 unsigned finder(unsigned finderMask);
171 void setFinderType(unsigned);
172 unsigned getFinderType(void)const;
173
174 /// sets/returns quality.
175 unsigned quality(void) const;
176 unsigned quality(unsigned qualityMask);
177
178 /// sets/returns fitting status.
179 unsigned fitting(void) const;
180 unsigned fitting(unsigned fitMask);
181
182 /// returns/sets internal state.(for bank output)
183 unsigned state(void) const;
184
185 /// assigns wire hits to this track.
186 void assign(unsigned maskForWireHit);
187
188 /// dumps debug information.
189 void dump(const std::string & message = std::string(""),
190 const std::string & prefix = std::string("")) const;
191
192 public:// Kinematics
193 /// returns charge.
194 double charge(void) const;
195
196 /// returns helix parameter.
197 const Helix & helix(void) const;
198
199 /// returns momentum.
200 Hep3Vector p(void) const;
201
202 /// returns magnitude of momentum.
203 double ptot(void) const;
204
205 /// returns Pt.
206 double pt(void) const;
207
208 /// returns Pz.
209 double pz(void) const;
210
211 /// returns signed impact parameter to the origin.
212 double impact(void) const;
213
214 /// returns position of helix center.
215 TPoint2D center(void) const;
216
217 /// returns signed radius.
218 double radius(void) const;
219
220 /// returns NDF.
221 unsigned ndf(void) const;
222
223 /// returns chi2.
224 double chi2(void) const;
225
226 /// returns confidence level.
227 double confidenceLevel(void) const;
228
229 public:// Utilities for segment operations.
230 /// returns AList<TSegment>.
232 const AList<TSegment> & segments(void) const;
233
234 public:// Utilities
235 /// calculates the closest approach to a wire in real space. Results are stored in TMLink. Return value is negative if error happened.
236 int approach(TMLink &) const;
237 int approach(TMLink &, bool sagCorrection) const;
238 int approach2D(TMLink &) const;
239
240 /// calculates arc length and z for a stereo hit.
241 int szPosition(TMLink & link) const;
242
243 /// calculates arc length and z for a segment. Results are stored in TMLink.
244 int szPosition(const TSegment & segment, TMLink & link) const;
245
246 /// calculates arc length for a point.
247 int szPosition(const HepPoint3D & p, HepPoint3D & szPosition) const;
248
249 /// calculates arc length and z for a stereo hit. uses these functions for curl tracks.
250#define OLD_STEREO 1
251#if OLD_STEREO
252 int stereoHitForCurl(TMLink & link, AList<HepPoint3D> & arcZList) const;
253 int stereoHitForCurl(TMLink & link, TMLink & link1) const;
254 int stereoHitForCurl(TMLink & link, TMLink & link1, TMLink & link2) const;
256 AList<HepPoint3D> &l2) const;
259 AList<HepPoint3D> &l3) const;
260#endif
261 /// calculates arc length and z for a stereo hit. uses these functions for curl tracks(included svd version).
263 ////int svdHitForCurl(AList<TSvdHit>&) const;
264
265 public:// Modifiers
266 /// sets charge.
267 double charge(double);
268
269 /// fits itself. Error was happened if return value is not zero.
270 // int fitx(void);
271
272 /// fits itself with r-phi view. Error was happened if return value is not zero.
273 int fit2D(unsigned = 0, double = 0.1, double = 0.015);
274
275 /// fits itself with cathode hits.
276 // int fitWithCathode( float windowSize = 0.6 , int SysCorr = 0 ); // mod by matsu ( 1999/07/05 )
277
278 /// remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called before calling this function. (using stereo wire as axial wire(z=0))
279 void refine2D(AList<TMLink> & list, float maxSigma);
280
281 /// moves pivot to the inner most hit.
282 void movePivot(void);
283
284 public:// temporary added
285 /// returns a cathode hit list.
286 // const AList<TMDCCatHit> & catHits(void) const;
287
288 /// calculates an intersection of this track and a cylinder.
289 int HelCyl(double rhole,
290 double rcyl,
291 double zb,
292 double zf,
293 double epsl,
294 double & phi,
295 HepPoint3D & xp) const;
296
297 /// finds cathode hits associated to this track.
298 // void findCatHit(unsigned trackid);
299
300 /// relation between cluster and wire
301 // void relationClusterWithWire();
302
303 /// relation between cluster and layer
304 // void relationClusterWithLayer(int SysCorr ); // by matsu ( 1999/07/05 )
305
306 /// appends Svd Hits(TSvdHit)
307 // void svdHits(AList<TSvdHit> &);
308
309 /// returns Svd Hits List
310 // AList<TSvdHit> & svdHits(void);
311 // const AList<TSvdHit> & svdHits(void) const;
312
313 /// sets/returns a list of TMLink which are used for table output.
314 const AList<TMLink> & finalHits(void) const;
315 const AList<TMLink> & finalHits(const AList<TMLink> & hits);
316
317 /// sets/returns a list of associated TMLink which are used for table output.
318 const AList<TMLink> & associateHits(void) const;
319 const AList<TMLink> & associateHits(const AList<TMLink> & hits);
320
321 private:
322 /// calculates dXda. 'link' and 'dPhi' are inputs. Others are outputs.
323 int dxda(const TMLink & link,
324 double dPhi,
325 Vector & dxda,
326 Vector & dyda,
327 Vector & dzda) const;
328
329 int dxda2D(const TMLink & link,
330 double dPhi,
331 Vector & dxda,
332 Vector & dyda,
333 Vector & dzda) const;
334
335 int dxda2D(const TMLink & link,
336 double dPhi,
337 Vector & dxda,
338 Vector & dyda) const;
339
340 int dxda2D(double dPhi,
341 Vector & dxda,
342 Vector & dyda) const;
343
344 unsigned defineType(void) const;
345
346 unsigned _findertype;
347 private:// Always updated
348 unsigned _state;
349 double _charge;
350 AList<TSegment> _segments;
351 TTrack * _mother;
352 TTrack * _daughter;
353 // AList<TSvdHit> _svdHits;
354 AList<TMLink> _finalHits;
355 AList<TMLink> _associateHits;
356
357 private:// Updated when fitted
358 //static const THelixFitter _fitter;//yzhang delete 2012-05-04
359 static const THelixFitter _fitter;//yzhang add
360 Helix * _helix;
361 unsigned _ndf;
362 double _chi2;
363 std::string _name;
364 mutable unsigned _type;
365
366 private:// temporary added
367 // AList<TMDCCatHit> _catHits;
368
369 friend class TTrackManager;
370 friend class TrkReco;
371 friend class THelixFitter;
372 friend class TCosmicFitter;
373 friend class Refit;
374 friend class TBuilder;
375 friend class TBuilder0;
376 friend class TBuilderCosmic;
377 friend class TBuilderCurl;
378 friend class TPMCurlFinder;
379 friend class TCurlFinder;
380
381 private:
382 mutable IMagneticFieldSvc* m_pmgnIMF;
383
384
385};
386
387/// Utility functions
388#if defined(__GNUG__)
389int
390SortByPt(const TTrack ** a, const TTrack ** b);
391#else
392extern "C" int
393SortByPt(const void* a, const void* b);
394#endif
395
396/// to dump a track.
397inline std::string
398TrackDump(const TTrack &);
399
400/// returns string of track type.
401inline std::string
402TrackType(const TTrack &);
403
404inline std::string
405TrackType(unsigned type);
406
407/// returns string of track status.
408std::string
409TrackStatus(const TTrack &);
410
411std::string
412TrackStatus(const MdcRec_trk &);
413
414std::string
416
417std::string
418TrackStatus(unsigned md,
419 unsigned mk,
420 unsigned mq,
421 unsigned ms,
422 unsigned mm,
423 unsigned ma);
424
425inline std::string
426TrackKinematics(const TTrack &);
427
428std::string
429TrackKinematics(const Helix &);
430
431std::string
432TrackInformation(const TTrack &);
433
434std::string
436
437std::string
438TrackInformation(unsigned nA, unsigned nS, unsigned n, float chisq);
439
440std::string
441TrackLayerUsage(const TTrack &);
442
443/// returns helix.
444Helix
445Track2Helix(const MdcRec_trk &);
446
447Helix
449
450Helix
451Track2Helix(const Gen_hepevt &);
452
453Helix
455
456/// Helix parameter validity
457bool
458HelixHasNan(const Helix &);
459
460/// Error matrix validity
461bool
462PositiveDefinite(const Helix &);
463
464//-----------------------------------------------------------------------------
465
466#ifdef TTrack_NO_INLINE
467#define inline
468#else
469#undef inline
470#define TTrack_INLINE_DEFINE_HERE
471#endif
472
473#ifdef TTrack_INLINE_DEFINE_HERE
474
475inline
476const Helix &
477TTrack::helix(void) const {
478#ifdef TRKRECO_DEBUG
479 // if (! _fitted) std::cout << "TTrack::helix !!! helix not updated" << std::endl;
480#endif
481 return * _helix;
482}
483
484inline
485unsigned
486TTrack::ndf(void) const {
487#ifdef TRKRECO_DEBUG
488 if (! _fitted) std::cout << "TTrack::ndf !!! ndf not updated" << std::endl;
489#endif
490 return _ndf;
491}
492
493inline
494double
495TTrack::chi2(void) const {
496#ifdef TRKRECO_DEBUG
497 if (! _fitted) std::cout << "TTrack::chi2 !!! chi2 not updated" << std::endl;
498#endif
499 return _chi2;
500}
501
502inline
503double
504TTrack::charge(void) const {
505 return _charge;
506}
507
508inline
509double
510TTrack::charge(double a) {
511 return _charge = a;
512}
513
514inline
515const std::string &
516TTrack::name(void) const {
517 return _name;
518}
519
520inline
521const std::string &
522TTrack::name(const std::string & a) {
523 return _name = a;
524}
525
526inline
527double
528TTrack::pt(void) const {
529 return 1. / fabs(_helix->a()[2]);
530}
531
532inline
533double
534TTrack::pz(void) const {
535 return (1. / fabs(_helix->a()[2])) * _helix->a()[4];
536}
537
538inline
539double
540TTrack::ptot(void) const {
541 return (1. / fabs(_helix->a()[2])) *
542 sqrt(1. + _helix->a()[4] * _helix->a()[4]);
543}
544
545inline
546double
548 return chisq2confLevel((int) _ndf, _chi2);
549}
550
551inline
552Hep3Vector
553TTrack::p(void) const {
554 return _helix->momentum(0.);
555}
556
557inline
558unsigned
560 return Track;
561}
562
563inline
564unsigned
565TTrack::type(void) const {
566 return defineType();
567}
568
569inline
570double
571TTrack::impact(void) const {
572 return fabs(_helix->radius()) - _helix->center().mag();
573}
574
575inline
576double
577TTrack::radius(void) const {
578 return _helix->radius();
579}
580
581inline
584 return _segments;
585}
586
587inline
588const AList<TSegment> &
589TTrack::segments(void) const {
590 return _segments;
591}
592
593inline
595TTrack::center(void) const {
596 return TPoint2D(_helix->center());
597}
598
599inline
600unsigned
601TTrack::finder(void) const {
602 return _state & TrackFinderMask;
603}
604
605inline
606unsigned
607TTrack::finder(unsigned a) {
608 _state |= (a & TrackFinderMask);
609 return finder();
610}
611
612inline
613unsigned
614TTrack::quality(void) const {
615 return (_state >> TrackQualityShift) & TrackQualityMask;
616}
617
618inline
619unsigned
620TTrack::quality(unsigned a) {
621// _state = ((a << TrackQualityShift) & TrackQualityMask) |
622// (_state & (~ (TrackQualityMask << TrackQualityShift)));
623 _state = ((a & TrackQualityMask) << TrackQualityShift) |
624 (_state & (~ (TrackQualityMask << TrackQualityShift)));
625 return quality();
626}
627
628inline
629unsigned
630TTrack::fitting(void) const {
631 return (_state >> TrackFitShift) & TrackFitMask;
632}
633
634inline
635unsigned
636TTrack::fitting(unsigned a) {
637 _state |= ((a << TrackFitShift) & TrackFitMask);
638 return fitting();
639}
640
641inline
642TTrack *
643TTrack::mother(void) const {
644 return _mother;
645}
646
647inline
648TTrack *
650 if (a) _state |= (TrackHasMother << TrackRelationShift);
651 else _state &= (~(TrackHasMother << TrackRelationShift));
652 return _mother = a;
653}
654
655inline
656TTrack *
657TTrack::daughter(void) const {
658 return _daughter;
659}
660
661inline
662TTrack *
664 if (a) _state |= (TrackHasDaughter << TrackRelationShift);
665 else _state &= (~(TrackHasDaughter << TrackRelationShift));
666 return _daughter = a;
667}
668
669inline
670unsigned
671TTrack::state(void) const {
672 return _state;
673}
674
675inline
676void TTrack::setFinderType(unsigned type){
677 _findertype=type;
678}
679inline
680unsigned TTrack::getFinderType(void)const{
681 return _findertype;
682}
683inline
684std::string
686 return TrackType(t.type());
687}
688
689inline
690std::string
692 return TrackKinematics(t.helix());
693}
694
695inline
696std::string
698 return t.name() + " " + TrackStatus(t) + " " + TrackKinematics(t) + " " +
700}
701
702inline
703const AList<TMLink> &
705 _finalHits = list;
706 return _finalHits;
707}
708
709inline
710const AList<TMLink> &
711TTrack::finalHits(void) const {
712 return _finalHits;
713}
714
715inline
716const AList<TMLink> &
718 _associateHits = list;
719 return _associateHits;
720}
721
722inline
723const AList<TMLink> &
725 return _associateHits;
726}
727
728
729#endif
730
731#undef inline
732
733#endif /* TTrack_FLAG_ */
const Int_t n
const double mk
Definition: Gam4pikp.cxx:48
double chisq2confLevel(int, double)
ALPHA = 10000. / 2.99792458 / 15.
Definition: TMDCUtil.cxx:156
HepGeom::Point3D< double > HepPoint3D
bool HelixHasNan(const Helix &)
Helix parameter validity.
Definition: TTrack.cxx:3934
Helix Track2Helix(const MdcRec_trk &)
returns helix.
Definition: TTrack.cxx:3684
std::string TrackLayerUsage(const TTrack &)
Definition: TTrack.cxx:3905
std::string TrackDump(const TTrack &)
to dump a track.
std::string TrackInformation(const TTrack &)
Definition: TTrack.cxx:3856
std::string TrackStatus(const TTrack &)
returns string of track status.
Definition: TTrack.cxx:3779
bool PositiveDefinite(const Helix &)
Error matrix validity.
Definition: TTrack.cxx:3918
std::string TrackKinematics(const TTrack &)
int SortByPt(const void *a, const void *b)
Utility functions.
Definition: TTrack.cxx:2530
TTree * t
Definition: binning.cxx:23
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
double radius(void) const
returns radious of helix.
const HepVector & a(void) const
returns helix parameters.
A class to represent a track in tracking.
A class to represent a circle in tracking.
A class to fit a TTrackBase object to a helix.
A class to fit a TTrackBase object to a helix.
A class to represent a point in 2D.
A class to represent a track in tracking.
A class to relate TMDCWireHit and TTrack objects.
A virtual class for a track class in tracking.
A manager of TTrack information to make outputs as MdcRec_trk.
A class to represent a track in tracking.
AList< TSegment > & segments(void)
returns AList<TSegment>.
void assign(unsigned maskForWireHit)
assigns wire hits to this track.
Definition: TTrack.cxx:3635
const Helix & helix(void) const
returns helix parameter.
unsigned ndf(void) const
returns NDF.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TTrack.cxx:229
int stereoHitForCurl(TMLink &link, AList< HepPoint3D > &arcZList) const
const std::string & name(void) const
returns/sets name.
TPoint2D center(void) const
returns position of helix center.
unsigned quality(void) const
sets/returns quality.
TTrack()
Default constructor.
Definition: TTrack.cxx:207
TTrack * mother(void) const
sets/returns mother/daughter.
int fit2D(unsigned=0, double=0.1, double=0.015)
fits itself. Error was happened if return value is not zero.
Definition: TTrack.cxx:2542
int stereoHitForCurl(TMLink &link, TMLink &link1) const
unsigned finder(void) const
sets/returns finder.
unsigned getFinderType(void) const
double radius(void) const
returns signed radius.
int HelCyl(double rhole, double rcyl, double zb, double zf, double epsl, double &phi, HepPoint3D &xp) const
returns a cathode hit list.
Definition: TTrack.cxx:316
TTrack(const T3DLine &)
Constructor.
unsigned type(void) const
returns type. Definition is depending on an object type.
const AList< TMLink > & associateHits(void) const
sets/returns a list of associated TMLink which are used for table output.
double confidenceLevel(void) const
returns confidence level.
double impact(void) const
returns signed impact parameter to the origin.
int stereoHitForCurl(TMLink &link, TMLink &link1, TMLink &link2) const
unsigned objectType(void) const
returns type.
double pt(void) const
returns Pt.
double ptot(void) const
returns magnitude of momentum.
unsigned state(void) const
returns/sets internal state.(for bank output)
void deleteListForCurl(AList< HepPoint3D > &l1, AList< HepPoint3D > &l2, AList< HepPoint3D > &l3) const
double pz(void) const
returns Pz.
int approach(TMLink &) const
calculates the closest approach to a wire in real space. Results are stored in TMLink....
Definition: TTrack.cxx:296
void refine2D(AList< TMLink > &list, float maxSigma)
fits itself with cathode hits.
Definition: TTrack.cxx:301
const AList< TMLink > & finalHits(void) const
finds cathode hits associated to this track.
int approach2D(TMLink &) const
Definition: TTrack.cxx:2891
void movePivot(void)
moves pivot to the inner most hit.
Definition: TTrack.cxx:262
unsigned fitting(void) const
sets/returns fitting status.
double chi2(void) const
returns chi2.
int szPosition(TMLink &link) const
calculates arc length and z for a stereo hit.
Definition: TTrack.cxx:3372
double charge(void) const
returns charge.
virtual ~TTrack()
Destructor.
Definition: TTrack.cxx:224
void deleteListForCurl(AList< HepPoint3D > &l1, AList< HepPoint3D > &l2) const
Hep3Vector p(void) const
returns momentum.
const double b
Definition: slope.cxx:9