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