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