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

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

Petits bugs - Reza 03/08/99

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