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 |
|
---|
23 |
|
---|
24 |
|
---|
25 | /* --Methode-- */
|
---|
26 | PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
|
---|
27 | {
|
---|
28 | mpiac = piac;
|
---|
29 | mObjMgr = omg;
|
---|
30 | mImgApp = app;
|
---|
31 | dynlink = NULL;
|
---|
32 | RegisterCommands();
|
---|
33 | }
|
---|
34 |
|
---|
35 | PIABaseExecutor::~PIABaseExecutor()
|
---|
36 | {
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 | /* --Methode-- */
|
---|
42 | int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
|
---|
43 | {
|
---|
44 |
|
---|
45 | // >>>>> Chargement de modules
|
---|
46 | if (kw == "loadmodule") {
|
---|
47 | if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl; return(0); }
|
---|
48 | mpiac->LoadModule(tokens[0], tokens[1]);
|
---|
49 | }
|
---|
50 | // >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques
|
---|
51 | else if (kw == "zone") {
|
---|
52 | if (tokens.size() < 2) { cout << "Usage: zone nx ny" << endl; return(0); }
|
---|
53 | int nx, ny;
|
---|
54 | nx = ny = 1;
|
---|
55 | nx = atoi(tokens[0].c_str()); ny = atoi(tokens[1].c_str());
|
---|
56 | mObjMgr->SetGraphicWinZone(nx, ny, false);
|
---|
57 | }
|
---|
58 | else if (kw == "newwin") {
|
---|
59 | if (tokens.size() < 2) { cout << "Usage: newwin nx ny" << endl; return(0); }
|
---|
60 | int nx, ny;
|
---|
61 | nx = ny = 1;
|
---|
62 | nx = atoi(tokens[0].c_str()); ny = atoi(tokens[1].c_str());
|
---|
63 | mObjMgr->SetGraphicWinZone(nx, ny, true);
|
---|
64 | }
|
---|
65 | else if (kw == "stacknext") mImgApp->StackWinNext();
|
---|
66 | else if (kw == "gratt") {
|
---|
67 | if (tokens.size() < 1) { cout << "Usage: gratt attributes_list (att=def->defaut)" << endl; return(0); }
|
---|
68 | mObjMgr->SetGraphicAttributes(tokens[0]);
|
---|
69 | }
|
---|
70 |
|
---|
71 | // >>>>>>>>>>> Link dynamique de fonctions C++
|
---|
72 | else if (kw == "link" ) {
|
---|
73 | if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl; return(0); }
|
---|
74 | string sph = "";
|
---|
75 | for(int gg=0; gg<5; gg++) tokens.push_back(sph);
|
---|
76 | int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
|
---|
77 | if (rc == 0) cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
|
---|
78 | }
|
---|
79 | else if (kw == "call" ) {
|
---|
80 | if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); }
|
---|
81 | UsFmap::iterator it = usfmap.find(tokens[0]);
|
---|
82 | if (it == usfmap.end()) {
|
---|
83 | cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
|
---|
84 | return(0);
|
---|
85 | }
|
---|
86 | cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
|
---|
87 | // on est oblige de faire un cast etant donne qu'on
|
---|
88 | // utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
|
---|
89 | DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
|
---|
90 | // On redirige la sortie sur le terminal
|
---|
91 | bool red = mImgApp->HasRedirectedStdOutErr();
|
---|
92 | mImgApp->RedirectStdOutErr(false);
|
---|
93 | TRY {
|
---|
94 | tokens.erase(tokens.begin());
|
---|
95 | fuf(tokens);
|
---|
96 | } CATCH(merr) {
|
---|
97 | fflush(stdout);
|
---|
98 | cout << endl;
|
---|
99 | cerr << endl;
|
---|
100 | string es = PeidaExc(merr);
|
---|
101 | cerr << "PIABaseExecutor: Call UserFunc Exception :" << merr << es;
|
---|
102 | }
|
---|
103 | mImgApp->RedirectStdOutErr(red);
|
---|
104 | }
|
---|
105 |
|
---|
106 | // >>>>>>>>>>> lecture/ecriture des objets, gestion des objets
|
---|
107 | else if (kw == "openfits" ) {
|
---|
108 | if (tokens.size() < 1) { cout << "Usage: openfits file " << endl; return(0); }
|
---|
109 | else mObjMgr->ReadFits(tokens[0]);
|
---|
110 | }
|
---|
111 | else if (kw == "savefits" ) {
|
---|
112 | if (tokens.size() < 2) { cout << "Usage: savefits nameobj filename " << endl; return(0); }
|
---|
113 | else mObjMgr->SaveFits(tokens[0], tokens[1]);
|
---|
114 | }
|
---|
115 | else if (kw == "openppf" ) {
|
---|
116 | if (tokens.size() < 1) { cout << "Usage: openppf file " << endl; return(0); }
|
---|
117 | mObjMgr->ReadAll(tokens[0]);
|
---|
118 | }
|
---|
119 | else if (kw == "saveall" ) {
|
---|
120 | if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
|
---|
121 | mObjMgr->SaveAll(tokens[0]);
|
---|
122 | }
|
---|
123 | else if (kw == "print" ) {
|
---|
124 | if (tokens.size() < 1) { cout << "Usage: print nameobj " << endl; return(0); }
|
---|
125 | mObjMgr->PrintObj(tokens[0]);
|
---|
126 | }
|
---|
127 | else if (kw == "rename" ) {
|
---|
128 | if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
|
---|
129 | mObjMgr->RenameObj(tokens[0], tokens[1]);
|
---|
130 | }
|
---|
131 | else if (kw == "del" ) {
|
---|
132 | if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
|
---|
133 | mObjMgr->DelObj(tokens[0]);
|
---|
134 | }
|
---|
135 | else if (kw == "delobjs" ) {
|
---|
136 | if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
|
---|
137 | mObjMgr->DelObjects(tokens[0]);
|
---|
138 | }
|
---|
139 | else if (kw == "listobjs") mObjMgr->ListObjs();
|
---|
140 |
|
---|
141 | // >>>>>>>>>>> Creation d'histos 1D-2D
|
---|
142 | else if (kw == "newh1d") {
|
---|
143 | if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
|
---|
144 | int nbx;
|
---|
145 | float xmin, xmax;
|
---|
146 | nbx = 100;
|
---|
147 | xmin = 0.; xmax = 1.;
|
---|
148 | nbx = atoi(tokens[3].c_str());
|
---|
149 | xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
|
---|
150 | Histo* h = new Histo(xmin, xmax, nbx);
|
---|
151 | mObjMgr->AddObj(h, tokens[0]);
|
---|
152 | }
|
---|
153 | else if (kw == "newh2d") {
|
---|
154 | if (tokens.size() < 7) {
|
---|
155 | cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl;
|
---|
156 | return(0);
|
---|
157 | }
|
---|
158 | int nbx, nby;
|
---|
159 | float xmin, xmax;
|
---|
160 | float ymin, ymax;
|
---|
161 | nbx = nby = 50;
|
---|
162 | xmin = 0.; xmax = 1.;
|
---|
163 | ymin = 0.; ymax = 1.;
|
---|
164 | nbx = atoi(tokens[3].c_str());
|
---|
165 | nby = atoi(tokens[6].c_str());
|
---|
166 | xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
|
---|
167 | ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
|
---|
168 | Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
|
---|
169 | mObjMgr->AddObj(h, tokens[0]);
|
---|
170 | }
|
---|
171 | else if (kw == "newprof") {
|
---|
172 | if (tokens.size() < 4)
|
---|
173 | { cout << "Usage: newprof name xmin xmax nbin [ymin ymax]" << endl; return(0); }
|
---|
174 | int nbx;
|
---|
175 | float xmin, xmax, ymin = 1., ymax = -1.;
|
---|
176 | if(tokens.size() > 5)
|
---|
177 | {ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());}
|
---|
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 | HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
|
---|
183 | mObjMgr->AddObj(h, tokens[0]);
|
---|
184 | }
|
---|
185 | else if (kw == "newgfd") {
|
---|
186 | if (tokens.size() < 3)
|
---|
187 | { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
|
---|
188 | int nvar, nalloc, errx=0;
|
---|
189 | if (tokens.size() > 3)
|
---|
190 | { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
|
---|
191 | nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
|
---|
192 | if(nvar>0 && nalloc>0) {
|
---|
193 | GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
|
---|
194 | mObjMgr->AddObj(gfd, tokens[0]);
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | // >>>>>>>>>>> Affichage des objets
|
---|
199 | else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
|
---|
200 | if (tokens.size() < 1) { cout << "Usage: disp/surf/imag nameobj [opt]" << endl; return(0); }
|
---|
201 | string opt = "n";
|
---|
202 | if (tokens.size() > 1) opt = tokens[1];
|
---|
203 | if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
|
---|
204 | else if (kw == "surf") mObjMgr->DisplaySurf3D(tokens[0], opt);
|
---|
205 | else if (kw == "imag") mObjMgr->DisplayImage(tokens[0], opt);
|
---|
206 | }
|
---|
207 |
|
---|
208 | else if (kw == "nt2d") {
|
---|
209 | if (tokens.size() < 5) { cout << "Usage: nt2d nameobj varx vary errx erry opt" << endl; return(0); }
|
---|
210 | string opt = "n";
|
---|
211 | if (tokens.size() > 5) opt = tokens[5];
|
---|
212 | string ph = "";
|
---|
213 | mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
|
---|
214 | }
|
---|
215 | else if (kw == "nt3d") {
|
---|
216 | if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
|
---|
217 | string opt = "n";
|
---|
218 | if (tokens.size() > 7) opt = tokens[7];
|
---|
219 | mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt);
|
---|
220 | }
|
---|
221 |
|
---|
222 | else if (kw == "gfd2d") {
|
---|
223 | if(tokens.size()<2)
|
---|
224 | {cout<<"Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
|
---|
225 | return(0);}
|
---|
226 | string numvary = "";
|
---|
227 | string err = "";
|
---|
228 | string opt = "n";
|
---|
229 | if(tokens.size()>2) err = tokens[2];
|
---|
230 | if(tokens.size()>3) opt = tokens[3];
|
---|
231 | mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
|
---|
232 | }
|
---|
233 | else if (kw == "gfd3d") {
|
---|
234 | if(tokens.size()<3)
|
---|
235 | {cout<<"Usage: gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
|
---|
236 | return(0);}
|
---|
237 | string err = "";
|
---|
238 | string opt = "n";
|
---|
239 | if(tokens.size()>3) err = tokens[3];
|
---|
240 | if(tokens.size()>4) opt = tokens[4];
|
---|
241 | mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
|
---|
242 | }
|
---|
243 |
|
---|
244 | // >>>>>>>>>>> Trace de fonctions
|
---|
245 | else if ( (kw == "func") ) {
|
---|
246 | if (tokens.size() < 4) { cout << "Usage: func f(x) xmin xmax npt [opt]" << endl; return(0); }
|
---|
247 | string opt = "n";
|
---|
248 | if (tokens.size() > 4) opt = tokens[4];
|
---|
249 | int np;
|
---|
250 | float xmin, xmax;
|
---|
251 | np = 100;
|
---|
252 | xmin = 0.; xmax = 1.;
|
---|
253 | np = atoi(tokens[3].c_str());
|
---|
254 | xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
|
---|
255 | mObjMgr->GetServiceObj()->PlotFunc(tokens[0], xmin, xmax, np, opt);
|
---|
256 | }
|
---|
257 | else if ( (kw == "funcff") ) {
|
---|
258 | if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); }
|
---|
259 | string opt = "n";
|
---|
260 | if (tokens.size() > 5) opt = tokens[5];
|
---|
261 | int np;
|
---|
262 | float xmin, xmax;
|
---|
263 | np = 100;
|
---|
264 | xmin = 0.; xmax = 1.;
|
---|
265 | np = atoi(tokens[4].c_str());
|
---|
266 | xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
|
---|
267 | mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], xmin, xmax, np, opt);
|
---|
268 | }
|
---|
269 | else if ( (kw == "func2d") ) {
|
---|
270 | if (tokens.size() < 7) {
|
---|
271 | cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty opt" << endl;
|
---|
272 | return(0);
|
---|
273 | }
|
---|
274 | int npx, npy;
|
---|
275 | float xmin, xmax;
|
---|
276 | float ymin, ymax;
|
---|
277 | npx = npy = 50;
|
---|
278 | xmin = 0.; xmax = 1.;
|
---|
279 | ymin = 0.; ymax = 1.;
|
---|
280 | npx = atoi(tokens[3].c_str());
|
---|
281 | npy = atoi(tokens[6].c_str());
|
---|
282 | xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
|
---|
283 | ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
|
---|
284 | string opt = "n";
|
---|
285 | if (tokens.size() > 7) opt = tokens[7];
|
---|
286 | mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
|
---|
287 | }
|
---|
288 | else if ( (kw == "func2dff") ) {
|
---|
289 | if (tokens.size() < 8) {
|
---|
290 | cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty opt" << endl;
|
---|
291 | return(0);
|
---|
292 | }
|
---|
293 | int npx, npy;
|
---|
294 | float xmin, xmax;
|
---|
295 | float ymin, ymax;
|
---|
296 | npx = npy = 50;
|
---|
297 | xmin = 0.; xmax = 1.;
|
---|
298 | ymin = 0.; ymax = 1.;
|
---|
299 | npx = atoi(tokens[4].c_str());
|
---|
300 | npy = atoi(tokens[7].c_str());
|
---|
301 | xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
|
---|
302 | ymin = atof(tokens[5].c_str()); ymax = atof(tokens[6].c_str());
|
---|
303 | string opt = "n";
|
---|
304 | if (tokens.size() > 8) opt = tokens[8];
|
---|
305 | mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], xmin, xmax, ymin, ymax, npx, npy, opt);
|
---|
306 | }
|
---|
307 |
|
---|
308 | // >>>>>>>>>>> Trace d'expressions de N_Tuple, StarList, etc ...
|
---|
309 | else if (kw == "plot2d" ) {
|
---|
310 | if (tokens.size() < 4) {
|
---|
311 | cout << "Usage: plot2d nameobj expx expy [experrx experry] expcut [opt]" << endl;
|
---|
312 | return(0);
|
---|
313 | }
|
---|
314 | string errx = ""; string erry = ""; string ecut = "1";
|
---|
315 | string opt = "n";
|
---|
316 | if (tokens.size() < 6) { // Plot sans les erreurs
|
---|
317 | ecut = tokens[3];
|
---|
318 | if (tokens.size() > 4) opt = tokens[4];
|
---|
319 | }
|
---|
320 | else { // Plot avec les erreurs
|
---|
321 | errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
|
---|
322 | if (tokens.size() > 6) opt = tokens[6];
|
---|
323 | }
|
---|
324 | mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
|
---|
325 | }
|
---|
326 |
|
---|
327 | else if (kw == "plot3d" ) {
|
---|
328 | if (tokens.size() < 5) {
|
---|
329 | cout << "Usage: plot3d nomobj expx expy expz expcut opt" << endl;
|
---|
330 | return(0);
|
---|
331 | }
|
---|
332 | string opt = "n";
|
---|
333 | if (tokens.size() > 5) opt = tokens[5];
|
---|
334 | mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
|
---|
335 | }
|
---|
336 |
|
---|
337 | else if (kw == "projh1d" ) {
|
---|
338 | if (tokens.size() < 5) {
|
---|
339 | cout << "Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
|
---|
340 | return(0);
|
---|
341 | }
|
---|
342 | string opt = "n";
|
---|
343 | if (tokens.size() > 5) opt = tokens[5];
|
---|
344 | mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
|
---|
345 | }
|
---|
346 |
|
---|
347 | else if (kw == "projh2d" ) {
|
---|
348 | if (tokens.size() < 6) {
|
---|
349 | cout << "Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
|
---|
350 | return(0);
|
---|
351 | }
|
---|
352 | string opt = "n";
|
---|
353 | if (tokens.size() > 6) opt = tokens[6];
|
---|
354 |
|
---|
355 | mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
|
---|
356 | }
|
---|
357 |
|
---|
358 | else if (kw == "projprof" ) {
|
---|
359 | if (tokens.size() < 6) {
|
---|
360 | cout << "Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
|
---|
361 | return(0);
|
---|
362 | }
|
---|
363 | string opt = "n";
|
---|
364 | if (tokens.size() > 6) opt = tokens[6];
|
---|
365 |
|
---|
366 | mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
|
---|
367 | }
|
---|
368 |
|
---|
369 | else if (kw == "fillnt" ) {
|
---|
370 | if (tokens.size() < 7) {
|
---|
371 | cout << "Usage: fillnt nameobj expx expy expz expt expcut nament" << endl;
|
---|
372 | return(0);
|
---|
373 | }
|
---|
374 | mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
|
---|
375 | }
|
---|
376 |
|
---|
377 | else if (kw == "fillvec" ) {
|
---|
378 | if (tokens.size() < 4) {
|
---|
379 | cout << "Usage: fillvec nameobj expx expcut nomvec opt" << endl;
|
---|
380 | return(0);
|
---|
381 | }
|
---|
382 | string opt = "n";
|
---|
383 | if (tokens.size() > 4) opt = tokens[4];
|
---|
384 | mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
|
---|
385 | }
|
---|
386 |
|
---|
387 | else if (kw == "fillgd1" ) {
|
---|
388 | if (tokens.size() < 5) {
|
---|
389 | cout << "Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
|
---|
390 | return(0);
|
---|
391 | }
|
---|
392 | string nomgfd = "";
|
---|
393 | if (tokens.size() > 5) nomgfd = tokens[5];
|
---|
394 | string expy = "";
|
---|
395 | mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
|
---|
396 | }
|
---|
397 |
|
---|
398 | else if (kw == "fillgd2" ) {
|
---|
399 | if (tokens.size() < 6) {
|
---|
400 | cout << "Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
|
---|
401 | return(0);
|
---|
402 | }
|
---|
403 | string nomgfd = "";
|
---|
404 | if (tokens.size() > 6) nomgfd = tokens[6];
|
---|
405 | mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
|
---|
406 | }
|
---|
407 |
|
---|
408 |
|
---|
409 | // Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
|
---|
410 | else if (kw == "fit") {
|
---|
411 | if (tokens.size() < 2) {
|
---|
412 | cout <<"Usage:fit nomobj func \n"
|
---|
413 | <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
|
---|
414 | return(0);
|
---|
415 | }
|
---|
416 | string p=""; string s=""; string m=""; string M=""; string O="";
|
---|
417 | if (tokens.size()>2)
|
---|
418 | for(int ip=2;ip<tokens.size();ip++) {
|
---|
419 | if(tokens[ip].length()<=2) continue;
|
---|
420 | const char *c = tokens[ip].c_str();
|
---|
421 | if(c[1]!=':') continue;
|
---|
422 | if(c[0]=='p') p=c+2;
|
---|
423 | else if(c[0]=='s') s=c+2;
|
---|
424 | else if(c[0]=='m') m=c+2;
|
---|
425 | else if(c[0]=='M') M=c+2;
|
---|
426 | else if(c[0]=='o') {O += ","; O += c+2;}
|
---|
427 | }
|
---|
428 | mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
|
---|
429 | }
|
---|
430 |
|
---|
431 |
|
---|
432 | else {
|
---|
433 | cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
|
---|
434 | return(-1);
|
---|
435 | }
|
---|
436 |
|
---|
437 | return(0);
|
---|
438 | }
|
---|
439 |
|
---|
440 | /* --Methode-- */
|
---|
441 | void PIABaseExecutor::RegisterCommands()
|
---|
442 | {
|
---|
443 | string kw, usage;
|
---|
444 | kw = "loadmodule";
|
---|
445 | usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
|
---|
446 | usage += "\n Related commands: link";
|
---|
447 | mpiac->RegisterCommand(kw, usage, this, "External Modules");
|
---|
448 | kw = "link";
|
---|
449 | usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
|
---|
450 | usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
|
---|
451 | usage += "\n Related commands: call loadmodule";
|
---|
452 | mpiac->RegisterCommand(kw, usage, this, "External Modules");
|
---|
453 | kw = "call";
|
---|
454 | usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
|
---|
455 | usage += "\n User function : f(vector<string>& args)";
|
---|
456 | usage += "\n Related commands: link";
|
---|
457 | mpiac->RegisterCommand(kw, usage, this, "External Modules");
|
---|
458 |
|
---|
459 | kw = "zone";
|
---|
460 | usage = "To Divide the Graphic window \n Usage: zone nx ny";
|
---|
461 | mpiac->RegisterCommand(kw, usage, this, "Graphics");
|
---|
462 | kw = "newwin";
|
---|
463 | usage = "To Create a New Graphic window, with zones \n Usage: newwin nx ny";
|
---|
464 | mpiac->RegisterCommand(kw, usage, this, "Graphics");
|
---|
465 | kw = "stacknext";
|
---|
466 | usage = "Displays the next widget on stack window \n Usage: stacknext";
|
---|
467 | mpiac->RegisterCommand(kw, usage, this, "Graphics");
|
---|
468 |
|
---|
469 | kw = "gratt";
|
---|
470 | usage = "To change default graphic options \n Usage: gratt att_list \n";
|
---|
471 | usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
|
---|
472 | usage += "\n ------------------ Graphic attribute list ------------------ \n";
|
---|
473 | usage += ">> Colors: defcol black white grey red blue green yellow magenta cyan \n";
|
---|
474 | usage += " turquoise navyblue orange siennared purple limegreen gold \n";
|
---|
475 | usage += ">> Lines: defline normalline thinline thickline dashedline thindashedline \n";
|
---|
476 | usage += " thickdashedline dottedline thindottedline thickdottedline \n";
|
---|
477 | usage += ">> Fonts: deffont normalfont boldfont italicfont smallfont smallboldfont \n";
|
---|
478 | usage += " smallitalicfont bigfont bigboldfont bigitalicfont \n";
|
---|
479 | usage += " hugefont hugeboldfont hugeitalicfont \n";
|
---|
480 | usage += ">> Marker: dotmarker<T> plusmarker<T> crossmarker<T> circlemarker <T> \n";
|
---|
481 | usage += " fcirclemarker<T> boxmarker<T> fboxmarker<T> trianglemarker<T> \n";
|
---|
482 | usage += " ftrianglemarker<T> starmarker<T> fstarmarker<T> \n";
|
---|
483 | usage += " with <T> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... \n";
|
---|
484 | usage += ">> ColorTables: defcmap grey32 greyinv32 colrj32 colbr32 \n";
|
---|
485 | usage += " grey128 greyinv128 colrj128 colbr128 \n";
|
---|
486 | usage += ">> ZoomFactors: defzoom zoomx1 zoomx2 zoomx3 zoomx4 zoomx5 \n";
|
---|
487 | usage += " zoom/2 zoom/3 zoom/4 zoom/5 \n";
|
---|
488 | usage += ">> Axes: stdaxes=defaxes=boxaxes simpleaxes boxaxesgrid \n";
|
---|
489 | usage += " fineaxes grid=fineaxesgrid \n";
|
---|
490 | usage += ">> DisplayWindow: next same win stack \n";
|
---|
491 | mpiac->RegisterCommand(kw, usage, this, "Graphics");
|
---|
492 |
|
---|
493 | kw = "openfits";
|
---|
494 | usage = "Loads a FITS file into an Image<T> \n Usage: openfits filename";
|
---|
495 | usage += "\n Related commands: savefits openppf";
|
---|
496 | mpiac->RegisterCommand(kw, usage, this, "FileIO");
|
---|
497 | kw = "savefits";
|
---|
498 | usage = "Save an object into a FITS file \n Usage: savefits nameobj filename";
|
---|
499 | usage += "\n Related commands: openfits saveall";
|
---|
500 | mpiac->RegisterCommand(kw, usage, this, "FileIO");
|
---|
501 | kw = "openppf";
|
---|
502 | usage = "Reads all objects from a PPF file \n Usage: openppf filename";
|
---|
503 | usage += "\n Related commands: saveall openfits";
|
---|
504 | mpiac->RegisterCommand(kw, usage, this, "FileIO");
|
---|
505 | kw = "saveall";
|
---|
506 | usage = "Saves all objects into a PPF file \n Usage: saveall filename";
|
---|
507 | usage += "\n Related commands: openppf savefits";
|
---|
508 | mpiac->RegisterCommand(kw, usage, this, "FileIO");
|
---|
509 |
|
---|
510 | kw = "print";
|
---|
511 | usage = "Prints an object \n Usage: print nameobj";
|
---|
512 | mpiac->RegisterCommand(kw, usage, this, "FileIO");
|
---|
513 |
|
---|
514 | kw = "listobjs";
|
---|
515 | usage = "Prints the list of objects";
|
---|
516 | usage += "\n Usage: listobjs";
|
---|
517 | mpiac->RegisterCommand(kw, usage, this, "Object Managment");
|
---|
518 | kw = "rename";
|
---|
519 | usage = "Rename an object \n Usage: rename nameobj namenew";
|
---|
520 | usage += "\n Related commands: del delobjs";
|
---|
521 | mpiac->RegisterCommand(kw, usage, this, "Object Managment");
|
---|
522 | kw = "del";
|
---|
523 | usage = "Deletes an object \n Usage: del nameobj";
|
---|
524 | usage += "\n Related commands: delobjs rename";
|
---|
525 | mpiac->RegisterCommand(kw, usage, this, "Object Managment");
|
---|
526 | kw = "delobjs";
|
---|
527 | usage = "Delete a set of objects with names matching a pattern (x?y*)";
|
---|
528 | usage += "\n Usage: delobjs nameobjpattern \n";
|
---|
529 | usage += "\n Related commands: del rename";
|
---|
530 | mpiac->RegisterCommand(kw, usage, this, "Object Managment");
|
---|
531 |
|
---|
532 | kw = "newh1d";
|
---|
533 | usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
|
---|
534 | usage += "\n Related commands: newh2d newprof newgfd ";
|
---|
535 | mpiac->RegisterCommand(kw, usage, this, "Histrograms");
|
---|
536 | kw = "newh2d";
|
---|
537 | usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
|
---|
538 | usage += "\n Related commands: newh1d newprof newgfd ";
|
---|
539 | mpiac->RegisterCommand(kw, usage, this, "Histrograms");
|
---|
540 | kw = "newprof";
|
---|
541 | usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
|
---|
542 | usage += "\n Related commands: newh1d newh2d newgfd ";
|
---|
543 | mpiac->RegisterCommand(kw, usage, this, "Histrograms");
|
---|
544 | kw = "newgfd";
|
---|
545 | usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
|
---|
546 | usage += "\n Related commands: newh1d newh2d newprof ";
|
---|
547 | mpiac->RegisterCommand(kw, usage, this, "Histrograms");
|
---|
548 |
|
---|
549 | kw = "disp";
|
---|
550 | usage = "Displays an object \n Usage: disp nameobj [graphic_attributes]";
|
---|
551 | usage += "\n Related commands: surf nt2d nt3d ";
|
---|
552 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
553 | kw = "imag";
|
---|
554 | usage = "Displays an object as an image \n Usage: imag nameobj [graphic_attributes]";
|
---|
555 | usage += "\n Related commands: disp surf nt2d nt3d ";
|
---|
556 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
557 | kw = "surf";
|
---|
558 | usage = "Displays an object as a 3D surface \n Usage: surf nameobj [graphic_attributes]";
|
---|
559 | usage += "\n Related commands: disp nt2d nt3d ";
|
---|
560 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
561 | kw = "nt2d";
|
---|
562 | usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
|
---|
563 | usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
|
---|
564 | usage += "\n Related commands: disp surf nt3d gfd2d ";
|
---|
565 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
566 | kw = "nt3d";
|
---|
567 | usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
|
---|
568 | usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
|
---|
569 | usage += "\n Related commands: disp surf nt2d gfd3d ";
|
---|
570 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
571 | kw = "gfd2d";
|
---|
572 | usage = "Displays Points (X-Y) with error-bars from a GeneralFit Data ";
|
---|
573 | usage += "\n Usage : gfd2d nameobj numvarx erreur=(x y xy) [graphic_attributes]";
|
---|
574 | usage += "\n Related commands: gfd3d nt2d nt3d ";
|
---|
575 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
576 | kw = "gfd3d";
|
---|
577 | usage = "Displays 3D-Points (X-Y-Z) with error-bars from a GeneralFit Data ";
|
---|
578 | usage += "\n Usage : gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) [graphic_attributes]";
|
---|
579 | usage += "\n Related commands: gfd2d nt2d nt3d ";
|
---|
580 | mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
|
---|
581 |
|
---|
582 | kw = "func";
|
---|
583 | usage = "Displays a function y=f(x) (Fills a vector with function values)";
|
---|
584 | usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]";
|
---|
585 | usage += "\n Related commands: funcff func2d func2dff ";
|
---|
586 | mpiac->RegisterCommand(kw, usage, this, "Func Plot");
|
---|
587 | kw = "funcff";
|
---|
588 | usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
|
---|
589 | usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]";
|
---|
590 | usage += "\n Related commands: func func2d func2dff ";
|
---|
591 | mpiac->RegisterCommand(kw, usage, this, "Func Plot");
|
---|
592 | kw = "func2d";
|
---|
593 | usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
|
---|
594 | usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
|
---|
595 | usage += "\n Related commands: func";
|
---|
596 | mpiac->RegisterCommand(kw, usage, this, "Func Plot");
|
---|
597 | kw = "func2dff";
|
---|
598 | usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
|
---|
599 | usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
|
---|
600 | usage += "\n Related commands: func funcff func2d ";
|
---|
601 | mpiac->RegisterCommand(kw, usage, this, "Func Plot");
|
---|
602 |
|
---|
603 | kw = "plot2d";
|
---|
604 | usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
|
---|
605 | usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
|
---|
606 | usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
|
---|
607 | usage += "\n Usage: plot2d nameobj f_X() g_Y() [ f_ErrX() f_ErrY() ] f_Cut() [graphic_attributes]";
|
---|
608 | usage += "\n Related commands: plot3d projh1d projh2d projprof fillnt fillvec fillgd1 ";
|
---|
609 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
610 | kw = "plot3d";
|
---|
611 | usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
|
---|
612 | usage += "\n Usage: plot2d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
|
---|
613 | usage += "\n Related commands: plot2d projh1d projh2d projprof fillnt fillvec ";
|
---|
614 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
615 |
|
---|
616 | kw = "projh1d";
|
---|
617 | usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
|
---|
618 | usage += "\n Usage: projh1d nameobj f_X() h_WT() Cut() nameh1d [graphic_attributes]";
|
---|
619 | usage += "\n Histo1D nameh1d is created if necessary ";
|
---|
620 | usage += "\n Related commands: plot2d projh2d projprof fillnt fillvec ";
|
---|
621 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
622 | kw = "projh2d";
|
---|
623 | usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
|
---|
624 | usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameh2d [graphic_attributes]";
|
---|
625 | usage += "\n Histo2D nameh2d is created if necessary ";
|
---|
626 | usage += "\n Related commands: plot2d projh1d projprof ";
|
---|
627 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
628 | kw = "projprof";
|
---|
629 | usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
|
---|
630 | usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameprof [graphic_attributes]";
|
---|
631 | usage += "\n HProf nameprof is created if necessary ";
|
---|
632 | usage += "\n Related commands: plot2d projh2d ";
|
---|
633 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
634 |
|
---|
635 | kw = "fillnt";
|
---|
636 | usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
|
---|
637 | usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() Cut() nameNt";
|
---|
638 | usage += "\n Related commands: plot2d projh1d projh2d projprof ";
|
---|
639 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
640 | kw = "fillvec";
|
---|
641 | usage = "Creates and Fills a Vector with X=f(Object)";
|
---|
642 | usage += "\n Usage: fillvec nameobj f_X() Cut() nameVec [graphic_attributes]";
|
---|
643 | usage += "\n Related commands: plot2d projh1d fillnt ";
|
---|
644 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
645 | kw = "fillgd1";
|
---|
646 | usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
|
---|
647 | usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_ErrY() Cut() nameGfd";
|
---|
648 | usage += "\n Related commands: plot2d fillnt ";
|
---|
649 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
650 | kw = "fillgd2";
|
---|
651 | usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
|
---|
652 | usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_Z() k_ErrZ() Cut() nameGfd";
|
---|
653 | usage += "\n Related commands: plot2d fillgd2 ";
|
---|
654 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
655 |
|
---|
656 | kw = "fit";
|
---|
657 | usage = "Fitting function to DataObjects (Histo, Histo2D, Vector, ...)";
|
---|
658 | usage += "\n Usage: fit nomobj func [Options]";
|
---|
659 | usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]";
|
---|
660 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
|
---|
661 |
|
---|
662 |
|
---|
663 | }
|
---|
664 |
|
---|
665 | /* --Methode-- */
|
---|
666 | int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
|
---|
667 | // string& func4, string& func5)
|
---|
668 | {
|
---|
669 | string cmd;
|
---|
670 | int rc;
|
---|
671 |
|
---|
672 | if (dynlink) delete dynlink; dynlink = NULL;
|
---|
673 | usfmap.clear();
|
---|
674 |
|
---|
675 | dynlink = new PDynLinkMgr(fnameso, true);
|
---|
676 | if (dynlink == NULL) {
|
---|
677 | string sn = fnameso;
|
---|
678 | cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
|
---|
679 | return(2);
|
---|
680 | }
|
---|
681 |
|
---|
682 | int nok=0;
|
---|
683 | // on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
|
---|
684 | // DlUserProcFunction f = NULL;
|
---|
685 | DlFunction f = NULL;
|
---|
686 | if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
|
---|
687 | // f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
|
---|
688 | f = dynlink->GetFunction(func1);
|
---|
689 | if (f) { nok++; usfmap[func1] = f; }
|
---|
690 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
|
---|
691 |
|
---|
692 | if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
|
---|
693 | // f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
|
---|
694 | f = dynlink->GetFunction(func2);
|
---|
695 | if (f) { nok++; usfmap[func2] = f; }
|
---|
696 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
|
---|
697 |
|
---|
698 | if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
|
---|
699 | // f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
|
---|
700 | f = dynlink->GetFunction(func3);
|
---|
701 | if (f) { nok++; usfmap[func3] = f; }
|
---|
702 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
|
---|
703 |
|
---|
704 | /* Pb compile g++ 2.7.2
|
---|
705 | if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
|
---|
706 | // f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
|
---|
707 | f = dynlink->GetFunction(func4);
|
---|
708 | if (f) { nok++; usfmap[func4] = f; }
|
---|
709 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
|
---|
710 |
|
---|
711 | if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
|
---|
712 | // f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
|
---|
713 | f = dynlink->GetFunction(func5);
|
---|
714 | if (f) { nok++; usfmap[func5] = f; }
|
---|
715 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
|
---|
716 | */
|
---|
717 | fin:
|
---|
718 | if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
|
---|
719 | else return(0);
|
---|
720 | }
|
---|
721 |
|
---|