KiTrackMarlin  1.9.0
Fitter.h
1 #ifndef Fitter_h
2 #define Fitter_h
3 
4 #include "MarlinTrk/Factory.h"
5 #include "MarlinTrk/IMarlinTrkSystem.h"
6 #include "MarlinTrk/IMarlinTrack.h"
7 #include "EVENT/Track.h"
8 #include "lcio.h"
9 
10 #include "Math/ProbFunc.h"
11 
12 
13 using namespace lcio;
14 
15 
16 
17 class FitterException : public std::exception {
18 
19 
20 protected:
21  std::string message ;
22 
23  FitterException(){ /*no_op*/ ; }
24 
25 public:
26  virtual ~FitterException() throw() { /*no_op*/; }
27 
28  FitterException( const std::string& text ){
29  message = "FitterException: " + text ;
30  }
31 
32  virtual const char* what() const throw() { return message.c_str() ; }
33 
34 };
35 
36 
37 
41 
42 
43 
44 public:
45 
46  const TrackState* getTrackState() const {return _trackState; }
47  double getChi2() const {return _chi2;}
48  int getNdf() const {return _Ndf;}
49 
50  TrackStatePlus( const TrackState* trackState, double chi2, int Ndf ):
51  _trackState( trackState ), _chi2( chi2 ), _Ndf( Ndf ){}
52 
53 
54 
55 private:
56 
57  const TrackState* _trackState;
58  double _chi2;
59  int _Ndf;
60 
61 
62 };
63 
64 
68 class Fitter{
69 
70 
71 public:
72 
73  Fitter( Track* track , MarlinTrk::IMarlinTrkSystem* trkSystem )throw( FitterException );
74  Fitter( std::vector < TrackerHit* > trackerHits, MarlinTrk::IMarlinTrkSystem* trkSystem )throw( FitterException );
75  Fitter( Track* track , MarlinTrk::IMarlinTrkSystem* trkSystem, int VXDFlag )throw( FitterException );
76 
77 
78  double getChi2Prob( int trackStateLocation ) throw( FitterException );
79  double getChi2( int trackStateLocation ) throw( FitterException );
80  int getNdf( int trackStateLocation ) throw( FitterException );
81 
82  //TODO: maybe add methods for custom points (location: TrackState::AtOther) In that case, the point would have to
83  // be passed as well. (or only the point is passed)
84 
85  const TrackState* getTrackState( int trackStateLocation ) throw( FitterException );
86 
87  ~Fitter(){
88 
89  for( unsigned i=0; i<_trackStatesPlus.size(); i++ ){
90 
91  delete _trackStatesPlus[i]->getTrackState();
92  delete _trackStatesPlus[i];
93 
94  }
95  _trackStatesPlus.clear();
96 
97  delete _marlinTrk;
98 
99  }
100 
101 private:
102 
103  void init_BField();
104 
105  const TrackStatePlus* getTrackStatePlus( int trackStateLocation ) throw( FitterException );
106 
107  void fit()throw( FitterException );
108 
109  void fitVXD()throw( FitterException );
110 
111  static float _bField;
112 
113 
114  std::vector< TrackerHit* > _trackerHits;
115 
117  std::vector< const TrackStatePlus* > _trackStatesPlus;
118 
119  MarlinTrk::IMarlinTrkSystem* _trkSystem;
120 
121  MarlinTrk::IMarlinTrack* _marlinTrk;
122 
123  // No copy constructor or assignment needed so far. so private for safety
124  // If they are needed, they need to be implemented in a clean way first!
125  Fitter( const Fitter& f ){};
126  Fitter& operator= ( Fitter const& f ){return *this;}
127 
128 };
129 
130 #endif
Definition: Fitter.h:17
A class to make it quick to fit a track or hits and get back the chi2, Ndf and chi2prob values and al...
Definition: Fitter.h:68
A class to store additional information together with a TrackState, namely the chi2 value and Ndf...
Definition: Fitter.h:40