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

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

Ajout flag int lev ds les adaptateurs NObjMgrAdapter::Print(ostream& os, int lev=0) et NamedObjMgr::Print() + modif commande print - Reza 20 Juin 2006

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