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

Last change on this file since 2672 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

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