Changeset 333 in Sophya for trunk/SophyaPI/PIext/basexecut.cc


Ignore:
Timestamp:
Jul 12, 1999, 1:12:29 PM (26 years ago)
Author:
ercodmgr
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/basexecut.cc

    r331 r333  
    2020#include "ntuple.h"
    2121#include "generaldata.h"
     22#include "cvector.h"
    2223
    2324
     
    4243int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
    4344{
    44 
     45Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
    4546// >>>>> Chargement de modules
    4647if (kw == "loadmodule") {
     
    124125  mObjMgr->ReadAll(tokens[0]); 
    125126}
     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}
    126131else if (kw == "saveall" ) {
    127132  if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
     
    132137  mObjMgr->PrintObj(tokens[0]); 
    133138}
    134 else if (kw == "rename" ) {
     139else if ( (kw == "rename" ) || (kw == "mv") ) {
    135140  if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
    136141  mObjMgr->RenameObj(tokens[0], tokens[1]); 
    137142}
    138 else if (kw == "del" ) {
     143else if ( (kw == "del" ) || (kw == "rm") ) {
    139144  if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
    140145  mObjMgr->DelObj(tokens[0]); 
     
    144149  mObjMgr->DelObjects(tokens[0]); 
    145150}
    146 else if (kw == "listobjs")   {
     151else if ( (kw == "listobjs") || (kw == "ls") )    {
    147152  if  (tokens.size() < 1)  tokens.push_back("*");
    148153  mObjMgr->ListObjs(tokens[0]);
    149154}
     155// Gestion des repertoires
     156else if (kw == "mkdir" ) {
     157  if (tokens.size() < 1) { cout << "Usage: mkdir dirname " << endl; return(0); }
     158  mObjMgr->CreateDir(tokens[0]); 
     159  }
     160else if (kw == "rmdir" ) {
     161  if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
     162  mObjMgr->DeleteDir(tokens[0]); 
     163  }
     164else if (kw == "cd")   {
     165  if  (tokens.size() < 1)  tokens.push_back("home");
     166  mObjMgr->SetCurrentDir(tokens[0]);
     167  }
     168else if (kw == "listdirs")   {
     169  if  (tokens.size() < 1)  tokens.push_back("*");
     170  mObjMgr->ListDirs(tokens[0]);
     171  }
    150172
    151173// >>>>>>>>>>> Creation d'histos 1D-2D
     
    206228  }
    207229
     230// Creation/remplissage de vecteur et de matrice
     231else if (kw == "newvec") {
     232  if (tokens.size() < 2) {
     233    cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0);
     234    }
     235  int n = atoi(tokens[1].c_str());
     236  double xmin, xmax;
     237  xmin = 0.;  xmax = n;
     238  if (tokens.size() < 3)  tokens.push_back("0.");
     239  if (tokens.size() < 4)  tokens.push_back("n");
     240  mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]);
     241  }
     242else if (kw == "newmtx") {
     243  if (tokens.size() < 3) {
     244    cout << "Usage: newvec name sizeX sizeY [f(i,j) dopt] " << endl; return(0);
     245    }
     246  int nx = atoi(tokens[1].c_str());
     247  int ny = atoi(tokens[2].c_str());
     248  double xmin, xmax, ymin, ymax;
     249  xmin = 0.;  xmax = nx;
     250  ymin = 0.;  ymax = ny;
     251  if (tokens.size() < 4)  tokens.push_back("0.");
     252  if (tokens.size() < 5)  tokens.push_back("n");
     253  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
     254                                       nx, ny, tokens[4]);
     255  }
     256
    208257// >>>>>>>>>>>  Affichage des objets
    209258else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
     
    223272  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
    224273  }
     274else if (kw == "nt2dw") {
     275  if (tokens.size() < 6) { cout << "Usage: nt2dw nameobj varx vary varz errx erry opt" << endl; return(0); }
     276  string opt = "n";
     277  if (tokens.size() > 6)  opt = tokens[6];
     278  string ph = "";
     279  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], ph, opt, false);
     280  }
    225281else if (kw == "nt3d") {
    226282  if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
    227283  string opt = "n";
    228284  if (tokens.size() > 7)  opt = tokens[7];
    229   mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt);
     285  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt, true);
    230286  }
    231287
     
    258314  if (tokens.size() > 4)  opt = tokens[4];
    259315  int np;
    260   float xmin, xmax;
     316  double xmin, xmax;
    261317  np = 100;
    262318  xmin = 0.;  xmax = 1.;
    263319  np = atoi(tokens[3].c_str());
    264320  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
    265   mObjMgr->GetServiceObj()->PlotFunc(tokens[0], xmin, xmax, np, opt);
     321  string nom = "";
     322  mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt);
    266323  }
    267324else if ( (kw == "funcff") ) {
     
    270327  if (tokens.size() > 5)  opt = tokens[5];
    271328  int np;
    272   float xmin, xmax;
     329  double xmin, xmax;
    273330  np = 100;
    274331  xmin = 0.;  xmax = 1.;
    275332  np = atoi(tokens[4].c_str());
    276333  xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
    277   mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], xmin, xmax, np, opt);
     334  string nom = "";
     335  mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt);
    278336  }
    279337else if ( (kw == "func2d") ) {
     
    283341    }
    284342  int npx, npy;
    285   float xmin, xmax;
    286   float ymin, ymax;
     343  double xmin, xmax;
     344  double ymin, ymax;
    287345  npx = npy = 50;
    288346  xmin = 0.;  xmax = 1.;
     
    294352  string opt = "n";
    295353  if (tokens.size() > 7)  opt = tokens[7];
    296   mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
     354  string nom = "";
     355  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
    297356  }
    298357else if ( (kw == "func2dff") ) {
     
    302361    }
    303362  int npx, npy;
    304   float xmin, xmax;
    305   float ymin, ymax;
     363  double xmin, xmax;
     364  double ymin, ymax;
    306365  npx = npy = 50;
    307366  xmin = 0.;  xmax = 1.;
     
    313372  string opt = "n";
    314373  if (tokens.size() > 8)  opt = tokens[8];
    315   mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], xmin, xmax, ymin, ymax, npx, npy, opt);
     374  string nom = "";
     375  mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
    316376  }
    317377
     
    332392    if (tokens.size() > 6)  opt = tokens[6];
    333393    }
    334   mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
    335   }
    336 
     394  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
     395  }
     396
     397else if (kw == "plot2dw" ) {
     398  if (tokens.size() < 5) {
     399    cout << "Usage: plot2dw nomobj expx expy expwt expcut opt" << endl;
     400    return(0);
     401    }
     402  string opt = "n";
     403  if (tokens.size() > 5)  opt = tokens[5];
     404  srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
     405  }
    337406else if (kw == "plot3d" ) {
    338407  if (tokens.size() < 5) {
     
    342411  string opt = "n";
    343412  if (tokens.size() > 5)  opt = tokens[5];
    344   mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
     413  srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
    345414  }
    346415
     
    352421  string opt = "n";
    353422  if (tokens.size() > 5)  opt = tokens[5];
    354   mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
     423  srvo->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
    355424  }
    356425
     
    363432  if (tokens.size() > 6)  opt = tokens[6];
    364433
    365   mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
     434  srvo->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
    366435  }
    367436
     
    374443  if (tokens.size() > 6)  opt = tokens[6];
    375444
    376   mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
     445  srvo->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
    377446  }
    378447
    379448else if (kw == "fillnt" ) {
    380   if (tokens.size() < 7) {
    381     cout << "Usage: fillnt nameobj expx expy expz expt expcut nament" << endl;
    382     return(0);
    383     }
    384   mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
     449  if (tokens.size() < 6) {
     450    cout << "Usage: fillnt nameobj expx expy expz expt expcut [ntname]" << endl;
     451    return(0);
     452    }
     453  if (tokens.size() < 7)  tokens.push_back("");
     454  srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
     455  }
     456
     457else if (kw == "ntloop" ) {
     458  if (tokens.size() < 3) {
     459    cout << "Usage: ntloop nameobj fname funcname [ntname]" << endl;
     460    return(0);
     461    }
     462  if (tokens.size() < 4)  tokens.push_back("");
     463  srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3]);
     464  }
     465
     466else if (kw == "ntexpcfile" ) {
     467  if (tokens.size() < 3) {
     468    cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
     469    return(0);
     470    }
     471  srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
    385472  }
    386473
     
    392479  string opt = "n";
    393480  if (tokens.size() > 4)  opt = tokens[4];
    394   mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
     481  srvo->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
    395482  }
    396483
     
    403490  if (tokens.size() > 5) nomgfd = tokens[5];
    404491  string expy = "";
    405   mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
     492  srvo->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
    406493  }
    407494
     
    413500  string nomgfd = "";
    414501  if (tokens.size() > 6) nomgfd = tokens[6];
    415   mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
     502  srvo->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
    416503  }
    417504
     
    436523      else if(c[0]=='o') {O += ","; O += c+2;}
    437524    }
    438   mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
     525  srvo->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
    439526}
    440527
     
    520607usage += "\n  Related commands: saveall openfits"; 
    521608mpiac->RegisterCommand(kw, usage, this, "FileIO");
     609kw = "saveobjs";
     610usage = "Saves objects with names matching a pattern (x?y*) into a PPF file \n";
     611usage += "Usage: saveall nameobjpattern filename";
     612usage += "\n  Related commands: saveall openppf savefits"; 
     613mpiac->RegisterCommand(kw, usage, this, "FileIO");
    522614kw = "saveall";
    523615usage = "Saves all objects into a PPF file \n Usage: saveall filename";
    524 usage += "\n  Related commands: openppf savefits"; 
     616usage += "\n  Related commands: saveobj openppf savefits"; 
    525617mpiac->RegisterCommand(kw, usage, this, "FileIO");
    526618
     
    529621mpiac->RegisterCommand(kw, usage, this, "FileIO");
    530622
     623kw = "mkdir";
     624usage = "Create a directory";
     625usage += "\n Usage: mkdir dirname";
     626mpiac->RegisterCommand(kw, usage, this, "Object Managment");
     627kw = "rmdir";
     628usage = "Removes an empty directory";
     629usage += "\n Usage: remove dirname";
     630mpiac->RegisterCommand(kw, usage, this, "Object Managment");
     631kw = "cd";
     632usage = "Change current directory";
     633usage += "\n Usage: cd [dirname]";
     634mpiac->RegisterCommand(kw, usage, this, "Object Managment");
     635kw = "pwd";
     636usage = "Prints current directory";
     637usage += "\n Usage: pwd";
     638mpiac->RegisterCommand(kw, usage, this, "Object Managment");
     639kw = "listdirs";
     640usage = "Prints the list of directories";
     641usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
     642mpiac->RegisterCommand(kw, usage, this, "Object Managment");
    531643kw = "listobjs";
    532 usage = "Prints the list of objects";
    533 usage += "\n Usage: listobjs";
     644usage = "Prints the list of objects (Alias: ls)";
     645 usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
    534646mpiac->RegisterCommand(kw, usage, this, "Object Managment");
    535647kw = "rename";
    536 usage = "Rename an object \n Usage: rename nameobj namenew";
     648usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
    537649usage += "\n  Related commands: del delobjs"; 
    538650mpiac->RegisterCommand(kw, usage, this, "Object Managment");
    539651kw = "del";
    540 usage = "Deletes an object \n Usage: del nameobj";
     652usage = "Deletes an object (Alias: rm) \n Usage: del nameobj";
    541653usage += "\n  Related commands: delobjs  rename"; 
    542654mpiac->RegisterCommand(kw, usage, this, "Object Managment");
     
    550662usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
    551663usage += "\n  Related commands: newh2d  newprof  newgfd "; 
    552 mpiac->RegisterCommand(kw, usage, this, "Histrograms");
     664mpiac->RegisterCommand(kw, usage, this, "Objects");
    553665kw = "newh2d";
    554666usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
    555667usage += "\n  Related commands: newh1d  newprof  newgfd "; 
    556 mpiac->RegisterCommand(kw, usage, this, "Histrograms");
     668mpiac->RegisterCommand(kw, usage, this, "Objects");
    557669kw = "newprof";
    558670usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
    559671usage += "\n  Related commands: newh1d  newh2d newgfd "; 
    560 mpiac->RegisterCommand(kw, usage, this, "Histrograms");
     672mpiac->RegisterCommand(kw, usage, this, "Objects");
    561673kw = "newgfd";
    562674usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
    563675usage += "\n  Related commands: newh1d  newh2d  newprof "; 
    564 mpiac->RegisterCommand(kw, usage, this, "Histrograms");
     676mpiac->RegisterCommand(kw, usage, this, "Objects");
     677kw = "newvec";
     678usage = "Creates (and fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
     679usage += "\n  Related commands: newmtx"; 
     680mpiac->RegisterCommand(kw, usage, this, "Objets");
     681kw = "newmtx";
     682usage = "Creates (and fills) a matrix \n Usage: newvec name sizeX sizeY [f(i,j) [dopt] ] ";
     683usage += "\n  Related commands: newvec"; 
     684mpiac->RegisterCommand(kw, usage, this, "Objets");
    565685
    566686kw = "disp";
     
    579699usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
    580700usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
    581 usage += "\n  Related commands: disp  surf  nt3d  gfd2d "; 
     701usage += "\n  Related commands: disp  surf  nt2dw nt3d  gfd2d "; 
     702mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
     703kw = "nt2dw";
     704usage = "Displays Points (X-Y) with weight [with error-bars] from an NTuple ";
     705usage += "\n Usage : nt2d nameobj varx vary varz [errx erry] [graphic_attributes]";
     706usage += "\n  Related commands: disp  surf  nt2d nt3d  gfd2d "; 
    582707mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
    583708kw = "nt3d";
    584709usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
    585710usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
    586 usage += "\n  Related commands: disp  surf  nt2d gfd3d "; 
     711usage += "\n  Related commands: disp  surf  nt2d nt2dw gfd3d "; 
    587712mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
    588713kw = "gfd2d";
     
    623748usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
    624749usage += "\n Usage: plot2d nameobj f_X() g_Y() [ f_ErrX() f_ErrY() ] f_Cut() [graphic_attributes]";
    625 usage += "\n  Related commands: plot3d  projh1d  projh2d  projprof  fillnt fillvec fillgd1 ";
     750usage += "\n  Related commands: plot2dw plot3d  projh1d  projh2d  projprof  fillnt fillvec fillgd1 ";
     751mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
     752kw = "plot2dw";
     753usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
     754usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() Cut() [graphic_attributes]";
     755usage += "\n  Related commands: plot2d  projh1d  projh2d  projprof  fillnt fillvec ";
    626756mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
    627757kw = "plot3d";
    628758usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
    629 usage += "\n Usage: plot2d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
    630 usage += "\n  Related commands: plot2d projh1d  projh2d  projprof  fillnt fillvec ";
     759usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
     760usage += "\n  Related commands: plot2d plot2dw projh1d  projh2d  projprof  fillnt fillvec ";
    631761mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
    632762
     
    653783usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
    654784usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() Cut() nameNt";
    655 usage += "\n  Related commands: plot2d  projh1d projh2d projprof ";
    656 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
     785usage += "\n  Related commands: ntloop plot2d projh1d projh2d projprof ";
     786mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
     787kw = "ntloop";
     788usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
     789usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
     790usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName]";
     791usage += "\n  Related commands: ntexpcfile fillnt";
     792mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
     793kw = "ntexpcfile";
     794usage = "Creates a C-File with declarations suitable to be used for ntloop";
     795usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
     796usage += "\n  Related commands: ntloop";
     797mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
     798
    657799kw = "fillvec";
    658800usage = "Creates and Fills a Vector with X=f(Object)";
     
    685827{
    686828string cmd;
    687 int rc;
    688829
    689830if (dynlink) delete dynlink;    dynlink = NULL;
Note: See TracChangeset for help on using the changeset viewer.