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

Last change on this file since 3306 was 3279, checked in by ansari, 18 years ago

correction commandes nt2dcn nt2dci et ajout commande plot2dc - Reza 05/07/2007

File size: 53.1 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")||(kw == "plot2dc")) { // Plot2d avec poids
625 if (tokens.size() < 4) {
626 cout << "Usage: plot2dw/c nomobj expx expy expwt/expcolidx [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 bool fgcolidx = false;
632 if (kw == "plot2dc") fgcolidx = true;
633 srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4],
634 fgcolidx, tokens[5], tokens[6]);
635 }
636else if (kw == "plot3d" ) {
637 if (tokens.size() < 4) {
638 cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl;
639 return(0);
640 }
641 if (tokens.size() < 5) tokens.push_back("1");
642 while (tokens.size() < 7) tokens.push_back("");
643 srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
644 }
645else if (kw == "plot3dw" ) {
646 if (tokens.size() < 5) {
647 cout << "Usage: plot3dw nomobj expx expy expz expwt [expcut opt loop_par]" << endl;
648 return(0);
649 }
650 if (tokens.size() < 6) tokens.push_back("1");
651 while (tokens.size() < 8) tokens.push_back("");
652 srvo->DisplayPoints3DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5],
653 tokens[6], tokens[7]);
654}
655
656else if (kw == "projh1d" ) {
657 if (tokens.size() < 3) {
658 cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl;
659 return(0);
660 }
661 if (tokens.size() < 4) tokens.push_back("1.");
662 if (tokens.size() < 5) tokens.push_back("1");
663 while (tokens.size() < 7) tokens.push_back("");
664 srvo->ProjectH1(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
665 }
666
667
668// Projection dans histogrammes
669else if (kw == "projh2d" ) {
670 if (tokens.size() < 4) {
671 cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl;
672 return(0);
673 }
674 if (tokens.size() < 5) tokens.push_back("1.");
675 if (tokens.size() < 6) tokens.push_back("1");
676 while (tokens.size() < 8) tokens.push_back("");
677 srvo->ProjectH2(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
678 tokens[6], tokens[7] );
679 }
680
681else if (kw == "projprof" ) {
682 if (tokens.size() < 4) {
683 cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl;
684 return(0);
685 }
686 if (tokens.size() < 5) tokens.push_back("1.");
687 if (tokens.size() < 6) tokens.push_back("1");
688 while (tokens.size() < 8) tokens.push_back("");
689 srvo->ProjectHProf(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
690 tokens[6], tokens[7] );
691 }
692
693// Projection dans vector/matrix
694else if (kw == "fillvec" ) {
695 if (tokens.size() < 4) {
696 cout << "Usage: fillvec nomvec nomobj expx expv [expcut opt loop_par]" << endl;
697 return(0);
698 }
699 if (tokens.size() < 5) tokens.push_back("1");
700 while (tokens.size() < 7) tokens.push_back("");
701 srvo->FillVect(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
702 }
703
704else if (kw == "fillmtx" ) {
705 if (tokens.size() < 5) {
706 cout << "Usage: fillmtx nommtx nomobj expx expy expv [expcut opt loop_par]" << endl;
707 return(0);
708 }
709 if (tokens.size() < 6) tokens.push_back("1");
710 while (tokens.size() < 8) tokens.push_back("");
711 srvo->FillMatx(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
712 tokens[6], tokens[7] );
713 }
714
715// Remplissage NTuple,Vecteurs, ... , boucle de NTuple
716else if (kw == "ntfrascii" ) {
717 if(tokens.size() < 2) {
718 cout<<"Usage: ntfrascii nt_name file_name [def_init_val]"<<endl;
719 return(0);
720 }
721 double def_val = 0.;
722 if(tokens.size()>=3) def_val = atof(tokens[2].c_str());
723 srvo->NtFromASCIIFile(tokens[0],tokens[1],def_val);
724 }
725
726#ifndef SANS_EVOLPLANCK
727/* Lecture matrice/vecteur depuis fichier ASCII */
728else if ((kw == "mtxfrascii") || (kw == "vecfrascii") ) {
729 if(tokens.size() < 2) {
730 cout<<"Usage: mtxfrascii/vecfrascii mtx/vec_name file_name [CommLine Separator]"<<endl;
731 return(0);
732 }
733 TMatrix<r_8> mtx;
734 TVector<r_8> vec;
735 FILE* fip = fopen(tokens[1].c_str(), "r");
736 if (fip == NULL) {
737 cout << "vec/mtxfrascii: can not open file " << tokens[1] << endl;
738 return(0);
739 }
740 fclose(fip);
741 ifstream is(tokens[1].c_str());
742 sa_size_t nr, nc;
743 char clm = '#';
744 string sep = " \t";
745 if (tokens.size()>2) clm = tokens[2][0];
746 if (tokens.size()>3) sep = tokens[3];
747 if (kw == "mtxfrascii") {
748 mtx.ReadASCII(is, nr, nc, clm, sep.c_str());
749 mObjMgr->AddObj(mtx, tokens[0]);
750 cout << "mtxfrascii: TMatrix<r_8> " << tokens[0] << " read from file "
751 << tokens[1] << endl;
752 }
753 else {
754 vec.ReadASCII(is, nr, nc, clm, sep.c_str());
755 mObjMgr->AddObj(vec, tokens[0]);
756 cout << "vecfrascii: TVector<r_8> " << tokens[0] << " read from file "
757 << tokens[1] << endl;
758 }
759}
760else if (kw == "arrtoascii") {
761 if(tokens.size() < 2) {
762 cout<<"Usage: arrtoascii array_name file_name "<<endl;
763 return(0);
764 }
765
766 AnyDataObj* obj;
767 obj = mObjMgr->GetObj(tokens[0]);
768 if(obj == NULL) {
769 cerr << "arrtoascii Error , No such object " << tokens[0] << endl;
770 return(0);
771 }
772 BaseArray* ba = dynamic_cast<BaseArray *>(obj);
773 if(ba == NULL) {
774 cerr << "arrtoascii Error " << tokens[0] << " not a BaseArray ! " << endl;
775 return(0);
776 }
777 ofstream os(tokens[1].c_str());
778 ba->WriteASCII(os);
779 cout << "arrtoascii: Array " << tokens[0] << " written to file " << tokens[1] << endl;
780}
781
782#endif
783
784else if (kw == "fillnt" ) {
785 if (tokens.size() < 5) {
786 cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl;
787 return(0);
788 }
789 while (tokens.size() < 8) tokens.push_back("");
790 srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], tokens[7] );
791 }
792
793else if (kw == "ntloop" ) {
794 if (tokens.size() < 3) {
795 cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl;
796 return(0);
797 }
798 while (tokens.size() < 5) tokens.push_back("");
799 srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]);
800 }
801
802else if (kw == "ntexpcfile" ) {
803 if (tokens.size() < 3) {
804 cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
805 return(0);
806 }
807 srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
808 }
809
810else if (kw == "expmeansig" ) {
811 if (tokens.size() < 2) {
812 cout << "Usage: expmeansig nameobj expx [expcut loop_par]" << endl;
813 return(0);
814 }
815 while (tokens.size() < 4) tokens.push_back("");
816 string dummy = "";
817 cout << " expmeansig: computing mean/sigma + min/max for " << tokens[0]
818 << "." << tokens[1] << endl;
819 srvo->ExpressionToVector(tokens[0],tokens[1],tokens[2],dummy,dummy,tokens[3]);
820 }
821
822else if (kw == "exptovec" ) {
823 if (tokens.size() < 3) {
824 cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl;
825 return(0);
826 }
827 while (tokens.size() < 6) tokens.push_back("");
828 srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]);
829 }
830
831else if (kw == "fillgd1" ) {
832 if (tokens.size() < 5) {
833 cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl;
834 return(0);
835 }
836 if (tokens.size() < 6) tokens.push_back("1");
837 if (tokens.size() < 7) tokens.push_back("");
838 string expy = "";
839 srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]);
840 }
841
842else if (kw == "fillgd2" ) {
843 if (tokens.size() < 6) {
844 cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl;
845 return(0);
846 }
847 if (tokens.size() < 7) tokens.push_back("1");
848 if (tokens.size() < 8) tokens.push_back("");
849 srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]);
850 }
851
852else if (kw == "gdfrvec" ) {
853 if(tokens.size()<3) {
854 cout<<"Usage: gdfrvec namegfd X Y\n"
855 <<" gdfrvec namegfd X Y"
856 <<" gdfrvec namegfd X Y ! EY\n"
857 <<" gdfrvec namegfd X Y Z\n"
858 <<" gdfrvec namegfd X Y Z EZ"<<endl;
859 return(0);
860 }
861 while(tokens.size()<5) tokens.push_back("!");
862 srvo->FillGFDfrVec(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4]);
863 }
864
865// >>>>>>>>>>> Calcul d'expression arithmetique
866else if ( (kw == "eval") ) {
867 if(tokens.size()<2)
868 {cout<<"Usage: eval resultvarname arithmetic expression...."<<endl; return(0);}
869 string expval = "";
870 for(unsigned int i=1;i<tokens.size();i++) expval+=tokens[i];
871 string resultvarname = "";
872 if(isalpha(tokens[0][0])) resultvarname=tokens[0];
873 mObjMgr->GetServiceObj()->ExpVal(expval,resultvarname);
874 }
875
876else {
877 cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
878 return(-1);
879 }
880
881return(0);
882}
883
884/* --Methode-- */
885bool PIABaseExecutor::IsThreadable(string const & keyw)
886{
887 if ( (keyw == "fillvec") || (keyw == "fillmtx") ||
888 (keyw == "fillnt") || (keyw == "ntloop") ) return true;
889 else if (keyw.substr(0,4) == "func") return true;
890 else {
891 string skw = keyw.substr(0,5);
892 if ( (skw == "plot2") || (skw == "plot3") || (skw == "projh") ) return true;
893 }
894 return false;
895}
896
897
898/* --Methode-- */
899void PIABaseExecutor::RegisterCommands()
900{
901string kw, usage, grp;
902//--------- Commandes du groupe modules externes
903grp = "External Modules";
904string gdesc = "Dynamic load (shared object modules) management command group";
905mpiac->AddHelpGroup(grp, gdesc);
906kw = "loadmodule";
907usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
908usage += "\n Related commands: link";
909mpiac->RegisterCommand(kw, usage, this, grp);
910kw = "link";
911usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
912usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
913usage += "\n Related commands: call loadmodule linkff2";
914mpiac->RegisterCommand(kw, usage, this, grp);
915kw = "linkff2";
916usage = "Dynamic linking of compiled user functions (Set 2)\n Usage: linkff2 fnameso f1 [f2 f3]";
917usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
918usage += "\n Related commands: call link loadmodule";
919mpiac->RegisterCommand(kw, usage, this, grp);
920kw = "call";
921usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
922usage += "\n User function : f(vector<string>& args)";
923usage += "\n Related commands: link";
924mpiac->RegisterCommand(kw, usage, this, grp);
925
926kw = "openppf";
927usage = "Reads all or some objects from a PPF file \n Usage: openppf filename [objname1 objname2 ...]";
928usage += "\n Related commands: saveall ";
929mpiac->RegisterCommand(kw, usage, this, "FileIO");
930kw = "saveppf";
931usage = "Saves objects with names matching a pattern into a\n";
932usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
933usage += "Usage: saveppf nameobjpattern filename";
934usage += "\n Related commands: saveobjs savelist saveall openppf";
935mpiac->RegisterCommand(kw, usage, this, "FileIO");
936kw = "saveobjs";
937usage = "Saves objects with names matching a pattern into a\n";
938usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
939usage += "Usage: saveobjs nameobjpattern filename";
940usage += "\n Related commands: saveppf savelist saveall openppf ";
941mpiac->RegisterCommand(kw, usage, this, "FileIO");
942kw = "saveall";
943usage = "Saves all objects into a PPF file \n Usage: saveall filename";
944usage += "\n Related commands: saveobj savelist openppf";
945mpiac->RegisterCommand(kw, usage, this, "FileIO");
946kw = "savelist";
947usage = "Saves a list of objects into a PPF file";
948usage = "\n Usage: savelist objname1 [objname2 ...] filename";
949usage += "\n Related commands: saveobj openppf";
950mpiac->RegisterCommand(kw, usage, this, "FileIO");
951kw = "ntfrascii";
952usage = "Fills an existing NTuple or DataTable from ASCII table file";
953usage += "\n Usage: ntfrascii nt_name file_name [def_init_val]";
954usage += "\n Related commands: ntloop fillnt ";
955mpiac->RegisterCommand(kw, usage, this, "FileIO");
956#ifndef SANS_EVOLPLANCK
957kw = "mtxfrascii";
958usage = "Reads a matrix from an ASCII file (TMatrix<r_8>)";
959usage += "\n Usage: mtxfrascii mtx_name file_name [CommChar Separator]";
960usage += "\n Related commands: arrtoascii vecfrascii ntfrascii ";
961mpiac->RegisterCommand(kw, usage, this, "FileIO");
962kw = "vecfrascii";
963usage = "Reads a vector from an ASCII file (TVector<r_8>)";
964usage += "\n Usage: vecfrascii vec_name file_name";
965usage += "\n Related commands: arrtoascii mtxfrascii ntfrascii [CommChar Separator]";
966mpiac->RegisterCommand(kw, usage, this, "FileIO");
967kw = "arrtoascii";
968usage = "Writes an array (TArray<T>) to an ASCII file ";
969usage += "\n Usage: arrtoascii array_name file_name";
970usage += "\n Related commands: mtxfrascii vecfrascii ntfrascii ";
971mpiac->RegisterCommand(kw, usage, this, "FileIO");
972#endif
973
974kw = "print";
975usage = "Prints an object \n Usage: print nameobj [prtlev]";
976usage += "\n prtlev = 0,1,2... default: prtlev=0";
977mpiac->RegisterCommand(kw, usage, this, "FileIO");
978
979//------- Commandes gestion de repertoires et d'objets
980kw = "mkdir";
981usage = "Create a directory";
982usage += "\n Usage: mkdir dirname [true]";
983usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
984mpiac->RegisterCommand(kw, usage, this, "Object Management");
985kw = "rmdir";
986usage = "Removes an empty directory";
987usage += "\n Usage: remove dirname";
988mpiac->RegisterCommand(kw, usage, this, "Object Management");
989kw = "setdiratt";
990usage = "Sets directory attributes";
991usage += "\n Usage: setdiratt dirname KeepOldFlag(=true/false)";
992usage += "\n KeepOldFlag=true Object with the same name is moved to old";
993usage += "\n when adding objects";
994mpiac->RegisterCommand(kw, usage, this, "Object Management");
995kw = "cd";
996usage = "Change current directory";
997usage += "\n Usage: cd [dirname]";
998mpiac->RegisterCommand(kw, usage, this, "Object Management");
999kw = "pwd";
1000usage = "Prints current directory";
1001usage += "\n Usage: pwd";
1002mpiac->RegisterCommand(kw, usage, this, "Object Management");
1003kw = "listdirs";
1004usage = "Prints the list of directories";
1005usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
1006mpiac->RegisterCommand(kw, usage, this, "Object Management");
1007kw = "listobjs";
1008usage = "Prints the list of objects (Alias: ls)";
1009 usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
1010mpiac->RegisterCommand(kw, usage, this, "Object Management");
1011kw = "rename";
1012usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
1013usage += "\n Related commands: mv del delobjs";
1014mpiac->RegisterCommand(kw, usage, this, "Object Management");
1015kw = "mv";
1016usage = "Rename an object (Alias: rename) \n Usage: mv nameobj namenew";
1017usage += "\n Related commands: rename del delobjs";
1018mpiac->RegisterCommand(kw, usage, this, "Object Management");
1019kw = "copy";
1020usage = "Copy objects (Alias cp) \n";
1021usage +=" Usage: copy name_from name_to";
1022usage += "\n Related commands: cp new...";
1023mpiac->RegisterCommand(kw, usage, this, "Object Management");
1024kw = "cp";
1025usage = "Copy objects (Alias copy) \n";
1026usage +=" Usage: cp name_from name_to";
1027usage += "\n Related commands: copy new...";
1028mpiac->RegisterCommand(kw, usage, this, "Object Management");
1029kw = "del";
1030usage = "Deletes an object (Alias: rm) \n Usage: del nameobj [nameobj2 ...]";
1031usage += "\n Related commands: rm delobjs rename";
1032mpiac->RegisterCommand(kw, usage, this, "Object Management");
1033kw = "rm";
1034usage = "Deletes an object (Alias: del) \n Usage: rm nameobj [nameobj2 ...]";
1035usage += "\n Related commands: del delobjs rename";
1036mpiac->RegisterCommand(kw, usage, this, "Object Management");
1037kw = "delobjs";
1038usage = "Delete a set of objects with names matching a pattern (x?y*)";
1039usage += "\n Usage: delobjs nameobjpattern \n";
1040usage += "\n Related commands: del rename";
1041mpiac->RegisterCommand(kw, usage, this, "Object Management");
1042
1043//------- Commandes creation/manipulation d'objets
1044kw = "newh1d";
1045usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
1046usage += "\n Related commands: newh2d newprof[e] newdt newnt newgfd ";
1047mpiac->RegisterCommand(kw, usage, this, "Objects");
1048kw = "newh2d";
1049usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
1050usage += "\n Related commands: newh1d newprof[e] newdt newnt newgfd ";
1051mpiac->RegisterCommand(kw, usage, this, "Objects");
1052kw = "newprof";
1053usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
1054usage += "\n Errors represent the data spread in the X bin ";
1055usage += "\n Related commands: newh1d newh2d newprofe newdt newnt newgfd ";
1056mpiac->RegisterCommand(kw, usage, this, "Objects");
1057kw = "newprofe";
1058usage = "Creates a profile histogramm \n Usage: newprofe name xmin xmax nbin [ymin ymax]";
1059usage += "\n Errors represent the error on the data mean in the X bin ";
1060usage += "\n Related commands: newh1d newh2d newprof newdt newnt newgfd ";
1061mpiac->RegisterCommand(kw, usage, this, "Objects");
1062kw = "newnt";
1063usage = "Creates a ntuple \n Usage: newnt name v1 v2 v3 .. vn";
1064usage += "\n newnt name nvar";
1065usage += "\n Related commands: newdt newh1d newh2d newprof[e] newgfd ";
1066mpiac->RegisterCommand(kw, usage, this, "Objects");
1067kw = "newdt";
1068usage = "Creates a datatable \n Usage: newdt name v1:t1 v2:t2 v3:t3 .. vn:tn";
1069usage += "\n newdt name nvar";
1070usage += "\n vi : variable name";
1071usage += "\n ti : variable type";
1072usage += "\n r8,r4 for 8 and 4 bytes float";
1073usage += "\n i8,i4 for 8 and 4 bytes signed integer";
1074usage += "\n s for string";
1075usage += "\n Related commands: newnt newh1d newh2d newprof[e] newgfd";
1076mpiac->RegisterCommand(kw, usage, this, "Objects");
1077kw = "newgfd";
1078usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
1079usage += "\n Related commands: newh1d newh2d newprof[e] newdt newnt ";
1080mpiac->RegisterCommand(kw, usage, this, "Objects");
1081kw = "newvec";
1082usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
1083usage += "\n Related commands: newmtx line2vec";
1084mpiac->RegisterCommand(kw, usage, this, "Objects");
1085kw = "newmtx";
1086usage = "Creates (and optionaly fills) a matrix \n";
1087usage +=" Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] ";
1088usage += "\n Related commands: newvec";
1089mpiac->RegisterCommand(kw, usage, this, "Objects");
1090kw = "line2vec";
1091usage = "Creates a vector from the line \n";
1092usage += " Usage: line2vec vecname v0 v1 v2 ... \n";
1093usage += " Related commands: newvec line2nt";
1094mpiac->RegisterCommand(kw, usage, this, "Objects");
1095kw = "line2nt";
1096usage = "Fills (append) an NTuple from the line content \n";
1097usage += " Usage: line2nt ntname col0 col1 ... \n";
1098usage += " Related commands: newnt line2vec ntline2var ntcol2var";
1099mpiac->RegisterCommand(kw, usage, this, "Objects");
1100kw = "vec2var";
1101usage = "Vector content to an interpreter variable varname = 'v0 v1 v2 ...' \n";
1102usage += " Usage: line2vec vecname varname [LoopParam start:end[:step] ]\n";
1103usage += " Related commands: line2vec ntline2var";
1104mpiac->RegisterCommand(kw, usage, this, "Objects");
1105kw = "ntline2var";
1106usage = "Object NTupleInterface line to an interpreter variable \n";
1107usage += " Usage: ntline2var objname line_number varname \n";
1108usage += " Related commands: vec2var ntcol2var";
1109mpiac->RegisterCommand(kw, usage, this, "Objects");
1110kw = "ntcol2var";
1111usage = "Object NTupleInterface column to an interpreter variable \n";
1112usage += " Usage: ntline2var objname column_number varname [LoopParam start:end[:step] ] \n";
1113usage += " Related commands: vec2var ntline2var";
1114mpiac->RegisterCommand(kw, usage, this, "Objects");
1115kw = "objaoper";
1116usage = "Perform an operation through the object adapter NObjMgrAdapter::PerformOperation()\n";
1117usage += " Usage: objaoper objname operation [arg1 ...] \n";
1118usage += " Examples of defined operations : \n";
1119usage += " Matrices: row indx_row , col indx_col \n";
1120usage += " Arrays: slicexy indx_Z , slicexz indx_Y, sliceyz indxX \n";
1121mpiac->RegisterCommand(kw, usage, this, "Objects");
1122
1123//------- Commandes trace de fonctions
1124kw = "func";
1125usage = "Displays a function y=f(x) (Fills a vector with function values)";
1126usage += "\n Usage: func f(x) xmin xmax [npt graphic_attributes]";
1127usage += "\n Related commands: funcff func2d func2dff ";
1128mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1129kw = "funcff";
1130usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
1131usage += "\n Usage: funcff C-FileName FunctionName xmin xmax [npt graphic_attributes]";
1132usage += "\n Related commands: func func2d func2dff ";
1133mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1134kw = "func2d";
1135usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
1136usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
1137usage += "\n Related commands: func";
1138mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1139kw = "func2dff";
1140usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
1141usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
1142usage += "\n Related commands: func funcff func2d ";
1143mpiac->RegisterCommand(kw, usage, this, "Func Plot");
1144
1145//------ Commandes trace d'expression
1146kw = "ObjectExpressions";
1147usage = "Any mathematical expression (math.h) with object variables can be used";
1148usage += "\n ------ Object Variable names (double) -------- ";
1149usage += "\n (_nl is the table line number or the sequential index)";
1150usage += "\n- NTuple: ntuple variable names,_nl";
1151usage += "\n- Histo1D/HProf: i,x,val,err,nb,_nl";
1152usage += "\n- Histo2D: i,j,x,y,val,err,_nl";
1153usage += "\n- HistoErr: i,x,val,err2,nb,_nl";
1154usage += "\n- Histo2DErr: i,j,x,y,val,err2,nb,_nl";
1155usage += "\n- Vector/Matrix: n,r,c,val,real,imag,mod,phas,_nl";
1156usage += "\n- TArray: n,x,y,z,t,u,val,real,imag,mod,phas,_nl";
1157usage += "\n- Image: i,j,x,y,val(=pix),_nl";
1158usage += "\n- GeneralFitData: x0,ex0 x1,ex1 ... xn,exn y,ey ok ,_nl";
1159usage += "\n- LocalMap/SphereThetaPhi/SphereHEALPix: ";
1160usage += "\n- i,k,val,real,imag,mod,phas,teta,phi,_nl";
1161usage += "\n- FITS Binary/ASCII table: fits column names,_nl";
1162#ifdef SANS_EVOLPLANCK
1163usage += "\n ------ Eros Variable names (double) -------- ";
1164usage += "\n- StarList: x,y,flux,fond,pixmax,flags,";
1165usage += "\n- xref,yref,fluxref,fondref,pixmaxref,_nl";
1166#endif
1167usage += "\n ------ Other parameters -------- ";
1168usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)";
1169usage += "\nThe default Cut() expression in true (=1) for all";
1170usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d plot3dw";
1171usage += "\n projh1d projh2d projprof fillvec fillmtx ";
1172usage += "\n fillnt fillgd1 fillgd2 ntloop exptovec ... ";
1173grp = "Expr. Plotting";
1174mpiac->RegisterHelp(kw, usage, grp);
1175kw = "plot2d";
1176usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
1177usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]";
1178usage += "\n Related commands: plot2de plot2dw plot3d plot3dw ObjectExpressions ...";
1179mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1180kw = "plot2de";
1181usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) ";
1182usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]";
1183usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1184mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1185kw = "plot2dw";
1186usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
1187usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]";
1188usage += "\n Related commands: plot2d plot2dc plot3d ObjectExpressions ...";
1189mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1190kw = "plot2dc";
1191usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Color ColIndex=h(Object) ";
1192usage += "\n Usage: plot2dc nameobj f_X() g_Y() h_Col() [Cut() graphic_attributes loop_param]";
1193usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1194mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1195kw = "plot3d";
1196usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object)";
1197usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]";
1198usage += "\n Related commands: plot2d plot2de plot3dw ObjectExpressions ...";
1199mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1200kw = "plot3dw";
1201usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) with Weight W=k(Object) ";
1202usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() k_Wt() [Cut() graphic_attributes loop_param]";
1203usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1204mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1205
1206kw = "projh1d";
1207usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
1208usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]";
1209usage += "\n Histo1D nameh1d is created if necessary ";
1210usage += "\n Related commands: projh2d projprof ObjectExpressions ...";
1211mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1212kw = "projh2d";
1213usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
1214usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
1215usage += "\n Histo2D nameh2d is created if necessary ";
1216usage += "\n Related commands: projh1d projprof ObjectExpressions ...";
1217mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1218kw = "projprof";
1219usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
1220usage += "\n Usage: projprof nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
1221usage += "\n HProf nameprof is created if necessary ";
1222usage += "\n Related commands: projh1d projh2d ObjectExpressions ...";
1223mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1224kw = "fillvec";
1225usage = "Fills a Vector V((int)(f_X(Object)+0.5)) = h_V(Object) ";
1226usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]";
1227usage += "\n Related commands: fillmtx fillnt ObjectExpressions ...";
1228mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1229kw = "fillmtx";
1230usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) = h_V(Object) ";
1231usage += "\n Usage: fillvec namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]";
1232usage += "\n Related commands: fillvec fillnt ObjectExpressions ...";
1233mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1234
1235kw = "fillnt";
1236usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
1237usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]";
1238usage += "\n Related commands: ntloop plot2d projh1d projh2d projprof ";
1239usage += "\n Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ...";
1240mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1241
1242kw = "ntloop";
1243usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
1244usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
1245usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]";
1246usage += "\n Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ...";
1247usage += "\n Related commands: ntexpcfile fillnt";
1248mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1249
1250kw = "ntexpcfile";
1251usage = "Creates a C-File with declarations suitable to be used for ntloop";
1252usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
1253usage += "\n Related commands: ntloop";
1254mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1255
1256kw = "expmeansig";
1257usage = "Computes Mean/Sigma (+Min/Max) for an expression X=f(Object)";
1258usage += "\n Usage: expmeansig nameobj f_X() [Cut() loop_param]";
1259usage += "\n Related commands: exptovec ntloop fillnt ObjectExpressions ...";
1260mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1261
1262kw = "exptovec";
1263usage = "Creates and Fills a Vector with X=f(Object)";
1264usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]";
1265usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
1266mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1267
1268kw = "fillgd1";
1269usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
1270usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]";
1271usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
1272mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1273kw = "fillgd2";
1274usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
1275usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]";
1276usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
1277mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1278kw = "gdfrvec";
1279usage = "Fills a GeneralFitData with vectors X,Y,Z,EZ";
1280usage += "\n Usage: gdfrvec namegfd X Y";
1281usage += "\n Usage: gdfrvec namegfd X Y ! EY";
1282usage += "\n Usage: gdfrvec namegfd X Y Z";
1283usage += "\n Usage: gdfrvec namegfd X Y Z EZ";
1284usage += "\n Related commands: fillgd1 fillgd2 ...";
1285mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1286
1287
1288kw = "eval";
1289usage = "Compute arithmetic expression\n";
1290usage += "\n Usage: eval resultvarname arithmetic expression....";
1291usage += "\n resultvarname: store result in variable resultvarname";
1292usage += "\n - If first character is not alphabetic, just print result";
1293usage += "\n arithmetic expression:";
1294usage += "\n ex: x + sqrt(y)+z +3.14 (x,y,z are variables)";
1295usage += "\n ex: $x + sqrt($y)+$z +3.14 (x,y,z are variables)";
1296usage += "\n ex: 360 * M_PI / 180.";
1297mpiac->RegisterCommand(kw, usage, this, "Expr. Arithmetic");
1298
1299}
1300
1301/* --Methode-- */
1302int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
1303// string& func4, string& func5)
1304{
1305string cmd;
1306
1307if (dynlink) delete dynlink; dynlink = NULL;
1308usfmap.clear();
1309
1310dynlink = new PDynLinkMgr(fnameso, true);
1311if (dynlink == NULL) {
1312 string sn = fnameso;
1313 cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
1314 return(2);
1315 }
1316
1317int nok=0;
1318// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1319// DlUserProcFunction f = NULL;
1320DlFunction f = NULL;
1321if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1322// f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
1323f = dynlink->GetFunction(func1);
1324if (f) { nok++; usfmap[func1] = f; }
1325else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
1326
1327if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1328// f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
1329f = dynlink->GetFunction(func2);
1330if (f) { nok++; usfmap[func2] = f; }
1331else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
1332
1333if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1334// f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
1335f = dynlink->GetFunction(func3);
1336if (f) { nok++; usfmap[func3] = f; }
1337else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
1338
1339/* Pb compile g++ 2.7.2
1340if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
1341// f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
1342f = dynlink->GetFunction(func4);
1343if (f) { nok++; usfmap[func4] = f; }
1344else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
1345
1346if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
1347// f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
1348f = dynlink->GetFunction(func5);
1349if (f) { nok++; usfmap[func5] = f; }
1350else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
1351*/
1352fin:
1353if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
1354else return(0);
1355}
1356
1357/* --Methode-- */
1358int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3)
1359{
1360string cmd;
1361
1362if (dynlink2) delete dynlink2; dynlink2 = NULL;
1363usfmap2.clear();
1364
1365dynlink2 = new PDynLinkMgr(fnameso, true);
1366if (dynlink2 == NULL) {
1367 string sn = fnameso;
1368 cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl;
1369 return(2);
1370 }
1371
1372int nok=0;
1373// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1374// DlUserProcFunction f = NULL;
1375DlFunction f = NULL;
1376if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1377f = dynlink2->GetFunction(func1);
1378if (f) { nok++; usfmap2[func1] = f; }
1379else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl;
1380
1381if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1382f = dynlink2->GetFunction(func2);
1383if (f) { nok++; usfmap2[func2] = f; }
1384else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl;
1385
1386if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1387f = dynlink2->GetFunction(func3);
1388if (f) { nok++; usfmap2[func3] = f; }
1389else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl;
1390
1391fin:
1392if (nok < 1) { if (dynlink2) delete dynlink2; dynlink2 = NULL; return(3); }
1393else return(0);
1394}
1395
Note: See TracBrowser for help on using the repository browser.