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