1 | #include <stdio.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <ctype.h>
|
---|
4 |
|
---|
5 | #include <typeinfo>
|
---|
6 | #include <iostream.h>
|
---|
7 | #include <string>
|
---|
8 | #include <list>
|
---|
9 | #include <map>
|
---|
10 |
|
---|
11 | #include "strutil.h"
|
---|
12 |
|
---|
13 | #include "nobjmgr.h"
|
---|
14 | #include "servnobjm.h"
|
---|
15 | #include "nomgadapter.h"
|
---|
16 | #include "pistdimgapp.h"
|
---|
17 |
|
---|
18 | #include "fct1dfit.h"
|
---|
19 | #include "fct2dfit.h"
|
---|
20 |
|
---|
21 | #include "matrix.h"
|
---|
22 | #include "cvector.h"
|
---|
23 | #include "ntuple.h"
|
---|
24 | #include "cimage.h"
|
---|
25 | #include "fitsimage.h"
|
---|
26 |
|
---|
27 | #include "histos.h"
|
---|
28 | #include "histos2.h"
|
---|
29 | #include "ntuple.h"
|
---|
30 | #include "hisprof.h"
|
---|
31 |
|
---|
32 | #include "piscdrawwdg.h"
|
---|
33 | #include "pisurfdr.h"
|
---|
34 |
|
---|
35 | #include "pintuple.h"
|
---|
36 | #include "pintup3d.h"
|
---|
37 |
|
---|
38 | #include "pipodrw.h"
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | /* --Methode-- */
|
---|
43 | Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
|
---|
44 | {
|
---|
45 | TmpDir = tmpdir;
|
---|
46 | PDynLinkMgr::SetTmpDir(tmpdir);
|
---|
47 | mImgapp = NULL;
|
---|
48 | mOmg = omg;
|
---|
49 | dynlink = NULL;
|
---|
50 | InitGrAttNames();
|
---|
51 | }
|
---|
52 |
|
---|
53 | /* --Methode-- */
|
---|
54 | Services2NObjMgr::~Services2NObjMgr()
|
---|
55 | {
|
---|
56 | CloseDLL();
|
---|
57 | }
|
---|
58 |
|
---|
59 | /* --Methode-- */
|
---|
60 | void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
|
---|
61 | {
|
---|
62 | ObjAdaptList::iterator it;
|
---|
63 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
64 | if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
|
---|
65 |
|
---|
66 | dataobj_adapter oba;
|
---|
67 | oba.obj = o;
|
---|
68 | oba.obja = oa;
|
---|
69 | objadaplist.push_back(oba);
|
---|
70 | }
|
---|
71 |
|
---|
72 | /* --Methode-- */
|
---|
73 | NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
|
---|
74 | {
|
---|
75 | ObjAdaptList::iterator it;
|
---|
76 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
77 | if (typeid(*o) == typeid(*((*it).obj))) return((*it).obja->Clone(o));
|
---|
78 | return(new NObjMgrAdapter(o));
|
---|
79 | }
|
---|
80 |
|
---|
81 | /* --Methode-- */
|
---|
82 | void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
|
---|
83 | {
|
---|
84 | FILE *fip;
|
---|
85 | string fname = TmpDir + "func1_pia_dl.c";
|
---|
86 | string cmd;
|
---|
87 | int rc;
|
---|
88 |
|
---|
89 | if (!mImgapp) return;
|
---|
90 |
|
---|
91 | cmd = "rm -f " + fname;
|
---|
92 | rc = system(cmd.c_str());
|
---|
93 | // printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
94 |
|
---|
95 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
96 | string sn = fname;
|
---|
97 | cout << "Services2NObjMgr/PlotFunc_Error: fopen( " << sn << endl;
|
---|
98 | return;
|
---|
99 | }
|
---|
100 |
|
---|
101 | // constitution du fichier a compiler
|
---|
102 | fputs("#include <math.h> \n", fip);
|
---|
103 | fputs("double func1_pia_dl_func(double x) \n{\n", fip);
|
---|
104 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
105 | fclose(fip);
|
---|
106 |
|
---|
107 | string func = "func1_pia_dl_func";
|
---|
108 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
109 | if (!f) return;
|
---|
110 | PlotFunc(f, nom, xmin, xmax, np, dopt);
|
---|
111 | CloseDLL();
|
---|
112 | return;
|
---|
113 | }
|
---|
114 |
|
---|
115 | /* --Methode-- */
|
---|
116 | void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax,
|
---|
117 | double ymin, double ymax, int npx, int npy, string dopt)
|
---|
118 | {
|
---|
119 | FILE *fip;
|
---|
120 | string fname = TmpDir + "func2_pia_dl.c";
|
---|
121 | string cmd;
|
---|
122 | int rc;
|
---|
123 |
|
---|
124 | if (!mImgapp) return;
|
---|
125 |
|
---|
126 | cmd = "rm " + fname;
|
---|
127 | rc = system(cmd.c_str());
|
---|
128 | // printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
129 |
|
---|
130 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
131 | string sn = fname;
|
---|
132 | cout << "Services2NObjMgr/PlotFunc2D_Error: fopen( " << sn << endl;
|
---|
133 | return;
|
---|
134 | }
|
---|
135 |
|
---|
136 | // constitution du fichier a compiler
|
---|
137 | fputs("#include <math.h> \n", fip);
|
---|
138 | fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
|
---|
139 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
140 | fclose(fip);
|
---|
141 |
|
---|
142 | string func = "func2_pia_dl_func";
|
---|
143 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
144 | if (!f) return;
|
---|
145 | PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
146 | CloseDLL();
|
---|
147 | return;
|
---|
148 | }
|
---|
149 |
|
---|
150 | /* --Methode-- */
|
---|
151 | void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom,
|
---|
152 | double xmin, double xmax, int np, string dopt)
|
---|
153 | {
|
---|
154 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
155 | if (!f) return;
|
---|
156 | PlotFunc(f, nom, xmin, xmax, np, dopt);
|
---|
157 | CloseDLL();
|
---|
158 | return;
|
---|
159 | }
|
---|
160 |
|
---|
161 | /* --Methode-- */
|
---|
162 | void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom,
|
---|
163 | double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
|
---|
164 | {
|
---|
165 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
166 | if (!f) return;
|
---|
167 | PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
168 | CloseDLL();
|
---|
169 | return;
|
---|
170 | }
|
---|
171 |
|
---|
172 | /* --Methode-- */
|
---|
173 | void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
|
---|
174 | {
|
---|
175 | if (!mImgapp) return;
|
---|
176 |
|
---|
177 | int k;
|
---|
178 | if (np < 1) np = 1;
|
---|
179 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
180 | Vector* vpy = new Vector(np);
|
---|
181 |
|
---|
182 | double xx;
|
---|
183 | double dx = (xmax-xmin)/np;
|
---|
184 | TRY {
|
---|
185 | for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
|
---|
186 | } CATCH(merr) {
|
---|
187 | fflush(stdout);
|
---|
188 | cout << endl;
|
---|
189 | cerr << endl;
|
---|
190 | string es = PeidaExc(merr);
|
---|
191 | cerr << "Services2NObjMgr::PlotFunc() Exception :" << merr << es;
|
---|
192 | delete vpy;
|
---|
193 | vpy = NULL;
|
---|
194 | } ENDTRY;
|
---|
195 |
|
---|
196 |
|
---|
197 | if (vpy) {
|
---|
198 | string titre;
|
---|
199 | if (nom.length() < 1) {
|
---|
200 | titre = "Function f(x)";
|
---|
201 | nom = "/autoc/f_x";
|
---|
202 | }
|
---|
203 | else titre = nom;
|
---|
204 |
|
---|
205 | P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
|
---|
206 | vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
|
---|
207 | PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
|
---|
208 | bool fgsr = true;
|
---|
209 | dopt = "thinline," + dopt;
|
---|
210 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
211 | int rsid = mImgapp->DispScDrawer(dr, titre, opt);
|
---|
212 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
213 | if (nom.length() > 0) {
|
---|
214 | mOmg->AddObj(vpy, nom);
|
---|
215 | mOmg->AddWRsId(nom, rsid);
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | return;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /* --Methode-- */
|
---|
223 | void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax,
|
---|
224 | int npx, int npy, string dopt)
|
---|
225 | {
|
---|
226 | if (!mImgapp) return;
|
---|
227 |
|
---|
228 | if (npx < 3) npx = 3;
|
---|
229 | if (npy < 3) npy = 3;
|
---|
230 | if (npx > 250) npx = 250;
|
---|
231 | if (npy > 250) npy = 250;
|
---|
232 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
233 | if (ymax <= ymin) ymax = ymin+1.;
|
---|
234 |
|
---|
235 | Matrix* mtx = new Matrix(npy, npx);
|
---|
236 |
|
---|
237 | int i,j;
|
---|
238 | double xx, yy;
|
---|
239 | double dx = (xmax-xmin)/npx;
|
---|
240 | double dy = (ymax-ymin)/npy;
|
---|
241 | // printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
|
---|
242 | TRY {
|
---|
243 | for(j=0; j<npy; j++) {
|
---|
244 | yy = ymin+dy*j;
|
---|
245 | for(i=0; i<npx; i++) {
|
---|
246 | xx = xmin+dx*i;
|
---|
247 | (*mtx)(j, i) = f(xx, yy);
|
---|
248 | }
|
---|
249 | }
|
---|
250 | } CATCH(merr) {
|
---|
251 | fflush(stdout);
|
---|
252 | cout << endl;
|
---|
253 | cerr << endl;
|
---|
254 | string es = PeidaExc(merr);
|
---|
255 | cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es;
|
---|
256 | delete mtx; mtx = NULL;
|
---|
257 | } ENDTRY;
|
---|
258 |
|
---|
259 | if (mtx) {
|
---|
260 | string titre;
|
---|
261 | if (nom.length() < 1) {
|
---|
262 | titre = "Function f(x,y)";
|
---|
263 | nom = "/autoc/f2d_xy";
|
---|
264 | }
|
---|
265 | else titre = nom;
|
---|
266 | bool fgsr = true;
|
---|
267 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
268 | P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false);
|
---|
269 | arr->DefineXYCoordinates(xmin, ymin, dx, dy);
|
---|
270 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
271 | int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
|
---|
272 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
273 | if (nom.length() > 0) {
|
---|
274 | mOmg->AddObj(mtx, nom);
|
---|
275 | mOmg->AddWRsId(nom, rsid);
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | return;
|
---|
280 | }
|
---|
281 |
|
---|
282 | /* --Methode-- */
|
---|
283 | void Services2NObjMgr::DisplayPoints2D(string& nom, string& expx, string& expy,
|
---|
284 | string& experrx, string& experry,
|
---|
285 | string& expcut, string dopt, string loop)
|
---|
286 | {
|
---|
287 | NObjMgrAdapter* obja=NULL;
|
---|
288 | obja = mOmg->GetObjAdapter(nom);
|
---|
289 | if (obja == NULL) {
|
---|
290 | cout << "Services2NObjMgr::DisplayPoints2D() Error , No such object " << nom << endl;
|
---|
291 | return;
|
---|
292 | }
|
---|
293 | if (!mImgapp) return;
|
---|
294 |
|
---|
295 | // Creation NTuple
|
---|
296 | char* ntn[4] = {"expx","expy","expex","expey",};
|
---|
297 | NTuple* nt = NULL;
|
---|
298 | bool haserr = false;
|
---|
299 |
|
---|
300 | if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) { haserr = true; nt = new NTuple(4, ntn); }
|
---|
301 | else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); }
|
---|
302 |
|
---|
303 | ComputeExpressions(obja, expx, expy, experrx, experry, expcut, loop, nt, NULL, NULL);
|
---|
304 |
|
---|
305 | if (nt->NEntry() < 1) {
|
---|
306 | cout << "Services2NObjMgr::DisplayPoints2D() Warning Zero points satisfy cut !" << endl;
|
---|
307 | delete nt;
|
---|
308 | return;
|
---|
309 | }
|
---|
310 |
|
---|
311 | // nt->Show();
|
---|
312 | // nt->Print(0,10);
|
---|
313 | PINTuple* pin = new PINTuple(nt, true);
|
---|
314 | pin->SelectXY(ntn[0], ntn[1]);
|
---|
315 | if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
|
---|
316 |
|
---|
317 | bool fgsr = true;
|
---|
318 | dopt = "defline," + dopt;
|
---|
319 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
320 | string titre = nom + ":" + expy + "%" + expx;
|
---|
321 | mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
|
---|
322 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
323 | return;
|
---|
324 | }
|
---|
325 |
|
---|
326 | /* --Methode-- */
|
---|
327 | void Services2NObjMgr::DisplayPoints3D(string& nom, string& expx, string& expy,
|
---|
328 | string& expz, string& expcut, string dopt, string loop)
|
---|
329 | {
|
---|
330 | NObjMgrAdapter* obja=NULL;
|
---|
331 | obja = mOmg->GetObjAdapter(nom);
|
---|
332 | if (obja == NULL) {
|
---|
333 | cout << "Services2NObjMgr::DisplayPoints3D() Error , No such object " << nom << endl;
|
---|
334 | return;
|
---|
335 | }
|
---|
336 | if (!mImgapp) return;
|
---|
337 |
|
---|
338 | char* ntn[3] = {"expx","expy","expz"};
|
---|
339 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
340 |
|
---|
341 | string expwt = "1.";
|
---|
342 | ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL);
|
---|
343 |
|
---|
344 | if (nt->NEntry() < 1) {
|
---|
345 | cout << "Services2NObjMgr::DisplayPoints3D() Warning Zero points satisfy cut !" << endl;
|
---|
346 | delete nt;
|
---|
347 | return;
|
---|
348 | }
|
---|
349 | nt->Show();
|
---|
350 | nt->Print(0,10);
|
---|
351 | PINTuple3D* pin = new PINTuple3D(nt, true);
|
---|
352 | pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
|
---|
353 | bool fgsr = true;
|
---|
354 | dopt = "defline," + dopt;
|
---|
355 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
356 |
|
---|
357 | // Pour plot a partir de DispScDrawer
|
---|
358 | // string nomdisp = "_NT3D_";
|
---|
359 | // mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
|
---|
360 | // Pour plot a partir de Disp3DDrawer
|
---|
361 | string titre = nom + ":" + expy + "%" + expx;
|
---|
362 | mImgapp->Disp3DDrawer(pin, titre, opt);
|
---|
363 |
|
---|
364 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
365 | return;
|
---|
366 | }
|
---|
367 |
|
---|
368 | /* --Methode-- */
|
---|
369 | void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy,
|
---|
370 | string& expwt, string& expcut, string dopt, string loop)
|
---|
371 | {
|
---|
372 | NObjMgrAdapter* obja=NULL;
|
---|
373 | obja = mOmg->GetObjAdapter(nom);
|
---|
374 | if (obja == NULL) {
|
---|
375 | cout << "Services2NObjMgr::DisplayPoints2DW() Error , No such object " << nom << endl;
|
---|
376 | return;
|
---|
377 | }
|
---|
378 | if (!mImgapp) return;
|
---|
379 |
|
---|
380 | char* ntn[3] = {"expx","expy","expw"};
|
---|
381 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
382 |
|
---|
383 | string exp = "1.";
|
---|
384 | ComputeExpressions(obja, expx, expy, expwt, exp, expcut, loop, nt, NULL, NULL);
|
---|
385 |
|
---|
386 | if (nt->NEntry() < 1) {
|
---|
387 | cout << "Services2NObjMgr::DisplayPoints2DW() Warning Zero points satisfy cut !" << endl;
|
---|
388 | delete nt;
|
---|
389 | return;
|
---|
390 | }
|
---|
391 |
|
---|
392 | PINTuple* pin = new PINTuple(nt, true);
|
---|
393 | pin->SelectXY(ntn[0], ntn[1]);
|
---|
394 | pin->SelectWt(ntn[2]);
|
---|
395 |
|
---|
396 | bool fgsr = true;
|
---|
397 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
398 | string titre = nom + ":" + expwt + "_" + expy + "%" + expx ;
|
---|
399 | mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
|
---|
400 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
401 | return;
|
---|
402 | }
|
---|
403 |
|
---|
404 | /* --Methode-- */
|
---|
405 | void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt,
|
---|
406 | string& expcut, string& nomh1, string dopt, string loop)
|
---|
407 | {
|
---|
408 | NObjMgrAdapter* obja=NULL;
|
---|
409 | obja = mOmg->GetObjAdapter(nom);
|
---|
410 | if (obja == NULL) {
|
---|
411 | cout << "Services2NObjMgr::ProjectH1() Error , No such object " << nom << endl;
|
---|
412 | return;
|
---|
413 | }
|
---|
414 | if (!mImgapp) return;
|
---|
415 |
|
---|
416 | Histo* h1 = NULL;
|
---|
417 | NTuple* nt = NULL;
|
---|
418 | AnyDataObj* oh = NULL;
|
---|
419 | if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
|
---|
420 | else nomh1 = "/tmp/projh1d";
|
---|
421 | if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();
|
---|
422 | else {
|
---|
423 | char* ntn[2]= {"hxval", "hwt"};
|
---|
424 | nt = new NTuple(2,ntn); // Creation NTuple
|
---|
425 | }
|
---|
426 | string expz = "0.";
|
---|
427 | ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, loop, nt, h1, NULL);
|
---|
428 |
|
---|
429 | if ((!h1) && (!nt)) return;
|
---|
430 | if (!h1) {
|
---|
431 | if (nt->NEntry() < 1) {
|
---|
432 | cout << "Services2NObjMgr::ProjectH1() Warning Zero points satisfy cut !" << endl;
|
---|
433 | delete nt;
|
---|
434 | return;
|
---|
435 | }
|
---|
436 | double xmin, xmax;
|
---|
437 | nt->GetMinMax(0, xmin, xmax);
|
---|
438 | h1 = new Histo(xmin, xmax, 100);
|
---|
439 | int k;
|
---|
440 | float* xn;
|
---|
441 | for(k=0; k<nt->NEntry(); k++) {
|
---|
442 | xn = nt->GetVec(k);
|
---|
443 | h1->Add(xn[0], xn[1]);
|
---|
444 | }
|
---|
445 | delete nt;
|
---|
446 | mOmg->AddObj(h1, nomh1);
|
---|
447 | }
|
---|
448 |
|
---|
449 | mOmg->DisplayObj(nomh1, dopt);
|
---|
450 | return;
|
---|
451 | }
|
---|
452 |
|
---|
453 | /* --Methode-- */
|
---|
454 | void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt,
|
---|
455 | string& expcut, string& nomh2, string dopt, string loop)
|
---|
456 | {
|
---|
457 | NObjMgrAdapter* obja=NULL;
|
---|
458 | obja = mOmg->GetObjAdapter(nom);
|
---|
459 | if (obja == NULL) {
|
---|
460 | cout << "Services2NObjMgr::ProjectH2() Error , No such object " << nom << endl;
|
---|
461 | return;
|
---|
462 | }
|
---|
463 | if (!mImgapp) return;
|
---|
464 |
|
---|
465 | Histo2D* h2 = NULL;
|
---|
466 | NTuple* nt = NULL;
|
---|
467 | AnyDataObj* oh = NULL;
|
---|
468 | if (nomh2.length() > 0) oh=mOmg->GetObj(nomh2);
|
---|
469 | else nomh2 = "/tmp/projh2d";
|
---|
470 | if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();
|
---|
471 | else {
|
---|
472 | char* ntn[3]= {"hxval", "hyval", "hwt"};
|
---|
473 | nt = new NTuple(3,ntn); // Creation NTuple
|
---|
474 | }
|
---|
475 | string expz = "0.";
|
---|
476 | ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, h2);
|
---|
477 |
|
---|
478 | if ((!h2) && (!nt)) return;
|
---|
479 | if (!h2) {
|
---|
480 | if (nt->NEntry() < 1) {
|
---|
481 | cout << "Services2NObjMgr::ProjectH2() Warning Zero points satisfy cut !" << endl;
|
---|
482 | delete nt;
|
---|
483 | return;
|
---|
484 | }
|
---|
485 | double xmin, xmax, ymin, ymax;
|
---|
486 | nt->GetMinMax(0, xmin, xmax);
|
---|
487 | nt->GetMinMax(1, ymin, ymax);
|
---|
488 | h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
|
---|
489 | int k;
|
---|
490 | float* xn;
|
---|
491 | for(k=0; k<nt->NEntry(); k++) {
|
---|
492 | xn = nt->GetVec(k);
|
---|
493 | h2->Add(xn[0], xn[1], xn[2]);
|
---|
494 | }
|
---|
495 | delete nt;
|
---|
496 | mOmg->AddObj(h2, nomh2);
|
---|
497 | }
|
---|
498 |
|
---|
499 | mOmg->DisplayObj(nomh2, dopt);
|
---|
500 | return;
|
---|
501 |
|
---|
502 | }
|
---|
503 |
|
---|
504 | /* --Methode-- cmv 13/10/98 */
|
---|
505 | void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
|
---|
506 | string& expcut, string& nomprof, string dopt, string loop)
|
---|
507 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
508 | //| nom = nom de l'objet a projeter dans un HProf.
|
---|
509 | //| expx = expression X de definition du bin.
|
---|
510 | //| expy = expression Y a additionner dans le bin.
|
---|
511 | //| expwt = expression W du poids a additionner.
|
---|
512 | //| expcut = expression du test de selection.
|
---|
513 | //| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
|
---|
514 | //| les limites Xmin,Xmax sont calculees automatiquement.
|
---|
515 | //| sinon ce sont celles de l'objet preexistant.
|
---|
516 | //| opt = options generales pour le display.
|
---|
517 | {
|
---|
518 | NObjMgrAdapter* obja=NULL;
|
---|
519 | obja = mOmg->GetObjAdapter(nom);
|
---|
520 | if (obja == NULL) {
|
---|
521 | cout << "Services2NObjMgr::ProjectHProf() Error , No such object " << nom << endl;
|
---|
522 | return;
|
---|
523 | }
|
---|
524 | if (!mImgapp) return;
|
---|
525 |
|
---|
526 | HProf* hprof = NULL;
|
---|
527 | NTuple* nt = NULL;
|
---|
528 | AnyDataObj* oh = NULL;
|
---|
529 | if (nomprof.length() > 0) oh=mOmg->GetObj(nomprof);
|
---|
530 | else nomprof = "/tmp/projprof";
|
---|
531 | if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh;
|
---|
532 | else {
|
---|
533 | char* ntn[3]= {"hxval", "hyval", "hwt"};
|
---|
534 | nt = new NTuple(3,ntn); // Creation NTuple
|
---|
535 | }
|
---|
536 | string expz = "0.";
|
---|
537 | ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, NULL, hprof);
|
---|
538 |
|
---|
539 | if((!hprof) && (!nt)) return;
|
---|
540 | if(!hprof) {
|
---|
541 | if (nt->NEntry() < 1) {
|
---|
542 | cout << "Services2NObjMgr::ProjectHProf() Warning Zero points satisfy cut !" << endl;
|
---|
543 | delete nt;
|
---|
544 | return;
|
---|
545 | }
|
---|
546 | double xmin, xmax;
|
---|
547 | nt->GetMinMax(0, xmin, xmax);
|
---|
548 | hprof = new HProf(xmin, xmax, 100);
|
---|
549 | int k;
|
---|
550 | float* xn;
|
---|
551 | for(k=0; k<nt->NEntry(); k++) {
|
---|
552 | xn = nt->GetVec(k);
|
---|
553 | hprof->Add(xn[0], xn[1], xn[2]);
|
---|
554 | }
|
---|
555 | delete nt;
|
---|
556 | mOmg->AddObj(hprof, nomprof);
|
---|
557 | }
|
---|
558 | hprof->UpdateHisto();
|
---|
559 |
|
---|
560 | mOmg->DisplayObj(nomprof, dopt);
|
---|
561 | return;
|
---|
562 | }
|
---|
563 |
|
---|
564 |
|
---|
565 | /* --Methode-- */
|
---|
566 | void Services2NObjMgr::FillVect(string& nom, string& expx, string& expv,
|
---|
567 | string& expcut, string& nomvec, string dopt, string loop)
|
---|
568 | {
|
---|
569 | NObjMgrAdapter* obja=NULL;
|
---|
570 | obja = mOmg->GetObjAdapter(nom);
|
---|
571 | if (obja == NULL) {
|
---|
572 | cout << "Services2NObjMgr::FillVect() Error , No such object: " << nom << endl;
|
---|
573 | return;
|
---|
574 | }
|
---|
575 | if (!mImgapp) return;
|
---|
576 |
|
---|
577 | Vector* v1 = NULL;
|
---|
578 | AnyDataObj* ov = NULL;
|
---|
579 | ov=mOmg->GetObj(nomvec);
|
---|
580 | if (ov != NULL) v1 = dynamic_cast<Vector *>(ov);
|
---|
581 | if (v1 == NULL) {
|
---|
582 | cout << "Services2NObjMgr::FillVect() Error , No such object or not a vector: " << nomvec << endl;
|
---|
583 | return;
|
---|
584 | }
|
---|
585 |
|
---|
586 | char* ntn[2]= {"vi", "vv"};
|
---|
587 | NTuple* nt = new NTuple(2,ntn); // Creation NTuple
|
---|
588 |
|
---|
589 | string expz = "0.";
|
---|
590 | ComputeExpressions(obja, expx, expv, expz, expz, expcut, loop, nt);
|
---|
591 |
|
---|
592 | if (!nt) return;
|
---|
593 | if (nt->NEntry() < 1) {
|
---|
594 | cout << "Services2NObjMgr::FillVect() Warning Zero points satisfy cut !" << endl;
|
---|
595 | delete nt;
|
---|
596 | return;
|
---|
597 | }
|
---|
598 |
|
---|
599 | int i,k;
|
---|
600 | double* xn;
|
---|
601 | for(k=0; k<nt->NEntry(); k++) {
|
---|
602 | xn = nt->GetLineD(k);
|
---|
603 | i = xn[0]+0.5;
|
---|
604 | if ( (i < 0) || i >= v1->NElts() ) continue;
|
---|
605 | (*v1)(i) = xn[1];
|
---|
606 | }
|
---|
607 | delete nt;
|
---|
608 |
|
---|
609 |
|
---|
610 | mOmg->DisplayObj(nomvec, dopt);
|
---|
611 | return;
|
---|
612 | }
|
---|
613 |
|
---|
614 | /* --Methode-- */
|
---|
615 | void Services2NObjMgr::FillMatx(string& nom, string& expx, string& expy, string& expv,
|
---|
616 | string& expcut, string& nommtx, string dopt, string loop)
|
---|
617 | {
|
---|
618 | NObjMgrAdapter* obja=NULL;
|
---|
619 | obja = mOmg->GetObjAdapter(nom);
|
---|
620 | if (obja == NULL) {
|
---|
621 | cout << "Services2NObjMgr::FillMatx() Error , No such objet " << nom << endl;
|
---|
622 | return;
|
---|
623 | }
|
---|
624 | if (!mImgapp) return;
|
---|
625 |
|
---|
626 | Matrix* mtx = NULL;
|
---|
627 | AnyDataObj* om = NULL;
|
---|
628 | om=mOmg->GetObj(nommtx);
|
---|
629 | if (om != NULL) mtx = dynamic_cast<Matrix *>(om);
|
---|
630 | if (mtx == NULL) {
|
---|
631 | cout << "Services2NObjMgr::FillMatx() Error , No such object or not a matrix " << nommtx << endl;
|
---|
632 | return;
|
---|
633 | }
|
---|
634 |
|
---|
635 | char* ntn[3]= {"mi", "mj", "mv"};
|
---|
636 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
637 |
|
---|
638 | string expz = "0.";
|
---|
639 | ComputeExpressions(obja, expx, expy, expv, expz, expcut, loop, nt);
|
---|
640 |
|
---|
641 | if (!nt) return;
|
---|
642 | if (nt->NEntry() < 1) {
|
---|
643 | cout << "Services2NObjMgr::FillMatx() Warning Zero points satisfy cut !" << endl;
|
---|
644 | delete nt;
|
---|
645 | return;
|
---|
646 | }
|
---|
647 |
|
---|
648 | int ic, jl, k;
|
---|
649 | double* xn;
|
---|
650 | for(k=0; k<nt->NEntry(); k++) {
|
---|
651 | xn = nt->GetLineD(k);
|
---|
652 | ic = xn[0]+0.5;
|
---|
653 | jl = xn[1]+0.5;
|
---|
654 | if ( (ic < 0) || ic >= mtx->NCol() ) continue;
|
---|
655 | if ( (jl < 0) || jl >= mtx->NRows() ) continue;
|
---|
656 | (*mtx)(jl, ic) = xn[2];
|
---|
657 | }
|
---|
658 | delete nt;
|
---|
659 |
|
---|
660 |
|
---|
661 | mOmg->DisplayObj(nommtx, dopt);
|
---|
662 | return;
|
---|
663 |
|
---|
664 | }
|
---|
665 |
|
---|
666 | /* --Methode-- */
|
---|
667 | void Services2NObjMgr::ExpressionToVector(string& nom, string& expx, string& expcut,
|
---|
668 | string& nomvec, string dopt, string loop)
|
---|
669 | {
|
---|
670 | NObjMgrAdapter* obja=NULL;
|
---|
671 | obja = mOmg->GetObjAdapter(nom);
|
---|
672 | if (obja == NULL) {
|
---|
673 | cout << "Services2NObjMgr::ExpressionToVector() Error , No such object " << nom << endl;
|
---|
674 | return;
|
---|
675 | }
|
---|
676 | if (!mImgapp) return;
|
---|
677 |
|
---|
678 | NTuple* nt = NULL;
|
---|
679 | if (nomvec.length() < 1) nomvec = "/tmp/expvec";
|
---|
680 |
|
---|
681 | char* ntn[2]= {"vecval", "vecwt"};
|
---|
682 | nt = new NTuple(1,ntn); // Creation NTuple
|
---|
683 |
|
---|
684 | string expwt = "1.";
|
---|
685 | string expz = "0.";
|
---|
686 | ComputeExpressions(obja, expx, expz, expz, expwt, expcut, loop, nt, NULL, NULL);
|
---|
687 |
|
---|
688 | if (!nt) return;
|
---|
689 | if (nt->NEntry() < 1) {
|
---|
690 | cout << "Services2NObjMgr::ExpressionToVector() Warning Zero points satisfy cut !" << endl;
|
---|
691 | delete nt;
|
---|
692 | return;
|
---|
693 | }
|
---|
694 |
|
---|
695 | Vector* vec = new Vector(nt->NEntry());
|
---|
696 | int k;
|
---|
697 | float* xn;
|
---|
698 | for(k=0; k<nt->NEntry(); k++) {
|
---|
699 | xn = nt->GetVec(k);
|
---|
700 | (*vec)(k) = xn[0];
|
---|
701 | }
|
---|
702 | delete nt;
|
---|
703 | mOmg->AddObj(vec, nomvec);
|
---|
704 | mOmg->DisplayObj(nomvec, dopt);
|
---|
705 | return;
|
---|
706 | }
|
---|
707 |
|
---|
708 | /* --Methode-- */
|
---|
709 | void Services2NObjMgr::NtFromASCIIFile(string& nom,string& filename,double def_val)
|
---|
710 | // Pour remplir un ntuple "nom" existant a partir du fichier
|
---|
711 | // ASCII table "filename". Si il y a plus de variables dans le
|
---|
712 | // ntuple que dans le fichier "filename",
|
---|
713 | // les sur-numeraires sont mises a "def_val" par defaut.
|
---|
714 | {
|
---|
715 | AnyDataObj* mobj = mOmg->GetObj(nom);
|
---|
716 | if(mobj == NULL)
|
---|
717 | {cout<<"NtFromASCIIFile() Error, object "<<nom<<" not existing"<<endl;
|
---|
718 | return;}
|
---|
719 | if(typeid(*mobj) != typeid(NTuple))
|
---|
720 | {cout<<"NtFromASCIIFile() Error, object "<<nom<<" not an NTuple"<<endl;
|
---|
721 | return;}
|
---|
722 | if (!mImgapp) return;
|
---|
723 |
|
---|
724 | NTuple* nt = (NTuple*) mobj;
|
---|
725 | nt->FillFromASCIIFile(filename, def_val);
|
---|
726 | return;
|
---|
727 | }
|
---|
728 |
|
---|
729 | /* --Methode-- */
|
---|
730 | void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz,
|
---|
731 | string& expt, string& expcut, string& nomnt, string loop)
|
---|
732 | {
|
---|
733 | NObjMgrAdapter* obja=NULL;
|
---|
734 | obja = mOmg->GetObjAdapter(nom);
|
---|
735 | if (obja == NULL) {
|
---|
736 | cout << "Services2NObjMgr::FillNT() Error , No such object " << nom << endl;
|
---|
737 | return;
|
---|
738 | }
|
---|
739 | if (!mImgapp) return;
|
---|
740 |
|
---|
741 | bool fgnnt = false;
|
---|
742 | NTuple* nt = NULL;
|
---|
743 | AnyDataObj* oh = NULL;
|
---|
744 | if (nomnt.length() > 0) oh=mOmg->GetObj(nomnt);
|
---|
745 | else nomnt = "/tmp/fillnt";
|
---|
746 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
747 | nt = (NTuple*)oh;
|
---|
748 | if (nt->NVar() > 10) {
|
---|
749 | cout << "Services2NObjMgr::FillNT() Warning , Max 10 var in NTuple -> new NTuple" << endl;
|
---|
750 | nt = NULL;
|
---|
751 | }
|
---|
752 | }
|
---|
753 | if (nt == NULL) {
|
---|
754 | char* ntn[4]= {"x", "y","z","t"};
|
---|
755 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
756 | fgnnt = true;
|
---|
757 | }
|
---|
758 |
|
---|
759 | ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
|
---|
760 |
|
---|
761 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
762 | return;
|
---|
763 |
|
---|
764 | }
|
---|
765 |
|
---|
766 | /* --Methode-- */
|
---|
767 | void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
|
---|
768 | string const & funcname, string & nomnt, string loop)
|
---|
769 | {
|
---|
770 | if (!mImgapp) return;
|
---|
771 |
|
---|
772 | NObjMgrAdapter* obja=NULL;
|
---|
773 | obja = mOmg->GetObjAdapter(nom);
|
---|
774 | if (obja == NULL) {
|
---|
775 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
|
---|
776 | return;
|
---|
777 | }
|
---|
778 | bool adel = true;
|
---|
779 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
780 | if (objnt == NULL) {
|
---|
781 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) Not an NTupleInterface !" <<endl;
|
---|
782 | return;
|
---|
783 | }
|
---|
784 |
|
---|
785 | NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
|
---|
786 | if (!f) {
|
---|
787 | cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl;
|
---|
788 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
789 | return;
|
---|
790 | }
|
---|
791 |
|
---|
792 | bool fgnnt = false;
|
---|
793 | NTuple* nt = NULL;
|
---|
794 | if (nomnt.length() > 0) {
|
---|
795 | AnyDataObj* oh = NULL;
|
---|
796 | oh=mOmg->GetObj(nomnt);
|
---|
797 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
798 | nt = (NTuple*)oh;
|
---|
799 | if (nt->NVar() > 10) {
|
---|
800 | cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var in NTuple -> new NTuple" << endl;
|
---|
801 | nt = NULL;
|
---|
802 | }
|
---|
803 | }
|
---|
804 | if (nt == NULL) {
|
---|
805 | char* ntn[4]= {"x", "y","z","t"};
|
---|
806 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
807 | fgnnt = true;
|
---|
808 | }
|
---|
809 | }
|
---|
810 |
|
---|
811 | double xnt[10];
|
---|
812 | float fxnt[10];
|
---|
813 |
|
---|
814 | int i,k;
|
---|
815 | for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
|
---|
816 |
|
---|
817 |
|
---|
818 | // $CHECK$ A virer des que possible - Pb blocage application quand trop d'impression
|
---|
819 | // redirige - On redirige la sortie sur le terminal
|
---|
820 | bool red = mImgapp->HasRedirectedStdOutErr();
|
---|
821 | mImgapp->RedirectStdOutErr(false);
|
---|
822 |
|
---|
823 | int k1,k2,dk;
|
---|
824 | k1 = 0; k2 = objnt->NbLines(); dk = 1;
|
---|
825 | DecodeLoopParameters(loop, k1, k2, dk);
|
---|
826 | if (k1 < 0) k1 = 0;
|
---|
827 | if (k2 < 0) k2 = objnt->NbLines();
|
---|
828 | if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
|
---|
829 | if (dk <= 0) dk = 1;
|
---|
830 |
|
---|
831 | TRY {
|
---|
832 | double* xn;
|
---|
833 | int kmax = k2;
|
---|
834 | for(k=k1; k<kmax; k+=dk) {
|
---|
835 | xn = objnt->GetLineD(k);
|
---|
836 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
|
---|
837 | if (nt) {
|
---|
838 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
839 | nt->Fill(fxnt);
|
---|
840 | }
|
---|
841 | }
|
---|
842 | }
|
---|
843 | }
|
---|
844 | CATCH(merr) {
|
---|
845 | fflush(stdout);
|
---|
846 | cout << endl;
|
---|
847 | cerr << endl;
|
---|
848 | string es = PeidaExc(merr);
|
---|
849 | cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es;
|
---|
850 | } ENDTRY;
|
---|
851 |
|
---|
852 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
853 | CloseDLL();
|
---|
854 |
|
---|
855 | // $CHECK$ A virer des que possible On redirige la sortie sur la fenetre PIConsole
|
---|
856 | mImgapp->RedirectStdOutErr(red);
|
---|
857 |
|
---|
858 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
859 | return;
|
---|
860 | }
|
---|
861 |
|
---|
862 | /* --Methode-- */
|
---|
863 | void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname,
|
---|
864 | string const & funcname)
|
---|
865 | {
|
---|
866 | NObjMgrAdapter* obja=NULL;
|
---|
867 | obja = mOmg->GetObjAdapter(nom);
|
---|
868 | if (obja == NULL) {
|
---|
869 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
|
---|
870 | return;
|
---|
871 | }
|
---|
872 | bool adel = true;
|
---|
873 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
874 | if (objnt == NULL) {
|
---|
875 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
|
---|
876 | << "...) No NTupleInterface !" <<endl;
|
---|
877 | return;
|
---|
878 | }
|
---|
879 | string vardec = objnt->VarList_C("_xnti_");
|
---|
880 |
|
---|
881 | FILE *fip;
|
---|
882 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
883 | cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
|
---|
884 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
885 | return;
|
---|
886 | }
|
---|
887 |
|
---|
888 | // constitution du fichier des decalarations des variables de l'interface NTuple
|
---|
889 | fputs("#include <stdlib.h> \n", fip);
|
---|
890 | fputs("#include <stdio.h> \n", fip);
|
---|
891 | fputs("#include <math.h> \n\n", fip);
|
---|
892 |
|
---|
893 | fputs("/* ------ Some random number generators --------- */ \n", fip);
|
---|
894 | fputs("#define frand01() ( (float) drand48() ) \n", fip);
|
---|
895 | fputs("#define drand01() drand48() \n", fip);
|
---|
896 | fputs("#define rand01() drand48() \n", fip);
|
---|
897 | fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
|
---|
898 | fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
899 | fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
900 | fputs("double NorRand(void) \n", fip);
|
---|
901 | fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
|
---|
902 | fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
|
---|
903 | fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
|
---|
904 | fputs(" return(x); \n } \n", fip);
|
---|
905 | fputs("#define GauRand() NorRand() \n", fip);
|
---|
906 | fputs("#define gaurand() NorRand() \n\n", fip);
|
---|
907 |
|
---|
908 | fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip);
|
---|
909 | fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip);
|
---|
910 | fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n",
|
---|
911 | funcname.c_str());
|
---|
912 | fprintf(fip," double* _rt_, int _n_, int _nmax_) \n");
|
---|
913 | fprintf(fip, "{ \n %s \n", vardec.c_str());
|
---|
914 | fputs(" if (!1) { /* Cut Expression failed */ \n", fip);
|
---|
915 | fputs(" *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.; return(0);", fip);
|
---|
916 | fputs(" } \n /* Cut expression satisfied */ \n", fip);
|
---|
917 | fputs(" *_rx_ = 1.; \n *_ry_ = 1.; \n *_rz_ = 1.; \n *_rt_ = 1.; \n", fip);
|
---|
918 | fputs(" return(1); \n} \n", fip);
|
---|
919 |
|
---|
920 | fclose(fip);
|
---|
921 |
|
---|
922 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
923 | return;
|
---|
924 | }
|
---|
925 |
|
---|
926 | /* --Methode-- cmv 13/10/98 */
|
---|
927 | void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
|
---|
928 | string& experr, string& expcut, string& nomgfd, string loop)
|
---|
929 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
930 | //| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
|
---|
931 | //| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
|
---|
932 | //| expx = expression X du GeneralFitData (1er abscisse)
|
---|
933 | //| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
|
---|
934 | //| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
|
---|
935 | //| experr = expression de l'erreur sur l'ordonnee Z
|
---|
936 | //| expcut = expression du test de selection
|
---|
937 | //| nomgfd = nom du GeneralFitData engendre (optionnel)
|
---|
938 | {
|
---|
939 | NObjMgrAdapter* obja=NULL;
|
---|
940 | obja = mOmg->GetObjAdapter(nom);
|
---|
941 | if (obja == NULL) {
|
---|
942 | cout << "Services2NObjMgr::FillGFD() Error , No such object "<<nom<<endl;
|
---|
943 | return;
|
---|
944 | }
|
---|
945 | if(!mImgapp) return;
|
---|
946 |
|
---|
947 | // 2D ou 3D?
|
---|
948 | int nvar = 2;
|
---|
949 | if(expy.length()<=0) {nvar = 1; expy = "0.";}
|
---|
950 |
|
---|
951 | // Creation NTuple Buffer
|
---|
952 | char* ntn[4]= {"x","y","f","e"};
|
---|
953 | NTuple*nt = new NTuple(4,ntn);
|
---|
954 |
|
---|
955 | // Remplissage NTuple buffer
|
---|
956 | ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
|
---|
957 | if(nt->NEntry() < 1)
|
---|
958 | {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
|
---|
959 | delete nt; return;}
|
---|
960 |
|
---|
961 | //Remplissage de la structure GeneraFitData
|
---|
962 | if (nt->NEntry() <= 0) {
|
---|
963 | cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
|
---|
964 | delete nt;
|
---|
965 | return;
|
---|
966 | }
|
---|
967 |
|
---|
968 | GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
|
---|
969 | int k;
|
---|
970 | float* xn;
|
---|
971 | for(k=0; k<nt->NEntry(); k++) {
|
---|
972 | xn = nt->GetVec(k);
|
---|
973 | gfd->AddData(xn,xn[2],xn[3]);
|
---|
974 | }
|
---|
975 |
|
---|
976 | // Menage et table d'objets
|
---|
977 | delete nt;
|
---|
978 | mOmg->AddObj(gfd, nomgfd);
|
---|
979 | return;
|
---|
980 | }
|
---|
981 |
|
---|
982 |
|
---|
983 | /* --Methode-- */
|
---|
984 | void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
|
---|
985 | string& expy, string& expz, string& expt, string& expcut, string& loop,
|
---|
986 | NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
|
---|
987 | {
|
---|
988 | if (obja == NULL) return;
|
---|
989 | bool adel = true;
|
---|
990 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
991 | if (objnt == NULL) return;
|
---|
992 | string vardec = objnt->VarList_C("_zz6qi_");
|
---|
993 |
|
---|
994 | PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
|
---|
995 | if (!f) {
|
---|
996 | cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
|
---|
997 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
998 | return;
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | double xnt[10];
|
---|
1002 | float fxnt[10];
|
---|
1003 |
|
---|
1004 | int i,k;
|
---|
1005 | for(i=0; i<10; i++) xnt[i] = 0.;
|
---|
1006 | int k1,k2,dk;
|
---|
1007 | k1 = 0; k2 = objnt->NbLines(); dk = 1;
|
---|
1008 | DecodeLoopParameters(loop, k1, k2, dk);
|
---|
1009 | if (k1 < 0) k1 = 0;
|
---|
1010 | if (k2 < 0) k2 = objnt->NbLines();
|
---|
1011 | if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
|
---|
1012 | if (dk <= 0) dk = 1;
|
---|
1013 | TRY {
|
---|
1014 | double* xn;
|
---|
1015 | for(k=k1; k<k2; k += dk) {
|
---|
1016 | xn = objnt->GetLineD(k);
|
---|
1017 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
1018 | if (nt) {
|
---|
1019 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
1020 | nt->Fill(fxnt);
|
---|
1021 | }
|
---|
1022 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
1023 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
1024 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
1025 | }
|
---|
1026 | }
|
---|
1027 | }
|
---|
1028 | CATCH(merr) {
|
---|
1029 | fflush(stdout);
|
---|
1030 | cout << endl;
|
---|
1031 | cerr << endl;
|
---|
1032 | string es = PeidaExc(merr);
|
---|
1033 | cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
|
---|
1034 | } ENDTRY;
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
1038 | // Fermeture du fichier .so
|
---|
1039 | CloseDLL();
|
---|
1040 | return;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 |
|
---|
1044 | /* --Methode-- */
|
---|
1045 | PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
|
---|
1046 | string& expz, string& expt, string& cut)
|
---|
1047 | {
|
---|
1048 | FILE *fip;
|
---|
1049 | string fname = TmpDir + "expf_pia_dl.c";
|
---|
1050 | string cmd;
|
---|
1051 | int rc;
|
---|
1052 |
|
---|
1053 | cmd = "rm -f " + fname;
|
---|
1054 | rc = system(cmd.c_str());
|
---|
1055 | //DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
1056 |
|
---|
1057 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
1058 | string sn = fname;
|
---|
1059 | cout << "Services2NObjMgr/LinkExprFunc_Error: fopen( " << sn << endl;
|
---|
1060 | return(NULL);
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | // constitution du fichier a compiler
|
---|
1064 | fputs("#include <stdlib.h> \n", fip);
|
---|
1065 | fputs("#include <math.h> \n", fip);
|
---|
1066 |
|
---|
1067 | fputs("/* ------ Some random number generators --------- */ \n", fip);
|
---|
1068 | fputs("#define frand01() ( (float) drand48() ) \n", fip);
|
---|
1069 | fputs("#define drand01() drand48() \n", fip);
|
---|
1070 | fputs("#define rand01() drand48() \n", fip);
|
---|
1071 | fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
|
---|
1072 | fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
1073 | fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
1074 | fputs("double NorRand(void) \n", fip);
|
---|
1075 | fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
|
---|
1076 | fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
|
---|
1077 | fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
|
---|
1078 | fputs(" return(x); \n } \n", fip);
|
---|
1079 | fputs("#define GauRand() NorRand() \n", fip);
|
---|
1080 | fputs("#define gaurand() NorRand() \n\n", fip);
|
---|
1081 |
|
---|
1082 | fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
|
---|
1083 | fprintf(fip,"%s \n", vardec.c_str());
|
---|
1084 | fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
|
---|
1085 | fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
|
---|
1086 | fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
|
---|
1087 | fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
|
---|
1088 | fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
|
---|
1089 | fputs("return(1); \n} \n", fip);
|
---|
1090 | fclose(fip);
|
---|
1091 | string func = "expf_pia_dl_func";
|
---|
1092 | return((PlotExprFunc)LinkFunctionFromFile(fname, func));
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 |
|
---|
1096 | /* --Methode-- */
|
---|
1097 | DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
|
---|
1098 | {
|
---|
1099 | // Le link dynamique
|
---|
1100 | CloseDLL();
|
---|
1101 | dynlink = PDynLinkMgr::BuildFromCFile(fname);
|
---|
1102 | if (dynlink == NULL) {
|
---|
1103 | cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
|
---|
1104 | return(NULL);
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | DlFunction retfunc = dynlink->GetFunction(funcname);
|
---|
1108 | if (retfunc == NULL) {
|
---|
1109 | string sn = funcname;
|
---|
1110 | cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
|
---|
1111 | CloseDLL();
|
---|
1112 | return(NULL);
|
---|
1113 | }
|
---|
1114 | else return(retfunc);
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | /* --Methode-- */
|
---|
1118 | void Services2NObjMgr::CloseDLL()
|
---|
1119 | {
|
---|
1120 | if (dynlink) delete dynlink; dynlink = NULL;
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | // Fonction static
|
---|
1124 | /* --Methode-- */
|
---|
1125 | void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
|
---|
1126 | {
|
---|
1127 | // Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies
|
---|
1128 | // sous forme i1[:i2[:di]]
|
---|
1129 | // cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di;
|
---|
1130 | size_t l = loop.length();
|
---|
1131 | if (l < 1) return;
|
---|
1132 | size_t p = loop.find(':');
|
---|
1133 | if (p >= l) { i1 = atoi(loop.c_str()); return; }
|
---|
1134 | i1 = atoi(loop.substr(0, p).c_str());
|
---|
1135 | string aa = loop.substr(p+1);
|
---|
1136 | p = aa.find(':');
|
---|
1137 | if (p < aa.length() ) {
|
---|
1138 | i2 = atoi(aa.substr(0,p).c_str());
|
---|
1139 | di = atoi(aa.substr(p+1).c_str());
|
---|
1140 | }
|
---|
1141 | else i2 = atoi(aa.c_str());
|
---|
1142 | // cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl;
|
---|
1143 | return;
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | /* --Methode-- */
|
---|
1147 | string Services2NObjMgr::FileName2Name(string const & fn)
|
---|
1148 | {
|
---|
1149 |
|
---|
1150 | char fsep[2] = {FILESEP, '\0'};
|
---|
1151 | char tsep[2] = {'.', '\0'};
|
---|
1152 | size_t p = fn.find_last_of(fsep);
|
---|
1153 | size_t l = fn.length();
|
---|
1154 | if (p >= l) p = 0;
|
---|
1155 | else p++;
|
---|
1156 | size_t q = fn.find_first_of(tsep,p);
|
---|
1157 | if (q < p) q = l;
|
---|
1158 | return(fn.substr(p,q-p));
|
---|
1159 | }
|
---|
1160 |
|
---|
1161 |
|
---|
1162 | typedef vector<string> GraTok;
|
---|
1163 |
|
---|
1164 | /* --Methode-- */
|
---|
1165 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
1166 | {
|
---|
1167 | int ropt = Disp_Next;
|
---|
1168 | if (!mImgapp) return(ropt);
|
---|
1169 |
|
---|
1170 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
1171 |
|
---|
1172 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
1173 |
|
---|
1174 | if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
|
---|
1175 | mImgapp->SetColAtt();
|
---|
1176 | mImgapp->SetLineAtt();
|
---|
1177 | mImgapp->SetFontAtt();
|
---|
1178 | mImgapp->SetMarkerAtt();
|
---|
1179 | mImgapp->SetColMapId();
|
---|
1180 | mImgapp->SetZoomAtt();
|
---|
1181 | mImgapp->SetAxesAtt();
|
---|
1182 | mImgapp->SetXYLimits();
|
---|
1183 | mImgapp->UseXYLimits();
|
---|
1184 | return(ropt);
|
---|
1185 | }
|
---|
1186 |
|
---|
1187 | // On separe en mots separes par des virgules
|
---|
1188 | gratt = ","+gratt;
|
---|
1189 | size_t p = 0;
|
---|
1190 | size_t q = 0;
|
---|
1191 | size_t l = gratt.length();
|
---|
1192 | string token;
|
---|
1193 |
|
---|
1194 | GraTok grt;
|
---|
1195 |
|
---|
1196 | while (q < l) {
|
---|
1197 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
1198 | if (p>=l) break;
|
---|
1199 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
1200 | token = gratt.substr(p,q-p);
|
---|
1201 | grt.push_back(token);
|
---|
1202 | }
|
---|
1203 |
|
---|
1204 |
|
---|
1205 | static GrAttNames::iterator it;
|
---|
1206 |
|
---|
1207 | int k;
|
---|
1208 | bool fgcont = true;
|
---|
1209 | fgsrgr = false;
|
---|
1210 |
|
---|
1211 | for(k=0; k<grt.size(); k++) {
|
---|
1212 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
1213 |
|
---|
1214 | // Decodage option affichage (win, next, etc
|
---|
1215 | fgcont = true;
|
---|
1216 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
1217 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
1218 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
1219 | else fgcont = false;
|
---|
1220 | if (fgcont) continue;
|
---|
1221 |
|
---|
1222 | // Utilisation limites X-Y
|
---|
1223 | if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
|
---|
1224 | // Si c'est une couleur
|
---|
1225 | it = GrAcolors.find(grt[k]);
|
---|
1226 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
1227 | // Si c'est un attribut de lignes
|
---|
1228 | it = GrAlines.find(grt[k]);
|
---|
1229 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
1230 | // Si c'est un attribut de fontes
|
---|
1231 | it = GrAfonts.find(grt[k]);
|
---|
1232 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
1233 | fgsrgr = true; continue; }
|
---|
1234 | // Si c'est un attribut de markers
|
---|
1235 | it = GrAmarkers.find(grt[k]);
|
---|
1236 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
1237 | fgsrgr = true; continue; }
|
---|
1238 | // Si c'est un colormap
|
---|
1239 | it = GrAcmap.find(grt[k]);
|
---|
1240 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
1241 | // Si c'est un facteur de zoom
|
---|
1242 | it = GrAzoom.find(grt[k]);
|
---|
1243 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
1244 | // Si c'est un attribut d'axe
|
---|
1245 | it = GrAaxes.find(grt[k]);
|
---|
1246 | if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
1247 |
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | return(ropt);
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 |
|
---|
1254 |
|
---|
1255 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
1256 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
1257 |
|
---|
1258 | /* --Methode-- */
|
---|
1259 | void Services2NObjMgr::InitGrAttNames()
|
---|
1260 | {
|
---|
1261 | gratt_item gi;
|
---|
1262 | // Les couleurs
|
---|
1263 | gi.a2 = 0;
|
---|
1264 | gi.a1 = PI_NotDefColor;
|
---|
1265 | GrAcolors["defcol"] = gi;
|
---|
1266 | gi.a1 = PI_Black;
|
---|
1267 | GrAcolors["black"] = gi;
|
---|
1268 | gi.a1 = PI_White;
|
---|
1269 | GrAcolors["white"] = gi;
|
---|
1270 | gi.a1 = PI_Grey;
|
---|
1271 | GrAcolors["grey"] = gi;
|
---|
1272 | gi.a1 = PI_Red;
|
---|
1273 | GrAcolors["red"] = gi;
|
---|
1274 | gi.a1 = PI_Blue;
|
---|
1275 | GrAcolors["blue"] = gi;
|
---|
1276 | gi.a1 = PI_Green;
|
---|
1277 | GrAcolors["green"] = gi;
|
---|
1278 | gi.a1 = PI_Yellow;
|
---|
1279 | GrAcolors["yellow"] = gi;
|
---|
1280 | gi.a1 = PI_Magenta;
|
---|
1281 | GrAcolors["magenta"] = gi;
|
---|
1282 |
|
---|
1283 | gi.a1 = PI_Cyan;
|
---|
1284 | GrAcolors["cyan"] = gi;
|
---|
1285 | gi.a1 = PI_Turquoise;
|
---|
1286 | GrAcolors["turquoise"] = gi;
|
---|
1287 | gi.a1 = PI_NavyBlue;
|
---|
1288 | GrAcolors["navyblue"] = gi;
|
---|
1289 | gi.a1 = PI_Orange;
|
---|
1290 | GrAcolors["orange"] = gi;
|
---|
1291 | gi.a1 = PI_SiennaRed;
|
---|
1292 | GrAcolors["siennared"] = gi;
|
---|
1293 | gi.a1 = PI_Purple;
|
---|
1294 | GrAcolors["purple"] = gi;
|
---|
1295 | gi.a1 = PI_LimeGreen;
|
---|
1296 | GrAcolors["limegreen"] = gi;
|
---|
1297 | gi.a1 = PI_Gold;
|
---|
1298 | GrAcolors["gold"] = gi;
|
---|
1299 |
|
---|
1300 | // Les attributs de lignes
|
---|
1301 | gi.a2 = 0;
|
---|
1302 | gi.a1 = PI_NotDefLineAtt;
|
---|
1303 | GrAlines["defline"] = gi;
|
---|
1304 | gi.a1 = PI_NormalLine;
|
---|
1305 | GrAlines["normalline"] = gi;
|
---|
1306 | gi.a1 = PI_ThinLine;
|
---|
1307 | GrAlines["thinline"] = gi;
|
---|
1308 | gi.a1 = PI_ThickLine;
|
---|
1309 | GrAlines["thickline"] = gi;
|
---|
1310 | gi.a1 = PI_DashedLine;
|
---|
1311 | GrAlines["dashedline"] = gi;
|
---|
1312 | gi.a1 = PI_ThinDashedLine;
|
---|
1313 | GrAlines["thindashedline"] = gi;
|
---|
1314 | gi.a1 = PI_ThickDashedLine;
|
---|
1315 | GrAlines["thickdashedline"] = gi;
|
---|
1316 | gi.a1 = PI_DottedLine;
|
---|
1317 | GrAlines["dottedline"] = gi;
|
---|
1318 | gi.a1 = PI_ThinDottedLine;
|
---|
1319 | GrAlines["thindottedline"] = gi;
|
---|
1320 | gi.a1 = PI_ThickDottedLine;
|
---|
1321 | GrAlines["thickdottedline"] = gi;
|
---|
1322 |
|
---|
1323 | // Les fontes
|
---|
1324 | gi.a2 = PI_NotDefFontSize;
|
---|
1325 | gi.a1 = PI_NotDefFontAtt;
|
---|
1326 | GrAfonts["deffont"] = gi;
|
---|
1327 |
|
---|
1328 | gi.a2 = PI_NormalSizeFont;
|
---|
1329 | gi.a1 = PI_RomanFont;
|
---|
1330 | GrAfonts["normalfont"] = gi;
|
---|
1331 | gi.a1 = PI_BoldFont;
|
---|
1332 | GrAfonts["boldfont"] = gi;
|
---|
1333 | gi.a1 = PI_ItalicFont;
|
---|
1334 | GrAfonts["italicfont"] = gi;
|
---|
1335 | gi.a2 = PI_SmallSizeFont;
|
---|
1336 | gi.a1 = PI_RomanFont;
|
---|
1337 | GrAfonts["smallfont"] = gi;
|
---|
1338 | gi.a1 = PI_BoldFont;
|
---|
1339 | GrAfonts["smallboldfont"] = gi;
|
---|
1340 | gi.a1 = PI_ItalicFont;
|
---|
1341 | GrAfonts["smallitalicfont"] = gi;
|
---|
1342 | gi.a2 = PI_BigSizeFont;
|
---|
1343 | gi.a1 = PI_RomanFont;
|
---|
1344 | GrAfonts["bigfont"] = gi;
|
---|
1345 | gi.a1 = PI_BoldFont;
|
---|
1346 | GrAfonts["bigboldfont"] = gi;
|
---|
1347 | gi.a1 = PI_ItalicFont;
|
---|
1348 | GrAfonts["bigitalicfont"] = gi;
|
---|
1349 | gi.a2 = PI_HugeSizeFont;
|
---|
1350 | gi.a1 = PI_RomanFont;
|
---|
1351 | GrAfonts["hugefont"] = gi;
|
---|
1352 | gi.a1 = PI_BoldFont;
|
---|
1353 | GrAfonts["hugeboldfont"] = gi;
|
---|
1354 | gi.a1 = PI_ItalicFont;
|
---|
1355 | GrAfonts["hugeitalicfont"] = gi;
|
---|
1356 |
|
---|
1357 |
|
---|
1358 | // Les markers
|
---|
1359 | const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
1360 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
1361 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
1362 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
1363 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
1364 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
1365 |
|
---|
1366 | gi.a2 = 0;
|
---|
1367 | gi.a1 = PI_NotDefMarker;
|
---|
1368 | GrAmarkers["defmarker"] = gi;
|
---|
1369 |
|
---|
1370 | for(int j=0; j<11; j++) {
|
---|
1371 | string smrk;
|
---|
1372 | char buff[16];
|
---|
1373 | for(int m=1; m<10; m+=2) {
|
---|
1374 | sprintf(buff,"%d",m);
|
---|
1375 | smrk = (string)mrkn[j] + (string)buff;
|
---|
1376 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
1377 | GrAmarkers[smrk] = gi;
|
---|
1378 | }
|
---|
1379 | }
|
---|
1380 |
|
---|
1381 | // Les tables de couleurs
|
---|
1382 | gi.a2 = 0;
|
---|
1383 | gi.a1 = CMAP_OTHER;
|
---|
1384 | GrAcmap["defcmap"] = gi;
|
---|
1385 | gi.a1 = CMAP_GREY32;
|
---|
1386 | GrAcmap["grey32"] = gi;
|
---|
1387 | gi.a1 = CMAP_GREYINV32;
|
---|
1388 | GrAcmap["greyinv32"] = gi;
|
---|
1389 | gi.a1 = CMAP_COLRJ32;
|
---|
1390 | GrAcmap["colrj32"] = gi;
|
---|
1391 | gi.a1 = CMAP_COLBR32;
|
---|
1392 | GrAcmap["colbr32"] = gi;
|
---|
1393 | gi.a1 = CMAP_GREY128;
|
---|
1394 | GrAcmap["grey128"] = gi;
|
---|
1395 | gi.a1 = CMAP_GREYINV128;
|
---|
1396 | GrAcmap["greyinv128"] = gi;
|
---|
1397 | gi.a1 = CMAP_COLRJ128;
|
---|
1398 | GrAcmap["colrj128"] = gi;
|
---|
1399 | gi.a1 = CMAP_COLBR128;
|
---|
1400 | GrAcmap["colbr128"] = gi;
|
---|
1401 |
|
---|
1402 | // La valeur de zoom
|
---|
1403 | gi.a2 = 0;
|
---|
1404 | gi.a1 = 0;
|
---|
1405 | GrAzoom["defzoom"] = gi;
|
---|
1406 | gi.a1 = 1;
|
---|
1407 | GrAzoom["zoomx1"] = gi;
|
---|
1408 | gi.a1 = 2;
|
---|
1409 | GrAzoom["zoomx2"] = gi;
|
---|
1410 | gi.a1 = 3;
|
---|
1411 | GrAzoom["zoomx3"] = gi;
|
---|
1412 | gi.a1 = 4;
|
---|
1413 | GrAzoom["zoomx4"] = gi;
|
---|
1414 | gi.a1 = 5;
|
---|
1415 | GrAzoom["zoomx5"] = gi;
|
---|
1416 | gi.a1 = -2;
|
---|
1417 | GrAzoom["zoom/2"] = gi;
|
---|
1418 | gi.a1 = -3;
|
---|
1419 | GrAzoom["zoom/3"] = gi;
|
---|
1420 | gi.a1 = -4;
|
---|
1421 | GrAzoom["zoom/4"] = gi;
|
---|
1422 | gi.a1 = -5;
|
---|
1423 | GrAzoom["zoom/5"] = gi;
|
---|
1424 |
|
---|
1425 | // Attributs d'axes
|
---|
1426 | gi.a2 = 0;
|
---|
1427 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
|
---|
1428 | GrAaxes["stdaxes"] = gi;
|
---|
1429 | GrAaxes["defaxes"] = gi;
|
---|
1430 | GrAaxes["boxaxes"] = gi;
|
---|
1431 | gi.a1 = (int)kAxesDflt;
|
---|
1432 | GrAaxes["simpleaxes"] = gi;
|
---|
1433 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
|
---|
1434 | GrAaxes["boxaxesgrid"] = gi;
|
---|
1435 |
|
---|
1436 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
|
---|
1437 | GrAaxes["fineaxes"] = gi;
|
---|
1438 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
|
---|
1439 | GrAaxes["grid"] = gi;
|
---|
1440 | GrAaxes["fineaxesgrid"] = gi;
|
---|
1441 |
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 |
|
---|
1445 | // SANS_EVOLPLANCK Attention !
|
---|
1446 | #include "pclassids.h"
|
---|
1447 |
|
---|
1448 | /* --Methode-- */
|
---|
1449 | char* Services2NObjMgr::PClassIdToClassName(int cid)
|
---|
1450 | {
|
---|
1451 | switch (cid) {
|
---|
1452 | case ClassId_Poly1 :
|
---|
1453 | return("Poly1");
|
---|
1454 | case ClassId_Poly2 :
|
---|
1455 | return("Poly2");
|
---|
1456 | case ClassId_Matrix :
|
---|
1457 | return("Matrix");
|
---|
1458 | case ClassId_Vector :
|
---|
1459 | return("Vector");
|
---|
1460 |
|
---|
1461 | case ClassId_DVList :
|
---|
1462 | return("DVList");
|
---|
1463 |
|
---|
1464 | case ClassId_Histo1D :
|
---|
1465 | return("Histo1D");
|
---|
1466 | case ClassId_Histo2D :
|
---|
1467 | return("Histo2D");
|
---|
1468 | case ClassId_HProf :
|
---|
1469 | return("HProf");
|
---|
1470 | case ClassId_NTuple :
|
---|
1471 | return("NTuple");
|
---|
1472 | case ClassId_XNTuple :
|
---|
1473 | return("XNTuple");
|
---|
1474 | case ClassId_GeneralFitData :
|
---|
1475 | return("GeneralFitData");
|
---|
1476 |
|
---|
1477 | case ClassId_Image :
|
---|
1478 | return("RzImage");
|
---|
1479 | case ClassId_Image + kuint_1 :
|
---|
1480 | return("ImageU1");
|
---|
1481 | case ClassId_Image + kint_1 :
|
---|
1482 | return("ImageI1");
|
---|
1483 | case ClassId_Image + kuint_2 :
|
---|
1484 | return("ImageU2");
|
---|
1485 | case ClassId_Image + kint_2 :
|
---|
1486 | return("ImageI2");
|
---|
1487 | case ClassId_Image + kuint_4 :
|
---|
1488 | return("ImageU4");
|
---|
1489 | case ClassId_Image + kint_4 :
|
---|
1490 | return("ImageI4");
|
---|
1491 | case ClassId_Image + kr_4 :
|
---|
1492 | return("ImageR4");
|
---|
1493 | case ClassId_Image + kr_8 :
|
---|
1494 | return("ImageR8");
|
---|
1495 |
|
---|
1496 | case ClassId_ZFidu :
|
---|
1497 | return("ZFidu");
|
---|
1498 |
|
---|
1499 | case ClassId_StarList :
|
---|
1500 | return("StarList");
|
---|
1501 | case ClassId_Transfo :
|
---|
1502 | return("Transfo");
|
---|
1503 | case ClassId_PSF :
|
---|
1504 | return("PSF");
|
---|
1505 |
|
---|
1506 |
|
---|
1507 | // - Ajout objet PPF
|
---|
1508 | default:
|
---|
1509 | return("AnyDataObj");
|
---|
1510 | }
|
---|
1511 | }
|
---|
1512 |
|
---|