source: Sophya/trunk/SophyaPI/PIext/basexecut.cc@ 3123

Last change on this file since 3123 was 3123, checked in by cmv, 19 years ago

modif HistoErr Histo2DErr cmv 10/01/07

File size: 52.6 KB
Line 
1#include "sopnamsp.h"
2#include "piacmd.h"
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <math.h>
7
8#include "basexecut.h"
9
10#include "pdlmgr.h"
11#include "ctimer.h"
12#include "strutilxx.h"
13
14#include "pistdimgapp.h"
15#include "nobjmgr.h"
16#include "servnobjm.h"
17#include "nomgadapter.h"
18
19#include "histos.h"
20#include "histos2.h"
21#include "hisprof.h"
22#include "ntuple.h"
23#include "generaldata.h"
24#include "datatable.h"
25
26#ifdef SANS_EVOLPLANCK
27#include "cvector.h"
28#else
29#include "tvector.h"
30#endif
31
32
33/* --Methode-- */
34PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
35{
36mpiac = piac;
37mObjMgr = omg;
38mImgApp = app;
39dynlink = NULL;
40dynlink2 = NULL;
41RegisterCommands();
42}
43
44PIABaseExecutor::~PIABaseExecutor()
45{
46 if (dynlink) delete dynlink;
47 if (dynlink2) delete dynlink2;
48}
49
50
51
52/* --Methode-- */
53int PIABaseExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
54{
55Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
56// >>>>> Chargement de modules
57if (kw == "loadmodule") {
58 if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl; return(0); }
59 mpiac->LoadModule(tokens[0], tokens[1]);
60 }
61
62// >>>>>>>>>>> Link dynamique de fonctions C++
63else if (kw == "link" ) {
64 if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl; return(0); }
65 string sph = "";
66 for(int gg=0; gg<5; gg++) tokens.push_back(sph);
67 int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
68 if (rc == 0) cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
69}
70else if (kw == "linkff2" ) {
71 if (tokens.size() < 2) { cout << "Usage: linkff2 fnameso f1 [f2 f3]" << endl; return(0); }
72 string sph = "";
73 for(int gg=0; gg<5; gg++) tokens.push_back(sph);
74 int rc = LinkUserFuncs2(tokens[0], tokens[1], tokens[2], tokens[3]);
75 if (rc == 0) cout << "PIABaseExecutor: Link2 from " << tokens[0] << " OK " << endl;
76}
77else if (kw == "call" ) {
78 if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); }
79 UsFmap::iterator it;
80 UsFmap::iterator it1 = usfmap.find(tokens[0]);
81 UsFmap::iterator it2 = usfmap2.find(tokens[0]);
82 if ((it1 == usfmap.end()) && (it2 == usfmap2.end()) ) {
83 cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
84 return(0);
85 }
86 if (it1 == usfmap.end()) it = it2;
87 else it = it1;
88 cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
89// on est oblige de faire un cast etant donne qu'on
90// utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
91 DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
92/*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004
93// On redirige la sortie sur le terminal
94 bool red = mImgApp->HasRedirectedStdOutErr();
95 mImgApp->RedirectStdOutErr(false);
96 --------DEL */
97#ifdef SANS_EVOLPLANCK
98 TRY {
99 tokens.erase(tokens.begin());
100 fuf(tokens);
101 } CATCH(merr) {
102 fflush(stdout);
103 string es = PeidaExc(merr);
104 cerr << "\n PIABaseExecutor: Call UserFunc Exception :" << merr << es;
105 cout << endl;
106 }
107#else
108 try {
109 tokens.erase(tokens.begin());
110 fuf(tokens);
111 return(0);
112 }
113 catch ( PThrowable & exc ) {
114 cerr << "\n PIABaseExecutor: Call / Catched Exception :"
115 << (string)typeid(exc).name() << " Msg= "
116 << exc.Msg() << endl;
117 return(-77);
118 }
119 catch ( ... ) {
120 cerr << "\n PIABaseExecutor: Call / Catched Exception ... "
121 << endl;
122 return(-79);
123 }
124#endif
125/*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004
126 mImgApp->RedirectStdOutErr(red);
127 --------DEL */
128}
129
130else if (kw == "openppf" ) {
131 if (tokens.size()<1) {cout<<"Usage: openppf file [objname1 objname2 ...]"<<endl; return(0); }
132 else if (tokens.size()==1) mObjMgr->ReadAll(tokens[0]);
133 else mObjMgr->ReadObj(tokens);
134}
135else if ((kw == "saveobjs") || (kw == "saveppf")) {
136 if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
137 mObjMgr->SaveObjects(tokens[0], tokens[1]);
138}
139else if (kw == "savelist") {
140 if (tokens.size() < 2) {
141 cout << "Usage: savelist objname1 [objname2 ...] filename "<<endl;
142 return(0);
143 }
144 mObjMgr->SaveListObjects(tokens);
145}
146else if (kw == "saveall" ) {
147 if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
148 mObjMgr->SaveAll(tokens[0]);
149}
150else if (kw == "print" ) {
151 if (tokens.size() < 1) { cout << "Usage: print nameobj [prtlev]" << endl; return(0); }
152 int lev = 0;
153 if (tokens.size()>1) lev = atoi(tokens[1].c_str());
154 mObjMgr->PrintObj(tokens[0], lev);
155}
156else if ( (kw == "rename" ) || (kw == "mv") ) {
157 if (tokens.size() < 2) { cout << "Usage: rename/mv nameobj namenew" << endl; return(0); }
158 mObjMgr->RenameObj(tokens[0], tokens[1]);
159}
160else if ( (kw == "del" ) || (kw == "rm") ) {
161 if (tokens.size() < 1) { cout << "Usage: del nameobj [nameobj2 ...]" << endl; return(0); }
162 if (tokens.size()>0)
163 for(uint_4 i=0;i<tokens.size();i++) mObjMgr->DelObj(tokens[i]);
164}
165else if (kw == "delobjs" ) {
166 if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
167 mObjMgr->DelObjects(tokens[0]);
168}
169else if ( (kw == "listobjs") || (kw == "ls") ) {
170 if (tokens.size() < 1) tokens.push_back("*");
171 if (tokens.size() < 2) mObjMgr->ListObjs(tokens[0]);
172 else {
173 vector<string> olv;
174 mObjMgr->GetObjList(tokens[0], olv);
175 mpiac->SetVar(tokens[1], olv);
176 }
177}
178
179// Gestion des repertoires
180else if (kw == "mkdir" ) {
181 if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); }
182 bool crd = mObjMgr->CreateDir(tokens[0]);
183 if ( crd && (tokens.size() > 1) && (tokens[1] == "true") )
184 mObjMgr->SetKeepOldDirAtt(tokens[0], true);
185 }
186else if (kw == "rmdir" ) {
187 if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
188 mObjMgr->DeleteDir(tokens[0]);
189 }
190else if (kw == "setdiratt" ) {
191 if (tokens.size() < 2) { cout << "Usage: setdiratt dirname true/false" << endl; return(0); }
192 if (tokens[1] == "true") mObjMgr->SetKeepOldDirAtt(tokens[0], true);
193 else mObjMgr->SetKeepOldDirAtt(tokens[0], false);
194}
195else if (kw == "cd") {
196 if (tokens.size() < 1) tokens.push_back("home");
197 mObjMgr->SetCurrentDir(tokens[0]);
198 }
199else if (kw == "pwd") {
200 string dirn;
201 mObjMgr->GetCurrentDir(dirn);
202 cout << "CurrentDirectory: " << dirn << endl;
203 }
204else if (kw == "listdirs") {
205 if (tokens.size() < 1) tokens.push_back("*");
206 mObjMgr->ListDirs(tokens[0]);
207 }
208
209// >>>>>>>>>>> Creation d'histos 1D-2D
210else if (kw == "newh1d") {
211 if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
212 int_4 nbx = 100;
213 r_8 xmin = 0., xmax = 1.;
214 nbx = atoi(tokens[3].c_str());
215 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
216 Histo* h = new Histo(xmin, xmax, nbx);
217 mObjMgr->AddObj(h, tokens[0]);
218 }
219else if (kw == "newh2d") {
220 if (tokens.size() < 7) {
221 cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl;
222 return(0);
223 }
224 int_4 nbx = 50, nby = 50;
225 r_8 xmin = 0., xmax = 1.;
226 r_8 ymin = 0., ymax = 1.;
227 nbx = atoi(tokens[3].c_str());
228 nby = atoi(tokens[6].c_str());
229 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
230 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
231 Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
232 mObjMgr->AddObj(h, tokens[0]);
233 }
234else if (kw == "newprof" || kw == "newprofe") {
235 if (tokens.size() < 4)
236 { cout << "Usage: newprof[e] name xmin xmax nbin [ymin ymax]" << endl; return(0); }
237 int_4 nbx = 100;
238 r_8 xmin = 0., xmax = 1., ymin = 1., ymax = -1.;
239 if(tokens.size() > 5)
240 {ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());}
241 nbx = atoi(tokens[3].c_str());
242 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
243 HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
244 if(kw == "newprofe") h->SetErrOpt(false);
245 mObjMgr->AddObj(h, tokens[0]);
246 }
247
248// Creation de NTuple
249else if (kw == "newnt") {
250 if(tokens.size() < 2)
251 {cout<<"Usage: newnt name v1 v2 ... vn / newnt name nvar"<<endl; return(0);}
252 vector<string> varname;
253 int nvar = 0;
254 const char *c = tokens[1].c_str();
255 if(isdigit(c[0])) {
256 nvar = atoi(tokens[1].c_str());
257 if(nvar<=0 || nvar>=10000)
258 {cout<<"newnt name nvar : nvar must be an positive integer<10000"<<endl;
259 return(0);}
260 for(int i=0;i<nvar;i++) {
261 char str[16]; sprintf(str,"%d",i);
262 string dum = "v"; dum += str;
263 varname.push_back(dum.c_str());
264 }
265 } else if( islower(c[0]) || isupper(c[0]) ) {
266 for(int i=1;i<(int)tokens.size();i++) {
267 varname.push_back(tokens[i].c_str());
268 nvar++;
269 }
270 } else {
271 cout<<"newnt name v1 v2 ... vn : name vi must begin by a letter"<<endl
272 <<"newnt name nvar : nvar must be an positive integer"<<endl;
273 return(0);
274 }
275 char **noms = new char*[nvar];
276 for(int i=0;i<nvar;i++) noms[i] = (char *)varname[i].c_str();
277 NTuple* nt = new NTuple(nvar,noms);
278 delete [] noms;
279 mObjMgr->AddObj(nt,tokens[0]);
280 }
281
282// Creation de DataTable
283else if (kw == "newdt") {
284 if(tokens.size() < 2)
285 {cout<<"Usage: newdt name v1:t1 v2:t2 ... vn:tn / newdt name nvar"<<endl; return(0);}
286 DataTable* dt = new DataTable();
287 const char *c = tokens[1].c_str();
288 if(isdigit(c[0])) {
289 int n = atoi(tokens[1].c_str());
290 if(n<=0 || n>=10000) {
291 cout<<"newdt name nvar : nvar="<<n<<" must be an positive integer<10000"<<endl;
292 delete dt; return(0);
293 }
294 for(int i=0;i<n;i++) {
295 char str[16]; sprintf(str,"v%d",i);
296 dt->AddDoubleColumn(str);
297 }
298 } else {
299 for(int i=1;i<tokens.size();i++) {
300 string vname = tokens[i];
301 uint_4 p = tokens[i].find(':');
302 if(p<tokens[i].size()) vname = vname.substr(0,p);
303 if(vname.size()<1) {
304 cout<<"Zero size name for variable: tokens["<<i<<"]="<<tokens[i]<<endl;
305 delete dt; return(0);
306 }
307 if (tokens[i].find(":r4")<tokens[i].size()) dt->AddFloatColumn(vname);
308 else if(tokens[i].find(":r8")<tokens[i].size()) dt->AddDoubleColumn(vname);
309 else if(tokens[i].find(":i4")<tokens[i].size()) dt->AddIntegerColumn(vname);
310 else if(tokens[i].find(":i8")<tokens[i].size()) dt->AddLongColumn(vname);
311 else if(tokens[i].find(":s") <tokens[i].size()) dt->AddStringColumn(vname);
312 else dt->AddDoubleColumn(vname);
313 }
314 }
315 mObjMgr->AddObj(dt,tokens[0]);
316}
317
318// Creation de GeneralFitData
319else if (kw == "newgfd") {
320 if (tokens.size() < 3)
321 { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
322 int nvar, nalloc, errx=0;
323 if (tokens.size() > 3)
324 { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
325 nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
326 if(nvar>0 && nalloc>0) {
327 GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
328 mObjMgr->AddObj(gfd, tokens[0]);
329 }
330 }
331
332// Creation/remplissage de vecteur et de matrice
333else if (kw == "newvec") {
334 if (tokens.size() < 2) {
335 cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0);
336 }
337 int n = atoi(tokens[1].c_str());
338 double xmin, xmax;
339 xmin = 0.; xmax = n;
340 if (tokens.size() < 3) {
341 Vector* v = new Vector(n);
342 mObjMgr->AddObj(v, tokens[0]);
343 }
344 else {
345 if (tokens.size() < 4) tokens.push_back("");
346 mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]);
347 }
348 }
349else if (kw == "newmtx") {
350 if (tokens.size() < 3) {
351 cout << "Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) dopt] " << endl; return(0);
352 }
353 int nx = atoi(tokens[1].c_str());
354 int ny = atoi(tokens[2].c_str());
355 double xmin, xmax, ymin, ymax;
356 xmin = 0.; xmax = nx;
357 ymin = 0.; ymax = ny;
358 if (tokens.size() < 4) {
359 Matrix* mtx = new Matrix(ny,nx);
360 mObjMgr->AddObj(mtx, tokens[0]);
361 }
362 else {
363 if (tokens.size() < 5) tokens.push_back("next");
364 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
365 nx, ny, tokens[4]);
366 }
367 }
368// ----- Vecteur/NTuple <> Lignes/variables interpreteur
369// Creation de vecteur depuis le contenu de la ligne
370else if (kw == "line2vec") {
371 if (tokens.size() < 2) {
372 cout << "Usage: line2vec vecname v0 v1 v2 ... " << endl; return(0);
373 }
374 int vsz = tokens.size()-1;
375 Vector* v = new Vector(vsz);
376 for(int kkv=0; kkv<vsz; kkv++) (*v)(kkv) = atof(tokens[kkv+1].c_str());
377 mObjMgr->AddObj(v, tokens[0]);
378 }
379// Remplissage de NTuple depuis la ligne
380else if (kw == "line2nt") {
381 if (tokens.size() < 2) {
382 cout << "Usage: line2nt ntname col0 col1 ..." << endl; return(0);
383 }
384 AnyDataObj* obj;
385 obj = mObjMgr->GetObj(tokens[0]);
386 if(obj == NULL) {
387 cerr << "line2nt Error , No such object " << tokens[0] << endl;
388 return(0);
389 }
390 NTuple* nt = dynamic_cast<NTuple *>(obj);
391 if(nt == NULL) {
392 cerr << "line2nt Error " << tokens[0] << " not an NTuple ! " << endl;
393 return(0);
394 }
395 if (nt->NbColumns() < 1) {
396 cerr << "line2nt Error: NbColumns < 1" << endl;
397 return(0);
398 }
399 r_4* xnt = new r_4[ nt->NbColumns() ];
400 int kkx;
401 for(kkx=0; kkx<nt->NbColumns(); kkx++) {
402 if (kkx < tokens.size()-1) xnt[kkx] = atof(tokens[kkx+1].c_str());
403 else xnt[kkx] = 0.;
404 }
405 nt->Fill(xnt);
406 delete[] xnt;
407}
408// Contenu du vecteur vers variable interpreteur
409#define MAXNWORDSO2V 32768
410else if (kw == "vec2var") {
411 if (tokens.size() < 2) {
412 cout << "Usage: vec2var vecname varname [loop_param start:end:step] " << endl; return(0);
413 }
414 AnyDataObj* obj;
415 obj = mObjMgr->GetObj(tokens[0]);
416 if(obj == NULL) {
417 cerr << "vec2var Error , No such object " << tokens[0] << endl;
418 return(0);
419 }
420 Vector* v = dynamic_cast<Vector *>(obj);
421 if(v == NULL) {
422 cerr << "vec2var Error " << tokens[0] << " not a Vector ! " << endl;
423 return(0);
424 }
425 int_8 kks = 0;
426 int_8 kke = v->NElts();
427 int_8 kkp = 1;
428 if (tokens.size() > 2) Services2NObjMgr::DecodeLoopParameters(tokens[2], kks, kke, kkp);
429 if (kks < 0) kks = 0;
430 if (kke > (int_8)v->NElts()) kke = v->NElts();
431 if (kkp < 1) kkp = 1;
432 int nelt = (kke-kks-1)/kkp;
433 if (nelt > MAXNWORDSO2V) {
434 nelt = MAXNWORDSO2V;
435 cout << "vec2var Warning: Only " << nelt
436 << " elements will be converted to string" << endl;
437 kke = kks+nelt*kkp;
438 }
439 string v2str;
440 char buff[64];
441 for(int kkv=kks; kkv<kke; kkv+=kkp) {
442 sprintf(buff, "%lg ", (*v)(kkv));
443 v2str += buff;
444 }
445
446 mpiac->SetVar(tokens[1], v2str);
447}
448// Une ligne du NTuple/NTupleInterface -> variable interpreteur
449else if ((kw == "ntline2var") || (kw == "ntcol2var")) {
450 if (tokens.size() < 3) {
451 cout << "Usage: ntline/col2var objname line_number varname" << endl;
452 return(0);
453 }
454 NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]);
455 if(oa == NULL) {
456 cerr << "ntline/col2var Error , No such object " << tokens[0] << endl;
457 return(0);
458 }
459 bool adel = false;
460 NTupleInterface* nti = oa->GetNTupleInterface(adel);
461 if(nti == NULL) {
462 cerr << "ntline/col2var Error: objet" << tokens[0] << " has no NTupleInterface" << endl;
463 return(0);
464 }
465
466 if (nti->NbColumns() < 1 || nti->NbLines() < 1) {
467 cerr << "ntline/col2var Error: NbColumns or NbLines < 1" << endl;
468 return(0);
469 }
470 string v2str;
471 char buff[64];
472 if (kw == "ntline2var") {
473 int numline = atoi(tokens[1].c_str());
474 if ( (numline >= nti->NbLines()) || (numline < 0) ) {
475 cerr << "ntline2var Error: numline" << tokens[1] << " out of bounds" << endl;
476 return(0);
477 }
478 r_8* dline = nti->GetLineD(numline);
479 for(int kkv=0; kkv<nti->NbColumns(); kkv++) {
480 sprintf(buff, "%lg ", dline[kkv]);
481 v2str += buff;
482 }
483 }
484 else {
485 int numcol = atoi(tokens[1].c_str());
486 if ( (numcol >= nti->NbColumns()) || (numcol < 0) ) {
487 cerr << "ntcol2var Error: numcol" << tokens[1] << " out of bounds" << endl;
488 return(0);
489 }
490 int_8 kks = 0;
491 int_8 kke = nti->NbLines();
492 int_8 kkp = 1;
493 if (tokens.size() > 3) Services2NObjMgr::DecodeLoopParameters(tokens[3], kks, kke, kkp);
494 if (kks < 0) kks = 0;
495 if (kke > (int_8)nti->NbLines()) kke = nti->NbLines();
496 if (kkp < 1) kkp = 1;
497 int nelt = (kke-kks-1)/kkp;
498 if (nelt > MAXNWORDSO2V) {
499 nelt = MAXNWORDSO2V;
500 cout << "ntcol2var Warning: Only " << nelt
501 << " lines " << " will be converted to string" << endl;
502 kke = kks+nelt*kkp;
503 }
504 r_8* dline;
505 for(int kkl=kks; kkl<kke; kkl+=kkp) {
506 dline = nti->GetLineD(kkl);
507 sprintf(buff, "%lg ", dline[numcol]);
508 v2str += buff;
509 }
510 }
511 mpiac->SetVar(tokens[2], v2str);
512 if (adel) delete nti;
513}
514// Operation sur objets a travers l'adaptateur NObjMgrAdapter::PerformOperation()
515else if (kw == "objaoper") {
516 if (tokens.size() < 2) {
517 cout << "Usage: objaoper objname operation [args ...]" << endl;
518 return(0);
519 }
520 NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]);
521 if(oa == NULL) {
522 cerr << "objaoper Error , No such object " << tokens[0] << endl;
523 return(0);
524 }
525 tokens.erase(tokens.begin());
526 return oa->PerformOperation(tokens);
527}
528
529// -------------------------------------------------------
530// Copie d'objets
531else if ( (kw == "copy") || (kw == "cp") ) {
532 if(tokens.size()<2) {
533 cout<<"Usage: copy name_from name_to"<<endl;return(0);
534 }
535 mObjMgr->CopyObj(tokens[0],tokens[1]);
536}
537
538
539// >>>>>>>>>>> Trace de fonctions
540else if ( (kw == "func") ) {
541 if(tokens.size()<3) {cout<<"Usage: func f(x) xmin xmax [npt opt]"<<endl; return(0);}
542 int np = 100;
543 double xmin=0., xmax=1.;
544 string opt = "", nom = "";
545 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
546 if (tokens.size() > 3) np = atoi(tokens[3].c_str());
547 if (tokens.size() > 4) opt = tokens[4];
548 mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt);
549 }
550else if ( (kw == "funcff") ) {
551 if (tokens.size()<4) {cout<<"Usage: funcff C-filename f(x)-name xmin xmax [npt opt]"<<endl; return(0);}
552 int np = 100;
553 double xmin=0., xmax=1.;
554 string opt = "", nom = "";
555 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
556 if(tokens.size()>4) np = atoi(tokens[4].c_str());
557 if(tokens.size()>5) opt = tokens[5];
558 mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt);
559 }
560else if ( (kw == "func2d") ) {
561 if (tokens.size() < 7) {
562 cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [opt]" << endl;
563 return(0);
564 }
565 int npx, npy;
566 double xmin, xmax;
567 double ymin, ymax;
568 npx = npy = 50;
569 xmin = 0.; xmax = 1.;
570 ymin = 0.; ymax = 1.;
571 npx = atoi(tokens[3].c_str());
572 npy = atoi(tokens[6].c_str());
573 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
574 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
575 string opt = "";
576 if (tokens.size() > 7) opt = tokens[7];
577 string nom = "";
578 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
579 }
580else if ( (kw == "func2dff") ) {
581 if (tokens.size() < 8) {
582 cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty [opt]" << endl;
583 return(0);
584 }
585 int npx, npy;
586 double xmin, xmax;
587 double ymin, ymax;
588 npx = npy = 50;
589 xmin = 0.; xmax = 1.;
590 ymin = 0.; ymax = 1.;
591 npx = atoi(tokens[4].c_str());
592 npy = atoi(tokens[7].c_str());
593 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
594 ymin = atof(tokens[5].c_str()); ymax = atof(tokens[6].c_str());
595 string opt = "";
596 if (tokens.size() > 8) opt = tokens[8];
597 string nom = "";
598 mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
599 }
600
601// >>>>>>>>>>> Trace d'expressions de N_Tuple, StarList, etc ...
602else if (kw == "plot2d" ) {
603 if (tokens.size() < 3) {
604 cout << "Usage: plot2d nameobj expx expy [expcut opt loop_par]" << endl;
605 return(0);
606 }
607 string errx = ""; string erry = "";
608 if (tokens.size() < 4) tokens.push_back("1");
609 while (tokens.size() < 6) tokens.push_back("");
610 srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,tokens[3],tokens[4],tokens[5]);
611 }
612
613else if (kw == "plot2de" ) { // Plot2D avec les erreurs
614 if (tokens.size() < 5) {
615 cout << "Usage: plot2de nameobj expx expy experrx experry [expcut opt loop_par]" << endl;
616 return(0);
617 }
618 if (tokens.size() < 6) tokens.push_back("1");
619 while (tokens.size() < 8) tokens.push_back("");
620 srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4],
621 tokens[5],tokens[6],tokens[7]);
622 }
623
624else if (kw == "plot2dw" ) { // Plot2d avec poids
625 if (tokens.size() < 4) {
626 cout << "Usage: plot2dw nomobj expx expy expwt [expcut opt loop_par]" << endl;
627 return(0);
628 }
629 if (tokens.size() < 5) tokens.push_back("1");
630 while (tokens.size() < 7) tokens.push_back("");
631 srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
632 }
633else if (kw == "plot3d" ) {
634 if (tokens.size() < 4) {
635 cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl;
636 return(0);
637 }
638 if (tokens.size() < 5) tokens.push_back("1");
639 while (tokens.size() < 7) tokens.push_back("");
640 srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
641 }
642else if (kw == "plot3dw" ) {
643 if (tokens.size() < 5) {
644 cout << "Usage: plot3dw nomobj expx expy expz expwt [expcut opt loop_par]" << endl;
645 return(0);
646 }
647 if (tokens.size() < 6) tokens.push_back("1");
648 while (tokens.size() < 8) tokens.push_back("");
649 srvo->DisplayPoints3DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5],
650 tokens[6], tokens[7]);
651}
652
653else if (kw == "projh1d" ) {
654 if (tokens.size() < 3) {
655 cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl;
656 return(0);
657 }
658 if (tokens.size() < 4) tokens.push_back("1.");
659 if (tokens.size() < 5) tokens.push_back("1");
660 while (tokens.size() < 7) tokens.push_back("");
661 srvo->ProjectH1(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
662 }
663
664
665// Projection dans histogrammes
666else if (kw == "projh2d" ) {
667 if (tokens.size() < 4) {
668 cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl;
669 return(0);
670 }
671 if (tokens.size() < 5) tokens.push_back("1.");
672 if (tokens.size() < 6) tokens.push_back("1");
673 while (tokens.size() < 8) tokens.push_back("");
674 srvo->ProjectH2(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
675 tokens[6], tokens[7] );
676 }
677
678else if (kw == "projprof" ) {
679 if (tokens.size() < 4) {
680 cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl;
681 return(0);
682 }
683 if (tokens.size() < 5) tokens.push_back("1.");
684 if (tokens.size() < 6) tokens.push_back("1");
685 while (tokens.size() < 8) tokens.push_back("");
686 srvo->ProjectHProf(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
687 tokens[6], tokens[7] );
688 }
689
690// Projection dans vector/matrix
691else if (kw == "fillvec" ) {
692 if (tokens.size() < 4) {
693 cout << "Usage: fillvec nomvec nomobj expx expv [expcut opt loop_par]" << endl;
694 return(0);
695 }
696 if (tokens.size() < 5) tokens.push_back("1");
697 while (tokens.size() < 7) tokens.push_back("");
698 srvo->FillVect(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
699 }
700
701else if (kw == "fillmtx" ) {
702 if (tokens.size() < 5) {
703 cout << "Usage: fillmtx nommtx nomobj expx expy expv [expcut opt loop_par]" << endl;
704 return(0);
705 }
706 if (tokens.size() < 6) tokens.push_back("1");
707 while (tokens.size() < 8) tokens.push_back("");
708 srvo->FillMatx(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
709 tokens[6], tokens[7] );
710 }
711
712// Remplissage NTuple,Vecteurs, ... , boucle de NTuple
713else if (kw == "ntfrascii" ) {
714 if(tokens.size() < 2) {
715 cout<<"Usage: ntfrascii nt_name file_name [def_init_val]"<<endl;
716 return(0);
717 }
718 double def_val = 0.;
719 if(tokens.size()>=3) def_val = atof(tokens[2].c_str());
720 srvo->NtFromASCIIFile(tokens[0],tokens[1],def_val);
721 }
722
723#ifndef SANS_EVOLPLANCK
724/* Lecture matrice/vecteur depuis fichier ASCII */
725else if ((kw == "mtxfrascii") || (kw == "vecfrascii") ) {
726 if(tokens.size() < 2) {
727 cout<<"Usage: mtxfrascii/vecfrascii mtx/vec_name file_name [CommLine Separator]"<<endl;
728 return(0);
729 }
730 TMatrix<r_8> mtx;
731 TVector<r_8> vec;
732 FILE* fip = fopen(tokens[1].c_str(), "r");
733 if (fip == NULL) {
734 cout << "vec/mtxfrascii: can not open file " << tokens[1] << endl;
735 return(0);
736 }
737 fclose(fip);
738 ifstream is(tokens[1].c_str());
739 sa_size_t nr, nc;
740 char clm = '#';
741 string sep = " \t";
742 if (tokens.size()>2) clm = tokens[2][0];
743 if (tokens.size()>3) sep = tokens[3];
744 if (kw == "mtxfrascii") {
745 mtx.ReadASCII(is, nr, nc, clm, sep.c_str());
746 mObjMgr->AddObj(mtx, tokens[0]);
747 cout << "mtxfrascii: TMatrix<r_8> " << tokens[0] << " read from file "
748 << tokens[1] << endl;
749 }
750 else {
751 vec.ReadASCII(is, nr, nc, clm, sep.c_str());
752 mObjMgr->AddObj(vec, tokens[0]);
753 cout << "vecfrascii: TVector<r_8> " << tokens[0] << " read from file "
754 << tokens[1] << endl;
755 }
756}
757else if (kw == "arrtoascii") {
758 if(tokens.size() < 2) {
759 cout<<"Usage: arrtoascii array_name file_name "<<endl;
760 return(0);
761 }
762
763 AnyDataObj* obj;
764 obj = mObjMgr->GetObj(tokens[0]);
765 if(obj == NULL) {
766 cerr << "arrtoascii Error , No such object " << tokens[0] << endl;
767 return(0);
768 }
769 BaseArray* ba = dynamic_cast<BaseArray *>(obj);
770 if(ba == NULL) {
771 cerr << "arrtoascii Error " << tokens[0] << " not a BaseArray ! " << endl;
772 return(0);
773 }
774 ofstream os(tokens[1].c_str());
775 ba->WriteASCII(os);
776 cout << "arrtoascii: Array " << tokens[0] << " written to file " << tokens[1] << endl;
777}
778
779#endif
780
781else if (kw == "fillnt" ) {
782 if (tokens.size() < 5) {
783 cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl;
784 return(0);
785 }
786 while (tokens.size() < 8) tokens.push_back("");
787 srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], tokens[7] );
788 }
789
790else if (kw == "ntloop" ) {
791 if (tokens.size() < 3) {
792 cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl;
793 return(0);
794 }
795 while (tokens.size() < 5) tokens.push_back("");
796 srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]);
797 }
798
799else if (kw == "ntexpcfile" ) {
800 if (tokens.size() < 3) {
801 cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
802 return(0);
803 }
804 srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
805 }
806
807else if (kw == "expmeansig" ) {
808 if (tokens.size() < 2) {
809 cout << "Usage: expmeansig nameobj expx [expcut loop_par]" << endl;
810 return(0);
811 }
812 while (tokens.size() < 4) tokens.push_back("");
813 string dummy = "";
814 cout << " expmeansig: computing mean/sigma + min/max for " << tokens[0]
815 << "." << tokens[1] << endl;
816 srvo->ExpressionToVector(tokens[0],tokens[1],tokens[2],dummy,dummy,tokens[3]);
817 }
818
819else if (kw == "exptovec" ) {
820 if (tokens.size() < 3) {
821 cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl;
822 return(0);
823 }
824 while (tokens.size() < 6) tokens.push_back("");
825 srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]);
826 }
827
828else if (kw == "fillgd1" ) {
829 if (tokens.size() < 5) {
830 cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl;
831 return(0);
832 }
833 if (tokens.size() < 6) tokens.push_back("1");
834 if (tokens.size() < 7) tokens.push_back("");
835 string expy = "";
836 srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]);
837 }
838
839else if (kw == "fillgd2" ) {
840 if (tokens.size() < 6) {
841 cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl;
842 return(0);
843 }
844 if (tokens.size() < 7) tokens.push_back("1");
845 if (tokens.size() < 8) tokens.push_back("");
846 srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]);
847 }
848
849else if (kw == "gdfrvec" ) {
850 if(tokens.size()<3) {
851 cout<<"Usage: gdfrvec namegfd X Y\n"
852 <<" gdfrvec namegfd X Y"
853 <<" gdfrvec namegfd X Y ! EY\n"
854 <<" gdfrvec namegfd X Y Z\n"
855 <<" gdfrvec namegfd X Y Z EZ"<<endl;
856 return(0);
857 }
858 while(tokens.size()<5) tokens.push_back("!");
859 srvo->FillGFDfrVec(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4]);
860 }
861
862// >>>>>>>>>>> Calcul d'expression arithmetique
863else if ( (kw == "eval") ) {
864 if(tokens.size()<2)
865 {cout<<"Usage: eval resultvarname arithmetic expression...."<<endl; return(0);}
866 string expval = "";
867 for(unsigned int i=1;i<tokens.size();i++) expval+=tokens[i];
868 string resultvarname = "";
869 if(isalpha(tokens[0][0])) resultvarname=tokens[0];
870 mObjMgr->GetServiceObj()->ExpVal(expval,resultvarname);
871 }
872
873else {
874 cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
875 return(-1);
876 }
877
878return(0);
879}
880
881/* --Methode-- */
882bool PIABaseExecutor::IsThreadable(string const & keyw)
883{
884 if ( (keyw == "fillvec") || (keyw == "fillmtx") ||
885 (keyw == "fillnt") || (keyw == "ntloop") ) return true;
886 else if (keyw.substr(0,4) == "func") return true;
887 else {
888 string skw = keyw.substr(0,5);
889 if ( (skw == "plot2") || (skw == "plot3") || (skw == "projh") ) return true;
890 }
891 return false;
892}
893
894
895/* --Methode-- */
896void PIABaseExecutor::RegisterCommands()
897{
898string kw, usage, grp;
899//--------- Commandes du groupe modules externes
900grp = "External Modules";
901string gdesc = "Dynamic load (shared object modules) management command group";
902mpiac->AddHelpGroup(grp, gdesc);
903kw = "loadmodule";
904usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
905usage += "\n Related commands: link";
906mpiac->RegisterCommand(kw, usage, this, grp);
907kw = "link";
908usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
909usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
910usage += "\n Related commands: call loadmodule linkff2";
911mpiac->RegisterCommand(kw, usage, this, grp);
912kw = "linkff2";
913usage = "Dynamic linking of compiled user functions (Set 2)\n Usage: linkff2 fnameso f1 [f2 f3]";
914usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
915usage += "\n Related commands: call link loadmodule";
916mpiac->RegisterCommand(kw, usage, this, grp);
917kw = "call";
918usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
919usage += "\n User function : f(vector<string>& args)";
920usage += "\n Related commands: link";
921mpiac->RegisterCommand(kw, usage, this, grp);
922
923kw = "openppf";
924usage = "Reads all or some objects from a PPF file \n Usage: openppf filename [objname1 objname2 ...]";
925usage += "\n Related commands: saveall ";
926mpiac->RegisterCommand(kw, usage, this, "FileIO");
927kw = "saveppf";
928usage = "Saves objects with names matching a pattern into a\n";
929usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
930usage += "Usage: saveppf nameobjpattern filename";
931usage += "\n Related commands: saveobjs savelist saveall openppf";
932mpiac->RegisterCommand(kw, usage, this, "FileIO");
933kw = "saveobjs";
934usage = "Saves objects with names matching a pattern into a\n";
935usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
936usage += "Usage: saveobjs nameobjpattern filename";
937usage += "\n Related commands: saveppf savelist saveall openppf ";
938mpiac->RegisterCommand(kw, usage, this, "FileIO");
939kw = "saveall";
940usage = "Saves all objects into a PPF file \n Usage: saveall filename";
941usage += "\n Related commands: saveobj savelist openppf";
942mpiac->RegisterCommand(kw, usage, this, "FileIO");
943kw = "savelist";
944usage = "Saves a list of objects into a PPF file";
945usage = "\n Usage: savelist objname1 [objname2 ...] filename";
946usage += "\n Related commands: saveobj openppf";
947mpiac->RegisterCommand(kw, usage, this, "FileIO");
948kw = "ntfrascii";
949usage = "Fills an existing NTuple or DataTable from ASCII table file";
950usage += "\n Usage: ntfrascii nt_name file_name [def_init_val]";
951usage += "\n Related commands: ntloop fillnt ";
952mpiac->RegisterCommand(kw, usage, this, "FileIO");
953#ifndef SANS_EVOLPLANCK
954kw = "mtxfrascii";
955usage = "Reads a matrix from an ASCII file (TMatrix<r_8>)";
956usage += "\n Usage: mtxfrascii mtx_name file_name [CommChar Separator]";
957usage += "\n Related commands: arrtoascii vecfrascii ntfrascii ";
958mpiac->RegisterCommand(kw, usage, this, "FileIO");
959kw = "vecfrascii";
960usage = "Reads a vector from an ASCII file (TVector<r_8>)";
961usage += "\n Usage: vecfrascii vec_name file_name";
962usage += "\n Related commands: arrtoascii mtxfrascii ntfrascii [CommChar Separator]";
963mpiac->RegisterCommand(kw, usage, this, "FileIO");
964kw = "arrtoascii";
965usage = "Writes an array (TArray<T>) to an ASCII file ";
966usage += "\n Usage: arrtoascii array_name file_name";
967usage += "\n Related commands: mtxfrascii vecfrascii ntfrascii ";
968mpiac->RegisterCommand(kw, usage, this, "FileIO");
969#endif
970
971kw = "print";
972usage = "Prints an object \n Usage: print nameobj [prtlev]";
973usage += "\n prtlev = 0,1,2... default: prtlev=0";
974mpiac->RegisterCommand(kw, usage, this, "FileIO");
975
976//------- Commandes gestion de repertoires et d'objets
977kw = "mkdir";
978usage = "Create a directory";
979usage += "\n Usage: mkdir dirname [true]";
980usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
981mpiac->RegisterCommand(kw, usage, this, "Object Management");
982kw = "rmdir";
983usage = "Removes an empty directory";
984usage += "\n Usage: remove dirname";
985mpiac->RegisterCommand(kw, usage, this, "Object Management");
986kw = "setdiratt";
987usage = "Sets directory attributes";
988usage += "\n Usage: setdiratt dirname KeepOldFlag(=true/false)";
989usage += "\n KeepOldFlag=true Object with the same name is moved to old";
990usage += "\n when adding objects";
991mpiac->RegisterCommand(kw, usage, this, "Object Management");
992kw = "cd";
993usage = "Change current directory";
994usage += "\n Usage: cd [dirname]";
995mpiac->RegisterCommand(kw, usage, this, "Object Management");
996kw = "pwd";
997usage = "Prints current directory";
998usage += "\n Usage: pwd";
999mpiac->RegisterCommand(kw, usage, this, "Object Management");
1000kw = "listdirs";
1001usage = "Prints the list of directories";
1002usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
1003mpiac->RegisterCommand(kw, usage, this, "Object Management");
1004kw = "listobjs";
1005usage = "Prints the list of objects (Alias: ls)";
1006 usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
1007mpiac->RegisterCommand(kw, usage, this, "Object Management");
1008kw = "rename";
1009usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
1010usage += "\n Related commands: mv del delobjs";
1011mpiac->RegisterCommand(kw, usage, this, "Object Management");
1012kw = "mv";
1013usage = "Rename an object (Alias: rename) \n Usage: mv nameobj namenew";
1014usage += "\n Related commands: rename del delobjs";
1015mpiac->RegisterCommand(kw, usage, this, "Object Management");
1016kw = "copy";
1017usage = "Copy objects (Alias cp) \n";
1018usage +=" Usage: copy name_from name_to";
1019usage += "\n Related commands: cp new...";
1020mpiac->RegisterCommand(kw, usage, this, "Object Management");
1021kw = "cp";
1022usage = "Copy objects (Alias copy) \n";
1023usage +=" Usage: cp name_from name_to";
1024usage += "\n Related commands: copy new...";
1025mpiac->RegisterCommand(kw, usage, this, "Object Management");
1026kw = "del";
1027usage = "Deletes an object (Alias: rm) \n Usage: del nameobj [nameobj2 ...]";
1028usage += "\n Related commands: rm delobjs rename";
1029mpiac->RegisterCommand(kw, usage, this, "Object Management");
1030kw = "rm";
1031usage = "Deletes an object (Alias: del) \n Usage: rm nameobj [nameobj2 ...]";
1032usage += "\n Related commands: del delobjs rename";
1033mpiac->RegisterCommand(kw, usage, this, "Object Management");
1034kw = "delobjs";
1035usage = "Delete a set of objects with names matching a pattern (x?y*)";
1036usage += "\n Usage: delobjs nameobjpattern \n";
1037usage += "\n Related commands: del rename";
1038mpiac->RegisterCommand(kw, usage, this, "Object Management");
1039
1040//------- Commandes creation/manipulation d'objets
1041kw = "newh1d";
1042usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
1043usage += "\n Related commands: newh2d newprof[e] newdt newnt newgfd ";
1044mpiac->RegisterCommand(kw, usage, this, "Objects");
1045kw = "newh2d";
1046usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
1047usage += "\n Related commands: newh1d newprof[e] newdt newnt newgfd ";
1048mpiac->RegisterCommand(kw, usage, this, "Objects");
1049kw = "newprof";
1050usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
1051usage += "\n Errors represent the data spread in the X bin ";
1052usage += "\n Related commands: newh1d newh2d newprofe newdt newnt newgfd ";
1053mpiac->RegisterCommand(kw, usage, this, "Objects");
1054kw = "newprofe";
1055usage = "Creates a profile histogramm \n Usage: newprofe name xmin xmax nbin [ymin ymax]";
1056usage += "\n Errors represent the error on the data mean in the X bin ";
1057usage += "\n Related commands: newh1d newh2d newprof newdt newnt newgfd ";
1058mpiac->RegisterCommand(kw, usage, this, "Objects");
1059kw = "newnt";
1060usage = "Creates a ntuple \n Usage: newnt name v1 v2 v3 .. vn";
1061usage += "\n newnt name nvar";
1062usage += "\n Related commands: newdt newh1d newh2d newprof[e] newgfd ";
1063mpiac->RegisterCommand(kw, usage, this, "Objects");
1064kw = "newdt";
1065usage = "Creates a datatable \n Usage: newdt name v1:t1 v2:t2 v3:t3 .. vn:tn";
1066usage += "\n newdt name nvar";
1067usage += "\n vi : variable name";
1068usage += "\n ti : variable type";
1069usage += "\n r8,r4 for 8 and 4 bytes float";
1070usage += "\n i8,i4 for 8 and 4 bytes signed integer";
1071usage += "\n s for string";
1072usage += "\n Related commands: newnt newh1d newh2d newprof[e] newgfd";
1073mpiac->RegisterCommand(kw, usage, this, "Objects");
1074kw = "newgfd";
1075usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
1076usage += "\n Related commands: newh1d newh2d newprof[e] newdt newnt ";
1077mpiac->RegisterCommand(kw, usage, this, "Objects");
1078kw = "newvec";
1079usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
1080usage += "\n Related commands: newmtx line2vec";
1081mpiac->RegisterCommand(kw, usage, this, "Objects");
1082kw = "newmtx";
1083usage = "Creates (and optionaly fills) a matrix \n";
1084usage +=" Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] ";
1085usage += "\n Related commands: newvec";
1086mpiac->RegisterCommand(kw, usage, this, "Objects");
1087kw = "line2vec";
1088usage = "Creates a vector from the line \n";
1089usage += " Usage: line2vec vecname v0 v1 v2 ... \n";
1090usage += " Related commands: newvec line2nt";
1091mpiac->RegisterCommand(kw, usage, this, "Objects");
1092kw = "line2nt";
1093usage = "Fills (append) an NTuple from the line content \n";
1094usage += " Usage: line2nt ntname col0 col1 ... \n";
1095usage += " Related commands: newnt line2vec ntline2var ntcol2var";
1096mpiac->RegisterCommand(kw, usage, this, "Objects");
1097kw = "vec2var";
1098usage = "Vector content to an interpreter variable varname = 'v0 v1 v2 ...' \n";
1099usage += " Usage: line2vec vecname varname [LoopParam start:end[:step] ]\n";
1100usage += " Related commands: line2vec ntline2var";
1101mpiac->RegisterCommand(kw, usage, this, "Objects");
1102kw = "ntline2var";
1103usage = "Object NTupleInterface line to an interpreter variable \n";
1104usage += " Usage: ntline2var objname line_number varname \n";
1105usage += " Related commands: vec2var ntcol2var";
1106mpiac->RegisterCommand(kw, usage, this, "Objects");
1107kw = "ntcol2var";
1108usage = "Object NTupleInterface column to an interpreter variable \n";
1109usage += " Usage: ntline2var objname column_number varname [LoopParam start:end[:step] ] \n";
1110usage += " Related commands: vec2var ntline2var";
1111mpiac->RegisterCommand(kw, usage, this, "Objects");
1112kw = "objaoper";
1113usage = "Perform an operation through the object adapter NObjMgrAdapter::PerformOperation()\n";
1114usage += " Usage: objaoper objname operation [arg1 ...] \n";
1115usage += " Examples of defined operations : \n";
1116usage += " Matrices: row indx_row , col indx_col \n";
1117usage += " Arrays: slicexy indx_Z , slicexz indx_Y, sliceyz indxX \n";
1118mpiac->RegisterCommand(kw, usage, this, "Objects");
1119
1120//------- Commandes trace de fonctions
1121kw = "func";
1122usage = "Displays a function y=f(x) (Fills a vector with function values)";
1123usage += "\n Usage: func f(x) xmin xmax [npt graphic_attributes]";
1124usage += "\n Related commands: funcff func2d func2dff ";
1125mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1126kw = "funcff";
1127usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
1128usage += "\n Usage: funcff C-FileName FunctionName xmin xmax [npt graphic_attributes]";
1129usage += "\n Related commands: func func2d func2dff ";
1130mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1131kw = "func2d";
1132usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
1133usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
1134usage += "\n Related commands: func";
1135mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1136kw = "func2dff";
1137usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
1138usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
1139usage += "\n Related commands: func funcff func2d ";
1140mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1141
1142//------ Commandes trace d'expression
1143kw = "ObjectExpressions";
1144usage = "Any mathematical expression (math.h) with object variables can be used";
1145usage += "\n ------ Object Variable names (double) -------- ";
1146usage += "\n (_nl is the table line number or the sequential index)";
1147usage += "\n- NTuple: ntuple variable names,_nl";
1148usage += "\n- Histo1D/HProf: i,x,val,err,nb,_nl";
1149usage += "\n- Histo2D: i,j,x,y,val,err,_nl";
1150usage += "\n- HistoErr: i,x,val,err2,nb,_nl";
1151usage += "\n- Histo2DErr: i,j,x,y,val,err2,nb,_nl";
1152usage += "\n- Vector/Matrix: n,r,c,val,real,imag,mod,phas,_nl";
1153usage += "\n- TArray: n,x,y,z,t,u,val,real,imag,mod,phas,_nl";
1154usage += "\n- Image: i,j,x,y,val(=pix),_nl";
1155usage += "\n- GeneralFitData: x0,ex0 x1,ex1 ... xn,exn y,ey ok ,_nl";
1156usage += "\n- LocalMap/SphereThetaPhi/SphereHEALPix: ";
1157usage += "\n- i,k,val,real,imag,mod,phas,teta,phi,_nl";
1158usage += "\n- FITS Binary/ASCII table: fits column names,_nl";
1159#ifdef SANS_EVOLPLANCK
1160usage += "\n ------ Eros Variable names (double) -------- ";
1161usage += "\n- StarList: x,y,flux,fond,pixmax,flags,";
1162usage += "\n- xref,yref,fluxref,fondref,pixmaxref,_nl";
1163#endif
1164usage += "\n ------ Other parameters -------- ";
1165usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)";
1166usage += "\nThe default Cut() expression in true (=1) for all";
1167usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d plot3dw";
1168usage += "\n projh1d projh2d projprof fillvec fillmtx ";
1169usage += "\n fillnt fillgd1 fillgd2 ntloop exptovec ... ";
1170grp = "Expr. Plotting";
1171mpiac->RegisterHelp(kw, usage, grp);
1172kw = "plot2d";
1173usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
1174usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]";
1175usage += "\n Related commands: plot2de plot2dw plot3d plot3dw ObjectExpressions ...";
1176mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1177kw = "plot2de";
1178usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) ";
1179usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]";
1180usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1181mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1182kw = "plot2dw";
1183usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
1184usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]";
1185usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1186mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1187kw = "plot3d";
1188usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object)";
1189usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]";
1190usage += "\n Related commands: plot2d plot2de plot3dw ObjectExpressions ...";
1191mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1192kw = "plot3dw";
1193usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) with Weight W=k(Object) ";
1194usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() k_Wt() [Cut() graphic_attributes loop_param]";
1195usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1196mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1197
1198kw = "projh1d";
1199usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
1200usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]";
1201usage += "\n Histo1D nameh1d is created if necessary ";
1202usage += "\n Related commands: projh2d projprof ObjectExpressions ...";
1203mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1204kw = "projh2d";
1205usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
1206usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
1207usage += "\n Histo2D nameh2d is created if necessary ";
1208usage += "\n Related commands: projh1d projprof ObjectExpressions ...";
1209mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1210kw = "projprof";
1211usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
1212usage += "\n Usage: projprof nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
1213usage += "\n HProf nameprof is created if necessary ";
1214usage += "\n Related commands: projh1d projh2d ObjectExpressions ...";
1215mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1216kw = "fillvec";
1217usage = "Fills a Vector V((int)(f_X(Object)+0.5)) = h_V(Object) ";
1218usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]";
1219usage += "\n Related commands: fillmtx fillnt ObjectExpressions ...";
1220mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1221kw = "fillmtx";
1222usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) = h_V(Object) ";
1223usage += "\n Usage: fillvec namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]";
1224usage += "\n Related commands: fillvec fillnt ObjectExpressions ...";
1225mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1226
1227kw = "fillnt";
1228usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
1229usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]";
1230usage += "\n Related commands: ntloop plot2d projh1d projh2d projprof ";
1231usage += "\n Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ...";
1232mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1233
1234kw = "ntloop";
1235usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
1236usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
1237usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]";
1238usage += "\n Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ...";
1239usage += "\n Related commands: ntexpcfile fillnt";
1240mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1241
1242kw = "ntexpcfile";
1243usage = "Creates a C-File with declarations suitable to be used for ntloop";
1244usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
1245usage += "\n Related commands: ntloop";
1246mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1247
1248kw = "expmeansig";
1249usage = "Computes Mean/Sigma (+Min/Max) for an expression X=f(Object)";
1250usage += "\n Usage: expmeansig nameobj f_X() [Cut() loop_param]";
1251usage += "\n Related commands: exptovec ntloop fillnt ObjectExpressions ...";
1252mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1253
1254kw = "exptovec";
1255usage = "Creates and Fills a Vector with X=f(Object)";
1256usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]";
1257usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
1258mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1259
1260kw = "fillgd1";
1261usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
1262usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]";
1263usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
1264mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1265kw = "fillgd2";
1266usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
1267usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]";
1268usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
1269mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1270kw = "gdfrvec";
1271usage = "Fills a GeneralFitData with vectors X,Y,Z,EZ";
1272usage += "\n Usage: gdfrvec namegfd X Y";
1273usage += "\n Usage: gdfrvec namegfd X Y ! EY";
1274usage += "\n Usage: gdfrvec namegfd X Y Z";
1275usage += "\n Usage: gdfrvec namegfd X Y Z EZ";
1276usage += "\n Related commands: fillgd1 fillgd2 ...";
1277mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1278
1279
1280kw = "eval";
1281usage = "Compute arithmetic expression\n";
1282usage += "\n Usage: eval resultvarname arithmetic expression....";
1283usage += "\n resultvarname: store result in variable resultvarname";
1284usage += "\n - If first character is not alphabetic, just print result";
1285usage += "\n arithmetic expression:";
1286usage += "\n ex: x + sqrt(y)+z +3.14 (x,y,z are variables)";
1287usage += "\n ex: $x + sqrt($y)+$z +3.14 (x,y,z are variables)";
1288usage += "\n ex: 360 * M_PI / 180.";
1289mpiac->RegisterCommand(kw, usage, this, "Expr. Arithmetic");
1290
1291}
1292
1293/* --Methode-- */
1294int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
1295// string& func4, string& func5)
1296{
1297string cmd;
1298
1299if (dynlink) delete dynlink; dynlink = NULL;
1300usfmap.clear();
1301
1302dynlink = new PDynLinkMgr(fnameso, true);
1303if (dynlink == NULL) {
1304 string sn = fnameso;
1305 cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
1306 return(2);
1307 }
1308
1309int nok=0;
1310// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1311// DlUserProcFunction f = NULL;
1312DlFunction f = NULL;
1313if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1314// f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
1315f = dynlink->GetFunction(func1);
1316if (f) { nok++; usfmap[func1] = f; }
1317else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
1318
1319if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1320// f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
1321f = dynlink->GetFunction(func2);
1322if (f) { nok++; usfmap[func2] = f; }
1323else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
1324
1325if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1326// f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
1327f = dynlink->GetFunction(func3);
1328if (f) { nok++; usfmap[func3] = f; }
1329else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
1330
1331/* Pb compile g++ 2.7.2
1332if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
1333// f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
1334f = dynlink->GetFunction(func4);
1335if (f) { nok++; usfmap[func4] = f; }
1336else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
1337
1338if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
1339// f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
1340f = dynlink->GetFunction(func5);
1341if (f) { nok++; usfmap[func5] = f; }
1342else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
1343*/
1344fin:
1345if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
1346else return(0);
1347}
1348
1349/* --Methode-- */
1350int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3)
1351{
1352string cmd;
1353
1354if (dynlink2) delete dynlink2; dynlink2 = NULL;
1355usfmap2.clear();
1356
1357dynlink2 = new PDynLinkMgr(fnameso, true);
1358if (dynlink2 == NULL) {
1359 string sn = fnameso;
1360 cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl;
1361 return(2);
1362 }
1363
1364int nok=0;
1365// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1366// DlUserProcFunction f = NULL;
1367DlFunction f = NULL;
1368if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1369f = dynlink2->GetFunction(func1);
1370if (f) { nok++; usfmap2[func1] = f; }
1371else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl;
1372
1373if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1374f = dynlink2->GetFunction(func2);
1375if (f) { nok++; usfmap2[func2] = f; }
1376else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl;
1377
1378if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1379f = dynlink2->GetFunction(func3);
1380if (f) { nok++; usfmap2[func3] = f; }
1381else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl;
1382
1383fin:
1384if (nok < 1) { if (dynlink2) delete dynlink2; dynlink2 = NULL; return(3); }
1385else return(0);
1386}
1387
Note: See TracBrowser for help on using the repository browser.