source: Sophya/trunk/SophyaPI/PIext/nomgfdadapter.cc@ 4042

Last change on this file since 4042 was 3572, checked in by cmv, 17 years ago

char* -> const char* pour regler les problemes de deprecated string const... + comparaison unsigned signed + suppression EVOL_PLANCK rz+cmv 07/02/2009

File size: 2.6 KB
Line 
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-- */
18NOMAdapter_GeneralFitData::NOMAdapter_GeneralFitData(GeneralFitData* o)
19 : NObjMgrAdapter(o)
20{
21mG = o;
22}
23
24/* --Methode-- */
25NOMAdapter_GeneralFitData::~NOMAdapter_GeneralFitData()
26{
27}
28
29/* --Methode-- */
30NObjMgrAdapter* NOMAdapter_GeneralFitData::Clone(AnyDataObj* o)
31{
32GeneralFitData* g = dynamic_cast<GeneralFitData *>(o);
33if (g) return ( new NOMAdapter_GeneralFitData(g) );
34return ( new NObjMgrAdapter(o) );
35}
36
37/* --Methode-- */
38string NOMAdapter_GeneralFitData::GetDataObjType()
39{
40return( "GeneralFitData " );
41}
42
43
44/* --Methode-- */
45AnyDataObj* NOMAdapter_GeneralFitData::CloneDataObj(bool /*share*/)
46{
47return( new GeneralFitData(*mG) );
48}
49
50/* --Methode-- */
51void NOMAdapter_GeneralFitData::SavePPF(POutPersist& pos, string const & nom)
52{
53ObjFileIO<GeneralFitData> fio(mG);
54fio.Write(pos, nom);
55}
56
57/* --Methode-- */
58void NOMAdapter_GeneralFitData::Print(ostream& os, int)
59{
60os << *(mG);
61}
62
63/* --Methode-- */
64NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface(bool& adel)
65{
66adel = false;
67return(mG);
68}
69
70/* --Methode-- */
71GeneralFitData* NOMAdapter_GeneralFitData::GetGeneralFitData(bool& adel
72 ,GeneralFitData::FitErrType errtype,double errscale,double errmin
73 ,int i1,int i2,int j1,int j2)
74{
75adel = false;
76if(!mG) return(NULL);
77
78int n = mG->NData();
79if(n<=0) return(NULL);
80int nv = mG->NVar();
81if(nv<=0) return(NULL);
82
83i1 = (i1<0||i1>=n)? 0: i1;
84i2 = (i2<0||i2>=n||i2<i1)? n-1: i2;
85n = i2-i1+1;
86
87// Pas de gestion des erreurs sur les Abscisses Xi
88GeneralFitData* mGData = new GeneralFitData(nv,n,0);
89adel = true;
90
91double *x = new double[nv];
92for(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}
100delete [] x;
101
102return mGData;
103}
104
105AnyDataObj* NOMAdapter_GeneralFitData::FitResidusObj(GeneralFit& mfit)
106{
107GeneralFitData* g = NULL;
108g = new GeneralFitData(ObjectFitter::FitResidus(*mG,mfit));
109return g;
110}
111
112AnyDataObj* NOMAdapter_GeneralFitData::FitFunctionObj(GeneralFit& mfit)
113{
114GeneralFitData* g = NULL;
115g = new GeneralFitData(ObjectFitter::FitFunction(*mG,mfit));
116return g;
117}
Note: See TracBrowser for help on using the repository browser.