My Project
 All Classes Functions Variables Pages
fitthread.h
1 #ifndef fitthread_H
2 #define fitthread_H
3 #include <gsl/gsl_vector.h>
4 #include <gsl/gsl_complex.h>
5 #include <gsl/gsl_complex_math.h>
6 #include <gsl/gsl_eigen.h>
7 #include <gsl/gsl_sort_vector.h>
8 #include <gsl/gsl_math.h>
9 #include <gsl/gsl_matrix.h>
10 #include <gsl/gsl_linalg.h>
11 #include <gsl/gsl_blas.h>
12 #include <gsl/gsl_multifit_nlin.h>
13 #include <gsl/gsl_multimin.h>
14 #include <gsl/gsl_multiroots.h>
15 #include <gsl/gsl_errno.h>
16 #include <gsl/gsl_rng.h>
17 #include <gsl/gsl_cdf.h>
18 #include <QProgressDialog>
19 #include <QMessageBox>
20 #include <QThread>
21 #include <QMutex>
22 #include <QTime>
23 #include "array.h"
24 #include "math.h"
25 
27 
34 enum ErrMod{uncorrelated,covariant,minos,montecarlo};
36 typedef struct fitcontent{
37  double (*chi2)(void*);
38  double (*runchi2)(void*,int);
39  void* instance;
40  int cpara;
41  int* IsChanged;
42  double* param;
43  int runi;
44 }fitcontent;
46 typedef struct fitcontentGauss{
47  double* x;
48  double* y;
49  double* sigma;
50  int count;
53 enum threattyp {fitseriell,fitglobal,errorseriell,errorglobal,notvalid};
55 
59  public:
69  CorrelationEle(int ia, int ib, double vala,
70  double valb, double valab,
71  double xa, double xb);
72  ~CorrelationEle();
73  bool operator<(const CorrelationEle o2)const;
74  int a,b;
75  double va,vb;
76  double correlation;
77 };
78 
80 
95 class fitthread: public QThread{
96 Q_OBJECT
97 public:
98  void run();
99  void exit();
101 
110  fitthread(double* para, int* changed, double* errors, int cpara,
111  double (*f)(void*), void* instance, int MaxIter,
112  double conv, bool forceSimplex);
114 
117  fitthread(double* para, int runi, double* errors, int cpara,
118  double (*f)(void*,int), void* instance, int MaxIter,
119  double conv);
120  ~fitthread();
122 
128  fitthread(double* para, int* changed, double *errors, int cpara,
129  double (*chi2)(void*), void* instance, ErrMod mode,
130  double (*fitting)(void*), int MonteCarloIterations,
131  int crun, int cglobal, bool (*correlated)(void*,int,int));
133  fitthread(double* para, int runi, double *errors, int cpara,
134  double (*chi2)(void*,int), void* instance, ErrMod mode,
135  int MonteCarloIterations);
137  void errors_covariant();
139 
141  void errors_MonteCarlo(double pdfmin, double sigmac);
143  void errors_uncorrelated(bool EmitSignals);
145  void errors_MINOS();
146 public slots:
147  void stop_calculations();
149 
155  void paraboloid(double **x, double *y, int N, int points, double* fxy);
156 private:
165  void fit_gaussian(double *x, double* y, double* sigma, int count,
166  double* gsigma, double* gy0, double* gx0);
167  void fit_seriell();
168  void fit_global();
169  void fit_global_simplex();
171  int correlation_possible(int xi, int yi);
173 
180  void get_Hesse(gsl_matrix *H, double* ss, double *k);
182 
192  void Hesse_to_covariant_errors(gsl_matrix *H, double* errors,
193  double* vals, int cpara);
195  QString correlations(gsl_matrix *H, int cpara, double* vals);
197 
203  double fxx(double* v, double v0, double* ss, double chi0);
205  double fx(double* v, double v0, double* ss, double chi0);
207  double fxy(double* vx, double* vy,
208  double v0x, double v0y,
209  double fxx, double fyy,
210  double ssx, double ssy, double chi0);
211  double* para;
212  int runi;
214  double* errors;
215  int* changed;
217  int cpara;
218  int crun;
219  int cglobal;
220  double (*f_global)(void*);
221  double (*fit)(void*);
222  double (*f_seriell)(void*,int);
223  bool (*correlated)(void*,int,int);
226  double f();
227  void* instance;
228  int MaxIter;
229  threattyp fitmodel;
230  int proceed_calc;
231  double conv;
232  bool usesimplex;
233  int montecarloiterations;
234  ErrMod errormode;
235 signals:
237  void refresh_progress(int ID, int citer,double chi2);
239  void finished(int ID);
241  void error_message(int runi, QString message);
242 
243 };
244 
245 #endif // fitthread_H
fitthread(double *para, int *changed, double *errors, int cpara, double(*f)(void *), void *instance, int MaxIter, double conv, bool forceSimplex)
global fitting
Definition: fitthread.cpp:5
container to be used in GSL minimization functions
Definition: fitthread.h:36
thread class to perform fitting and error calculation tasks
Definition: fitthread.h:95
void errors_covariant()
see ErrMod
Definition: fitthread.cpp:296
void error_message(int runi, QString message)
fitmodel instance should print error message
container to sort correlation matrix elements using qSort()
Definition: fitthread.h:58
container to be used in GSL minimization functions
Definition: fitthread.h:46
void refresh_progress(int ID, int citer, double chi2)
progressbar in fitmodel should be updated
CorrelationEle(int ia, int ib, double vala, double valb, double valab, double xa, double xb)
Definition: fitthread.cpp:1163
void finished(int ID)
calculation is finished
void errors_uncorrelated(bool EmitSignals)
see ErrMod, EmitSignals may suppress Progressbar update at internal use
Definition: fitthread.cpp:372
void errors_MINOS()
see ErrMod
Definition: fitthread.cpp:388
void paraboloid(double **x, double *y, int N, int points, double *fxy)
fits a dim-dimensional paraboloid centered at zero at points x, UNUSED
Definition: fitthread.cpp:768
void errors_MonteCarlo(double pdfmin, double sigmac)
see ErrMod
Definition: fitthread.cpp:436
parser and handler of user input mbs-files
Definition: fitmodel.h:159