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

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

cmv 7/7/2000

nomhistadapter.cc :

GetCopyObj() on fait un UpdateHisto() si c'est un HProf

servnobjm.cc :

ProjectHProf() on fait un UpdateHisto()

pihisto.cc :

Draw() on fait un UpdateHisto() si c'est un HProf

pawexecut.cc :

h/integ, h/deriv, h/rebin, h/cadd, h/cmult NON valable pour un HProf
h/oper teste et h3->Zero() ENLEVE pour permettre

h/oper @ h1 h3 h3
h/oper @ h3 h3 h3 ... etc...

cmv 7/7/2000

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