BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrkReco/include/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 : yoshihito.iwasaki@kek.jp
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/TBuilder0.h"
73#include "TrkReco/TBuilderCosmic.h"
74#include "TrkReco/TBuilderCurl.h"
75#include "TrkReco/TMDCUtil.h"
76#include "TrkReco/TMLink.h"
77#include "TrkReco/TTrackBase.h"
78// #include "TrkReco/TMDCCatHit.h"
79#include "TrkReco/TPoint2D.h"
80// #include "TrkReco/TSvdHit.h"
81
82#include "GaudiKernel/IInterface.h"
83#include "GaudiKernel/Kernel.h"
84#include "GaudiKernel/Service.h"
85#include "MagneticFieldSvc/IBesMagFieldSvc.h"
86#include "TrkReco/T3DLine.h"
87#include "TrkReco/TRunge.h"
88// #include "MagneticField/MagneticFieldSvc.h"
89
90#include "CLHEP/Geometry/Point3D.h"
91#include "CLHEP/Matrix/SymMatrix.h"
92#include "CLHEP/Matrix/Vector.h"
93#include "CLHEP/Vector/LorentzVector.h"
94#include "CLHEP/Vector/ThreeVector.h"
95
96using CLHEP::Hep3Vector;
97
98#ifndef CLHEP_POINT3D_H
99# include "CLHEP/Geometry/Point3D.h"
100#endif
101#ifndef ENABLE_BACKWARDS_COMPATIBILITY
102typedef HepGeom::Point3D<double> HepPoint3D;
103#endif
104using HepGeom::Point3D;
105
106// class HepPoint3D;
107class TrkReco;
108class TTrackManager;
109class TCircle;
110class TCosmicFitter;
111class Refit;
112class THelixFitter;
113class TBuilder;
114// class TPMCurlFinder;
115class TCurlFinder;
116// struct reccdc_trk;
117// struct reccdc_trk_add;
118// struct rectrk_localz;
119// struct gen_hepevt;
120// struct mdst_trk_fit;
121class MdcRec_trk;
122class MdcRec_trk_add;
123class MdcTrk_localz;
124class Gen_hepevt;
125class Mdst_trk_fit;
126
127/// A class to represent a track in tracking.
128class TTrack : public TTrackBase {
129
130public:
131 /// Default constructor
133
134 /// Constructor
135 TTrack( const TCircle& );
136
137 /// Copy constructor
138 TTrack( const TTrack& );
139
140 /// Constructor
141 TTrack( const T3DLine& );
142
143 /// Constructor
144 TTrack( const Helix& );
145
146 TTrack( const TRunge& );
147 /// Destructor
148 virtual ~TTrack();
149
150public: // General information
151 /// returns/sets name.
152 const std::string& name( void ) const;
153 const std::string& name( const std::string& newName );
154
155 /// sets/returns mother/daughter.
156 TTrack* mother( void ) const;
158 TTrack* daughter( void ) const;
160
161 /// returns type.
162 unsigned objectType( void ) const;
163
164 /// returns type. Definition is depending on an object type.
165 unsigned type( void ) const;
166
167 /// sets/returns finder.
168 unsigned finder( void ) const;
169 unsigned finder( unsigned finderMask );
170 void setFinderType( unsigned );
171 unsigned getFinderType( void ) const;
172
173 /// sets/returns quality.
174 unsigned quality( void ) const;
175 unsigned quality( unsigned qualityMask );
176
177 /// sets/returns fitting status.
178 unsigned fitting( void ) const;
179 unsigned fitting( unsigned fitMask );
180
181 /// returns/sets internal state.(for bank output)
182 unsigned state( void ) const;
183
184 /// assigns wire hits to this track.
185 void assign( unsigned maskForWireHit );
186
187 /// dumps debug information.
188 void dump( const std::string& message = std::string( "" ),
189 const std::string& prefix = std::string( "" ) ) const;
190
191public: // Kinematics
192 /// returns charge.
193 double charge( void ) const;
194
195 /// returns helix parameter.
196 const Helix& helix( void ) const;
197
198 /// returns momentum.
199 Hep3Vector p( void ) const;
200
201 /// returns magnitude of momentum.
202 double ptot( void ) const;
203
204 /// returns Pt.
205 double pt( void ) const;
206
207 /// returns Pz.
208 double pz( void ) const;
209
210 /// returns signed impact parameter to the origin.
211 double impact( void ) const;
212
213 /// returns position of helix center.
214 TPoint2D center( void ) const;
215
216 /// returns signed radius.
217 double radius( void ) const;
218
219 /// returns NDF.
220 unsigned ndf( void ) const;
221
222 /// returns chi2.
223 double chi2( void ) const;
224
225 /// returns confidence level.
226 double confidenceLevel( void ) const;
227
228public: // Utilities for segment operations.
229 /// returns AList<TSegment>.
231 const AList<TSegment>& segments( void ) const;
232
233public: // Utilities
234 /// calculates the closest approach to a wire in real space. Results are stored in TMLink.
235 /// 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.
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;
257 AList<HepPoint3D>& l3 ) const;
258#endif
259 /// calculates arc length and z for a stereo hit. uses these functions for curl
260 /// tracks(included svd version).
262 ////int svdHitForCurl(AList<TSvdHit>&) const;
263
264public: // Modifiers
265 /// sets charge.
266 double charge( double );
267
268 /// fits itself. Error was happened if return value is not zero.
269 // int fitx(void);
270
271 /// fits itself with r-phi view. Error was happened if return value is not zero.
272 int fit2D( unsigned = 0, double = 0.1, double = 0.015 );
273
274 /// fits itself with cathode hits.
275 // int fitWithCathode( float windowSize = 0.6 , int SysCorr = 0 ); // mod by matsu (
276 // 1999/07/05 )
277
278 /// remove bad points by chi2. Bad points are returned in a 'list'. fit() should be called
279 /// before calling this function. (using stereo wire as axial wire(z=0))
280 void refine2D( AList<TMLink>& list, float maxSigma );
281
282 /// moves pivot to the inner most hit.
283 void movePivot( void );
284
285public: // temporary added
286 /// returns a cathode hit list.
287 // const AList<TMDCCatHit> & catHits(void) const;
288
289 /// calculates an intersection of this track and a cylinder.
290 int HelCyl( double rhole, double rcyl, double zb, double zf, double epsl, double& phi,
291 HepPoint3D& xp ) const;
292
293 /// finds cathode hits associated to this track.
294 // void findCatHit(unsigned trackid);
295
296 /// relation between cluster and wire
297 // void relationClusterWithWire();
298
299 /// relation between cluster and layer
300 // void relationClusterWithLayer(int SysCorr ); // by matsu ( 1999/07/05 )
301
302 /// appends Svd Hits(TSvdHit)
303 // void svdHits(AList<TSvdHit> &);
304
305 /// returns Svd Hits List
306 // AList<TSvdHit> & svdHits(void);
307 // const AList<TSvdHit> & svdHits(void) const;
308
309 /// sets/returns a list of TMLink which are used for table output.
310 const AList<TMLink>& finalHits( void ) const;
311 const AList<TMLink>& finalHits( const AList<TMLink>& hits );
312
313 /// sets/returns a list of associated TMLink which are used for table output.
314 const AList<TMLink>& associateHits( void ) const;
316
317private:
318 /// calculates dXda. 'link' and 'dPhi' are inputs. Others are outputs.
319 int dxda( const TMLink& link, double dPhi, Vector& dxda, Vector& dyda, Vector& dzda ) const;
320
321 int dxda2D( const TMLink& link, double dPhi, Vector& dxda, Vector& dyda,
322 Vector& dzda ) const;
323
324 int dxda2D( const TMLink& link, double dPhi, Vector& dxda, Vector& dyda ) const;
325
326 int dxda2D( double dPhi, Vector& dxda, Vector& dyda ) const;
327
328 unsigned defineType( void ) const;
329
330 unsigned _findertype;
331
332private: // Always updated
333 unsigned _state;
334 double _charge;
335 AList<TSegment> _segments;
336 TTrack* _mother;
337 TTrack* _daughter;
338 // AList<TSvdHit> _svdHits;
339 AList<TMLink> _finalHits;
340 AList<TMLink> _associateHits;
341
342private: // Updated when fitted
343 // static const THelixFitter _fitter;//yzhang delete 2012-05-04
344 static const THelixFitter _fitter; // yzhang add
345 Helix* _helix;
346 unsigned _ndf;
347 double _chi2;
348 std::string _name;
349 mutable unsigned _type;
350
351private: // temporary added
352 // AList<TMDCCatHit> _catHits;
353
354 friend class TTrackManager;
355 friend class TrkReco;
356 friend class THelixFitter;
357 friend class TCosmicFitter;
358 friend class Refit;
359 friend class TBuilder;
360 friend class TBuilder0;
361 friend class TBuilderCosmic;
362 friend class TBuilderCurl;
363 friend class TPMCurlFinder;
364 friend class TCurlFinder;
365
366private:
367 IBesMagFieldSvc* getPmgnIMF() const;
368 mutable IBesMagFieldSvc* m_pmgnIMF;
369};
370
371/// Utility functions
372#if defined( __GNUG__ )
373int SortByPt( const TTrack** a, const TTrack** b );
374#else
375extern "C" int SortByPt( const void* a, const void* b );
376#endif
377
378/// to dump a track.
379inline std::string TrackDump( const TTrack& );
380
381/// returns string of track type.
382inline std::string TrackType( const TTrack& );
383
384inline std::string TrackType( unsigned type );
385
386/// returns string of track status.
387std::string TrackStatus( const TTrack& );
388
389std::string TrackStatus( const MdcRec_trk& );
390
391std::string TrackStatus( const MdcRec_trk_add& );
392
393std::string TrackStatus( unsigned md, unsigned mk, unsigned mq, unsigned ms, unsigned mm,
394 unsigned ma );
395
396inline std::string TrackKinematics( const TTrack& );
397
398std::string TrackKinematics( const Helix& );
399
400std::string TrackInformation( const TTrack& );
401
402std::string TrackInformation( const MdcRec_trk& );
403
404std::string TrackInformation( unsigned nA, unsigned nS, unsigned n, float chisq );
405
406std::string TrackLayerUsage( const TTrack& );
407
408/// returns helix.
410
412
414
416
417/// Helix parameter validity
418bool HelixHasNan( const Helix& );
419
420/// Error matrix validity
421bool PositiveDefinite( const Helix& );
422
423//-----------------------------------------------------------------------------
424
425#ifdef TTrack_NO_INLINE
426# define inline
427#else
428# undef inline
429# define TTrack_INLINE_DEFINE_HERE
430#endif
431
432#ifdef TTrack_INLINE_DEFINE_HERE
433
434inline const Helix& TTrack::helix( void ) const {
435# ifdef TRKRECO_DEBUG
436 // if (! _fitted) std::cout << "TTrack::helix !!! helix not updated" << std::endl;
437# endif
438 return *_helix;
439}
440
441inline unsigned TTrack::ndf( void ) const {
442# ifdef TRKRECO_DEBUG
443 if ( !_fitted ) std::cout << "TTrack::ndf !!! ndf not updated" << std::endl;
444# endif
445 return _ndf;
446}
447
448inline double TTrack::chi2( void ) const {
449# ifdef TRKRECO_DEBUG
450 if ( !_fitted ) std::cout << "TTrack::chi2 !!! chi2 not updated" << std::endl;
451# endif
452 return _chi2;
453}
454
455inline double TTrack::charge( void ) const { return _charge; }
456
457inline double TTrack::charge( double a ) { return _charge = a; }
458
459inline const std::string& TTrack::name( void ) const { return _name; }
460
461inline const std::string& TTrack::name( const std::string& a ) { return _name = a; }
462
463inline double TTrack::pt( void ) const { return 1. / fabs( _helix->a()[2] ); }
464
465inline double TTrack::pz( void ) const {
466 return ( 1. / fabs( _helix->a()[2] ) ) * _helix->a()[4];
467}
468
469inline double TTrack::ptot( void ) const {
470 return ( 1. / fabs( _helix->a()[2] ) ) * sqrt( 1. + _helix->a()[4] * _helix->a()[4] );
471}
472
473inline double TTrack::confidenceLevel( void ) const {
474 return chisq2confLevel( (int)_ndf, _chi2 );
475}
476
477inline Hep3Vector TTrack::p( void ) const { return _helix->momentum( 0. ); }
478
479inline unsigned TTrack::objectType( void ) const { return Track; }
480
481inline unsigned TTrack::type( void ) const { return defineType(); }
482
483inline double TTrack::impact( void ) const {
484 return fabs( _helix->radius() ) - _helix->center().mag();
485}
486
487inline double TTrack::radius( void ) const { return _helix->radius(); }
488
489inline AList<TSegment>& TTrack::segments( void ) { return _segments; }
490
491inline const AList<TSegment>& TTrack::segments( void ) const { return _segments; }
492
493inline TPoint2D TTrack::center( void ) const { return TPoint2D( _helix->center() ); }
494
495inline unsigned TTrack::finder( void ) const { return _state & TrackFinderMask; }
496
497inline unsigned TTrack::finder( unsigned a ) {
498 _state |= ( a & TrackFinderMask );
499 return finder();
500}
501
502inline unsigned TTrack::quality( void ) const {
503 return ( _state >> TrackQualityShift ) & TrackQualityMask;
504}
505
506inline unsigned TTrack::quality( unsigned a ) {
507 // _state = ((a << TrackQualityShift) & TrackQualityMask) |
508 // (_state & (~ (TrackQualityMask << TrackQualityShift)));
509 _state = ( ( a & TrackQualityMask ) << TrackQualityShift ) |
510 ( _state & ( ~( TrackQualityMask << TrackQualityShift ) ) );
511 return quality();
512}
513
514inline unsigned TTrack::fitting( void ) const {
515 return ( _state >> TrackFitShift ) & TrackFitMask;
516}
517
518inline unsigned TTrack::fitting( unsigned a ) {
519 _state |= ( ( a << TrackFitShift ) & TrackFitMask );
520 return fitting();
521}
522
523inline TTrack* TTrack::mother( void ) const { return _mother; }
524
525inline TTrack* TTrack::mother( TTrack* a ) {
526 if ( a ) _state |= ( TrackHasMother << TrackRelationShift );
527 else _state &= ( ~( TrackHasMother << TrackRelationShift ) );
528 return _mother = a;
529}
530
531inline TTrack* TTrack::daughter( void ) const { return _daughter; }
532
533inline TTrack* TTrack::daughter( TTrack* a ) {
534 if ( a ) _state |= ( TrackHasDaughter << TrackRelationShift );
535 else _state &= ( ~( TrackHasDaughter << TrackRelationShift ) );
536 return _daughter = a;
537}
538
539inline unsigned TTrack::state( void ) const { return _state; }
540
541inline void TTrack::setFinderType( unsigned type ) { _findertype = type; }
542inline unsigned TTrack::getFinderType( void ) const { return _findertype; }
543inline std::string TrackType( const TTrack& t ) { return TrackType( t.type() ); }
544
545inline std::string TrackKinematics( const TTrack& t ) { return TrackKinematics( t.helix() ); }
546
547inline std::string TrackDump( const TTrack& t ) {
548 return t.name() + " " + TrackStatus( t ) + " " + TrackKinematics( t ) + " " +
550}
551
552inline const AList<TMLink>& TTrack::finalHits( const AList<TMLink>& list ) {
553 _finalHits = list;
554 return _finalHits;
555}
556
557inline const AList<TMLink>& TTrack::finalHits( void ) const { return _finalHits; }
558
559inline const AList<TMLink>& TTrack::associateHits( const AList<TMLink>& list ) {
560 _associateHits = list;
561 return _associateHits;
562}
563
564inline const AList<TMLink>& TTrack::associateHits( void ) const { return _associateHits; }
565
566#endif
567
568#undef inline
569
570#endif /* TTrack_FLAG_ */
HepGeom::Point3D< double > HepPoint3D
const Int_t n
const double mk
Definition Gam4pikp.cxx:33
double chisq2confLevel(int, double)
ALPHA = 10000. / 2.99792458 / 15.
Definition TMDCUtil.cxx:147
HepGeom::Point3D< double > HepPoint3D
bool HelixHasNan(const Helix &)
Helix parameter validity.
Definition TTrack.cxx:3939
Helix Track2Helix(const MdcRec_trk &)
returns helix.
Definition TTrack.cxx:3707
std::string TrackLayerUsage(const TTrack &)
Definition TTrack.cxx:3911
std::string TrackDump(const TTrack &)
to dump a track.
std::string TrackInformation(const TTrack &)
Definition TTrack.cxx:3867
std::string TrackStatus(const TTrack &)
returns string of track status.
Definition TTrack.cxx:3801
bool PositiveDefinite(const Helix &)
Error matrix validity.
Definition TTrack.cxx:3924
std::string TrackKinematics(const TTrack &)
int SortByPt(const void *a, const void *b)
Utility functions.
Definition TTrack.cxx:2514
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 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.
int szPosition(const HepPoint3D &p, HepPoint3D &szPosition) const
calculates arc length for a point.
int approach(TMLink &, bool sagCorrection) const
const Helix & helix(void) const
returns helix parameter.
unsigned ndf(void) const
returns NDF.
const std::string & name(const std::string &newName)
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
int stereoHitForCurl(TMLink &link, AList< HepPoint3D > &arcZList) const
const AList< TMLink > & finalHits(const AList< TMLink > &hits)
const std::string & name(void) const
returns/sets name.
TTrack(const Helix &)
Constructor.
TPoint2D center(void) const
returns position of helix center.
TTrack * daughter(void) const
unsigned quality(void) const
sets/returns quality.
TTrack()
Default constructor.
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.
int stereoHitForCurl(TMLink &link, TMLink &link1) const
unsigned finder(void) const
sets/returns finder.
unsigned getFinderType(void) const
const AList< TMLink > & associateHits(const AList< TMLink > &hits)
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.
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 quality(unsigned qualityMask)
TTrack(const TCircle &)
Constructor.
unsigned objectType(void) const
returns type.
void setFinderType(unsigned)
TTrack(const TTrack &)
Copy constructor.
TTrack * mother(TTrack *)
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
TTrack(const TRunge &)
int stereoHitForCurl(AList< TMLink > &) const
unsigned fitting(unsigned fitMask)
double pz(void) const
returns Pz.
int approach(TMLink &) const
void refine2D(AList< TMLink > &list, float maxSigma)
fits itself with cathode hits.
const AList< TSegment > & segments(void) const
unsigned finder(unsigned finderMask)
const AList< TMLink > & finalHits(void) const
finds cathode hits associated to this track.
int approach2D(TMLink &) const
void movePivot(void)
moves pivot to the inner most hit.
TTrack * daughter(TTrack *)
unsigned fitting(void) const
sets/returns fitting status.
virtual ~TTrack()
Destructor.
double chi2(void) const
returns chi2.
double charge(double)
sets charge.
int szPosition(TMLink &link) const
calculates arc length and z for a stereo hit.
int szPosition(const TSegment &segment, TMLink &link) const
calculates arc length and z for a segment. Results are stored in TMLink.
double charge(void) const
returns charge.
void deleteListForCurl(AList< HepPoint3D > &l1, AList< HepPoint3D > &l2) const
Hep3Vector p(void) const
returns momentum.
A tracking module.
Definition TrkReco.h:46
int t()
Definition t.c:1