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

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

Pour creer les ADAPTER de GeneralFitData cmv 27/7/99

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