source: Sophya/trunk/SophyaPI/PIext/nomhistadapter.cc@ 463

Last change on this file since 463 was 463, checked in by ercodmgr, 26 years ago

HelpToTex + CopyObj (ds Adapter) et PawExecutor cmv+Reza 12/10/99

File size: 7.6 KB
Line 
1#include "machdefs.h"
2#include <stdlib.h>
3#include <typeinfo>
4#include <iostream.h>
5#include <string>
6
7#include "nomhistadapter.h"
8#include "pihisto.h"
9#include "pihisto2d.h"
10#include "pipodrw.h"
11
12//-------------------------------------------------------------------------
13// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo / HProf
14//-------------------------------------------------------------------------
15
16/* --Methode-- */
17NOMAdapter_Histo::NOMAdapter_Histo(Histo* o)
18 : NObjMgrAdapter(o)
19{
20mHis = o;
21}
22
23/* --Methode-- */
24NOMAdapter_Histo::~NOMAdapter_Histo()
25{
26}
27
28/* --Methode-- */
29NObjMgrAdapter* NOMAdapter_Histo::Clone(AnyDataObj* o)
30{
31Histo* h = dynamic_cast<Histo *>(o);
32if (h) return ( new NOMAdapter_Histo(h) );
33return ( new NObjMgrAdapter(o) );
34}
35
36/* --Methode-- */
37AnyDataObj* NOMAdapter_Histo::GetCopyObj()
38{
39HProf * hp = dynamic_cast<HProf *>(mHis);
40if (hp == NULL) return( new Histo(*mHis) );
41else return( new HProf(*hp) );
42}
43
44/* --Methode-- */
45void NOMAdapter_Histo::SavePPF(POutPersist& pos, string const & nom)
46{
47#ifdef SANS_EVOLPLANCK
48// PEIDA-EROS L'histo est lui-meme PPersist
49string tag = nom; // A cause de const
50mHis->Write(pos,0,tag);
51#else
52string s = typeid(*mObj).name();
53cout << "NOMAdapter_Histo::SavePPF() - Error : Not supported for " << s << endl;
54#endif
55}
56
57/* --Methode-- */
58void NOMAdapter_Histo::Print(ostream& os)
59{
60mHis->Print(60);
61}
62
63/* --Methode-- */
64PIDrawer* NOMAdapter_Histo::GetDrawer(string & dopt)
65{
66if (typeid(*mHis) == typeid(HProf)) dopt = "fcirclemarker5," + dopt;
67else dopt = "thinline," + dopt;
68return( new PIHisto(mHis, false) );
69}
70
71/* --Methode-- */
72NTupleInterface* NOMAdapter_Histo::GetNTupleInterface(bool& adel)
73{
74adel = true;
75return( new NTupInt_Histo(mHis) );
76}
77
78
79// -------------------------------------------------------------
80
81/* --Methode-- */
82NTupInt_Histo::NTupInt_Histo(Histo* h)
83{
84mHis = h;
85}
86
87/* --Methode-- */
88NTupInt_Histo::~NTupInt_Histo()
89{
90}
91
92/* --Methode-- */
93uint_4 NTupInt_Histo::NbLines() const
94{
95return(mHis->NBins());
96}
97
98/* --Methode-- */
99uint_4 NTupInt_Histo::NbColumns() const
100{
101return(4);
102}
103
104/* --Methode-- */
105r_8* NTupInt_Histo::GetLineD(int k) const
106{
107int i;
108if ((k < 0) || (k >= mHis->NBins()))
109 for(i=0; i<4; i++) mRet[i] = 0.;
110else {
111 mRet[0] = k; mRet[1] = mHis->BinCenter(k);
112 mRet[2] = (*mHis)(k); mRet[3] = mHis->Error(k);
113 }
114return(mRet);
115}
116
117/* --Methode-- */
118string NTupInt_Histo::VarList_C(const char* nx) const
119{
120string nomx;
121if (nx) nomx = nx;
122else nomx = "_xh_";
123string vardec = "double i,x,val,err; \n";
124vardec += "i = " + nomx + "[0]; x = " + nomx + "[1]; \n";
125vardec += "val = " + nomx + "[2]; err = " + nomx + "[3]; \n";
126return(vardec);
127}
128
129//-------------------------------------------------------------------------
130// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo2D
131//-------------------------------------------------------------------------
132
133
134/* --Methode-- */
135NOMAdapter_Histo2D::NOMAdapter_Histo2D(Histo2D* o)
136 : NObjMgrAdapter(o)
137{
138mHis = o;
139}
140
141/* --Methode-- */
142NOMAdapter_Histo2D::~NOMAdapter_Histo2D()
143{
144}
145
146/* --Methode-- */
147NObjMgrAdapter* NOMAdapter_Histo2D::Clone(AnyDataObj* o)
148{
149Histo2D* h = dynamic_cast<Histo2D *>(o);
150if (h) return ( new NOMAdapter_Histo2D(h) );
151return ( new NObjMgrAdapter(o) );
152}
153
154/* --Methode-- */
155AnyDataObj* NOMAdapter_Histo2D::GetCopyObj()
156{
157return ( new Histo2D(*mHis) );
158}
159
160/* --Methode-- */
161void NOMAdapter_Histo2D::SavePPF(POutPersist& pos, string const & nom)
162{
163#ifdef SANS_EVOLPLANCK
164// PEIDA-EROS L'histo est lui-meme PPersist
165string tag = nom; // A cause de const
166mHis->Write(pos,0,tag);
167#else
168string s = typeid(*mObj).name();
169cout << "NOMAdapter_Histo2D::SavePPF() - Error : Not supported for " << s << endl;
170#endif
171}
172
173/* --Methode-- */
174void NOMAdapter_Histo2D::Print(ostream& os)
175{
176mHis->Print();
177}
178
179/* --Methode-- */
180PIDrawer* NOMAdapter_Histo2D::GetDrawer(string & dopt)
181{
182dopt = "thinline," + dopt;
183return( new PIHisto2D(mHis, false) );
184}
185
186/* --Methode-- */
187P2DArrayAdapter* NOMAdapter_Histo2D::Get2DArray(string & dopt)
188{
189return (new POH2DAdapter(mHis, false) );
190}
191
192/* --Methode-- */
193NTupleInterface* NOMAdapter_Histo2D::GetNTupleInterface(bool& adel)
194{
195adel = true;
196return( new NTupInt_Histo2D(mHis) );
197}
198
199
200
201// -------------------------------------------------------------
202
203/* --Methode-- */
204NTupInt_Histo2D::NTupInt_Histo2D(Histo2D* h)
205{
206mHis = h;
207}
208
209/* --Methode-- */
210NTupInt_Histo2D::~NTupInt_Histo2D()
211{
212}
213
214/* --Methode-- */
215uint_4 NTupInt_Histo2D::NbLines() const
216{
217return(mHis->NBinX()*mHis->NBinY());
218}
219
220/* --Methode-- */
221uint_4 NTupInt_Histo2D::NbColumns() const
222{
223return(6);
224}
225
226/* --Methode-- */
227r_8* NTupInt_Histo2D::GetLineD(int n) const
228{
229int i,j;
230float f2,f3;
231if ((n < 0) || (n >= mHis->NBinX()*mHis->NBinY()))
232 for(i=0; i<6; i++) mRet[i] = 0.;
233else {
234 i = n%mHis->NBinX(); j = n/mHis->NBinX();
235 mRet[0] = i; mRet[1] = j;
236 mHis->BinCenter(i,j,f2,f3);
237 mRet[2] = f2; mRet[3] = f3;
238 mRet[4] = (*mHis)(i,j); mRet[5] = mHis->Error(i, j);
239 }
240return(mRet);
241}
242
243/* --Methode-- */
244string NTupInt_Histo2D::VarList_C(const char* nx) const
245{
246string nomx;
247if (nx) nomx = nx;
248else nomx = "_xh_";
249string vardec = "double i,j,x,y,val,err; \n";
250vardec += "i = " + nomx + "[0]; j = " + nomx + "[1]; \n";
251vardec += "x = " + nomx + "[2]; y = " + nomx + "[3]; \n";
252vardec += "val = " + nomx + "[4]; err = " + nomx + "[5]; \n";
253return(vardec);
254}
255
256
257
258//-------------------------------------------------------------------------
259// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet NTuple
260//-------------------------------------------------------------------------
261
262/* --Methode-- */
263NOMAdapter_NTuple::NOMAdapter_NTuple(NTuple* o)
264 : NObjMgrAdapter(o)
265{
266mNt = o;
267}
268
269/* --Methode-- */
270NOMAdapter_NTuple::~NOMAdapter_NTuple()
271{
272}
273
274/* --Methode-- */
275NObjMgrAdapter* NOMAdapter_NTuple::Clone(AnyDataObj* o)
276{
277NTuple* nt = dynamic_cast<NTuple *>(o);
278if (nt) return ( new NOMAdapter_NTuple(nt) );
279return ( new NObjMgrAdapter(o) );
280}
281
282/* --Methode-- */
283AnyDataObj* NOMAdapter_NTuple::GetCopyObj()
284{
285return ( new NTuple(*mNt) );
286}
287
288/* --Methode-- */
289void NOMAdapter_NTuple::SavePPF(POutPersist& pos, string const & nom)
290{
291#ifdef SANS_EVOLPLANCK
292// PEIDA-EROS L'histo est lui-meme PPersist
293string tag = nom; // A cause de const
294mNt->Write(pos,0,tag);
295#else
296string s = typeid(*mObj).name();
297cout << "NOMAdapter_NTuple::SavePPF() - Error : Not supported for " << s << endl;
298#endif
299}
300
301/* --Methode-- */
302void NOMAdapter_NTuple::Print(ostream& os)
303{
304os << mNt->Info();
305os << *(mNt);
306}
307
308
309/* --Methode-- */
310NTupleInterface* NOMAdapter_NTuple::GetNTupleInterface(bool& adel)
311{
312adel = false;
313return(mNt);
314// return( new NTupInt_NTuple(mNt) );
315}
316
317//-------------------------------------------------------------------------
318// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet XNTuple
319//-------------------------------------------------------------------------
320
321/* --Methode-- */
322NOMAdapter_XNTuple::NOMAdapter_XNTuple(XNTuple* o)
323 : NObjMgrAdapter(o)
324{
325mNt = o;
326}
327
328/* --Methode-- */
329NOMAdapter_XNTuple::~NOMAdapter_XNTuple()
330{
331}
332
333/* --Methode-- */
334NObjMgrAdapter* NOMAdapter_XNTuple::Clone(AnyDataObj* o)
335{
336XNTuple* nt = dynamic_cast<XNTuple *>(o);
337if (nt) return ( new NOMAdapter_XNTuple(nt) );
338return ( new NObjMgrAdapter(o) );
339}
340
341
342/* --Methode-- */
343void NOMAdapter_XNTuple::SavePPF(POutPersist& pos, string const & nom)
344{
345#ifdef SANS_EVOLPLANCK
346// PEIDA-EROS L'histo est lui-meme PPersist
347string tag = nom; // A cause de const
348mNt->Write(pos,0,tag);
349#else
350string s = typeid(*mObj).name();
351cout << "NOMAdapter_XNTuple::SavePPF() - Error : Not supported for " << s << endl;
352#endif
353}
354
355/* --Methode-- */
356void NOMAdapter_XNTuple::Print(ostream& os)
357{
358// os << mNt->Info();
359mNt->Show(os);
360}
361
362
363/* --Methode-- */
364NTupleInterface* NOMAdapter_XNTuple::GetNTupleInterface(bool& adel)
365{
366adel = false;
367return(mNt);
368}
369
370
Note: See TracBrowser for help on using the repository browser.