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