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

Last change on this file was 3588, checked in by ansari, 17 years ago

Declaration HelpGroup Expr.Plotting mal placee, Reza 05/03/2009

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