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

Last change on this file since 2833 was 2792, checked in by cmv, 20 years ago

spiapp cmd "newdt" pour creer une DataTable
spiapp cmd "n/read" modifier pour remplir aussi des DataTable (option -dt)
NtFromASCIIFile modifier pour remplir aussi des DataTable

mais le decodage FillFromASCII de la classe DataTAble est encore a faire

cmv 01/06/2005

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