| 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 "anydataobj.h"
 | 
|---|
| 14 | 
 | 
|---|
| 15 | #include "pdlmgr.h"
 | 
|---|
| 16 | #include "dlftypes.h"
 | 
|---|
| 17 | #include "piacmd.h"
 | 
|---|
| 18 | 
 | 
|---|
| 19 | class PIStdImgApp;
 | 
|---|
| 20 | class PIAFitterWind;
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #ifdef SANS_EVOLPLANCK
 | 
|---|
| 23 | #include "cvector.h"
 | 
|---|
| 24 | class GeneralFunction; class GeneralFunc; class GeneralFit;
 | 
|---|
| 25 | class GeneralFitData;
 | 
|---|
| 26 | class Histo;  class Histo2D;
 | 
|---|
| 27 | class RzImage; 
 | 
|---|
| 28 | #else
 | 
|---|
| 29 | #include "tvector.h"
 | 
|---|
| 30 | namespace SOPHYA { 
 | 
|---|
| 31 | class GeneralFunction; class GeneralFunc; class GeneralFit;
 | 
|---|
| 32 | class GeneralFitData;
 | 
|---|
| 33 | class Histo; class Histo2D;
 | 
|---|
| 34 | class RzImage; //CMV_A_VIRER class RzImage
 | 
|---|
| 35 | }
 | 
|---|
| 36 | #endif
 | 
|---|
| 37 | 
 | 
|---|
| 38 | class PIAFitter : public CmdExecutor {
 | 
|---|
| 39 | public :
 | 
|---|
| 40 |   PIAFitter(PIACmd* piac, PIStdImgApp* app);
 | 
|---|
| 41 |   virtual ~PIAFitter();
 | 
|---|
| 42 |   virtual int Execute(string& keyw, vector<string>& args);
 | 
|---|
| 43 |   virtual void LinkFitFunc(string const& fname, string const& funcname
 | 
|---|
| 44 |                           ,int nvar,int npar);
 | 
|---|
| 45 |   virtual void PrepareFitFuncCFile(string const& fname, string const& funcname
 | 
|---|
| 46 |                                   ,int nvar,int npar);
 | 
|---|
| 47 | 
 | 
|---|
| 48 | friend class PIAFitterWind;
 | 
|---|
| 49 | 
 | 
|---|
| 50 | protected :
 | 
|---|
| 51 | 
 | 
|---|
| 52 | typedef struct DFOptions {
 | 
|---|
| 53 |   bool okres, okfun;
 | 
|---|
| 54 |   int polcx,polcy; double xc,yc;
 | 
|---|
| 55 |   double err_e, err_E;
 | 
|---|
| 56 |   double stc2;
 | 
|---|
| 57 |   int nstep;
 | 
|---|
| 58 |   int lp,lpg;
 | 
|---|
| 59 |   int_4 i1,i2,j1,j2;
 | 
|---|
| 60 |   bool fromlastfit,autoinifit;
 | 
|---|
| 61 | } DFOPTIONS ;
 | 
|---|
| 62 | 
 | 
|---|
| 63 | void ResetDPointer(void);
 | 
|---|
| 64 | void ResetOptions(void);
 | 
|---|
| 65 | void DecodeOptions(string opt);
 | 
|---|
| 66 | void DecodeObject(string obj);
 | 
|---|
| 67 | void CheckOptions(void);
 | 
|---|
| 68 | void PrintOptions(void);
 | 
|---|
| 69 | void FillGData(void);
 | 
|---|
| 70 | void DecodeFunction(string func);
 | 
|---|
| 71 | void ReSetParam(void);
 | 
|---|
| 72 | void AutoIniFit(void);
 | 
|---|
| 73 | void InitParFromLastFit(void);
 | 
|---|
| 74 | void DecodeParam(string par,string step,string min,string max,string fix);
 | 
|---|
| 75 | int  DoFit(void);
 | 
|---|
| 76 | void FitFunRes(void);
 | 
|---|
| 77 | void LinFit(void);
 | 
|---|
| 78 | 
 | 
|---|
| 79 | // pour initialiser les parametres du fit
 | 
|---|
| 80 | void IniFitP1ou2D(void);
 | 
|---|
| 81 | void IniFitGhP1D(void);
 | 
|---|
| 82 | void IniFitGvP1D(void);
 | 
|---|
| 83 | void IniFitGv2D(void);
 | 
|---|
| 84 | static int IniFitGaus(GeneralFitData& g,double& h,double& v
 | 
|---|
| 85 |        ,double& x0,double& y0,double& sx,double& sy,double& f);
 | 
|---|
| 86 | 
 | 
|---|
| 87 | // Graphique
 | 
|---|
| 88 | PIStdImgApp* mApp; // Do not delete
 | 
|---|
| 89 | PIAFitterWind* FWindFit; // Fenetre de config interactive
 | 
|---|
| 90 | // Objet a fitter
 | 
|---|
| 91 | string mNObj; AnyDataObj* mObj; // Do not delete
 | 
|---|
| 92 | // Structure de data pour le fit, parametres et options
 | 
|---|
| 93 | GeneralFitData* mGData;
 | 
|---|
| 94 | int_4 mNPar,mNVar,mNBinX,mNBinY,mNData;
 | 
|---|
| 95 | Vector mPar; Vector mStep; Vector mMin; Vector mMax; Vector mFix;
 | 
|---|
| 96 | Vector mParSave; Vector mStepSave; Vector mMinSave; Vector mMaxSave; Vector mFixSave;
 | 
|---|
| 97 | GeneralFit* mFit;
 | 
|---|
| 98 | DFOPTIONS mOpt;
 | 
|---|
| 99 | DFOPTIONS mOptSave;
 | 
|---|
| 100 | // Possibles objets a fitter
 | 
|---|
| 101 | Vector* mV; Histo* mH; // Do not delete
 | 
|---|
| 102 | Matrix* mM; Histo2D* mH2; // Do not delete
 | 
|---|
| 103 | RzImage* mIm; // Do not delete
 | 
|---|
| 104 | GeneralFitData* mG; // Do not delete
 | 
|---|
| 105 | // Gestion des fonctions de fit predefinies
 | 
|---|
| 106 | GeneralFunction* mFunction; string mFName;
 | 
|---|
| 107 | // Gestion de fonction de fit definie par l'utilisateur
 | 
|---|
| 108 | GeneralFunc* mFunc;
 | 
|---|
| 109 | PDynLinkMgr* mDlUFunc;
 | 
|---|
| 110 | string mNameFitFunc;
 | 
|---|
| 111 | DlUserFitFunc mFitFunc;
 | 
|---|
| 112 | DlUserFitFuncDer mFitFuncDer;
 | 
|---|
| 113 | int_4 mUFNVar, mUFNPar; 
 | 
|---|
| 114 | };
 | 
|---|
| 115 | 
 | 
|---|
| 116 | #endif
 | 
|---|