00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef THELIXFITTER_FLAG_
00014 #define THELIXFITTER_FLAG_
00015
00016 #ifdef TRKRECO_DEBUG_DETAIL
00017 #ifndef TRKRECO_DEBUG
00018 #define TRKRECO_DEBUG
00019 #endif
00020 #endif
00021 #define HEP_SHORT_NAMES
00022 #include "CLHEP/Matrix/Vector.h"
00023
00024
00025 #include "TrackUtil/Helix.h"
00026 #include "TrkReco/TMFitter.h"
00027 #include "TrkReco/TTrackBase.h"
00028
00029 #include "MagneticField/IMagneticFieldSvc.h"
00030 #include "MagneticField/MagneticFieldSvc.h"
00031
00032 #include "CLHEP/Matrix/SymMatrix.h"
00033 #include "CLHEP/Vector/ThreeVector.h"
00034 #include "CLHEP/Vector/LorentzVector.h"
00035 #include "CLHEP/Geometry/Point3D.h"
00036
00037
00038 class TMLink;
00039
00040 using CLHEP::HepVector;
00041
00042
00043 #define TrackFitNoCorrection 0
00044 #define TrackFitCorrectOnce 1
00045 #define TrackFitCorrectEveryIteration 2
00046
00048 class THelixFitter : public TMFitter {
00049
00050 public:
00052 THelixFitter(const std::string & name);
00053
00055 virtual ~THelixFitter();
00056
00057 public:
00059 void dump(const std::string & message = std::string(""),
00060 const std::string & prefix = std::string("")) const;
00061
00062 public:
00064 bool fit2D(void) const;
00065 bool fit2D(bool);
00066
00068 bool freeT0(void) const;
00069 bool freeT0(bool);
00070
00072 unsigned corrections(void) const;
00073 unsigned corrections(unsigned);
00074
00075 public:
00077 bool sag(void) const;
00078 bool sag(bool);
00079
00081 bool propagation(void) const;
00082 bool propagation(bool);
00083
00085 bool tof(void) const;
00086 bool tof(bool);
00087
00089 bool tanl(void) const;
00090 bool tanl(bool);
00091
00093 double preChi2(void) const;
00094
00096 double chi2(void) const;
00097
00098 IMagneticFieldSvc* getMagneticFieldPointer(void) const{return m_pmgnIMF;}
00099 public:
00100 int fit(TTrackBase &) const;
00101 int fit(TTrackBase &, double *pre_chi2, double *fitted_chi2) const;
00102 int fit(TTrackBase &, float t0Offset, double *pre_chi2=NULL, double *fitted_chi2=NULL) const;
00103 int fit(TTrackBase &, float & tev, float & tev_err, double *pre_chi2=NULL, double *fitted_chi2=NULL) const;
00104
00105 private:
00107 int main(TTrackBase &, float t0Offset, double *pre_chi2=NULL, double *fitted_chi2=NULL) const;
00108
00110 int main(TTrackBase &, float & tev, float & tev_err, double *pre_chi2=NULL, double *fitted_chi2=NULL) const;
00111
00113 void drift(const TTrack &,
00114 TMLink &,
00115 float t0Offset,
00116 double & distance,
00117 double & itsError) const;
00118
00120 void drift(const TTrack &,
00121 TMLink &,
00122 float t0Offset,
00123 double & distance,
00124 double & itsError,
00125 double & ddda) const;
00126
00128
00129 int dxda(const TMLink & link,
00130 const Helix & helix,
00131 double dPhi,
00132 HepVector & dxda,
00133 HepVector & dyda,
00134 HepVector & dzda) const;
00135
00136 private:
00137 bool _fit2D;
00138 bool _freeT0;
00139 unsigned _corrections;
00140
00141 bool _sag;
00142 int _propagation;
00143 bool _tof;
00144 bool _tanl;
00145
00146
00147 double _driftTime;
00148 mutable double _pre_chi2;
00149 mutable double _fitted_chi2;
00150 private:
00151 mutable IMagneticFieldSvc* m_pmgnIMF;
00152
00153
00154 };
00155
00156
00157
00158 #ifdef TRKRECO_NO_INLINE
00159 #define inline
00160 #else
00161 #undef inline
00162 #define THELIXFITTER_INLINE_DEFINE_HERE
00163 #endif
00164
00165 #ifdef THELIXFITTER_INLINE_DEFINE_HERE
00166
00167 inline
00168 bool
00169 THelixFitter::fit2D(void) const {
00170 return _fit2D;
00171 }
00172
00173 inline
00174 bool
00175 THelixFitter::fit2D(bool a) {
00176 return _fit2D = a;
00177 }
00178
00179 inline
00180 bool
00181 THelixFitter::sag(void) const {
00182 return _sag;
00183 }
00184
00185 inline
00186 bool
00187 THelixFitter::sag(bool a) {
00188 return _sag = a;
00189 }
00190
00191 inline
00192 bool
00193 THelixFitter::propagation(void) const {
00194 return (bool) _propagation;
00195 }
00196
00197 inline
00198 bool
00199 THelixFitter::propagation(bool a) {
00200 if (a) _propagation = 1;
00201 else _propagation = 0;
00202 return propagation();
00203 }
00204
00205 inline
00206 bool
00207 THelixFitter::tof(void) const {
00208 return _tof;
00209 }
00210
00211 inline
00212 bool
00213 THelixFitter::tof(bool a) {
00214 return _tof = a;
00215 }
00216
00217 inline
00218 bool
00219 THelixFitter::tanl(void) const {
00220 return _tanl;
00221 }
00222
00223 inline
00224 bool
00225 THelixFitter::tanl(bool a) {
00226 return _tanl = a;
00227 }
00228
00229 inline
00230 int
00231 THelixFitter::fit(TTrackBase & a) const {
00232 if (! _freeT0) return main(a, 0.);
00233 else {
00234 float tev = 0.;
00235 float tevError;
00236 return main(a, tev, tevError);
00237 }
00238 }
00239
00240 inline
00241 int
00242 THelixFitter::fit(TTrackBase & a,
00243 double *pre_chi2, double *fitted_chi2) const {
00244 if (! _freeT0) return main(a, 0., pre_chi2, fitted_chi2);
00245 else {
00246 float tev = 0.;
00247 float tevError;
00248 return main(a, tev, tevError, pre_chi2, fitted_chi2);
00249 }
00250 }
00251
00252 inline
00253 int
00254 THelixFitter::fit(TTrackBase & a, float t0Offset,
00255 double *pre_chi2, double *fitted_chi2) const {
00256 a._fitted = false;
00257 if (! _freeT0) return main(a, t0Offset, pre_chi2, fitted_chi2);
00258 else {
00259 float tev = t0Offset;
00260 float tevError;
00261 return main(a, tev, tevError, pre_chi2, fitted_chi2);
00262 }
00263 }
00264
00265 inline
00266 int
00267 THelixFitter::fit(TTrackBase & a, float & tev, float & tev_err,
00268 double *pre_chi2, double *fitted_chi2) const {
00269 a._fitted = false;
00270 return main(a, tev, tev_err, pre_chi2, fitted_chi2);
00271 }
00272
00273 inline
00274 bool
00275 THelixFitter::freeT0(void) const {
00276 return _freeT0;
00277 }
00278
00279 inline
00280 bool
00281 THelixFitter::freeT0(bool a) {
00282 return _freeT0 = a;
00283 }
00284
00285 inline
00286 unsigned
00287 THelixFitter::corrections(void) const {
00288 return _corrections;
00289 }
00290
00291 inline
00292 unsigned
00293 THelixFitter::corrections(unsigned a) {
00294 return _corrections = a;
00295 }
00296
00297 inline
00298 double
00299 THelixFitter::preChi2(void) const {
00300 return _pre_chi2;
00301 }
00302
00303 inline
00304 double
00305 THelixFitter::chi2(void) const {
00306 return _fitted_chi2;
00307 }
00308
00309 #endif
00310
00311 #undef inline
00312
00313 #endif