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

Last change on this file since 2781 was 2781, checked in by ansari, 20 years ago

1/ Separation de basexecut.cc en deux : commandes graphiques mises ds graphexecut.cc .h
2/ Finalisation commandes bargraph et textdrawer ds graphexecut.cc
3/ Adaptation piacmd.cc , suppression limite a 250 ds func2d et MAJ MAkefile et objlist.list

Reza 30 Mai 2005

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