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

Last change on this file since 2944 was 2944, checked in by ansari, 19 years ago

1- Correction/Amelioration gestion code de retour (Rc) ds les
CmdExecutor (basexecut.cc cxxexecutor.cc) - pour c++exec en particulier
2- ajout flag fgsmall (constructeur PIStdImgApp) pour petite fenetre
principale

Reza , 26/04/2006

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