File indexing completed on 2024-04-06 12:23:35
0001 #ifndef TKinFitter_h
0002 #define TKinFitter_h
0003
0004 #include <vector>
0005 #include "TMatrixD.h"
0006 #include "TNamed.h"
0007 #include "PhysicsTools/KinFitter/interface/TAbsFitParticle.h"
0008
0009 class TAbsFitConstraint;
0010 class TH1D;
0011 class TLorentzVector;
0012
0013 class TKinFitter : public TNamed {
0014 public:
0015 TKinFitter();
0016 TKinFitter(const TString& name, const TString& title);
0017 ~TKinFitter() override;
0018 void reset();
0019 void resetStatus();
0020
0021 Int_t fit();
0022
0023 void addMeasParticle(TAbsFitParticle* particle);
0024 void addMeasParticles(TAbsFitParticle* p1,
0025 TAbsFitParticle* p2 = nullptr,
0026 TAbsFitParticle* p3 = nullptr,
0027 TAbsFitParticle* p4 = nullptr,
0028 TAbsFitParticle* p5 = nullptr,
0029 TAbsFitParticle* p6 = nullptr,
0030 TAbsFitParticle* p7 = nullptr,
0031 TAbsFitParticle* p8 = nullptr,
0032 TAbsFitParticle* p9 = nullptr);
0033 void addUnmeasParticle(TAbsFitParticle* particle);
0034 void addUnmeasParticles(TAbsFitParticle* p1,
0035 TAbsFitParticle* p2 = nullptr,
0036 TAbsFitParticle* p3 = nullptr,
0037 TAbsFitParticle* p4 = nullptr,
0038 TAbsFitParticle* p5 = nullptr,
0039 TAbsFitParticle* p6 = nullptr,
0040 TAbsFitParticle* p7 = nullptr,
0041 TAbsFitParticle* p8 = nullptr,
0042 TAbsFitParticle* p9 = nullptr);
0043 void addConstraint(TAbsFitConstraint* constraint);
0044
0045 Int_t getNDF() { return (_constraints.size() - _nParA); }
0046 Int_t getNParA() { return _nParA; }
0047 Int_t getNParB() { return _nParB; }
0048 void setMaxNbIter(Int_t maxNbIter) { _maxNbIter = maxNbIter; }
0049 Int_t getMaxNumberIter() { return _maxNbIter; }
0050 Int_t getNbIter() { return _nbIter; }
0051 Int_t getStatus() { return _status; }
0052 void setMaxDeltaS(Double_t maxDeltaS) { _maxDeltaS = TMath::Abs(maxDeltaS); }
0053 Double_t getMaxDeltaS() { return _maxDeltaS; }
0054 void setMaxF(Double_t maxF) { _maxF = TMath::Abs(maxF); }
0055 Double_t getMaxF() { return _maxF; }
0056 const TMatrixD* getCovMatrix() { return &_V; }
0057 void setCovMatrix(TMatrixD& V);
0058 const TMatrixD* getCovMatrixFit() { return &_yaVFit; }
0059 Double_t getS();
0060 Double_t getF();
0061 void setVerbosity(Int_t verbosity = 1);
0062 Int_t getVerbosity() { return _verbosity; }
0063
0064 Int_t nbMeasParticles() { return _measParticles.size(); }
0065 const TAbsFitParticle* getMeasParticle(Int_t index) { return _measParticles[index]; }
0066 const TLorentzVector* get4Vec(Int_t index) { return (_measParticles[index])->getCurr4Vec(); }
0067
0068 Int_t nbUnmeasParticles() { return _unmeasParticles.size(); }
0069 const TAbsFitParticle* getUnmeasParticle(Int_t index) { return _unmeasParticles[index]; }
0070 Int_t nbConstraints() { return _constraints.size(); }
0071
0072 void print();
0073
0074 protected:
0075 Bool_t calcA();
0076 Bool_t calcB();
0077 Bool_t calcVA();
0078 Bool_t calcVB();
0079 Bool_t calcC();
0080
0081 Bool_t calcC11();
0082 Bool_t calcC21();
0083 Bool_t calcC22();
0084 Bool_t calcC31();
0085 Bool_t calcC32();
0086 Bool_t calcC33();
0087
0088 Bool_t calcDeltaA();
0089 Bool_t calcDeltaY();
0090 Bool_t calcLambda();
0091
0092 Bool_t calcV();
0093 Bool_t calcVFit();
0094
0095 Bool_t applyDeltaA();
0096 Bool_t applyDeltaY();
0097 void applyVFit();
0098
0099 Bool_t converged(Double_t F, Double_t prevS, Double_t currS);
0100
0101 TString getStatusString();
0102 void countMeasParams();
0103 void countUnmeasParams();
0104 void resetParams();
0105
0106 void printMatrix(const TMatrixD& matrix, const TString& name = "");
0107
0108 private:
0109 Int_t _maxNbIter;
0110 Double_t _maxDeltaS;
0111 Double_t _maxF;
0112 Int_t _verbosity;
0113
0114 TMatrixD _A;
0115 TMatrixD _AT;
0116 TMatrixD _B;
0117 TMatrixD _BT;
0118 TMatrixD _V;
0119 TMatrixD _Vinv;
0120 TMatrixD _VB;
0121 TMatrixD _VBinv;
0122 TMatrixD _VA;
0123 TMatrixD _VAinv;
0124 TMatrixD _c;
0125
0126 TMatrixD _C11;
0127 TMatrixD _C11T;
0128 TMatrixD _C21;
0129 TMatrixD _C21T;
0130 TMatrixD _C22;
0131 TMatrixD _C22T;
0132 TMatrixD _C31;
0133 TMatrixD _C31T;
0134 TMatrixD _C32;
0135 TMatrixD _C32T;
0136 TMatrixD _C33;
0137 TMatrixD _C33T;
0138
0139 TMatrixD _deltaA;
0140 TMatrixD _deltaY;
0141 TMatrixD _deltaAstar;
0142 TMatrixD _deltaYstar;
0143 TMatrixD _lambda;
0144 TMatrixD _lambdaT;
0145
0146 TMatrixD _lambdaVFit;
0147 TMatrixD _yaVFit;
0148
0149 Int_t _nParA;
0150 Int_t _nParB;
0151
0152 std::vector<TAbsFitConstraint*> _constraints;
0153 std::vector<TAbsFitParticle*> _measParticles;
0154 std::vector<TAbsFitParticle*> _unmeasParticles;
0155
0156 Int_t _status;
0157 Int_t _nbIter;
0158
0159 ClassDefOverride(TKinFitter, 0)
0160 };
0161
0162 #endif