CMS 3D CMS Logo

TKinFitter.h

Go to the documentation of this file.
00001 
00002 using namespace std;
00003 
00004 #ifndef TKinFitter_h
00005 #define TKinFitter_h
00006 
00007 
00008 #include <vector>
00009 #include "TMatrixD.h"
00010 #include "TNamed.h"
00011 
00012 class TAbsFitParticle;
00013 class TAbsFitConstraint;
00014 class TH1D;
00015 
00016 class TKinFitter : public TNamed {
00017 
00018 public :
00019 
00020   TKinFitter();
00021   TKinFitter(const TString &name, const TString &title);  
00022   ~TKinFitter();
00023   void reset();         
00024   void resetStatus();   
00025 
00026   Int_t fit();
00027 
00028   void addMeasParticle( TAbsFitParticle* particle );
00029   void addMeasParticles( TAbsFitParticle* p1, TAbsFitParticle* p2 = 0, TAbsFitParticle* p3 = 0, 
00030                          TAbsFitParticle* p4 = 0, TAbsFitParticle* p5 = 0, TAbsFitParticle* p6 = 0,
00031                          TAbsFitParticle* p7 = 0, TAbsFitParticle* p8 = 0, TAbsFitParticle* p9 = 0);
00032   void addUnmeasParticle( TAbsFitParticle* particle );
00033   void addUnmeasParticles( TAbsFitParticle* p1, TAbsFitParticle* p2 = 0, TAbsFitParticle* p3 = 0, 
00034                            TAbsFitParticle* p4 = 0, TAbsFitParticle* p5 = 0, TAbsFitParticle* p6 = 0,
00035                            TAbsFitParticle* p7 = 0, TAbsFitParticle* p8 = 0, TAbsFitParticle* p9 = 0);
00036   void addConstraint( TAbsFitConstraint* constraint );
00037 
00038   Int_t getNDF() { return  (_constraints.size() - _nParA); }
00039   Int_t getNParA() { return _nParA; }
00040   Int_t getNParB() { return _nParB; }
00041   void setMaxNbIter( Int_t maxNbIter ) { _maxNbIter = maxNbIter; }
00042   Int_t getMaxNumberIter() { return _maxNbIter; }
00043   Int_t getNbIter() { return _nbIter; }
00044   Int_t getStatus() { return _status; }
00045   void setMaxDeltaS( Double_t maxDeltaS ) { _maxDeltaS = TMath::Abs( maxDeltaS ); }
00046   Double_t getMaxDeltaS() { return _maxDeltaS; }
00047   void setMaxF( Double_t maxF ) { _maxF = TMath::Abs( maxF ); }
00048   Double_t getMaxF() { return _maxF; }
00049   const TMatrixD* getCovMatrix() { return &_V; }
00050   void setCovMatrix( TMatrixD &V );
00051   const TMatrixD* getCovMatrixFit() { return &_yaVFit; }
00052   Double_t getS();
00053   Double_t getF();
00054   void setVerbosity( Int_t verbosity = 1 );
00055   Int_t getVerbosity( ) { return _verbosity; }
00056 
00057   Int_t nbMeasParticles() { return _measParticles.size(); }
00058   const TAbsFitParticle* getMeasParticle( Int_t index ) { return _measParticles[index]; }
00059   Int_t nbUnmeasParticles() { return _unmeasParticles.size(); }
00060   const TAbsFitParticle* getUnmeasParticle( Int_t index ) { return _unmeasParticles[index]; }
00061 
00062   void print();
00063 
00064 protected:
00065 
00066   Bool_t calcA();
00067   Bool_t calcB();
00068   Bool_t calcVA();
00069   Bool_t calcVB();
00070   Bool_t calcC();
00071 
00072   Bool_t calcC11();
00073   Bool_t calcC21();
00074   Bool_t calcC22();
00075   Bool_t calcC31();
00076   Bool_t calcC32();
00077   Bool_t calcC33();
00078 
00079   Bool_t calcDeltaA();
00080   Bool_t calcDeltaY();
00081   Bool_t calcLambda();
00082 
00083   Bool_t calcV();
00084   Bool_t calcVFit();
00085 
00086   Bool_t applyDeltaA();
00087   Bool_t applyDeltaY();
00088   void applyVFit();
00089 
00090   Bool_t converged(Double_t F, Double_t prevS, Double_t currS);
00091 
00092   TString getStatusString();
00093   void countMeasParams();
00094   void countUnmeasParams();
00095   void resetParams();
00096 
00097   void printMatrix(const TMatrixD &matrix, const TString name = "");
00098 
00099 private :
00100 
00101   Int_t _maxNbIter;       // Maximum number of iterations
00102   Double_t _maxDeltaS;    // Convergence criterium for deltaS
00103   Double_t _maxF;       // Convergence criterium for F
00104   Int_t _verbosity;       // Verbosty of the fitter 0: quiet, 1: print result, 2: print iterations, 3: print also matrices
00105 
00106   TMatrixD _A;      // Jacobi Matrix of unmeasured parameters
00107   TMatrixD _AT;     // Transposed Jacobi Matrix of unmeasured parameters
00108   TMatrixD _B;      // Jacobi Matrix of measured parameters
00109   TMatrixD _BT;     // Transposed Jacobi Matrix of measured parameters
00110   TMatrixD _V;      // Covariance matrix
00111   TMatrixD _Vinv;   // Inverse covariance matrix
00112   TMatrixD _VB;     // VB    = ( B*V*BT )^(-1)
00113   TMatrixD _VBinv;  // VBinv = ( B*V*BT )
00114   TMatrixD _VA;     // VA    = ( AT*VB*A )
00115   TMatrixD _VAinv;  // VAinv = ( AT*VB*A )^(-1)
00116   TMatrixD _c;      // Vector c = A*delta(a*) + B*delta(y*) - f*
00117 
00118   TMatrixD _C11;     // Matrix C11
00119   TMatrixD _C11T;    // Matrix C11T
00120   TMatrixD _C21;     // Matrix C21
00121   TMatrixD _C21T;    // Matrix C21T
00122   TMatrixD _C22;     // Matrix C22
00123   TMatrixD _C22T;    // Matrix C22T
00124   TMatrixD _C31;     // Matrix C31
00125   TMatrixD _C31T;    // Matrix C31T
00126   TMatrixD _C32;     // Matrix C32
00127   TMatrixD _C32T;    // Matrix C32T
00128   TMatrixD _C33;     // Matrix C33
00129   TMatrixD _C33T;    // Matrix C33T
00130 
00131   TMatrixD _deltaA;  // The correction vector deltaA for unmeasured particles of the last iteration
00132   TMatrixD _deltaY;  // The correction vector deltaY for measured particles of the last iteration
00133   TMatrixD _lambda;  // The column vector of Lagrange multiplicators (likelihood L = S + 2 sum_i lambda_i * f_i)
00134   TMatrixD _lambdaT; // The row vector of Lagrange multiplicators (likelihood L = S + 2 sum_i lambda_i * f_i)
00135 
00136   TMatrixD _lambdaVFit;   // Covariance matrix of lambda after the fit
00137   TMatrixD _yaVFit;       // Combined covariance matrix of y and a after the fit
00138 
00139   Int_t _nParA;     // Number of unmeasured parameters
00140   Int_t _nParB;     // Number of measured parameters
00141 
00142   vector<TAbsFitConstraint*> _constraints;    // vector with constraints
00143   vector<TAbsFitParticle*> _measParticles;    // vector with measured particles
00144   vector<TAbsFitParticle*> _unmeasParticles;  // vector with unmeasured particles
00145 
00146   Int_t _status;        // Status of the last fit;_
00147   Int_t _nbIter;        // number of iteration performed in the fit
00148 
00149   ClassDef(TKinFitter, 1) // Class to perform kinematic fit with non-linear constraints
00150 };
00151 
00152 #endif

Generated on Tue Jun 9 17:41:15 2009 for CMSSW by  doxygen 1.5.4