| [339] | 1 | #include "machdefs.h"
 | 
|---|
 | 2 | #include <stdlib.h>
 | 
|---|
 | 3 | #include <typeinfo>
 | 
|---|
 | 4 | #include <iostream.h>
 | 
|---|
 | 5 | #include <string>
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | #include "nomgfdadapter.h"
 | 
|---|
 | 8 | #include "pipodrw.h"
 | 
|---|
 | 9 | 
 | 
|---|
| [1207] | 10 | #ifndef SANS_EVOLPLANCK
 | 
|---|
 | 11 | #include "objfitter.h"
 | 
|---|
 | 12 | #endif
 | 
|---|
 | 13 | 
 | 
|---|
| [339] | 14 | //-------------------------------------------------------------------------
 | 
|---|
 | 15 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet GeneralFitData
 | 
|---|
 | 16 | //-------------------------------------------------------------------------
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | /* --Methode-- */
 | 
|---|
 | 19 | NOMAdapter_GeneralFitData::NOMAdapter_GeneralFitData(GeneralFitData* o)
 | 
|---|
 | 20 |   : NObjMgrAdapter(o)
 | 
|---|
 | 21 | {
 | 
|---|
 | 22 | mG = o;
 | 
|---|
 | 23 | }
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | /* --Methode-- */
 | 
|---|
 | 26 | NOMAdapter_GeneralFitData::~NOMAdapter_GeneralFitData()
 | 
|---|
 | 27 | {
 | 
|---|
 | 28 | }
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | /* --Methode-- */
 | 
|---|
 | 31 | NObjMgrAdapter* NOMAdapter_GeneralFitData::Clone(AnyDataObj* o)
 | 
|---|
 | 32 | {
 | 
|---|
 | 33 | GeneralFitData* g = dynamic_cast<GeneralFitData *>(o);
 | 
|---|
 | 34 | if (g) return ( new NOMAdapter_GeneralFitData(g) );
 | 
|---|
 | 35 | return ( new NObjMgrAdapter(o) );
 | 
|---|
 | 36 | }
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 | /* --Methode-- */
 | 
|---|
| [1165] | 39 | string NOMAdapter_GeneralFitData::GetDataObjType()
 | 
|---|
| [463] | 40 | {
 | 
|---|
| [1165] | 41 | return( "GeneralFitData " );
 | 
|---|
 | 42 | }
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | /* --Methode-- */
 | 
|---|
| [1315] | 46 | AnyDataObj* NOMAdapter_GeneralFitData::CloneDataObj(bool /*share*/)
 | 
|---|
| [1165] | 47 | {
 | 
|---|
| [463] | 48 | return( new GeneralFitData(*mG) );
 | 
|---|
 | 49 | }
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 | /* --Methode-- */
 | 
|---|
| [339] | 52 | void NOMAdapter_GeneralFitData::SavePPF(POutPersist& pos, string const & nom)
 | 
|---|
 | 53 | {
 | 
|---|
 | 54 | #ifdef SANS_EVOLPLANCK
 | 
|---|
 | 55 | string tag = nom;  // A cause de const
 | 
|---|
 | 56 | mG->Write(pos,0,tag);
 | 
|---|
 | 57 | #else
 | 
|---|
| [1068] | 58 | ObjFileIO<GeneralFitData> fio(mG);
 | 
|---|
 | 59 | fio.Write(pos, nom);
 | 
|---|
| [339] | 60 | #endif
 | 
|---|
 | 61 | }
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 | /* --Methode-- */
 | 
|---|
 | 64 | void NOMAdapter_GeneralFitData::Print(ostream& os)
 | 
|---|
 | 65 | {
 | 
|---|
 | 66 | os << *(mG);
 | 
|---|
 | 67 | }
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | /* --Methode-- */
 | 
|---|
| [344] | 70 | NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface(bool& adel)
 | 
|---|
| [339] | 71 | {
 | 
|---|
| [344] | 72 | adel = false;
 | 
|---|
 | 73 | return(mG);
 | 
|---|
| [339] | 74 | }
 | 
|---|
 | 75 | 
 | 
|---|
| [1207] | 76 | /* --Methode-- */
 | 
|---|
 | 77 | GeneralFitData* NOMAdapter_GeneralFitData::GetGeneralFitData(bool& adel
 | 
|---|
 | 78 |  ,GeneralFitData::FitErrType errtype,double errscale,double errmin
 | 
|---|
 | 79 |  ,int i1,int i2,int j1,int j2)
 | 
|---|
 | 80 | {
 | 
|---|
 | 81 | adel = false;
 | 
|---|
 | 82 | if(!mG) return(NULL);
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 | int n = mG->NData();
 | 
|---|
 | 85 | if(n<=0) return(NULL);
 | 
|---|
 | 86 | int nv = mG->NVar();
 | 
|---|
 | 87 | if(nv<=0) return(NULL);
 | 
|---|
 | 88 | 
 | 
|---|
 | 89 | i1 = (i1<0||i1>=n)? 0: i1;
 | 
|---|
 | 90 | i2 = (i2<0||i2>=n||i2<i1)? n-1: i2;
 | 
|---|
 | 91 | n = i2-i1+1;
 | 
|---|
 | 92 | 
 | 
|---|
 | 93 | // Pas de gestion des erreurs sur les Abscisses Xi
 | 
|---|
 | 94 | GeneralFitData* mGData = new GeneralFitData(nv,n,0);
 | 
|---|
 | 95 | adel = true;
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 | double *x = new double[nv];
 | 
|---|
 | 98 | for(int i=i1;i<=i2;i++) {
 | 
|---|
 | 99 |   for(int j=0;j<nv;j++) x[j] = mG->Absc(j,i);
 | 
|---|
 | 100 |   double f = mG->Val(i);
 | 
|---|
 | 101 |   double e = mG->EVal(i);
 | 
|---|
 | 102 |   e = GeneralFitData::ComputeError(f,e,errtype,errscale,errmin);
 | 
|---|
 | 103 |   mGData->AddData(x,f,e);
 | 
|---|
 | 104 |   if(!mG->IsValid(i)) mGData->KillData(i);
 | 
|---|
 | 105 | }
 | 
|---|
 | 106 | delete [] x;
 | 
|---|
 | 107 | 
 | 
|---|
 | 108 | return mGData;
 | 
|---|
 | 109 | }
 | 
|---|
 | 110 | 
 | 
|---|
 | 111 | AnyDataObj* NOMAdapter_GeneralFitData::FitResidusObj(GeneralFit& mfit)
 | 
|---|
 | 112 | {
 | 
|---|
 | 113 | GeneralFitData* g = NULL;
 | 
|---|
 | 114 | #ifdef SANS_EVOLPLANCK
 | 
|---|
 | 115 | g = mG->FitResidus(mfit); 
 | 
|---|
 | 116 | #else
 | 
|---|
 | 117 | g = new GeneralFitData(ObjectFitter::FitResidus(*mG,mfit));
 | 
|---|
 | 118 | #endif
 | 
|---|
 | 119 | return g;
 | 
|---|
 | 120 | }
 | 
|---|
 | 121 | 
 | 
|---|
 | 122 | AnyDataObj* NOMAdapter_GeneralFitData::FitFunctionObj(GeneralFit& mfit)
 | 
|---|
 | 123 | {
 | 
|---|
 | 124 | GeneralFitData* g = NULL;
 | 
|---|
 | 125 | #ifdef SANS_EVOLPLANCK
 | 
|---|
 | 126 | g = mG->FitFunction(mfit); 
 | 
|---|
 | 127 | #else
 | 
|---|
 | 128 | g = new GeneralFitData(ObjectFitter::FitFunction(*mG,mfit));
 | 
|---|
 | 129 | #endif
 | 
|---|
 | 130 | return g;
 | 
|---|
 | 131 | }
 | 
|---|