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

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

1/ NTupleInterface mis ds Outils++ et complete -
2/ Les PINtuple et PINtup3D utilisent maintenant NTupleInterface
3/ Debut modification interface NObjMgr - Reza 23/6/99

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