BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrkReco/include/TrkReco/THelixFitter.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: THelixFitter.h,v 1.14 2012/05/28 05:16:29 maoh Exp $
3//-----------------------------------------------------------------------------
4// Filename : THelixFitter.h
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : yoshihito.iwasaki@kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to fit a TTrackBase object to a helix.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#ifndef THELIXFITTER_FLAG_
14#define THELIXFITTER_FLAG_
15
16#ifdef TRKRECO_DEBUG_DETAIL
17# ifndef TRKRECO_DEBUG
18# define TRKRECO_DEBUG
19# endif
20#endif
21// #define HEP_SHORT_NAMES
22#include "CLHEP/Matrix/Vector.h"
23// #include "helix/Helix.h"
24// #include "TrkReco/Helix.h"
25#include "TrackUtil/Helix.h"
26#include "TrkReco/TMFitter.h"
27#include "TrkReco/TTrackBase.h"
28
29#include "MagneticFieldSvc/IBesMagFieldSvc.h"
30// #include "MagneticField/MagneticFieldSvc.h"
31
32#include "CLHEP/Geometry/Point3D.h"
33#include "CLHEP/Matrix/SymMatrix.h"
34#include "CLHEP/Vector/LorentzVector.h"
35#include "CLHEP/Vector/ThreeVector.h"
36
37class TMLink;
38
39using CLHEP::HepVector;
40
41//...Drift time correction method...
42#define TrackFitNoCorrection 0
43#define TrackFitCorrectOnce 1
44#define TrackFitCorrectEveryIteration 2
45
46/// A class to fit a TTrackBase object to a helix.
47class THelixFitter : public TMFitter {
48
49public:
50 /// Constructor.
51 THelixFitter( const std::string& name );
52
53 /// Destructor
54 virtual ~THelixFitter();
55
56public: // Informations
57 /// dumps debug information.
58 void dump( const std::string& message = std::string( "" ),
59 const std::string& prefix = std::string( "" ) ) const;
60
61public: // Options
62 /// sets/returns 2D flag.
63 bool fit2D( void ) const;
64 bool fit2D( bool );
65
66 /// sets/returns free T0 flag.
67 bool freeT0( void ) const;
68 bool freeT0( bool );
69
70 /// sets/returns correctin flag.
71 unsigned corrections( void ) const;
72 unsigned corrections( unsigned );
73
74public: // Options (obsolete)
75 /// sets/returns sag correction flag.
76 bool sag( void ) const;
77 bool sag( bool );
78
79 /// sets/returns propagation-delay correction flag.
80 bool propagation( void ) const;
81 bool propagation( bool );
82
83 /// sets/returns propagation-delay correction flag.
84 bool tof( void ) const;
85 bool tof( bool );
86
87 /// sets/returns tanLambda correction flag.
88 bool tanl( void ) const;
89 bool tanl( bool );
90
91 /// returns sum of chi2 before fit.
92 double preChi2( void ) const;
93
94 /// returns sum of chi2 aftter fit.
95 double chi2( void ) const;
96
97 IBesMagFieldSvc* getMagneticFieldPointer( void ) const { return m_pmgnIMF; }
98
99public: // Fitting
100 int fit( TTrackBase& ) const;
101 int fit( TTrackBase&, double* pre_chi2, double* fitted_chi2 ) const;
102 int fit( TTrackBase&, float t0Offset, double* pre_chi2 = NULL,
103 double* fitted_chi2 = NULL ) const;
104 int fit( TTrackBase&, float& tev, float& tev_err, double* pre_chi2 = NULL,
105 double* fitted_chi2 = NULL ) const;
106
107private:
108 /// main routine for fixed T0.
109 int main( TTrackBase&, float t0Offset, double* pre_chi2 = NULL,
110 double* fitted_chi2 = NULL ) const;
111
112 /// main routine for free T0.
113 int main( TTrackBase&, float& tev, float& tev_err, double* pre_chi2 = NULL,
114 double* fitted_chi2 = NULL ) const;
115
116 /// calculates drift distance and its error.
117 void drift( const TTrack&, TMLink&, float t0Offset, double& distance,
118 double& itsError ) const;
119 // be cautious here
120 /// calculates drift distance and its error for free T0 case.
121 void drift( const TTrack&, TMLink&, float t0Offset, double& distance, double& itsError,
122 double& ddda ) const;
123 // be cautious here
124 /// calculates dXda. 'link' and 'dPhi' are inputs. Others are outputs.
125 // virtual
126 int dxda( const TMLink& link, const Helix& helix, double dPhi, HepVector& dxda,
127 HepVector& dyda, HepVector& dzda ) const;
128
129private:
130 bool _fit2D;
131 bool _freeT0;
132 unsigned _corrections;
133
134 bool _sag;
135 int _propagation;
136 bool _tof;
137 bool _tanl;
138
139 // jialk
140 double _driftTime;
141 mutable double _pre_chi2;
142 mutable double _fitted_chi2;
143
144private:
145 mutable IBesMagFieldSvc* m_pmgnIMF;
146};
147
148//-----------------------------------------------------------------------------
149
150#ifdef TRKRECO_NO_INLINE
151# define inline
152#else
153# undef inline
154# define THELIXFITTER_INLINE_DEFINE_HERE
155#endif
156
157#ifdef THELIXFITTER_INLINE_DEFINE_HERE
158
159inline bool THelixFitter::fit2D( void ) const { return _fit2D; }
160
161inline bool THelixFitter::fit2D( bool a ) { return _fit2D = a; }
162
163inline bool THelixFitter::sag( void ) const { return _sag; }
164
165inline bool THelixFitter::sag( bool a ) { return _sag = a; }
166
167inline bool THelixFitter::propagation( void ) const { return (bool)_propagation; }
168
169inline bool THelixFitter::propagation( bool a ) {
170 if ( a ) _propagation = 1;
171 else _propagation = 0;
172 return propagation();
173}
174
175inline bool THelixFitter::tof( void ) const { return _tof; }
176
177inline bool THelixFitter::tof( bool a ) { return _tof = a; }
178
179inline bool THelixFitter::tanl( void ) const { return _tanl; }
180
181inline bool THelixFitter::tanl( bool a ) { return _tanl = a; }
182
183inline int THelixFitter::fit( TTrackBase& a ) const {
184 if ( !_freeT0 ) return main( a, 0. );
185 else
186 {
187 float tev = 0.;
188 float tevError;
189 return main( a, tev, tevError );
190 }
191}
192
193inline int THelixFitter::fit( TTrackBase& a, double* pre_chi2, double* fitted_chi2 ) const {
194 if ( !_freeT0 ) return main( a, 0., pre_chi2, fitted_chi2 );
195 else
196 {
197 float tev = 0.;
198 float tevError;
199 return main( a, tev, tevError, pre_chi2, fitted_chi2 );
200 }
201}
202
203inline int THelixFitter::fit( TTrackBase& a, float t0Offset, double* pre_chi2,
204 double* fitted_chi2 ) const {
205 a._fitted = false;
206 if ( !_freeT0 ) return main( a, t0Offset, pre_chi2, fitted_chi2 );
207 else
208 {
209 float tev = t0Offset;
210 float tevError;
211 return main( a, tev, tevError, pre_chi2, fitted_chi2 );
212 }
213}
214
215inline int THelixFitter::fit( TTrackBase& a, float& tev, float& tev_err, double* pre_chi2,
216 double* fitted_chi2 ) const {
217 a._fitted = false;
218 return main( a, tev, tev_err, pre_chi2, fitted_chi2 );
219}
220
221inline bool THelixFitter::freeT0( void ) const { return _freeT0; }
222
223inline bool THelixFitter::freeT0( bool a ) { return _freeT0 = a; }
224
225inline unsigned THelixFitter::corrections( void ) const { return _corrections; }
226
227inline unsigned THelixFitter::corrections( unsigned a ) { return _corrections = a; }
228
229inline double THelixFitter::preChi2( void ) const { return _pre_chi2; }
230
231inline double THelixFitter::chi2( void ) const { return _fitted_chi2; }
232
233#endif
234
235#undef inline
236
237#endif /* THELIXFITTER_FLAG_ */
A class to fit a TTrackBase object to a helix.
double chi2(void) const
returns sum of chi2 aftter fit.
bool sag(bool)
virtual ~THelixFitter()
Destructor.
unsigned corrections(unsigned)
IBesMagFieldSvc * getMagneticFieldPointer(void) const
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
int fit(TTrackBase &, float &tev, float &tev_err, double *pre_chi2=NULL, double *fitted_chi2=NULL) const
bool freeT0(void) const
sets/returns free T0 flag.
bool fit2D(void) const
sets/returns 2D flag.
int fit(TTrackBase &, float t0Offset, double *pre_chi2=NULL, double *fitted_chi2=NULL) const
double preChi2(void) const
returns sum of chi2 before fit.
bool tof(bool)
unsigned corrections(void) const
sets/returns correctin flag.
int fit(TTrackBase &, double *pre_chi2, double *fitted_chi2) const
bool tof(void) const
sets/returns propagation-delay correction flag.
bool tanl(bool)
int fit(TTrackBase &) const
bool propagation(bool)
bool sag(void) const
sets/returns sag correction flag.
bool fit2D(bool)
bool freeT0(bool)
THelixFitter(const std::string &name)
Constructor.
bool tanl(void) const
sets/returns tanLambda correction flag.
bool propagation(void) const
sets/returns propagation-delay correction flag.
const std::string & name(void) const
returns name.
A virtual class for a track class in tracking.
A class to represent a track in tracking.
int main()
Definition phokhara.cc:42