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