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

Last change on this file since 344 was 344, checked in by ercodmgr, 26 years ago

1/ Extension de fonctionalites de gestion de repertoires (Lock, ...)
2/ Plus de NTupIntf_Adapter quand les objets heritent de NTupleInterface
3/ Support pour affichage info texte, ds PINtuple et PIStarList

File size: 34.9 KB
Line 
1#include "piacmd.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <math.h>
6
7#include "basexecut.h"
8
9#include "pdlmgr.h"
10#include "ctimer.h"
11// #include "dlftypes.h"
12
13#include "pistdimgapp.h"
14#include "nobjmgr.h"
15#include "servnobjm.h"
16
17#include "histos.h"
18#include "histos2.h"
19#include "hisprof.h"
20#include "ntuple.h"
21#include "generaldata.h"
22#include "cvector.h"
23
24
25
26/* --Methode-- */
27PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
28{
29mpiac = piac;
30mObjMgr = omg;
31mImgApp = app;
32dynlink = NULL;
33RegisterCommands();
34}
35
36PIABaseExecutor::~PIABaseExecutor()
37{
38}
39
40
41
42/* --Methode-- */
43int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
44{
45Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
46// >>>>> Chargement de modules
47if (kw == "loadmodule") {
48 if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl; return(0); }
49 mpiac->LoadModule(tokens[0], tokens[1]);
50 }
51// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques
52else if (kw == "zone") {
53 if (tokens.size() < 2) { cout << "Usage: zone nx ny" << endl; return(0); }
54 int nx, ny;
55 nx = ny = 1;
56 nx = atoi(tokens[0].c_str()); ny = atoi(tokens[1].c_str());
57 mObjMgr->SetGraphicWinZone(nx, ny, false);
58 }
59else if (kw == "newwin") {
60 if (tokens.size() < 2) { cout << "Usage: newwin nx ny" << endl; return(0); }
61 int nx, ny;
62 nx = ny = 1;
63 nx = atoi(tokens[0].c_str()); ny = atoi(tokens[1].c_str());
64 mObjMgr->SetGraphicWinZone(nx, ny, true);
65 }
66else if (kw == "stacknext") mImgApp->StackWinNext();
67else if (kw == "gratt") {
68 if (tokens.size() < 1) { cout << "Usage: gratt attributes_list (att=def->defaut)" << endl; return(0); }
69 mObjMgr->SetGraphicAttributes(tokens[0]);
70 }
71else if (kw == "setxylimits") {
72 if (tokens.size() < 4) { cout << "Usage: setxylimits xmin xmax ymin ymax" << endl; return(0); }
73 double xmin = atof(tokens[0].c_str());
74 double xmax = atof(tokens[1].c_str());
75 double ymin = atof(tokens[2].c_str());
76 double ymax = atof(tokens[3].c_str());
77 mImgApp->SetXYLimits(xmin, xmax, ymin, ymax);
78 }
79// >>>>>>>>>>> Link dynamique de fonctions C++
80else if (kw == "link" ) {
81 if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl; return(0); }
82 string sph = "";
83 for(int gg=0; gg<5; gg++) tokens.push_back(sph);
84 int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
85 if (rc == 0) cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
86}
87else if (kw == "call" ) {
88 if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); }
89 UsFmap::iterator it = usfmap.find(tokens[0]);
90 if (it == usfmap.end()) {
91 cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
92 return(0);
93 }
94 cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
95// on est oblige de faire un cast etant donne qu'on
96// utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
97 DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
98// On redirige la sortie sur le terminal
99 bool red = mImgApp->HasRedirectedStdOutErr();
100 mImgApp->RedirectStdOutErr(false);
101 TRY {
102 tokens.erase(tokens.begin());
103 fuf(tokens);
104 } CATCH(merr) {
105 fflush(stdout);
106 cout << endl;
107 cerr << endl;
108 string es = PeidaExc(merr);
109 cerr << "PIABaseExecutor: Call UserFunc Exception :" << merr << es;
110 }
111 mImgApp->RedirectStdOutErr(red);
112}
113
114// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets
115else if (kw == "openfits" ) {
116 if (tokens.size() < 1) { cout << "Usage: openfits file " << endl; return(0); }
117 else { string nomobj = ""; mObjMgr->ReadFits(tokens[0], nomobj); }
118}
119else if (kw == "savefits" ) {
120 if (tokens.size() < 2) { cout << "Usage: savefits nameobj filename " << endl; return(0); }
121 else mObjMgr->SaveFits(tokens[0], tokens[1]);
122}
123else if (kw == "openppf" ) {
124 if (tokens.size() < 1) { cout << "Usage: openppf file " << endl; return(0); }
125 mObjMgr->ReadAll(tokens[0]);
126}
127else if (kw == "saveobjs" ) {
128 if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
129 mObjMgr->SaveObjects(tokens[0], tokens[1]);
130}
131else if (kw == "saveall" ) {
132 if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
133 mObjMgr->SaveAll(tokens[0]);
134}
135else if (kw == "print" ) {
136 if (tokens.size() < 1) { cout << "Usage: print nameobj " << endl; return(0); }
137 mObjMgr->PrintObj(tokens[0]);
138}
139else if ( (kw == "rename" ) || (kw == "mv") ) {
140 if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
141 mObjMgr->RenameObj(tokens[0], tokens[1]);
142}
143else if ( (kw == "del" ) || (kw == "rm") ) {
144 if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
145 mObjMgr->DelObj(tokens[0]);
146}
147else if (kw == "delobjs" ) {
148 if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
149 mObjMgr->DelObjects(tokens[0]);
150}
151else if ( (kw == "listobjs") || (kw == "ls") ) {
152 if (tokens.size() < 1) tokens.push_back("*");
153 mObjMgr->ListObjs(tokens[0]);
154}
155// Gestion des repertoires
156else if (kw == "mkdir" ) {
157 if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); }
158 bool crd = mObjMgr->CreateDir(tokens[0]);
159 if ( crd && (tokens.size() > 1) && (tokens[1] == "true") )
160 mObjMgr->SetKeepOldDirAtt(tokens[0], true);
161 }
162else if (kw == "rmdir" ) {
163 if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
164 mObjMgr->DeleteDir(tokens[0]);
165 }
166else if (kw == "cd") {
167 if (tokens.size() < 1) tokens.push_back("home");
168 mObjMgr->SetCurrentDir(tokens[0]);
169 }
170else if (kw == "listdirs") {
171 if (tokens.size() < 1) tokens.push_back("*");
172 mObjMgr->ListDirs(tokens[0]);
173 }
174
175// >>>>>>>>>>> Creation d'histos 1D-2D
176else if (kw == "newh1d") {
177 if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
178 int nbx;
179 float xmin, xmax;
180 nbx = 100;
181 xmin = 0.; xmax = 1.;
182 nbx = atoi(tokens[3].c_str());
183 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
184 Histo* h = new Histo(xmin, xmax, nbx);
185 mObjMgr->AddObj(h, tokens[0]);
186 }
187else if (kw == "newh2d") {
188 if (tokens.size() < 7) {
189 cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl;
190 return(0);
191 }
192 int nbx, nby;
193 float xmin, xmax;
194 float ymin, ymax;
195 nbx = nby = 50;
196 xmin = 0.; xmax = 1.;
197 ymin = 0.; ymax = 1.;
198 nbx = atoi(tokens[3].c_str());
199 nby = atoi(tokens[6].c_str());
200 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
201 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
202 Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
203 mObjMgr->AddObj(h, tokens[0]);
204 }
205else if (kw == "newprof") {
206 if (tokens.size() < 4)
207 { cout << "Usage: newprof name xmin xmax nbin [ymin ymax]" << endl; return(0); }
208 int nbx;
209 float xmin, xmax, ymin = 1., ymax = -1.;
210 if(tokens.size() > 5)
211 {ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());}
212 nbx = 100;
213 xmin = 0.; xmax = 1.;
214 nbx = atoi(tokens[3].c_str());
215 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
216 HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
217 mObjMgr->AddObj(h, tokens[0]);
218 }
219else if (kw == "newgfd") {
220 if (tokens.size() < 3)
221 { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
222 int nvar, nalloc, errx=0;
223 if (tokens.size() > 3)
224 { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
225 nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
226 if(nvar>0 && nalloc>0) {
227 GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
228 mObjMgr->AddObj(gfd, tokens[0]);
229 }
230 }
231
232// Creation/remplissage de vecteur et de matrice
233else if (kw == "newvec") {
234 if (tokens.size() < 2) {
235 cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0);
236 }
237 int n = atoi(tokens[1].c_str());
238 double xmin, xmax;
239 xmin = 0.; xmax = n;
240 if (tokens.size() < 3) tokens.push_back("0.");
241 if (tokens.size() < 4) tokens.push_back("n");
242 mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]);
243 }
244else if (kw == "newmtx") {
245 if (tokens.size() < 3) {
246 cout << "Usage: newvec name sizeX sizeY [f(i,j) dopt] " << endl; return(0);
247 }
248 int nx = atoi(tokens[1].c_str());
249 int ny = atoi(tokens[2].c_str());
250 double xmin, xmax, ymin, ymax;
251 xmin = 0.; xmax = nx;
252 ymin = 0.; ymax = ny;
253 if (tokens.size() < 4) tokens.push_back("0.");
254 if (tokens.size() < 5) tokens.push_back("n");
255 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
256 nx, ny, tokens[4]);
257 }
258
259// >>>>>>>>>>> Affichage des objets
260else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
261 if (tokens.size() < 1) { cout << "Usage: disp/surf/imag nameobj [opt]" << endl; return(0); }
262 string opt = "n";
263 if (tokens.size() > 1) opt = tokens[1];
264 if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
265 else if (kw == "surf") mObjMgr->DisplaySurf3D(tokens[0], opt);
266 else if (kw == "imag") mObjMgr->DisplayImage(tokens[0], opt);
267 }
268
269else if (kw == "nt2d") {
270 if (tokens.size() < 5) { cout << "Usage: nt2d nameobj varx vary errx erry opt" << endl; return(0); }
271 string opt = "n";
272 if (tokens.size() > 5) opt = tokens[5];
273 string ph = "";
274 mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
275 }
276else if (kw == "nt2dw") {
277 if (tokens.size() < 6) { cout << "Usage: nt2dw nameobj varx vary varz errx erry opt" << endl; return(0); }
278 string opt = "n";
279 if (tokens.size() > 6) opt = tokens[6];
280 string ph = "";
281 mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], ph, opt, false);
282 }
283else if (kw == "nt3d") {
284 if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
285 string opt = "n";
286 if (tokens.size() > 7) opt = tokens[7];
287 mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt, true);
288 }
289
290// Obsolete : ne pas virer SVP, cmv 26/7/99
291else if (kw == "gfd2d") {
292 cout<<"----- gfd2d OBSOLETE: utilisez nt2d -----"<<endl;
293 if(tokens.size()<2)
294 {cout<<"Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
295 return(0);}
296 string numvary = "";
297 string err = "";
298 string opt = "n";
299 if(tokens.size()>2) err = tokens[2];
300 if(tokens.size()>3) opt = tokens[3];
301 mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
302 }
303else if (kw == "gfd3d") {
304 cout<<"----- gfd3d OBSOLETE: utilisez nt3d -----"<<endl;
305 if(tokens.size()<3)
306 {cout<<"Usage: gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
307 return(0);}
308 string err = "";
309 string opt = "n";
310 if(tokens.size()>3) err = tokens[3];
311 if(tokens.size()>4) opt = tokens[4];
312 mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
313 }
314
315// >>>>>>>>>>> Trace de fonctions
316else if ( (kw == "func") ) {
317 if (tokens.size() < 4) { cout << "Usage: func f(x) xmin xmax npt [opt]" << endl; return(0); }
318 string opt = "n";
319 if (tokens.size() > 4) opt = tokens[4];
320 int np;
321 double xmin, xmax;
322 np = 100;
323 xmin = 0.; xmax = 1.;
324 np = atoi(tokens[3].c_str());
325 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
326 string nom = "";
327 mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt);
328 }
329else if ( (kw == "funcff") ) {
330 if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); }
331 string opt = "n";
332 if (tokens.size() > 5) opt = tokens[5];
333 int np;
334 double xmin, xmax;
335 np = 100;
336 xmin = 0.; xmax = 1.;
337 np = atoi(tokens[4].c_str());
338 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
339 string nom = "";
340 mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt);
341 }
342else if ( (kw == "func2d") ) {
343 if (tokens.size() < 7) {
344 cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty opt" << endl;
345 return(0);
346 }
347 int npx, npy;
348 double xmin, xmax;
349 double ymin, ymax;
350 npx = npy = 50;
351 xmin = 0.; xmax = 1.;
352 ymin = 0.; ymax = 1.;
353 npx = atoi(tokens[3].c_str());
354 npy = atoi(tokens[6].c_str());
355 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
356 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
357 string opt = "n";
358 if (tokens.size() > 7) opt = tokens[7];
359 string nom = "";
360 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
361 }
362else if ( (kw == "func2dff") ) {
363 if (tokens.size() < 8) {
364 cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty opt" << endl;
365 return(0);
366 }
367 int npx, npy;
368 double xmin, xmax;
369 double ymin, ymax;
370 npx = npy = 50;
371 xmin = 0.; xmax = 1.;
372 ymin = 0.; ymax = 1.;
373 npx = atoi(tokens[4].c_str());
374 npy = atoi(tokens[7].c_str());
375 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
376 ymin = atof(tokens[5].c_str()); ymax = atof(tokens[6].c_str());
377 string opt = "n";
378 if (tokens.size() > 8) opt = tokens[8];
379 string nom = "";
380 mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
381 }
382
383// >>>>>>>>>>> Trace d'expressions de N_Tuple, StarList, etc ...
384else if (kw == "plot2d" ) {
385 if (tokens.size() < 4) {
386 cout << "Usage: plot2d nameobj expx expy [experrx experry] expcut [opt]" << endl;
387 return(0);
388 }
389 string errx = ""; string erry = ""; string ecut = "1";
390 string opt = "n";
391 if (tokens.size() < 6) { // Plot sans les erreurs
392 ecut = tokens[3];
393 if (tokens.size() > 4) opt = tokens[4];
394 }
395 else { // Plot avec les erreurs
396 errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
397 if (tokens.size() > 6) opt = tokens[6];
398 }
399 srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
400 }
401
402else if (kw == "plot2dw" ) {
403 if (tokens.size() < 5) {
404 cout << "Usage: plot2dw nomobj expx expy expwt expcut opt" << endl;
405 return(0);
406 }
407 string opt = "n";
408 if (tokens.size() > 5) opt = tokens[5];
409 srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
410 }
411else if (kw == "plot3d" ) {
412 if (tokens.size() < 5) {
413 cout << "Usage: plot3d nomobj expx expy expz expcut opt" << endl;
414 return(0);
415 }
416 string opt = "n";
417 if (tokens.size() > 5) opt = tokens[5];
418 srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
419 }
420
421else if (kw == "projh1d" ) {
422 if (tokens.size() < 5) {
423 cout << "Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
424 return(0);
425 }
426 string opt = "n";
427 if (tokens.size() > 5) opt = tokens[5];
428 srvo->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
429 }
430
431else if (kw == "projh2d" ) {
432 if (tokens.size() < 6) {
433 cout << "Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
434 return(0);
435 }
436 string opt = "n";
437 if (tokens.size() > 6) opt = tokens[6];
438
439 srvo->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
440 }
441
442else if (kw == "projprof" ) {
443 if (tokens.size() < 6) {
444 cout << "Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
445 return(0);
446 }
447 string opt = "n";
448 if (tokens.size() > 6) opt = tokens[6];
449
450 srvo->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
451 }
452
453else if (kw == "fillnt" ) {
454 if (tokens.size() < 6) {
455 cout << "Usage: fillnt nameobj expx expy expz expt expcut [ntname]" << endl;
456 return(0);
457 }
458 if (tokens.size() < 7) tokens.push_back("");
459 srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
460 }
461
462else if (kw == "ntloop" ) {
463 if (tokens.size() < 3) {
464 cout << "Usage: ntloop nameobj fname funcname [ntname [N1 N2] ]" << endl;
465 return(0);
466 }
467 if (tokens.size() < 4) tokens.push_back("");
468 if (tokens[3] == "!") tokens[3] = "";
469 int nl1 = -1;
470 int nl2 = -1;
471 if (tokens.size() > 5) {
472 nl1 = atoi(tokens[4].c_str());
473 nl2 = atoi(tokens[5].c_str());
474 }
475 srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], nl1, nl2);
476 }
477
478else if (kw == "ntexpcfile" ) {
479 if (tokens.size() < 3) {
480 cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
481 return(0);
482 }
483 srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
484 }
485
486else if (kw == "fillvec" ) {
487 if (tokens.size() < 4) {
488 cout << "Usage: fillvec nameobj expx expcut nomvec opt" << endl;
489 return(0);
490 }
491 string opt = "n";
492 if (tokens.size() > 4) opt = tokens[4];
493 srvo->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
494 }
495
496else if (kw == "fillgd1" ) {
497 if (tokens.size() < 5) {
498 cout << "Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
499 return(0);
500 }
501 string nomgfd = "";
502 if (tokens.size() > 5) nomgfd = tokens[5];
503 string expy = "";
504 srvo->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
505 }
506
507else if (kw == "fillgd2" ) {
508 if (tokens.size() < 6) {
509 cout << "Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
510 return(0);
511 }
512 string nomgfd = "";
513 if (tokens.size() > 6) nomgfd = tokens[6];
514 srvo->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
515 }
516
517
518// Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
519else if (kw == "fit") {
520 if (tokens.size() < 2) {
521 cout <<"Usage:fit nomobj func \n"
522 <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
523 return(0);
524 }
525 string p=""; string s=""; string m=""; string M=""; string O="";
526 if (tokens.size()>2)
527 for(int ip=2;ip<tokens.size();ip++) {
528 if(tokens[ip].length()<=2) continue;
529 const char *c = tokens[ip].c_str();
530 if(c[1]!=':') continue;
531 if(c[0]=='p') p=c+2;
532 else if(c[0]=='s') s=c+2;
533 else if(c[0]=='m') m=c+2;
534 else if(c[0]=='M') M=c+2;
535 else if(c[0]=='o') {O += ","; O += c+2;}
536 }
537 srvo->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
538}
539
540
541else {
542 cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
543 return(-1);
544 }
545
546return(0);
547}
548
549/* --Methode-- */
550void PIABaseExecutor::RegisterCommands()
551{
552string kw, usage;
553kw = "loadmodule";
554usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
555usage += "\n Related commands: link";
556mpiac->RegisterCommand(kw, usage, this, "External Modules");
557kw = "link";
558usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
559usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
560usage += "\n Related commands: call loadmodule";
561mpiac->RegisterCommand(kw, usage, this, "External Modules");
562kw = "call";
563usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
564usage += "\n User function : f(vector<string>& args)";
565usage += "\n Related commands: link";
566mpiac->RegisterCommand(kw, usage, this, "External Modules");
567
568kw = "zone";
569usage = "To Divide the Graphic window \n Usage: zone nx ny";
570mpiac->RegisterCommand(kw, usage, this, "Graphics");
571kw = "newwin";
572usage = "To Create a New Graphic window, with zones \n Usage: newwin nx ny";
573mpiac->RegisterCommand(kw, usage, this, "Graphics");
574kw = "stacknext";
575usage = "Displays the next widget on stack window \n Usage: stacknext";
576mpiac->RegisterCommand(kw, usage, this, "Graphics");
577
578kw = "gratt";
579usage = "To change default graphic options \n Usage: gratt att_list \n";
580usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
581usage += "\n ------------------ Graphic attribute list ------------------ \n";
582usage += ">> Colors: defcol black white grey red blue green yellow magenta cyan \n";
583usage += " turquoise navyblue orange siennared purple limegreen gold \n";
584usage += ">> Lines: defline normalline thinline thickline dashedline thindashedline \n";
585usage += " thickdashedline dottedline thindottedline thickdottedline \n";
586usage += ">> Fonts: deffont normalfont boldfont italicfont smallfont smallboldfont \n";
587usage += " smallitalicfont bigfont bigboldfont bigitalicfont \n";
588usage += " hugefont hugeboldfont hugeitalicfont \n";
589usage += ">> Marker: dotmarker<T> plusmarker<T> crossmarker<T> circlemarker <T> \n";
590usage += " fcirclemarker<T> boxmarker<T> fboxmarker<T> trianglemarker<T> \n";
591usage += " ftrianglemarker<T> starmarker<T> fstarmarker<T> \n";
592usage += " with <T> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... \n";
593usage += ">> ColorTables: defcmap grey32 greyinv32 colrj32 colbr32 \n";
594usage += " grey128 greyinv128 colrj128 colbr128 \n";
595usage += ">> ZoomFactors: defzoom zoomx1 zoomx2 zoomx3 zoomx4 zoomx5 \n";
596usage += " zoom/2 zoom/3 zoom/4 zoom/5 \n";
597usage += ">> Axes: stdaxes=defaxes=boxaxes simpleaxes boxaxesgrid \n";
598usage += " fineaxes grid=fineaxesgrid \n";
599usage += ">> XYLimits : xylimits -> Forces X-Y limits in 2-D plots \n";
600usage += ">> DisplayWindow: next same win stack \n";
601usage += " Related commands: setxylimits";
602mpiac->RegisterCommand(kw, usage, this, "Graphics");
603
604kw = "setxylimits";
605usage = "Define 2-D plot limits \n Usage: setxylimits xmin xmax ymin ymax";
606usage += "\n Related commands: gratt";
607mpiac->RegisterCommand(kw, usage, this, "Graphics");
608
609kw = "openfits";
610usage = "Loads a FITS file into an Image<T> \n Usage: openfits filename";
611usage += "\n Related commands: savefits openppf";
612mpiac->RegisterCommand(kw, usage, this, "FileIO");
613kw = "savefits";
614usage = "Save an object into a FITS file \n Usage: savefits nameobj filename";
615usage += "\n Related commands: openfits saveall";
616mpiac->RegisterCommand(kw, usage, this, "FileIO");
617kw = "openppf";
618usage = "Reads all objects from a PPF file \n Usage: openppf filename";
619usage += "\n Related commands: saveall openfits";
620mpiac->RegisterCommand(kw, usage, this, "FileIO");
621kw = "saveobjs";
622usage = "Saves objects with names matching a pattern (x?y*) into a PPF file \n";
623usage += "Usage: saveall nameobjpattern filename";
624usage += "\n Related commands: saveall openppf savefits";
625mpiac->RegisterCommand(kw, usage, this, "FileIO");
626kw = "saveall";
627usage = "Saves all objects into a PPF file \n Usage: saveall filename";
628usage += "\n Related commands: saveobj openppf savefits";
629mpiac->RegisterCommand(kw, usage, this, "FileIO");
630
631kw = "print";
632usage = "Prints an object \n Usage: print nameobj";
633mpiac->RegisterCommand(kw, usage, this, "FileIO");
634
635kw = "mkdir";
636usage = "Create a directory";
637usage += "\n Usage: mkdir dirname [true]";
638usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
639mpiac->RegisterCommand(kw, usage, this, "Object Managment");
640kw = "rmdir";
641usage = "Removes an empty directory";
642usage += "\n Usage: remove dirname";
643mpiac->RegisterCommand(kw, usage, this, "Object Managment");
644kw = "cd";
645usage = "Change current directory";
646usage += "\n Usage: cd [dirname]";
647mpiac->RegisterCommand(kw, usage, this, "Object Managment");
648kw = "pwd";
649usage = "Prints current directory";
650usage += "\n Usage: pwd";
651mpiac->RegisterCommand(kw, usage, this, "Object Managment");
652kw = "listdirs";
653usage = "Prints the list of directories";
654usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
655mpiac->RegisterCommand(kw, usage, this, "Object Managment");
656kw = "listobjs";
657usage = "Prints the list of objects (Alias: ls)";
658 usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
659mpiac->RegisterCommand(kw, usage, this, "Object Managment");
660kw = "rename";
661usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
662usage += "\n Related commands: del delobjs";
663mpiac->RegisterCommand(kw, usage, this, "Object Managment");
664kw = "del";
665usage = "Deletes an object (Alias: rm) \n Usage: del nameobj";
666usage += "\n Related commands: delobjs rename";
667mpiac->RegisterCommand(kw, usage, this, "Object Managment");
668kw = "delobjs";
669usage = "Delete a set of objects with names matching a pattern (x?y*)";
670usage += "\n Usage: delobjs nameobjpattern \n";
671usage += "\n Related commands: del rename";
672mpiac->RegisterCommand(kw, usage, this, "Object Managment");
673
674kw = "newh1d";
675usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
676usage += "\n Related commands: newh2d newprof newgfd ";
677mpiac->RegisterCommand(kw, usage, this, "Objects");
678kw = "newh2d";
679usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
680usage += "\n Related commands: newh1d newprof newgfd ";
681mpiac->RegisterCommand(kw, usage, this, "Objects");
682kw = "newprof";
683usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
684usage += "\n Related commands: newh1d newh2d newgfd ";
685mpiac->RegisterCommand(kw, usage, this, "Objects");
686kw = "newgfd";
687usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
688usage += "\n Related commands: newh1d newh2d newprof ";
689mpiac->RegisterCommand(kw, usage, this, "Objects");
690kw = "newvec";
691usage = "Creates (and fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
692usage += "\n Related commands: newmtx";
693mpiac->RegisterCommand(kw, usage, this, "Objets");
694kw = "newmtx";
695usage = "Creates (and fills) a matrix \n Usage: newvec name sizeX sizeY [f(i,j) [dopt] ] ";
696usage += "\n Related commands: newvec";
697mpiac->RegisterCommand(kw, usage, this, "Objets");
698
699kw = "disp";
700usage = "Displays an object \n Usage: disp nameobj [graphic_attributes]";
701usage += "\n Related commands: surf nt2d nt3d ";
702mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
703kw = "imag";
704usage = "Displays an object as an image \n Usage: imag nameobj [graphic_attributes]";
705usage += "\n Related commands: disp surf nt2d nt3d ";
706mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
707kw = "surf";
708usage = "Displays an object as a 3D surface \n Usage: surf nameobj [graphic_attributes]";
709usage += "\n Related commands: disp nt2d nt3d ";
710mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
711kw = "nt2d";
712usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
713usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
714usage += "\n Related commands: disp surf nt2dw nt3d gfd2d ";
715mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
716kw = "nt2dw";
717usage = "Displays Points (X-Y) with weight [with error-bars] from an NTuple ";
718usage += "\n Usage : nt2d nameobj varx vary varz [errx erry] [graphic_attributes]";
719usage += "\n Related commands: disp surf nt2d nt3d gfd2d ";
720mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
721kw = "nt3d";
722usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
723usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
724usage += "\n Related commands: disp surf nt2d nt2dw gfd3d ";
725usage += "\n Related commands: disp surf nt2d nt2dw ";
726mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
727
728// Ceci est maintenant obsolete, on garde pour info.
729kw = "gfd2d";
730usage = "Displays Points (X-Y) with error-bars from a GeneralFit Data ";
731usage += "\n Usage : gfd2d nameobj numvarx erreur=(x y xy) [graphic_attributes]";
732usage += "\n Related commands: gfd3d nt2d nt3d ";
733usage += "\n ----- OBSOLETE: utilisez nt2d -----";
734mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
735kw = "gfd3d";
736usage = "Displays 3D-Points (X-Y-Z) with error-bars from a GeneralFit Data ";
737usage += "\n Usage : gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) [graphic_attributes]";
738usage += "\n Related commands: gfd2d nt2d nt3d ";
739usage += "\n ----- OBSOLETE: utilisez nt3d -----";
740mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
741
742kw = "func";
743usage = "Displays a function y=f(x) (Fills a vector with function values)";
744usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]";
745usage += "\n Related commands: funcff func2d func2dff ";
746mpiac->RegisterCommand(kw, usage, this, "Func Plot");
747kw = "funcff";
748usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
749usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]";
750usage += "\n Related commands: func func2d func2dff ";
751mpiac->RegisterCommand(kw, usage, this, "Func Plot");
752kw = "func2d";
753usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
754usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
755usage += "\n Related commands: func";
756mpiac->RegisterCommand(kw, usage, this, "Func Plot");
757kw = "func2dff";
758usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
759usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
760usage += "\n Related commands: func funcff func2d ";
761mpiac->RegisterCommand(kw, usage, this, "Func Plot");
762
763kw = "plot2d";
764usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
765usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
766usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
767usage += "\n Usage: plot2d nameobj f_X() g_Y() [ f_ErrX() f_ErrY() ] f_Cut() [graphic_attributes]";
768usage += "\n Related commands: plot2dw plot3d projh1d projh2d projprof fillnt fillvec fillgd1 ";
769mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
770kw = "plot2dw";
771usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
772usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() Cut() [graphic_attributes]";
773usage += "\n Related commands: plot2d projh1d projh2d projprof fillnt fillvec ";
774mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
775kw = "plot3d";
776usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
777usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
778usage += "\n Related commands: plot2d plot2dw projh1d projh2d projprof fillnt fillvec ";
779mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
780
781kw = "projh1d";
782usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
783usage += "\n Usage: projh1d nameobj f_X() h_WT() Cut() nameh1d [graphic_attributes]";
784usage += "\n Histo1D nameh1d is created if necessary ";
785usage += "\n Related commands: plot2d projh2d projprof fillnt fillvec ";
786mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
787kw = "projh2d";
788usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
789usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameh2d [graphic_attributes]";
790usage += "\n Histo2D nameh2d is created if necessary ";
791usage += "\n Related commands: plot2d projh1d projprof ";
792mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
793kw = "projprof";
794usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
795usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameprof [graphic_attributes]";
796usage += "\n HProf nameprof is created if necessary ";
797usage += "\n Related commands: plot2d projh2d ";
798mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
799
800kw = "fillnt";
801usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
802usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() Cut() nameNt";
803usage += "\n Related commands: ntloop plot2d projh1d projh2d projprof ";
804mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
805kw = "ntloop";
806usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
807usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
808usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName [N1 N2] ]";
809usage += "\n Or: ntloop nameobj CFileName FuncName ! N1 N2 ";
810usage += "\n Related commands: ntexpcfile fillnt";
811mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
812kw = "ntexpcfile";
813usage = "Creates a C-File with declarations suitable to be used for ntloop";
814usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
815usage += "\n Related commands: ntloop";
816mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
817
818kw = "fillvec";
819usage = "Creates and Fills a Vector with X=f(Object)";
820usage += "\n Usage: fillvec nameobj f_X() Cut() nameVec [graphic_attributes]";
821usage += "\n Related commands: plot2d projh1d fillnt ";
822mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
823kw = "fillgd1";
824usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
825usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_ErrY() Cut() nameGfd";
826usage += "\n Related commands: plot2d fillnt ";
827mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
828kw = "fillgd2";
829usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
830usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_Z() k_ErrZ() Cut() nameGfd";
831usage += "\n Related commands: plot2d fillgd2 ";
832mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
833
834kw = "fit";
835usage = "Fitting function to DataObjects (Histo, Histo2D, Vector, ...)";
836usage += "\n Usage: fit nomobj func [Options]";
837usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]";
838mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
839
840}
841
842/* --Methode-- */
843int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
844// string& func4, string& func5)
845{
846string cmd;
847
848if (dynlink) delete dynlink; dynlink = NULL;
849usfmap.clear();
850
851dynlink = new PDynLinkMgr(fnameso, true);
852if (dynlink == NULL) {
853 string sn = fnameso;
854 cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
855 return(2);
856 }
857
858int nok=0;
859// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
860// DlUserProcFunction f = NULL;
861DlFunction f = NULL;
862if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
863// f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
864f = dynlink->GetFunction(func1);
865if (f) { nok++; usfmap[func1] = f; }
866else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
867
868if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
869// f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
870f = dynlink->GetFunction(func2);
871if (f) { nok++; usfmap[func2] = f; }
872else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
873
874if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
875// f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
876f = dynlink->GetFunction(func3);
877if (f) { nok++; usfmap[func3] = f; }
878else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
879
880/* Pb compile g++ 2.7.2
881if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
882// f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
883f = dynlink->GetFunction(func4);
884if (f) { nok++; usfmap[func4] = f; }
885else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
886
887if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
888// f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
889f = dynlink->GetFunction(func5);
890if (f) { nok++; usfmap[func5] = f; }
891else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
892*/
893fin:
894if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
895else return(0);
896}
897
Note: See TracBrowser for help on using the repository browser.