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

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

Trace de NTuple en 2D avec Marker de taille proportionnelle a Weight
Introduction des repertoires dans la gestion d'objets NameObjMgr
Reorganisation NamedObjMgr et Services2NObjMgr, ajout de commandes , ...
Reza 12/7/99

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