Belle II Software  release-05-01-25
OPALFitterGSL.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * See https://github.com/tferber/OrcaKinfit, forked from *
4  * https://github.com/iLCSoft/MarlinKinfit *
5  * *
6  * Further information about the fit engine and the user interface *
7  * provided in MarlinKinfit can be found at *
8  * https://www.desy.de/~blist/kinfit/doc/html/ *
9  * and in the LCNotes LC-TOOL-2009-001 and LC-TOOL-2009-004 available *
10  * from http://www-flc.desy.de/lcnotes/ *
11  * *
12  * Adopted by: Torben Ferber (torben.ferber@desy.de) (TF) *
13  * *
14  * This software is provided "as is" without any warranty. *
15  **************************************************************************/
16 
17 #ifndef __OPALFITTERGSL_H
18 #define __OPALFITTERGSL_H
19 
20 #include<vector>
21 #include "analysis/OrcaKinFit/BaseFitter.h"
22 
23 #include <gsl/gsl_vector.h>
24 #include <gsl/gsl_matrix.h>
25 #include <gsl/gsl_permutation.h>
26 
27 namespace Belle2 {
33  namespace OrcaKinFit {
34 
35  class BaseFitObject;
36  class BaseConstraint;
88  class OPALFitterGSL : public BaseFitter {
89  public:
90  OPALFitterGSL();
91  virtual ~OPALFitterGSL();
92  virtual double fit() override;
93 
95 
103  virtual int getError() const override;
105 
107  virtual double getProbability() const override;
109  virtual double getChi2() const override;
111  virtual int getDoF() const override;
113  virtual int getIterations() const override;
114 
116  virtual int getNcon() const;
117 
119  virtual int getNsoft() const;
120 
122  virtual int getNpar() const;
123 
125  virtual int getNunm() const;
126 
127  virtual bool initialize() override;
128 
130  virtual void setDebug(int debuglevel);
131 
132  protected:
133 
134 
135  virtual bool updateFitObjects(double etaxi[]);
136  enum {NPARMAX = 50, NCONMAX = 20, NUNMMAX = 20};
137 
138  int npar; // total number of parameters
139  int nmea; // total number of measured parameters
140  int nunm; // total number of unmeasured parameters
141  int ncon; // total number of constraints
142  int ierr; // Error status
143  int nit; // Number of iterations
144 
145  double fitprob; // fit probability
146  double chi2; // final chi2
147 
148  static void ini_gsl_permutation(gsl_permutation*& p, unsigned int size);
149  static void ini_gsl_vector(gsl_vector*& v, int unsigned size);
150  static void ini_gsl_matrix(gsl_matrix*& m, int unsigned size1, unsigned int size2);
151 
152  static void debug_print(gsl_matrix* m, const char* name);
153  static void debug_print(gsl_vector* v, const char* name);
154 
155  private:
156  gsl_vector* f;
157  gsl_vector* r;
158  gsl_matrix* Fetaxi;
159  gsl_matrix* S;
160  gsl_matrix* Sinv;
161  gsl_matrix* SinvFxi;
162  gsl_matrix* SinvFeta;
163  gsl_matrix* W1;
164  gsl_matrix* G;
165  gsl_matrix* H;
166  gsl_matrix* HU;
167  gsl_matrix* IGV;
168  gsl_matrix* V;
169  gsl_matrix* VLU;
170  gsl_matrix* Vinv;
171  gsl_matrix* Vnew;
172  gsl_matrix* Minv;
173  gsl_matrix* dxdt;
174  gsl_matrix* Vdxdt;
175  gsl_vector* dxi;
176  gsl_vector* Fxidxi;
177  gsl_vector* lambda;
178  gsl_vector* FetaTlambda;
179  gsl_vector* etaxi;
180  gsl_vector* etasv;
181  gsl_vector* y;
182  gsl_vector* y_eta;
183  gsl_vector* Vinvy_eta;
184  // gsl_matrix *Feta; //<-- DJeans: not used/needed
185  gsl_matrix* FetaV;
186 
187  gsl_permutation* permS;
188  gsl_permutation* permU;
189  gsl_permutation* permV;
190 
191  int debug;
192 
193  };
194 
195  }// end OrcaKinFit namespace
197 } // end Belle2 namespace
198 
199 #endif // __OPALFITTERGSL_H
Belle2::OrcaKinFit::OPALFitterGSL::getIterations
virtual int getIterations() const override
Get the number of iterations of the last fit.
Definition: OPALFitterGSL.cc:1015
Belle2::OrcaKinFit::OPALFitterGSL::getChi2
virtual double getChi2() const override
Get the chi**2 of the last fit.
Definition: OPALFitterGSL.cc:1013
Belle2::OrcaKinFit::OPALFitterGSL::permS
gsl_permutation * permS
Helper permutation vector.
Definition: OPALFitterGSL.h:201
Belle2::OrcaKinFit::OPALFitterGSL::getProbability
virtual double getProbability() const override
Get the fit probability of the last fit.
Definition: OPALFitterGSL.cc:1012
Belle2::OrcaKinFit::OPALFitterGSL::permU
gsl_permutation * permU
Helper permutation vector.
Definition: OPALFitterGSL.h:202
Belle2::OrcaKinFit::OPALFitterGSL::fit
virtual double fit() override
Definition: OPALFitterGSL.cc:132
Belle2::OrcaKinFit::OPALFitterGSL::getDoF
virtual int getDoF() const override
Get the number of degrees of freedom of the last fit.
Definition: OPALFitterGSL.cc:1014
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::OrcaKinFit::OPALFitterGSL::getNunm
virtual int getNunm() const
Get the number of unmeasured parameters of the last fit.
Definition: OPALFitterGSL.cc:1073
Belle2::OrcaKinFit::OPALFitterGSL::getNcon
virtual int getNcon() const
Get the number of hard constraints of the last fit.
Definition: OPALFitterGSL.cc:1071
Belle2::OrcaKinFit::OPALFitterGSL::permV
gsl_permutation * permV
Helper permutation vector.
Definition: OPALFitterGSL.h:203
Belle2::OrcaKinFit::OPALFitterGSL::getNsoft
virtual int getNsoft() const
Get the number of soft constraints of the last fit.
Definition: OPALFitterGSL.cc:1072
Belle2::OrcaKinFit::OPALFitterGSL::setDebug
virtual void setDebug(int debuglevel)
Set the Debug Level.
Definition: OPALFitterGSL.cc:1051
Belle2::OrcaKinFit::OPALFitterGSL::getError
virtual int getError() const override
Return error code.
Definition: OPALFitterGSL.cc:1011
Belle2::OrcaKinFit::OPALFitterGSL::getNpar
virtual int getNpar() const
Get the number of all parameters of the last fit.
Definition: OPALFitterGSL.cc:1074