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

Last change on this file since 1451 was 1315, checked in by ercodmgr, 25 years ago

Adaptateur pour TArray et flag share ds methode CloneDataObj() - Reza 9/11/2000

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