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

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

Ajout commande expmeansig pour TD/TP SurvEnv - Reza 27/3/2006

File size: 51.7 KB
RevLine 
[2615]1#include "sopnamsp.h"
[293]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"
[2263]12#include "strutilxx.h"
[293]13
14#include "pistdimgapp.h"
15#include "nobjmgr.h"
[326]16#include "servnobjm.h"
[2305]17#include "nomgadapter.h"
[293]18
19#include "histos.h"
20#include "histos2.h"
21#include "hisprof.h"
22#include "ntuple.h"
23#include "generaldata.h"
[2792]24#include "datatable.h"
[769]25
26#ifdef SANS_EVOLPLANCK
[333]27#include "cvector.h"
[769]28#else
29#include "tvector.h"
30#endif
[293]31
32
33/* --Methode-- */
34PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
35{
36mpiac = piac;
37mObjMgr = omg;
38mImgApp = app;
[312]39dynlink = NULL;
[1276]40dynlink2 = NULL;
[293]41RegisterCommands();
42}
43
44PIABaseExecutor::~PIABaseExecutor()
45{
[1276]46 if (dynlink) delete dynlink;
47 if (dynlink2) delete dynlink2;
[293]48}
49
50
[2755]51
[293]52/* --Methode-- */
[1268]53int PIABaseExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
[293]54{
[333]55Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
[293]56// >>>>> Chargement de modules
[2307]57if (kw == "loadmodule") {
[293]58 if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl; return(0); }
59 mpiac->LoadModule(tokens[0], tokens[1]);
60 }
[349]61
[293]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}
[1276]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}
[293]77else if (kw == "call" ) {
78 if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); }
[1276]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()) ) {
[293]83 cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
84 return(0);
85 }
[1276]86 if (it1 == usfmap.end()) it = it2;
87 else it = it1;
[293]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;
[2494]92/*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004
[293]93// On redirige la sortie sur le terminal
94 bool red = mImgApp->HasRedirectedStdOutErr();
95 mImgApp->RedirectStdOutErr(false);
[2494]96 --------DEL */
[1276]97#ifdef SANS_EVOLPLANCK
[293]98 TRY {
99 tokens.erase(tokens.begin());
100 fuf(tokens);
101 } CATCH(merr) {
102 fflush(stdout);
[1276]103 string es = PeidaExc(merr);
104 cerr << "\n PIABaseExecutor: Call UserFunc Exception :" << merr << es;
[293]105 cout << endl;
106 }
[1276]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
[2494]124/*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004
[293]125 mImgApp->RedirectStdOutErr(red);
[2494]126 --------DEL */
[293]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); }
[331]132 else { string nomobj = ""; mObjMgr->ReadFits(tokens[0], nomobj); }
[293]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" ) {
[2645]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);
[293]142}
[2132]143else if ((kw == "saveobjs") || (kw == "saveppf")) {
[333]144 if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
145 mObjMgr->SaveObjects(tokens[0], tokens[1]);
146}
[2669]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}
[293]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}
[333]162else if ( (kw == "rename" ) || (kw == "mv") ) {
[2132]163 if (tokens.size() < 2) { cout << "Usage: rename/mv nameobj namenew" << endl; return(0); }
[293]164 mObjMgr->RenameObj(tokens[0], tokens[1]);
165}
[333]166else if ( (kw == "del" ) || (kw == "rm") ) {
[1655]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]);
[293]170}
171else if (kw == "delobjs" ) {
172 if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
173 mObjMgr->DelObjects(tokens[0]);
174}
[333]175else if ( (kw == "listobjs") || (kw == "ls") ) {
[331]176 if (tokens.size() < 1) tokens.push_back("*");
[2519]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 }
[331]183}
[2519]184
[333]185// Gestion des repertoires
186else if (kw == "mkdir" ) {
[344]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);
[333]191 }
192else if (kw == "rmdir" ) {
193 if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
194 mObjMgr->DeleteDir(tokens[0]);
195 }
[2132]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}
[333]201else if (kw == "cd") {
202 if (tokens.size() < 1) tokens.push_back("home");
203 mObjMgr->SetCurrentDir(tokens[0]);
204 }
[345]205else if (kw == "pwd") {
206 string dirn;
207 mObjMgr->GetCurrentDir(dirn);
208 cout << "CurrentDirectory: " << dirn << endl;
209 }
[333]210else if (kw == "listdirs") {
211 if (tokens.size() < 1) tokens.push_back("*");
212 mObjMgr->ListDirs(tokens[0]);
213 }
[293]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); }
[1091]218 int_4 nbx = 100;
219 r_8 xmin = 0., xmax = 1.;
[293]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 }
[1091]230 int_4 nbx = 50, nby = 50;
231 r_8 xmin = 0., xmax = 1.;
232 r_8 ymin = 0., ymax = 1.;
[293]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 }
[1035]240else if (kw == "newprof" || kw == "newprofe") {
[293]241 if (tokens.size() < 4)
[1035]242 { cout << "Usage: newprof[e] name xmin xmax nbin [ymin ymax]" << endl; return(0); }
[1091]243 int_4 nbx = 100;
244 r_8 xmin = 0., xmax = 1., ymin = 1., ymax = -1.;
[293]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);
[1035]250 if(kw == "newprofe") h->SetErrOpt(false);
[293]251 mObjMgr->AddObj(h, tokens[0]);
252 }
[447]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]) ) {
[1548]272 for(int i=1;i<(int)tokens.size();i++) {
[447]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
[2792]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
[447]324// Creation de GeneralFitData
[293]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
[333]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;
[357]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 }
[333]354 }
355else if (kw == "newmtx") {
356 if (tokens.size() < 3) {
[1917]357 cout << "Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) dopt] " << endl; return(0);
[333]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;
[357]364 if (tokens.size() < 4) {
365 Matrix* mtx = new Matrix(ny,nx);
366 mObjMgr->AddObj(mtx, tokens[0]);
367 }
368 else {
[1971]369 if (tokens.size() < 5) tokens.push_back("next");
[357]370 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
371 nx, ny, tokens[4]);
372 }
[333]373 }
[2305]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 }
[2419]431 int_8 kks = 0;
432 int_8 kke = v->NElts();
433 int_8 kkp = 1;
[2305]434 if (tokens.size() > 2) Services2NObjMgr::DecodeLoopParameters(tokens[2], kks, kke, kkp);
435 if (kks < 0) kks = 0;
[2419]436 if (kke > (int_8)v->NElts()) kke = v->NElts();
[2305]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 }
[333]471
[2305]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 }
[2419]496 int_8 kks = 0;
497 int_8 kke = nti->NbLines();
498 int_8 kkp = 1;
[2305]499 if (tokens.size() > 3) Services2NObjMgr::DecodeLoopParameters(tokens[3], kks, kke, kkp);
500 if (kks < 0) kks = 0;
[2419]501 if (kke > (int_8)nti->NbLines()) kke = nti->NbLines();
[2305]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// -------------------------------------------------------
[455]522// Copie d'objets
[2176]523else if ( (kw == "copy") || (kw == "cp") ) {
[455]524 if(tokens.size()<2) {
525 cout<<"Usage: copy name_from name_to"<<endl;return(0);
526 }
[463]527 mObjMgr->CopyObj(tokens[0],tokens[1]);
[455]528}
529
530
[293]531// >>>>>>>>>>> Trace de fonctions
532else if ( (kw == "func") ) {
[1938]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());
[293]539 if (tokens.size() > 4) opt = tokens[4];
[333]540 mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt);
[293]541 }
[326]542else if ( (kw == "funcff") ) {
[1938]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];
[333]550 mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt);
[326]551 }
[293]552else if ( (kw == "func2d") ) {
553 if (tokens.size() < 7) {
[357]554 cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [opt]" << endl;
[293]555 return(0);
556 }
557 int npx, npy;
[333]558 double xmin, xmax;
559 double ymin, ymax;
[293]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());
[357]567 string opt = "";
[293]568 if (tokens.size() > 7) opt = tokens[7];
[333]569 string nom = "";
570 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
[293]571 }
[326]572else if ( (kw == "func2dff") ) {
573 if (tokens.size() < 8) {
[357]574 cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty [opt]" << endl;
[326]575 return(0);
576 }
577 int npx, npy;
[333]578 double xmin, xmax;
579 double ymin, ymax;
[326]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());
[357]587 string opt = "";
[326]588 if (tokens.size() > 8) opt = tokens[8];
[333]589 string nom = "";
590 mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
[326]591 }
[293]592
593// >>>>>>>>>>> Trace d'expressions de N_Tuple, StarList, etc ...
594else if (kw == "plot2d" ) {
[357]595 if (tokens.size() < 3) {
596 cout << "Usage: plot2d nameobj expx expy [expcut opt loop_par]" << endl;
[293]597 return(0);
598 }
[357]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);
[293]609 }
[357]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]);
[293]614 }
615
[357]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;
[333]619 return(0);
620 }
[357]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]);
[333]624 }
[357]625else if (kw == "plot3d" ) {
626 if (tokens.size() < 4) {
627 cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl;
[293]628 return(0);
629 }
[357]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]);
[293]633 }
634
635else if (kw == "projh1d" ) {
[357]636 if (tokens.size() < 3) {
637 cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl;
[293]638 return(0);
639 }
[357]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] );
[293]644 }
645
[357]646
647// Projection dans histogrammes
[293]648else if (kw == "projh2d" ) {
[357]649 if (tokens.size() < 4) {
650 cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl;
[293]651 return(0);
652 }
[357]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] );
[293]658 }
659
660else if (kw == "projprof" ) {
[357]661 if (tokens.size() < 4) {
662 cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl;
[293]663 return(0);
664 }
[357]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],
[1091]669 tokens[6], tokens[7] );
[357]670 }
[293]671
[357]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] );
[293]681 }
682
[357]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
[447]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
[2263]705#ifndef SANS_EVOLPLANCK
706/* Lecture matrice/vecteur depuis fichier ASCII */
707else if ((kw == "mtxfrascii") || (kw == "vecfrascii") ) {
708 if(tokens.size() < 2) {
[2289]709 cout<<"Usage: mtxfrascii/vecfrascii mtx/vec_name file_name [CommLine Separator]"<<endl;
[2263]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;
[2289]722 char clm = '#';
723 string sep = " \t";
724 if (tokens.size()>2) clm = tokens[2][0];
725 if (tokens.size()>3) sep = tokens[3];
[2263]726 if (kw == "mtxfrascii") {
[2289]727 mtx.ReadASCII(is, nr, nc, clm, sep.c_str());
[2263]728 mObjMgr->AddObj(mtx, tokens[0]);
729 cout << "mtxfrascii: TMatrix<r_8> " << tokens[0] << " read from file "
730 << tokens[1] << endl;
731 }
732 else {
[2289]733 vec.ReadASCII(is, nr, nc, clm, sep.c_str());
[2263]734 mObjMgr->AddObj(vec, tokens[0]);
735 cout << "vecfrascii: TVector<r_8> " << tokens[0] << " read from file "
736 << tokens[1] << endl;
737 }
738}
[2268]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
[2263]761#endif
762
[293]763else if (kw == "fillnt" ) {
[357]764 if (tokens.size() < 5) {
765 cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl;
[293]766 return(0);
767 }
[357]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] );
[293]770 }
771
[333]772else if (kw == "ntloop" ) {
773 if (tokens.size() < 3) {
[357]774 cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl;
[333]775 return(0);
776 }
[357]777 while (tokens.size() < 5) tokens.push_back("");
778 srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]);
[333]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
[2922]789else if (kw == "expmeansig" ) {
790 if (tokens.size() < 2) {
791 cout << "Usage: expmeansig nameobj expx [expcut loop_par]" << endl;
792 return(0);
793 }
794 while (tokens.size() < 4) tokens.push_back("");
795 string dummy = "";
796 cout << " expmeansig: computing mean/sigma + min/max for " << tokens[0]
797 << "." << tokens[1] << endl;
798 srvo->ExpressionToVector(tokens[0],tokens[1],tokens[2],dummy,dummy,tokens[3]);
799 }
800
[357]801else if (kw == "exptovec" ) {
802 if (tokens.size() < 3) {
803 cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl;
[293]804 return(0);
805 }
[357]806 while (tokens.size() < 6) tokens.push_back("");
807 srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]);
[293]808 }
809
810else if (kw == "fillgd1" ) {
811 if (tokens.size() < 5) {
[357]812 cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl;
[293]813 return(0);
814 }
[357]815 if (tokens.size() < 6) tokens.push_back("1");
816 if (tokens.size() < 7) tokens.push_back("");
[293]817 string expy = "";
[357]818 srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]);
[293]819 }
820
821else if (kw == "fillgd2" ) {
822 if (tokens.size() < 6) {
[357]823 cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl;
[293]824 return(0);
825 }
[357]826 if (tokens.size() < 7) tokens.push_back("1");
827 if (tokens.size() < 8) tokens.push_back("");
828 srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]);
[293]829 }
830
[1067]831else if (kw == "gdfrvec" ) {
832 if(tokens.size()<3) {
833 cout<<"Usage: gdfrvec namegfd X Y\n"
834 <<" gdfrvec namegfd X Y"
835 <<" gdfrvec namegfd X Y ! EY\n"
836 <<" gdfrvec namegfd X Y Z\n"
837 <<" gdfrvec namegfd X Y Z EZ"<<endl;
838 return(0);
839 }
840 while(tokens.size()<5) tokens.push_back("!");
841 srvo->FillGFDfrVec(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4]);
842 }
[293]843
[2180]844// >>>>>>>>>>> Calcul d'expression arithmetique
845else if ( (kw == "eval") ) {
846 if(tokens.size()<2)
847 {cout<<"Usage: eval resultvarname arithmetic expression...."<<endl; return(0);}
848 string expval = "";
849 for(unsigned int i=1;i<tokens.size();i++) expval+=tokens[i];
850 string resultvarname = "";
851 if(isalpha(tokens[0][0])) resultvarname=tokens[0];
852 mObjMgr->GetServiceObj()->ExpVal(expval,resultvarname);
853 }
[293]854
855else {
856 cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
857 return(-1);
858 }
859
860return(0);
861}
862
[2755]863/* --Methode-- */
864bool PIABaseExecutor::IsThreadable(string const & keyw)
865{
866 if ( (keyw == "fillvec") || (keyw == "fillmtx") ||
867 (keyw == "fillnt") || (keyw == "ntloop") ) return true;
868 else if (keyw.substr(0,4) == "func") return true;
869 else {
870 string skw = keyw.substr(0,5);
871 if ( (skw == "plot2") || (skw == "plot3") || (skw == "projh") ) return true;
872 }
873 return false;
874}
875
[388]876
[293]877/* --Methode-- */
878void PIABaseExecutor::RegisterCommands()
879{
[2419]880string kw, usage, grp;
[2781]881//--------- Commandes du groupe modules externes
[2465]882grp = "External Modules";
883string gdesc = "Dynamic load (shared object modules) management command group";
884mpiac->AddHelpGroup(grp, gdesc);
[293]885kw = "loadmodule";
886usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
887usage += "\n Related commands: link";
[2465]888mpiac->RegisterCommand(kw, usage, this, grp);
[293]889kw = "link";
890usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
891usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
[1276]892usage += "\n Related commands: call loadmodule linkff2";
[2465]893mpiac->RegisterCommand(kw, usage, this, grp);
[1276]894kw = "linkff2";
895usage = "Dynamic linking of compiled user functions (Set 2)\n Usage: linkff2 fnameso f1 [f2 f3]";
896usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
897usage += "\n Related commands: call link loadmodule";
[2465]898mpiac->RegisterCommand(kw, usage, this, grp);
[293]899kw = "call";
900usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
901usage += "\n User function : f(vector<string>& args)";
902usage += "\n Related commands: link";
[2465]903mpiac->RegisterCommand(kw, usage, this, grp);
[293]904
[2781]905//------- Commandes FileIO
[293]906kw = "openfits";
[2263]907usage = "Loads a FITS file into an appropriate object \n Usage: openfits filename";
[293]908usage += "\n Related commands: savefits openppf";
[330]909mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]910kw = "savefits";
911usage = "Save an object into a FITS file \n Usage: savefits nameobj filename";
[2132]912usage += "\n Related commands: openfits saveobjs saveall";
[330]913mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]914kw = "openppf";
[2645]915usage = "Reads all or some objects from a PPF file \n Usage: openppf filename [objname1 objname2 ...]";
[293]916usage += "\n Related commands: saveall openfits";
[330]917mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2132]918kw = "saveppf";
919usage = "Saves objects with names matching a pattern into a\n";
920usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
921usage += "Usage: saveppf nameobjpattern filename";
[2669]922usage += "\n Related commands: saveobjs savelist saveall openppf savefits";
[2132]923mpiac->RegisterCommand(kw, usage, this, "FileIO");
[333]924kw = "saveobjs";
[2132]925usage = "Saves objects with names matching a pattern into a\n";
926usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
[1068]927usage += "Usage: saveobjs nameobjpattern filename";
[2669]928usage += "\n Related commands: saveppf savelist saveall openppf savefits";
[333]929mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]930kw = "saveall";
931usage = "Saves all objects into a PPF file \n Usage: saveall filename";
[2669]932usage += "\n Related commands: saveobj savelist openppf savefits";
933mpiac->RegisterCommand(kw, usage, this, "FileIO");
934kw = "savelist";
935usage = "Saves a list of objects into a PPF file";
936usage = "\n Usage: savelist objname1 [objname2 ...] filename";
[333]937usage += "\n Related commands: saveobj openppf savefits";
[330]938mpiac->RegisterCommand(kw, usage, this, "FileIO");
[449]939kw = "ntfrascii";
[2792]940usage = "Fills an existing NTuple or DataTable from ASCII table file";
[449]941usage += "\n Usage: ntfrascii nt_name file_name [def_init_val]";
942usage += "\n Related commands: ntloop fillnt ";
943mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2263]944#ifndef SANS_EVOLPLANCK
945kw = "mtxfrascii";
946usage = "Reads a matrix from an ASCII file (TMatrix<r_8>)";
[2289]947usage += "\n Usage: mtxfrascii mtx_name file_name [CommChar Separator]";
[2268]948usage += "\n Related commands: arrtoascii vecfrascii ntfrascii ";
[2263]949mpiac->RegisterCommand(kw, usage, this, "FileIO");
950kw = "vecfrascii";
[2268]951usage = "Reads a vector from an ASCII file (TVector<r_8>)";
[2263]952usage += "\n Usage: vecfrascii vec_name file_name";
[2289]953usage += "\n Related commands: arrtoascii mtxfrascii ntfrascii [CommChar Separator]";
[2263]954mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2268]955kw = "arrtoascii";
956usage = "Writes an array (TArray<T>) to an ASCII file ";
957usage += "\n Usage: arrtoascii array_name file_name";
958usage += "\n Related commands: mtxfrascii vecfrascii ntfrascii ";
959mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2263]960#endif
[293]961
962kw = "print";
963usage = "Prints an object \n Usage: print nameobj";
[330]964mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]965
[2781]966//------- Commandes gestion de repertoires et d'objets
[333]967kw = "mkdir";
968usage = "Create a directory";
[344]969usage += "\n Usage: mkdir dirname [true]";
970usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
[463]971mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]972kw = "rmdir";
973usage = "Removes an empty directory";
974usage += "\n Usage: remove dirname";
[463]975mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]976kw = "setdiratt";
977usage = "Sets directory attributes";
978usage += "\n Usage: setdiratt dirname KeepOldFlag(=true/false)";
979usage += "\n KeepOldFlag=true Object with the same name is moved to old";
980usage += "\n when adding objects";
981mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]982kw = "cd";
983usage = "Change current directory";
984usage += "\n Usage: cd [dirname]";
[463]985mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]986kw = "pwd";
987usage = "Prints current directory";
988usage += "\n Usage: pwd";
[463]989mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]990kw = "listdirs";
991usage = "Prints the list of directories";
992usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
[463]993mpiac->RegisterCommand(kw, usage, this, "Object Management");
[295]994kw = "listobjs";
[333]995usage = "Prints the list of objects (Alias: ls)";
996 usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
[463]997mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]998kw = "rename";
[333]999usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
[2132]1000usage += "\n Related commands: mv del delobjs";
[463]1001mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]1002kw = "mv";
1003usage = "Rename an object (Alias: rename) \n Usage: mv nameobj namenew";
1004usage += "\n Related commands: rename del delobjs";
1005mpiac->RegisterCommand(kw, usage, this, "Object Management");
[463]1006kw = "copy";
[2132]1007usage = "Copy objects (Alias cp) \n";
[463]1008usage +=" Usage: copy name_from name_to";
[2132]1009usage += "\n Related commands: cp new...";
[2176]1010mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]1011kw = "cp";
1012usage = "Copy objects (Alias copy) \n";
1013usage +=" Usage: cp name_from name_to";
1014usage += "\n Related commands: copy new...";
[463]1015mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1016kw = "del";
[1655]1017usage = "Deletes an object (Alias: rm) \n Usage: del nameobj [nameobj2 ...]";
[2132]1018usage += "\n Related commands: rm delobjs rename";
[463]1019mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]1020kw = "rm";
1021usage = "Deletes an object (Alias: del) \n Usage: rm nameobj [nameobj2 ...]";
1022usage += "\n Related commands: del delobjs rename";
1023mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1024kw = "delobjs";
1025usage = "Delete a set of objects with names matching a pattern (x?y*)";
1026usage += "\n Usage: delobjs nameobjpattern \n";
1027usage += "\n Related commands: del rename";
[463]1028mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1029
[2781]1030//------- Commandes creation/manipulation d'objets
[293]1031kw = "newh1d";
1032usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
[2792]1033usage += "\n Related commands: newh2d newprof[e] newdt newnt newgfd ";
[333]1034mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1035kw = "newh2d";
1036usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
[2792]1037usage += "\n Related commands: newh1d newprof[e] newdt newnt newgfd ";
[333]1038mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1039kw = "newprof";
1040usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
[1035]1041usage += "\n Errors represent the data spread in the X bin ";
[2792]1042usage += "\n Related commands: newh1d newh2d newprofe newdt newnt newgfd ";
[333]1043mpiac->RegisterCommand(kw, usage, this, "Objects");
[1035]1044kw = "newprofe";
1045usage = "Creates a profile histogramm \n Usage: newprofe name xmin xmax nbin [ymin ymax]";
1046usage += "\n Errors represent the error on the data mean in the X bin ";
[2792]1047usage += "\n Related commands: newh1d newh2d newprof newdt newnt newgfd ";
[1035]1048mpiac->RegisterCommand(kw, usage, this, "Objects");
[447]1049kw = "newnt";
1050usage = "Creates a ntuple \n Usage: newnt name v1 v2 v3 .. vn";
1051usage += "\n newnt name nvar";
[2792]1052usage += "\n Related commands: newdt newh1d newh2d newprof[e] newgfd ";
[447]1053mpiac->RegisterCommand(kw, usage, this, "Objects");
[2792]1054kw = "newdt";
1055usage = "Creates a datatable \n Usage: newdt name v1:t1 v2:t2 v3:t3 .. vn:tn";
1056usage += "\n newdt name nvar";
1057usage += "\n vi : variable name";
1058usage += "\n ti : variable type";
1059usage += "\n r8,r4 for 8 and 4 bytes float";
1060usage += "\n i8,i4 for 8 and 4 bytes signed integer";
1061usage += "\n s for string";
1062usage += "\n Related commands: newnt newh1d newh2d newprof[e] newgfd";
1063mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1064kw = "newgfd";
1065usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
[2792]1066usage += "\n Related commands: newh1d newh2d newprof[e] newdt newnt ";
[333]1067mpiac->RegisterCommand(kw, usage, this, "Objects");
1068kw = "newvec";
[357]1069usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
[2305]1070usage += "\n Related commands: newmtx line2vec";
[357]1071mpiac->RegisterCommand(kw, usage, this, "Objects");
[333]1072kw = "newmtx";
[357]1073usage = "Creates (and optionaly fills) a matrix \n";
[1917]1074usage +=" Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] ";
[333]1075usage += "\n Related commands: newvec";
[357]1076mpiac->RegisterCommand(kw, usage, this, "Objects");
[2305]1077kw = "line2vec";
1078usage = "Creates a vector from the line \n";
1079usage += " Usage: line2vec vecname v0 v1 v2 ... \n";
1080usage += " Related commands: newvec line2nt";
1081mpiac->RegisterCommand(kw, usage, this, "Objects");
1082kw = "line2nt";
1083usage = "Fills (append) an NTuple from the line content \n";
1084usage += " Usage: line2nt ntname col0 col1 ... \n";
1085usage += " Related commands: newnt line2vec ntline2var ntcol2var";
1086mpiac->RegisterCommand(kw, usage, this, "Objects");
1087kw = "vec2var";
1088usage = "Vector content to an interpreter variable varname = 'v0 v1 v2 ...' \n";
1089usage += " Usage: line2vec vecname varname [LoopParam start:end[:step] ]\n";
1090usage += " Related commands: line2vec ntline2var";
1091mpiac->RegisterCommand(kw, usage, this, "Objects");
1092kw = "ntline2var";
1093usage = "Object NTupleInterface line to an interpreter variable \n";
1094usage += " Usage: ntline2var objname line_number varname \n";
1095usage += " Related commands: vec2var ntcol2var";
1096mpiac->RegisterCommand(kw, usage, this, "Objects");
1097kw = "ntcol2var";
1098usage = "Object NTupleInterface column to an interpreter variable \n";
1099usage += " Usage: ntline2var objname column_number varname [LoopParam start:end[:step] ] \n";
1100usage += " Related commands: vec2var ntline2var";
1101mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1102
[2781]1103//------- Commandes trace de fonctions
[293]1104kw = "func";
1105usage = "Displays a function y=f(x) (Fills a vector with function values)";
[1938]1106usage += "\n Usage: func f(x) xmin xmax [npt graphic_attributes]";
[326]1107usage += "\n Related commands: funcff func2d func2dff ";
[330]1108mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[326]1109kw = "funcff";
1110usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
[1938]1111usage += "\n Usage: funcff C-FileName FunctionName xmin xmax [npt graphic_attributes]";
[326]1112usage += "\n Related commands: func func2d func2dff ";
[330]1113mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[293]1114kw = "func2d";
1115usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
1116usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
1117usage += "\n Related commands: func";
[330]1118mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[326]1119kw = "func2dff";
1120usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
1121usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
1122usage += "\n Related commands: func funcff func2d ";
[330]1123mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[293]1124
[2781]1125//------ Commandes trace d'expression
[357]1126kw = "ObjectExpressions";
1127usage = "Any mathematical expression (math.h) with object variables can be used";
1128usage += "\n ------ Object Variable names (double) -------- ";
[2419]1129usage += "\n (_nl is the table line number or the sequential index)";
1130usage += "\n- NTuple: ntuple variable names,_nl";
1131usage += "\n- Histo1D/HProf: i,x,val,err,_nl";
1132usage += "\n- Histo2D: i,j,x,y,val,err,_nl";
1133usage += "\n- Vector/Matrix: n,r,c,val,real,imag,mod,phas,_nl";
1134usage += "\n- TArray: n,x,y,z,t,u,val,real,imag,mod,phas,_nl";
1135usage += "\n- Image: i,j,x,y,val(=pix),_nl";
1136usage += "\n- GeneralFitData: x0,ex0 x1,ex1 ... xn,exn y,ey ok ,_nl";
[1548]1137usage += "\n- LocalMap/SphereThetaPhi/SphereHEALPix: ";
[2419]1138usage += "\n- i,k,val,real,imag,mod,phas,teta,phi,_nl";
1139usage += "\n- FITS Binary/ASCII table: fits column names,_nl";
[2128]1140#ifdef SANS_EVOLPLANCK
1141usage += "\n ------ Eros Variable names (double) -------- ";
1142usage += "\n- StarList: x,y,flux,fond,pixmax,flags,";
[2419]1143usage += "\n- xref,yref,fluxref,fondref,pixmaxref,_nl";
[2128]1144#endif
[1548]1145usage += "\n ------ Other parameters -------- ";
[357]1146usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)";
1147usage += "\nThe default Cut() expression in true (=1) for all";
[1548]1148usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d ";
[357]1149usage += "\n projh1d projh2d projprof fillvec fillmtx ";
1150usage += "\n fillnt fillgd1 fillgd2 ntloop exptovec ... ";
[2419]1151grp = "Expr. Plotting";
1152mpiac->RegisterHelp(kw, usage, grp);
[293]1153kw = "plot2d";
1154usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
[357]1155usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]";
1156usage += "\n Related commands: plot2de plot2dw plot3d ObjectExpressions ...";
[330]1157mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1158kw = "plot2de";
1159usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) ";
1160usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]";
1161usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1162mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[333]1163kw = "plot2dw";
1164usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
[357]1165usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]";
1166usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
[333]1167mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1168kw = "plot3d";
1169usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
[357]1170usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]";
1171usage += "\n Related commands: plot2d plot2dw plot2de plot3d ObjectExpressions ...";
[330]1172mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1173
1174kw = "projh1d";
1175usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
[357]1176usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]";
[293]1177usage += "\n Histo1D nameh1d is created if necessary ";
[357]1178usage += "\n Related commands: projh2d projprof ObjectExpressions ...";
[330]1179mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1180kw = "projh2d";
1181usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
[357]1182usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
[293]1183usage += "\n Histo2D nameh2d is created if necessary ";
[357]1184usage += "\n Related commands: projh1d projprof ObjectExpressions ...";
[330]1185mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1186kw = "projprof";
1187usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
[709]1188usage += "\n Usage: projprof nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
[293]1189usage += "\n HProf nameprof is created if necessary ";
[357]1190usage += "\n Related commands: projh1d projh2d ObjectExpressions ...";
[330]1191mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1192kw = "fillvec";
1193usage = "Fills a Vector V((int)(f_X(Object)+0.5)) = h_V(Object) ";
1194usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]";
1195usage += "\n Related commands: fillmtx fillnt ObjectExpressions ...";
1196mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1197kw = "fillmtx";
1198usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) = h_V(Object) ";
1199usage += "\n Usage: fillvec namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]";
1200usage += "\n Related commands: fillvec fillnt ObjectExpressions ...";
1201mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1202
1203kw = "fillnt";
1204usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
[357]1205usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]";
[333]1206usage += "\n Related commands: ntloop plot2d projh1d projh2d projprof ";
[357]1207usage += "\n Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ...";
[330]1208mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1209
[333]1210kw = "ntloop";
1211usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
1212usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
[357]1213usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]";
1214usage += "\n Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ...";
[333]1215usage += "\n Related commands: ntexpcfile fillnt";
1216mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1217
[333]1218kw = "ntexpcfile";
1219usage = "Creates a C-File with declarations suitable to be used for ntloop";
1220usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
1221usage += "\n Related commands: ntloop";
1222mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1223
[2922]1224kw = "expmeansig";
1225usage = "Computes Mean/Sigma (+Min/Max) for an expression X=f(Object)";
1226usage += "\n Usage: expmeansig nameobj f_X() [Cut() loop_param]";
1227usage += "\n Related commands: exptovec ntloop fillnt ObjectExpressions ...";
1228mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1229
[357]1230kw = "exptovec";
[293]1231usage = "Creates and Fills a Vector with X=f(Object)";
[357]1232usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]";
1233usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
[330]1234mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[2922]1235
[293]1236kw = "fillgd1";
1237usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
[357]1238usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]";
1239usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
[330]1240mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1241kw = "fillgd2";
1242usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
[357]1243usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]";
1244usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
[330]1245mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[1067]1246kw = "gdfrvec";
1247usage = "Fills a GeneralFitData with vectors X,Y,Z,EZ";
1248usage += "\n Usage: gdfrvec namegfd X Y";
1249usage += "\n Usage: gdfrvec namegfd X Y ! EY";
1250usage += "\n Usage: gdfrvec namegfd X Y Z";
1251usage += "\n Usage: gdfrvec namegfd X Y Z EZ";
1252usage += "\n Related commands: fillgd1 fillgd2 ...";
1253mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1254
[2180]1255
1256kw = "eval";
1257usage = "Compute arithmetic expression\n";
1258usage += "\n Usage: eval resultvarname arithmetic expression....";
1259usage += "\n resultvarname: store result in variable resultvarname";
1260usage += "\n - If first character is not alphabetic, just print result";
1261usage += "\n arithmetic expression:";
1262usage += "\n ex: x + sqrt(y)+z +3.14 (x,y,z are variables)";
1263usage += "\n ex: $x + sqrt($y)+$z +3.14 (x,y,z are variables)";
1264usage += "\n ex: 360 * M_PI / 180.";
1265mpiac->RegisterCommand(kw, usage, this, "Expr. Arithmetic");
1266
[293]1267}
1268
1269/* --Methode-- */
1270int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
1271// string& func4, string& func5)
1272{
1273string cmd;
1274
1275if (dynlink) delete dynlink; dynlink = NULL;
1276usfmap.clear();
1277
1278dynlink = new PDynLinkMgr(fnameso, true);
1279if (dynlink == NULL) {
1280 string sn = fnameso;
1281 cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
1282 return(2);
1283 }
1284
1285int nok=0;
1286// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1287// DlUserProcFunction f = NULL;
1288DlFunction f = NULL;
1289if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1290// f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
1291f = dynlink->GetFunction(func1);
1292if (f) { nok++; usfmap[func1] = f; }
1293else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
1294
1295if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1296// f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
1297f = dynlink->GetFunction(func2);
1298if (f) { nok++; usfmap[func2] = f; }
1299else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
1300
1301if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1302// f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
1303f = dynlink->GetFunction(func3);
1304if (f) { nok++; usfmap[func3] = f; }
1305else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
1306
1307/* Pb compile g++ 2.7.2
1308if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
1309// f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
1310f = dynlink->GetFunction(func4);
1311if (f) { nok++; usfmap[func4] = f; }
1312else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
1313
1314if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
1315// f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
1316f = dynlink->GetFunction(func5);
1317if (f) { nok++; usfmap[func5] = f; }
1318else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
1319*/
1320fin:
1321if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
1322else return(0);
1323}
1324
[1276]1325/* --Methode-- */
1326int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3)
1327{
1328string cmd;
1329
1330if (dynlink2) delete dynlink2; dynlink2 = NULL;
1331usfmap2.clear();
1332
1333dynlink2 = new PDynLinkMgr(fnameso, true);
1334if (dynlink2 == NULL) {
1335 string sn = fnameso;
1336 cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl;
1337 return(2);
1338 }
1339
1340int nok=0;
1341// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1342// DlUserProcFunction f = NULL;
1343DlFunction f = NULL;
1344if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1345f = dynlink2->GetFunction(func1);
1346if (f) { nok++; usfmap2[func1] = f; }
1347else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl;
1348
1349if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1350f = dynlink2->GetFunction(func2);
1351if (f) { nok++; usfmap2[func2] = f; }
1352else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl;
1353
1354if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1355f = dynlink2->GetFunction(func3);
1356if (f) { nok++; usfmap2[func3] = f; }
1357else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl;
1358
1359fin:
1360if (nok < 1) { if (dynlink2) delete dynlink2; dynlink2 = NULL; return(3); }
1361else return(0);
1362}
1363
Note: See TracBrowser for help on using the repository browser.