| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | // Classe d ajustement pour  piapp | 
|---|
| 3 | // cmv                            98-99 | 
|---|
| 4 | // CEA-DAPNIA      LAL-IN2P3/CNRS | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef PIAFITTING_H_SEEN | 
|---|
| 7 | #define PIAFITTING_H_SEEN | 
|---|
| 8 |  | 
|---|
| 9 | #include "machdefs.h" | 
|---|
| 10 | #include <string> | 
|---|
| 11 | #include <vector> | 
|---|
| 12 |  | 
|---|
| 13 | #include "nomgadapter.h" | 
|---|
| 14 |  | 
|---|
| 15 | #include "pdlmgr.h" | 
|---|
| 16 | #include "dlftypes.h" | 
|---|
| 17 | #include "piacmd.h" | 
|---|
| 18 | #include "zthread.h" | 
|---|
| 19 |  | 
|---|
| 20 | class PIStdImgApp; | 
|---|
| 21 | class PIAFitterWind; | 
|---|
| 22 |  | 
|---|
| 23 | #ifdef SANS_EVOLPLANCK | 
|---|
| 24 | #include "cvector.h" | 
|---|
| 25 | class GeneralFunction; class GeneralFunc; class GeneralFit; | 
|---|
| 26 | class GeneralFitData; | 
|---|
| 27 | #else | 
|---|
| 28 | #include "tvector.h" | 
|---|
| 29 | namespace SOPHYA { | 
|---|
| 30 | class GeneralFunction; class GeneralFunc; class GeneralFit; | 
|---|
| 31 | class GeneralFitData; | 
|---|
| 32 | } | 
|---|
| 33 | #endif | 
|---|
| 34 |  | 
|---|
| 35 | class PIAFitter : public CmdExecutor { | 
|---|
| 36 | public : | 
|---|
| 37 | PIAFitter(PIACmd* piac, PIStdImgApp* app); | 
|---|
| 38 | virtual ~PIAFitter(); | 
|---|
| 39 | virtual int Execute(string& keyw, vector<string>& args, string& toks); | 
|---|
| 40 | virtual void LinkFitFunc(string const& fname, string const& funcname | 
|---|
| 41 | ,int nvar,int npar); | 
|---|
| 42 | virtual void PrepareFitFuncCFile(string const& fname, string const& funcname | 
|---|
| 43 | ,int nvar,int npar); | 
|---|
| 44 |  | 
|---|
| 45 | inline void  SetFgEvtLoopFlag(bool fg=false) { fg_evtloop = fg; } | 
|---|
| 46 | inline ZMutex &   getMutex() { return singlefit_mutex; } | 
|---|
| 47 |  | 
|---|
| 48 | friend class PIAFitterWind; | 
|---|
| 49 |  | 
|---|
| 50 | protected : | 
|---|
| 51 | bool fg_evtloop;   // true : appel depuis Boucle d'evts, PIAFitterWind | 
|---|
| 52 | // Attributs pour controle de thread | 
|---|
| 53 | ZMutex singlefit_mutex;  // Pour empecher l'execution simultanee de deux fits | 
|---|
| 54 |  | 
|---|
| 55 | typedef struct DFOptions { | 
|---|
| 56 | bool okres, okfun; | 
|---|
| 57 | int polcx,polcy; double xc,yc; | 
|---|
| 58 | GeneralFitData::FitErrType err_type; | 
|---|
| 59 | double err_scale,err_min; | 
|---|
| 60 | double stc2; | 
|---|
| 61 | int nstep; | 
|---|
| 62 | int lp,lpg; | 
|---|
| 63 | int_4 i1,i2,j1,j2; | 
|---|
| 64 | bool fromlastfit,autoinifit; | 
|---|
| 65 | } DFOPTIONS ; | 
|---|
| 66 |  | 
|---|
| 67 | void ResetOptions(void); | 
|---|
| 68 | void DecodeOptions(string opt); | 
|---|
| 69 | void DecodeObject(string obj); | 
|---|
| 70 | void CheckOptions(void); | 
|---|
| 71 | void PrintOptions(void); | 
|---|
| 72 | void FillGData(void); | 
|---|
| 73 | void GetCentering(void); | 
|---|
| 74 | void DecodeFunction(string func); | 
|---|
| 75 | void ReSetParam(void); | 
|---|
| 76 | void AutoIniFit(void); | 
|---|
| 77 | void InitParFromLastFit(void); | 
|---|
| 78 | void DecodeParam(string par,string step,string min,string max,string fix); | 
|---|
| 79 | int  DoFit(void); | 
|---|
| 80 | void FitFunRes(void); | 
|---|
| 81 | void LinFit(void); | 
|---|
| 82 |  | 
|---|
| 83 | // pour initialiser les parametres du fit | 
|---|
| 84 | void IniFitP1ou2D(void); | 
|---|
| 85 | void IniFitGhP1D(void); | 
|---|
| 86 | void IniFitGvP1D(void); | 
|---|
| 87 | void IniFitGv2D(void); | 
|---|
| 88 | static int IniFitGaus(GeneralFitData& g,double& h,double& v | 
|---|
| 89 | ,double& x0,double& y0,double& sx,double& sy,double& f); | 
|---|
| 90 |  | 
|---|
| 91 | // Graphique | 
|---|
| 92 | PIStdImgApp* mApp; // Do not delete | 
|---|
| 93 | PIAFitterWind* FWindFit; // Fenetre de config interactive | 
|---|
| 94 | // Objet a fitter | 
|---|
| 95 | string mNObj; | 
|---|
| 96 | NObjMgrAdapter* mAdObj; // Ne pas deleter | 
|---|
| 97 | // Structure de data pour le fit, parametres et options | 
|---|
| 98 | GeneralFitData* mGData; | 
|---|
| 99 | bool delmGData; | 
|---|
| 100 | int_4 mNPar,mNVar,mNData; | 
|---|
| 101 | Vector mPar; Vector mStep; Vector mMin; Vector mMax; Vector mFix; | 
|---|
| 102 | Vector mParSave; Vector mStepSave; Vector mMinSave; Vector mMaxSave; Vector mFixSave; | 
|---|
| 103 | GeneralFit* mFit; | 
|---|
| 104 | DFOPTIONS mOpt; | 
|---|
| 105 | DFOPTIONS mOptSave; | 
|---|
| 106 | // Gestion des fonctions de fit predefinies | 
|---|
| 107 | GeneralFunction* mFunction; string mFName; | 
|---|
| 108 | // Gestion de fonction de fit definie par l'utilisateur | 
|---|
| 109 | GeneralFunc* mFunc; | 
|---|
| 110 | PDynLinkMgr* mDlUFunc; | 
|---|
| 111 | string mNameFitFunc; | 
|---|
| 112 | DlUserFitFunc mFitFunc; | 
|---|
| 113 | DlUserFitFuncDer mFitFuncDer; | 
|---|
| 114 | int_4 mUFNVar, mUFNPar; | 
|---|
| 115 | }; | 
|---|
| 116 |  | 
|---|
| 117 | #endif | 
|---|