CMS 3D CMS Logo

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 public:
15  TKinFitter();
16  TKinFitter(const TString& name, const TString& title);
17  ~TKinFitter() override;
18  void reset();
19  void resetStatus();
20 
21  Int_t fit();
22 
23  void addMeasParticle(TAbsFitParticle* particle);
25  TAbsFitParticle* p2 = nullptr,
26  TAbsFitParticle* p3 = nullptr,
27  TAbsFitParticle* p4 = nullptr,
28  TAbsFitParticle* p5 = nullptr,
29  TAbsFitParticle* p6 = nullptr,
30  TAbsFitParticle* p7 = nullptr,
31  TAbsFitParticle* p8 = nullptr,
32  TAbsFitParticle* p9 = nullptr);
33  void addUnmeasParticle(TAbsFitParticle* particle);
35  TAbsFitParticle* p2 = nullptr,
36  TAbsFitParticle* p3 = nullptr,
37  TAbsFitParticle* p4 = nullptr,
38  TAbsFitParticle* p5 = nullptr,
39  TAbsFitParticle* p6 = nullptr,
40  TAbsFitParticle* p7 = nullptr,
41  TAbsFitParticle* p8 = nullptr,
42  TAbsFitParticle* p9 = nullptr);
44 
45  Int_t getNDF() { return (_constraints.size() - _nParA); }
46  Int_t getNParA() { return _nParA; }
47  Int_t getNParB() { return _nParB; }
48  void setMaxNbIter(Int_t maxNbIter) { _maxNbIter = maxNbIter; }
49  Int_t getMaxNumberIter() { return _maxNbIter; }
50  Int_t getNbIter() { return _nbIter; }
51  Int_t getStatus() { return _status; }
53  Double_t getMaxDeltaS() { return _maxDeltaS; }
54  void setMaxF(Double_t maxF) { _maxF = TMath::Abs(maxF); }
55  Double_t getMaxF() { return _maxF; }
56  const TMatrixD* getCovMatrix() { return &_V; }
57  void setCovMatrix(TMatrixD& V);
58  const TMatrixD* getCovMatrixFit() { return &_yaVFit; }
59  Double_t getS();
60  Double_t getF();
61  void setVerbosity(Int_t verbosity = 1);
62  Int_t getVerbosity() { return _verbosity; }
63 
64  Int_t nbMeasParticles() { return _measParticles.size(); }
66  const TLorentzVector* get4Vec(Int_t index) { return (_measParticles[index])->getCurr4Vec(); }
67 
68  Int_t nbUnmeasParticles() { return _unmeasParticles.size(); }
70  Int_t nbConstraints() { return _constraints.size(); }
71 
72  void print();
73 
74 protected:
75  Bool_t calcA();
76  Bool_t calcB();
77  Bool_t calcVA();
78  Bool_t calcVB();
79  Bool_t calcC();
80 
81  Bool_t calcC11();
82  Bool_t calcC21();
83  Bool_t calcC22();
84  Bool_t calcC31();
85  Bool_t calcC32();
86  Bool_t calcC33();
87 
88  Bool_t calcDeltaA();
89  Bool_t calcDeltaY();
90  Bool_t calcLambda();
91 
92  Bool_t calcV();
93  Bool_t calcVFit();
94 
95  Bool_t applyDeltaA();
96  Bool_t applyDeltaY();
97  void applyVFit();
98 
99  Bool_t converged(Double_t F, Double_t prevS, Double_t currS);
100 
101  TString getStatusString();
102  void countMeasParams();
103  void countUnmeasParams();
104  void resetParams();
105 
106  void printMatrix(const TMatrixD& matrix, const TString& name = "");
107 
108 private:
109  Int_t _maxNbIter; // Maximum number of iterations
110  Double_t _maxDeltaS; // Convergence criterium for deltaS
111  Double_t _maxF; // Convergence criterium for F
112  Int_t _verbosity; // Verbosty of the fitter 0: quiet, 1: print result, 2: print iterations, 3: print also matrices
113 
114  TMatrixD _A; // Jacobi Matrix of unmeasured parameters
115  TMatrixD _AT; // Transposed Jacobi Matrix of unmeasured parameters
116  TMatrixD _B; // Jacobi Matrix of measured parameters
117  TMatrixD _BT; // Transposed Jacobi Matrix of measured parameters
118  TMatrixD _V; // Covariance matrix
119  TMatrixD _Vinv; // Inverse covariance matrix
120  TMatrixD _VB; // VB = ( B*V*BT )^(-1)
121  TMatrixD _VBinv; // VBinv = ( B*V*BT )
122  TMatrixD _VA; // VA = ( AT*VB*A )
123  TMatrixD _VAinv; // VAinv = ( AT*VB*A )^(-1)
124  TMatrixD _c; // Vector c = A*delta(a*) + B*delta(y*) - f*
125 
126  TMatrixD _C11; // Matrix C11
127  TMatrixD _C11T; // Matrix C11T
128  TMatrixD _C21; // Matrix C21
129  TMatrixD _C21T; // Matrix C21T
130  TMatrixD _C22; // Matrix C22
131  TMatrixD _C22T; // Matrix C22T
132  TMatrixD _C31; // Matrix C31
133  TMatrixD _C31T; // Matrix C31T
134  TMatrixD _C32; // Matrix C32
135  TMatrixD _C32T; // Matrix C32T
136  TMatrixD _C33; // Matrix C33
137  TMatrixD _C33T; // Matrix C33T
138 
139  TMatrixD _deltaA; // The correction vector deltaA for unmeasured particles of the current iteration
140  TMatrixD _deltaY; // The correction vector deltaY for measured particles of the current iteration
141  TMatrixD _deltaAstar; // The correction vector deltaA for unmeasured particles of the previous iteration
142  TMatrixD _deltaYstar; // The correction vector deltaY for measured particles of the previous iteration
143  TMatrixD _lambda; // The column vector of Lagrange multiplicators (likelihood L = S + 2 sum_i lambda_i * f_i)
144  TMatrixD _lambdaT; // The row vector of Lagrange multiplicators (likelihood L = S + 2 sum_i lambda_i * f_i)
145 
146  TMatrixD _lambdaVFit; // Covariance matrix of lambda after the fit
147  TMatrixD _yaVFit; // Combined covariance matrix of y and a after the fit
148 
149  Int_t _nParA; // Number of unmeasured parameters
150  Int_t _nParB; // Number of measured parameters
151 
152  std::vector<TAbsFitConstraint*> _constraints; // vector with constraints
153  std::vector<TAbsFitParticle*> _measParticles; // vector with measured particles
154  std::vector<TAbsFitParticle*> _unmeasParticles; // vector with unmeasured particles
155 
156  Int_t _status; // Status of the last fit;_
157  Int_t _nbIter; // number of iteration performed in the fit
158 
159  ClassDefOverride(TKinFitter, 0)
160 };
161 
162 #endif
TKinFitter::getMaxF
Double_t getMaxF()
Definition: TKinFitter.h:55
TKinFitter::_BT
TMatrixD _BT
Definition: TKinFitter.h:117
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
cms::cuda::V
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t int cudaStream_t V
Definition: HistoContainer.h:99
TKinFitter::setMaxF
void setMaxF(Double_t maxF)
Definition: TKinFitter.h:54
TKinFitter::calcVA
Bool_t calcVA()
Definition: TKinFitter.cc:638
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
TKinFitter::getNbIter
Int_t getNbIter()
Definition: TKinFitter.h:50
TKinFitter::calcVFit
Bool_t calcVFit()
Definition: TKinFitter.cc:916
TKinFitter::applyVFit
void applyVFit()
Definition: TKinFitter.cc:959
TKinFitter::getF
Double_t getF()
Definition: TKinFitter.cc:1054
makeMuonMisalignmentScenario.matrix
list matrix
Definition: makeMuonMisalignmentScenario.py:141
HLT_FULL_cff.constraint
constraint
Definition: HLT_FULL_cff.py:51999
TKinFitter::_maxF
Double_t _maxF
Definition: TKinFitter.h:111
TKinFitter::calcDeltaY
Bool_t calcDeltaY()
Definition: TKinFitter.cc:883
TKinFitter::calcC22
Bool_t calcC22()
Definition: TKinFitter.cc:705
TKinFitter::_lambda
TMatrixD _lambda
Definition: TKinFitter.h:143
TKinFitter::_C11T
TMatrixD _C11T
Definition: TKinFitter.h:127
TKinFitter::_nbIter
Int_t _nbIter
Definition: TKinFitter.h:157
TKinFitter::applyDeltaY
Bool_t applyDeltaY()
Definition: TKinFitter.cc:1023
TKinFitter::getStatusString
TString getStatusString()
Definition: TKinFitter.cc:1096
TKinFitter::_C32T
TMatrixD _C32T
Definition: TKinFitter.h:135
TKinFitter::calcC21
Bool_t calcC21()
Definition: TKinFitter.cc:687
TKinFitter::~TKinFitter
~TKinFitter() override
Definition: TKinFitter.cc:171
TKinFitter::_VBinv
TMatrixD _VBinv
Definition: TKinFitter.h:121
TKinFitter::converged
Bool_t converged(Double_t F, Double_t prevS, Double_t currS)
Definition: TKinFitter.cc:1081
TKinFitter::_C32
TMatrixD _C32
Definition: TKinFitter.h:134
TKinFitter::calcVB
Bool_t calcVB()
Definition: TKinFitter.cc:618
TKinFitter
Definition: TKinFitter.h:13
TKinFitter::addMeasParticles
void addMeasParticles(TAbsFitParticle *p1, TAbsFitParticle *p2=nullptr, TAbsFitParticle *p3=nullptr, TAbsFitParticle *p4=nullptr, TAbsFitParticle *p5=nullptr, TAbsFitParticle *p6=nullptr, TAbsFitParticle *p7=nullptr, TAbsFitParticle *p8=nullptr, TAbsFitParticle *p9=nullptr)
Definition: TKinFitter.cc:208
TKinFitter::getUnmeasParticle
const TAbsFitParticle * getUnmeasParticle(Int_t index)
Definition: TKinFitter.h:69
TKinFitter::_C31T
TMatrixD _C31T
Definition: TKinFitter.h:133
TKinFitter::getMaxNumberIter
Int_t getMaxNumberIter()
Definition: TKinFitter.h:49
TKinFitter::getCovMatrix
const TMatrixD * getCovMatrix()
Definition: TKinFitter.h:56
TKinFitter::calcV
Bool_t calcV()
Definition: TKinFitter.cc:474
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
TKinFitter::_VA
TMatrixD _VA
Definition: TKinFitter.h:122
TKinFitter::getNParA
Int_t getNParA()
Definition: TKinFitter.h:46
TKinFitter::setCovMatrix
void setCovMatrix(TMatrixD &V)
Definition: TKinFitter.cc:462
TKinFitter::_VB
TMatrixD _VB
Definition: TKinFitter.h:120
TKinFitter::fit
Int_t fit()
Definition: TKinFitter.cc:318
TKinFitter::calcC11
Bool_t calcC11()
Definition: TKinFitter.cc:658
TAbsFitConstraint
Definition: TAbsFitConstraint.h:10
Abs
T Abs(T a)
Definition: MathUtil.h:49
TKinFitter::getMeasParticle
const TAbsFitParticle * getMeasParticle(Int_t index)
Definition: TKinFitter.h:65
TKinFitter::getMaxDeltaS
Double_t getMaxDeltaS()
Definition: TKinFitter.h:53
TKinFitter::_status
Int_t _status
Definition: TKinFitter.h:156
TKinFitter::getS
Double_t getS()
Definition: TKinFitter.cc:1066
TKinFitter::printMatrix
void printMatrix(const TMatrixD &matrix, const TString &name="")
Definition: TKinFitter.cc:1205
TKinFitter::_nParA
Int_t _nParA
Definition: TKinFitter.h:149
p2
double p2[4]
Definition: TauolaWrapper.h:90
TKinFitter::_lambdaVFit
TMatrixD _lambdaVFit
Definition: TKinFitter.h:146
TKinFitter::resetParams
void resetParams()
Definition: TKinFitter.cc:154
TKinFitter::calcA
Bool_t calcA()
Definition: TKinFitter.cc:521
TKinFitter::_yaVFit
TMatrixD _yaVFit
Definition: TKinFitter.h:147
TKinFitter::_maxDeltaS
Double_t _maxDeltaS
Definition: TKinFitter.h:110
TKinFitter::calcLambda
Bool_t calcLambda()
Definition: TKinFitter.cc:901
TKinFitter::_unmeasParticles
std::vector< TAbsFitParticle * > _unmeasParticles
Definition: TKinFitter.h:154
TKinFitter::print
void print()
Definition: TKinFitter.cc:1125
TAbsFitParticle
Definition: TAbsFitParticle.h:9
TKinFitter::nbUnmeasParticles
Int_t nbUnmeasParticles()
Definition: TKinFitter.h:68
TKinFitter::applyDeltaA
Bool_t applyDeltaA()
Definition: TKinFitter.cc:1005
TKinFitter::_C21T
TMatrixD _C21T
Definition: TKinFitter.h:129
TKinFitter::calcB
Bool_t calcB()
Definition: TKinFitter.cc:556
TKinFitter::getVerbosity
Int_t getVerbosity()
Definition: TKinFitter.h:62
TKinFitter::addUnmeasParticle
void addUnmeasParticle(TAbsFitParticle *particle)
Definition: TKinFitter.cc:243
TKinFitter::calcC
Bool_t calcC()
Definition: TKinFitter.cc:781
TKinFitter::setVerbosity
void setVerbosity(Int_t verbosity=1)
Definition: TKinFitter.cc:304
TKinFitter::_nParB
Int_t _nParB
Definition: TKinFitter.h:150
TKinFitter::nbConstraints
Int_t nbConstraints()
Definition: TKinFitter.h:70
TKinFitter::_C33T
TMatrixD _C33T
Definition: TKinFitter.h:137
TKinFitter::setMaxNbIter
void setMaxNbIter(Int_t maxNbIter)
Definition: TKinFitter.h:48
TKinFitter::getStatus
Int_t getStatus()
Definition: TKinFitter.h:51
TKinFitter::_maxNbIter
Int_t _maxNbIter
Definition: TKinFitter.h:109
TKinFitter::_Vinv
TMatrixD _Vinv
Definition: TKinFitter.h:119
TKinFitter::_C21
TMatrixD _C21
Definition: TKinFitter.h:128
TKinFitter::_A
TMatrixD _A
Definition: TKinFitter.h:114
TKinFitter::getNDF
Int_t getNDF()
Definition: TKinFitter.h:45
TKinFitter::_c
TMatrixD _c
Definition: TKinFitter.h:124
TKinFitter::resetStatus
void resetStatus()
Definition: TKinFitter.cc:147
TKinFitter::_constraints
std::vector< TAbsFitConstraint * > _constraints
Definition: TKinFitter.h:152
p4
double p4[4]
Definition: TauolaWrapper.h:92
TKinFitter::get4Vec
const TLorentzVector * get4Vec(Int_t index)
Definition: TKinFitter.h:66
TKinFitter::_deltaY
TMatrixD _deltaY
Definition: TKinFitter.h:140
TKinFitter::_AT
TMatrixD _AT
Definition: TKinFitter.h:115
p1
double p1[4]
Definition: TauolaWrapper.h:89
TKinFitter::nbMeasParticles
Int_t nbMeasParticles()
Definition: TKinFitter.h:64
TKinFitter::calcC33
Bool_t calcC33()
Definition: TKinFitter.cc:759
TKinFitter::_C11
TMatrixD _C11
Definition: TKinFitter.h:126
StEvtSolProducer_cfi.maxDeltaS
maxDeltaS
Definition: StEvtSolProducer_cfi.py:25
TKinFitter::_deltaAstar
TMatrixD _deltaAstar
Definition: TKinFitter.h:141
TKinFitter::addConstraint
void addConstraint(TAbsFitConstraint *constraint)
Definition: TKinFitter.cc:292
TKinFitter::getCovMatrixFit
const TMatrixD * getCovMatrixFit()
Definition: TKinFitter.h:58
TKinFitter::TKinFitter
TKinFitter()
Definition: TKinFitter.cc:19
TKinFitter::calcC31
Bool_t calcC31()
Definition: TKinFitter.cc:718
TKinFitter::_deltaA
TMatrixD _deltaA
Definition: TKinFitter.h:139
TKinFitter::countUnmeasParams
void countUnmeasParams()
Definition: TKinFitter.cc:185
TKinFitter::_B
TMatrixD _B
Definition: TKinFitter.h:116
TKinFitter::setMaxDeltaS
void setMaxDeltaS(Double_t maxDeltaS)
Definition: TKinFitter.h:52
TKinFitter::countMeasParams
void countMeasParams()
Definition: TKinFitter.cc:173
TKinFitter::addMeasParticle
void addMeasParticle(TAbsFitParticle *particle)
Definition: TKinFitter.cc:194
TKinFitter::_C33
TMatrixD _C33
Definition: TKinFitter.h:136
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
p3
double p3[4]
Definition: TauolaWrapper.h:91
TKinFitter::_measParticles
std::vector< TAbsFitParticle * > _measParticles
Definition: TKinFitter.h:153
TAbsFitParticle.h
TKinFitter::_V
TMatrixD _V
Definition: TKinFitter.h:118
TKinFitter::_verbosity
Int_t _verbosity
Definition: TKinFitter.h:112
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
TKinFitter::calcC32
Bool_t calcC32()
Definition: TKinFitter.cc:744
TKinFitter::calcDeltaA
Bool_t calcDeltaA()
Definition: TKinFitter.cc:865
TKinFitter::addUnmeasParticles
void addUnmeasParticles(TAbsFitParticle *p1, TAbsFitParticle *p2=nullptr, TAbsFitParticle *p3=nullptr, TAbsFitParticle *p4=nullptr, TAbsFitParticle *p5=nullptr, TAbsFitParticle *p6=nullptr, TAbsFitParticle *p7=nullptr, TAbsFitParticle *p8=nullptr, TAbsFitParticle *p9=nullptr)
Definition: TKinFitter.cc:257
TKinFitter::_deltaYstar
TMatrixD _deltaYstar
Definition: TKinFitter.h:142
TKinFitter::getNParB
Int_t getNParB()
Definition: TKinFitter.h:47
TKinFitter::_VAinv
TMatrixD _VAinv
Definition: TKinFitter.h:123
TKinFitter::_C22T
TMatrixD _C22T
Definition: TKinFitter.h:131
TKinFitter::_C22
TMatrixD _C22
Definition: TKinFitter.h:130
StEvtSolProducer_cfi.maxF
maxF
Definition: StEvtSolProducer_cfi.py:26
TKinFitter::reset
void reset()
Definition: TKinFitter.cc:97
TKinFitter::_C31
TMatrixD _C31
Definition: TKinFitter.h:132
TKinFitter::_lambdaT
TMatrixD _lambdaT
Definition: TKinFitter.h:144