CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TKinFitter.h
Go to the documentation of this file.
1 #ifndef TKinFitter_h
2 #define TKinFitter_h
3 
4 #include <vector>
5 #include "TMatrixD.h"
6 #include "TNamed.h"
7 
8 class TAbsFitParticle;
10 class TH1D;
11 
12 class TKinFitter : public TNamed {
13 
14 public :
15 
16  TKinFitter();
17  TKinFitter(const TString &name, const TString &title);
18  ~TKinFitter();
19  void reset();
20  void resetStatus();
21 
22  Int_t fit();
23 
24  void addMeasParticle( TAbsFitParticle* particle );
26  TAbsFitParticle* p4 = 0, TAbsFitParticle* p5 = 0, TAbsFitParticle* p6 = 0,
27  TAbsFitParticle* p7 = 0, TAbsFitParticle* p8 = 0, TAbsFitParticle* p9 = 0);
28  void addUnmeasParticle( TAbsFitParticle* particle );
30  TAbsFitParticle* p4 = 0, TAbsFitParticle* p5 = 0, TAbsFitParticle* p6 = 0,
31  TAbsFitParticle* p7 = 0, TAbsFitParticle* p8 = 0, TAbsFitParticle* p9 = 0);
32  void addConstraint( TAbsFitConstraint* constraint );
33 
34  Int_t getNDF() { return (_constraints.size() - _nParA); }
35  Int_t getNParA() { return _nParA; }
36  Int_t getNParB() { return _nParB; }
37  void setMaxNbIter( Int_t maxNbIter ) { _maxNbIter = maxNbIter; }
38  Int_t getMaxNumberIter() { return _maxNbIter; }
39  Int_t getNbIter() { return _nbIter; }
40  Int_t getStatus() { return _status; }
41  void setMaxDeltaS( Double_t maxDeltaS ) { _maxDeltaS = TMath::Abs( maxDeltaS ); }
42  Double_t getMaxDeltaS() { return _maxDeltaS; }
43  void setMaxF( Double_t maxF ) { _maxF = TMath::Abs( maxF ); }
44  Double_t getMaxF() { return _maxF; }
45  const TMatrixD* getCovMatrix() { return &_V; }
46  void setCovMatrix( TMatrixD &V );
47  const TMatrixD* getCovMatrixFit() { return &_yaVFit; }
48  Double_t getS();
49  Double_t getF();
50  void setVerbosity( Int_t verbosity = 1 );
51  Int_t getVerbosity( ) { return _verbosity; }
52 
53  Int_t nbMeasParticles() { return _measParticles.size(); }
55  Int_t nbUnmeasParticles() { return _unmeasParticles.size(); }
57  Int_t nbConstraints() { return _constraints.size(); }
58 
59  void print();
60 
61 protected:
62 
63  Bool_t calcA();
64  Bool_t calcB();
65  Bool_t calcVA();
66  Bool_t calcVB();
67  Bool_t calcC();
68 
69  Bool_t calcC11();
70  Bool_t calcC21();
71  Bool_t calcC22();
72  Bool_t calcC31();
73  Bool_t calcC32();
74  Bool_t calcC33();
75 
76  Bool_t calcDeltaA();
77  Bool_t calcDeltaY();
78  Bool_t calcLambda();
79 
80  Bool_t calcV();
81  Bool_t calcVFit();
82 
83  Bool_t applyDeltaA();
84  Bool_t applyDeltaY();
85  void applyVFit();
86 
87  Bool_t converged(Double_t F, Double_t prevS, Double_t currS);
88 
89  TString getStatusString();
90  void countMeasParams();
91  void countUnmeasParams();
92  void resetParams();
93 
94  void printMatrix(const TMatrixD &matrix, const TString name = "");
95 
96 private :
97 
98  Int_t _maxNbIter; // Maximum number of iterations
99  Double_t _maxDeltaS; // Convergence criterium for deltaS
100  Double_t _maxF; // Convergence criterium for F
101  Int_t _verbosity; // Verbosty of the fitter 0: quiet, 1: print result, 2: print iterations, 3: print also matrices
102 
103  TMatrixD _A; // Jacobi Matrix of unmeasured parameters
104  TMatrixD _AT; // Transposed Jacobi Matrix of unmeasured parameters
105  TMatrixD _B; // Jacobi Matrix of measured parameters
106  TMatrixD _BT; // Transposed Jacobi Matrix of measured parameters
107  TMatrixD _V; // Covariance matrix
108  TMatrixD _Vinv; // Inverse covariance matrix
109  TMatrixD _VB; // VB = ( B*V*BT )^(-1)
110  TMatrixD _VBinv; // VBinv = ( B*V*BT )
111  TMatrixD _VA; // VA = ( AT*VB*A )
112  TMatrixD _VAinv; // VAinv = ( AT*VB*A )^(-1)
113  TMatrixD _c; // Vector c = A*delta(a*) + B*delta(y*) - f*
114 
115  TMatrixD _C11; // Matrix C11
116  TMatrixD _C11T; // Matrix C11T
117  TMatrixD _C21; // Matrix C21
118  TMatrixD _C21T; // Matrix C21T
119  TMatrixD _C22; // Matrix C22
120  TMatrixD _C22T; // Matrix C22T
121  TMatrixD _C31; // Matrix C31
122  TMatrixD _C31T; // Matrix C31T
123  TMatrixD _C32; // Matrix C32
124  TMatrixD _C32T; // Matrix C32T
125  TMatrixD _C33; // Matrix C33
126  TMatrixD _C33T; // Matrix C33T
127 
128  TMatrixD _deltaA; // The correction vector deltaA for unmeasured particles of the current iteration
129  TMatrixD _deltaY; // The correction vector deltaY for measured particles of the current iteration
130  TMatrixD _deltaAstar; // The correction vector deltaA for unmeasured particles of the previous iteration
131  TMatrixD _deltaYstar; // The correction vector deltaY for measured particles of the previous iteration
132  TMatrixD _lambda; // The column vector of Lagrange multiplicators (likelihood L = S + 2 sum_i lambda_i * f_i)
133  TMatrixD _lambdaT; // The row vector of Lagrange multiplicators (likelihood L = S + 2 sum_i lambda_i * f_i)
134 
135  TMatrixD _lambdaVFit; // Covariance matrix of lambda after the fit
136  TMatrixD _yaVFit; // Combined covariance matrix of y and a after the fit
137 
138  Int_t _nParA; // Number of unmeasured parameters
139  Int_t _nParB; // Number of measured parameters
140 
141  std::vector<TAbsFitConstraint*> _constraints; // vector with constraints
142  std::vector<TAbsFitParticle*> _measParticles; // vector with measured particles
143  std::vector<TAbsFitParticle*> _unmeasParticles; // vector with unmeasured particles
144 
145  Int_t _status; // Status of the last fit;_
146  Int_t _nbIter; // number of iteration performed in the fit
147 
148 };
149 
150 #endif
TMatrixD _deltaY
Definition: TKinFitter.h:129
Int_t getNbIter()
Definition: TKinFitter.h:39
TMatrixD _C11
Definition: TKinFitter.h:115
Double_t getMaxDeltaS()
Definition: TKinFitter.h:42
Bool_t calcC33()
Definition: TKinFitter.cc:774
Bool_t calcV()
Definition: TKinFitter.cc:467
void setMaxF(Double_t maxF)
Definition: TKinFitter.h:43
void countMeasParams()
Definition: TKinFitter.cc:186
Bool_t converged(Double_t F, Double_t prevS, Double_t currS)
Definition: TKinFitter.cc:1126
Bool_t calcVFit()
Definition: TKinFitter.cc:944
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:142
Bool_t calcVB()
Definition: TKinFitter.cc:626
Bool_t calcC11()
Definition: TKinFitter.cc:668
Int_t fit()
Definition: TKinFitter.cc:309
void setMaxDeltaS(Double_t maxDeltaS)
Definition: TKinFitter.h:41
TString getStatusString()
Definition: TKinFitter.cc:1142
Int_t getMaxNumberIter()
Definition: TKinFitter.h:38
Int_t _nParA
Definition: TKinFitter.h:138
TMatrixD _C33T
Definition: TKinFitter.h:126
TMatrixD _lambda
Definition: TKinFitter.h:132
void addMeasParticles(TAbsFitParticle *p1, TAbsFitParticle *p2=0, TAbsFitParticle *p3=0, TAbsFitParticle *p4=0, TAbsFitParticle *p5=0, TAbsFitParticle *p6=0, TAbsFitParticle *p7=0, TAbsFitParticle *p8=0, TAbsFitParticle *p9=0)
Definition: TKinFitter.cc:224
TMatrixD _C32T
Definition: TKinFitter.h:124
Bool_t calcC21()
Definition: TKinFitter.cc:698
TMatrixD _V
Definition: TKinFitter.h:107
void reset()
Definition: TKinFitter.cc:105
TMatrixD _C21T
Definition: TKinFitter.h:118
TMatrixD _VB
Definition: TKinFitter.h:109
TMatrixD _C31T
Definition: TKinFitter.h:122
const TAbsFitParticle * getUnmeasParticle(Int_t index)
Definition: TKinFitter.h:56
void resetParams()
Definition: TKinFitter.cc:164
TMatrixD _yaVFit
Definition: TKinFitter.h:136
TMatrixD _C32
Definition: TKinFitter.h:123
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:143
Double_t getMaxF()
Definition: TKinFitter.h:44
TMatrixD _VA
Definition: TKinFitter.h:111
Double_t getS()
Definition: TKinFitter.cc:1108
void addUnmeasParticles(TAbsFitParticle *p1, TAbsFitParticle *p2=0, TAbsFitParticle *p3=0, TAbsFitParticle *p4=0, TAbsFitParticle *p5=0, TAbsFitParticle *p6=0, TAbsFitParticle *p7=0, TAbsFitParticle *p8=0, TAbsFitParticle *p9=0)
Definition: TKinFitter.cc:260
TMatrixD _deltaA
Definition: TKinFitter.h:128
void applyVFit()
Definition: TKinFitter.cc:991
Bool_t applyDeltaY()
Definition: TKinFitter.cc:1059
Int_t _maxNbIter
Definition: TKinFitter.h:98
Bool_t calcB()
Definition: TKinFitter.cc:558
void print()
Definition: TKinFitter.cc:1174
TMatrixD _C33
Definition: TKinFitter.h:125
TMatrixD _deltaAstar
Definition: TKinFitter.h:130
Bool_t calcDeltaY()
Definition: TKinFitter.cc:909
double p4[4]
Definition: TauolaWrapper.h:92
void addConstraint(TAbsFitConstraint *constraint)
Definition: TKinFitter.cc:281
Bool_t calcA()
Definition: TKinFitter.cc:519
void printMatrix(const TMatrixD &matrix, const TString name="")
Definition: TKinFitter.cc:1256
Bool_t calcLambda()
Definition: TKinFitter.cc:928
Bool_t calcC31()
Definition: TKinFitter.cc:731
Int_t nbUnmeasParticles()
Definition: TKinFitter.h:55
void countUnmeasParams()
Definition: TKinFitter.cc:199
Int_t getVerbosity()
Definition: TKinFitter.h:51
Int_t getStatus()
Definition: TKinFitter.h:40
Int_t _status
Definition: TKinFitter.h:145
TMatrixD _B
Definition: TKinFitter.h:105
const TAbsFitParticle * getMeasParticle(Int_t index)
Definition: TKinFitter.h:54
TMatrixD _C22T
Definition: TKinFitter.h:120
void addUnmeasParticle(TAbsFitParticle *particle)
Definition: TKinFitter.cc:245
TMatrixD _VAinv
Definition: TKinFitter.h:112
Int_t getNDF()
Definition: TKinFitter.h:34
void addMeasParticle(TAbsFitParticle *particle)
Definition: TKinFitter.cc:209
TMatrixD _C22
Definition: TKinFitter.h:119
double p2[4]
Definition: TauolaWrapper.h:90
TMatrixD _c
Definition: TKinFitter.h:113
Double_t _maxDeltaS
Definition: TKinFitter.h:99
const TMatrixD * getCovMatrixFit()
Definition: TKinFitter.h:47
void setCovMatrix(TMatrixD &V)
Definition: TKinFitter.cc:454
TMatrixD _A
Definition: TKinFitter.h:103
const int verbosity
TMatrixD _lambdaT
Definition: TKinFitter.h:133
void setVerbosity(Int_t verbosity=1)
Definition: TKinFitter.cc:294
const TMatrixD * getCovMatrix()
Definition: TKinFitter.h:45
Bool_t calcVA()
Definition: TKinFitter.cc:647
TMatrixD _lambdaVFit
Definition: TKinFitter.h:135
TMatrixD _C31
Definition: TKinFitter.h:121
void resetStatus()
Definition: TKinFitter.cc:156
Bool_t applyDeltaA()
Definition: TKinFitter.cc:1038
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:141
TMatrixD _deltaYstar
Definition: TKinFitter.h:131
Int_t getNParB()
Definition: TKinFitter.h:36
TMatrixD _BT
Definition: TKinFitter.h:106
TMatrixD _AT
Definition: TKinFitter.h:104
void setMaxNbIter(Int_t maxNbIter)
Definition: TKinFitter.h:37
Int_t nbConstraints()
Definition: TKinFitter.h:57
Int_t _nbIter
Definition: TKinFitter.h:146
double p1[4]
Definition: TauolaWrapper.h:89
Bool_t calcC32()
Definition: TKinFitter.cc:758
Int_t _verbosity
Definition: TKinFitter.h:101
Double_t getF()
Definition: TKinFitter.cc:1095
TMatrixD _VBinv
Definition: TKinFitter.h:110
Bool_t calcC22()
Definition: TKinFitter.cc:717
Bool_t calcC()
Definition: TKinFitter.cc:796
Int_t _nParB
Definition: TKinFitter.h:139
TMatrixD _C11T
Definition: TKinFitter.h:116
Int_t nbMeasParticles()
Definition: TKinFitter.h:53
TMatrixD _C21
Definition: TKinFitter.h:117
TMatrixD _Vinv
Definition: TKinFitter.h:108
Bool_t calcDeltaA()
Definition: TKinFitter.cc:890
Int_t getNParA()
Definition: TKinFitter.h:35
Double_t _maxF
Definition: TKinFitter.h:100
double p3[4]
Definition: TauolaWrapper.h:91