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