Index: trunk/SophyaPI/PIext/basexecut.cc
===================================================================
--- trunk/SophyaPI/PIext/basexecut.cc	(revision 331)
+++ trunk/SophyaPI/PIext/basexecut.cc	(revision 333)
@@ -20,4 +20,5 @@
 #include "ntuple.h"
 #include "generaldata.h"
+#include "cvector.h"
 
 
@@ -42,5 +43,5 @@
 int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
 {
-
+Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
 // >>>>> Chargement de modules
 if (kw == "loadmodule") {
@@ -124,4 +125,8 @@
   mObjMgr->ReadAll(tokens[0]);  
 }
+else if (kw == "saveobjs" ) {
+  if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
+  mObjMgr->SaveObjects(tokens[0], tokens[1]);  
+}
 else if (kw == "saveall" ) {
   if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
@@ -132,9 +137,9 @@
   mObjMgr->PrintObj(tokens[0]);  
 }
-else if (kw == "rename" ) {
+else if ( (kw == "rename" ) || (kw == "mv") )  {
   if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
   mObjMgr->RenameObj(tokens[0], tokens[1]);  
 }
-else if (kw == "del" ) {
+else if ( (kw == "del" ) || (kw == "rm") ) {
   if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
   mObjMgr->DelObj(tokens[0]);  
@@ -144,8 +149,25 @@
   mObjMgr->DelObjects(tokens[0]);  
 }
-else if (kw == "listobjs")   { 
+else if ( (kw == "listobjs") || (kw == "ls") )    { 
   if  (tokens.size() < 1)  tokens.push_back("*");
   mObjMgr->ListObjs(tokens[0]);
 }
+// Gestion des repertoires
+else if (kw == "mkdir" ) {
+  if (tokens.size() < 1) { cout << "Usage: mkdir dirname " << endl; return(0); }
+  mObjMgr->CreateDir(tokens[0]);  
+  }
+else if (kw == "rmdir" ) {
+  if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
+  mObjMgr->DeleteDir(tokens[0]);  
+  }
+else if (kw == "cd")   { 
+  if  (tokens.size() < 1)  tokens.push_back("home");
+  mObjMgr->SetCurrentDir(tokens[0]);
+  }
+else if (kw == "listdirs")   { 
+  if  (tokens.size() < 1)  tokens.push_back("*");
+  mObjMgr->ListDirs(tokens[0]);
+  }
 
 // >>>>>>>>>>> Creation d'histos 1D-2D
@@ -206,4 +228,31 @@
   }
 
+// Creation/remplissage de vecteur et de matrice
+else if (kw == "newvec") {
+  if (tokens.size() < 2) { 
+    cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0); 
+    }
+  int n = atoi(tokens[1].c_str());
+  double xmin, xmax;
+  xmin = 0.;  xmax = n;
+  if (tokens.size() < 3)  tokens.push_back("0.");
+  if (tokens.size() < 4)  tokens.push_back("n");
+  mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]); 
+  }
+else if (kw == "newmtx") {
+  if (tokens.size() < 3) { 
+    cout << "Usage: newvec name sizeX sizeY [f(i,j) dopt] " << endl; return(0); 
+    }
+  int nx = atoi(tokens[1].c_str());
+  int ny = atoi(tokens[2].c_str());
+  double xmin, xmax, ymin, ymax;
+  xmin = 0.;  xmax = nx;
+  ymin = 0.;  ymax = ny;
+  if (tokens.size() < 4)  tokens.push_back("0.");
+  if (tokens.size() < 5)  tokens.push_back("n");
+  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax, 
+                                       nx, ny, tokens[4]);
+  }
+
 // >>>>>>>>>>>  Affichage des objets 
 else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
@@ -223,9 +272,16 @@
   mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
   }
+else if (kw == "nt2dw") {
+  if (tokens.size() < 6) { cout << "Usage: nt2dw nameobj varx vary varz errx erry opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+  string ph = "";
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], ph, opt, false);
+  }
 else if (kw == "nt3d") {
   if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
   string opt = "n";
   if (tokens.size() > 7)  opt = tokens[7];
-  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt);
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt, true);
   }
 
@@ -258,10 +314,11 @@
   if (tokens.size() > 4)  opt = tokens[4];
   int np;
-  float xmin, xmax;
+  double xmin, xmax;
   np = 100;
   xmin = 0.;  xmax = 1.;
   np = atoi(tokens[3].c_str());
   xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
-  mObjMgr->GetServiceObj()->PlotFunc(tokens[0], xmin, xmax, np, opt); 
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt); 
   }
 else if ( (kw == "funcff") ) {
@@ -270,10 +327,11 @@
   if (tokens.size() > 5)  opt = tokens[5];
   int np;
-  float xmin, xmax;
+  double xmin, xmax;
   np = 100;
   xmin = 0.;  xmax = 1.;
   np = atoi(tokens[4].c_str());
   xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
-  mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], xmin, xmax, np, opt); 
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt); 
   }
 else if ( (kw == "func2d") ) {
@@ -283,6 +341,6 @@
     }
   int npx, npy;
-  float xmin, xmax;
-  float ymin, ymax;
+  double xmin, xmax;
+  double ymin, ymax;
   npx = npy = 50;
   xmin = 0.;  xmax = 1.;
@@ -294,5 +352,6 @@
   string opt = "n";
   if (tokens.size() > 7)  opt = tokens[7];
-  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
   }
 else if ( (kw == "func2dff") ) {
@@ -302,6 +361,6 @@
     }
   int npx, npy;
-  float xmin, xmax;
-  float ymin, ymax;
+  double xmin, xmax;
+  double ymin, ymax;
   npx = npy = 50;
   xmin = 0.;  xmax = 1.;
@@ -313,5 +372,6 @@
   string opt = "n";
   if (tokens.size() > 8)  opt = tokens[8];
-  mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], xmin, xmax, ymin, ymax, npx, npy, opt);
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
   }
 
@@ -332,7 +392,16 @@
     if (tokens.size() > 6)  opt = tokens[6];
     }
-  mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
-  }
-
+  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
+  }
+
+else if (kw == "plot2dw" ) {
+  if (tokens.size() < 5) { 
+    cout << "Usage: plot2dw nomobj expx expy expwt expcut opt" << endl;
+    return(0); 
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
+  }
 else if (kw == "plot3d" ) {
   if (tokens.size() < 5) { 
@@ -342,5 +411,5 @@
   string opt = "n";
   if (tokens.size() > 5)  opt = tokens[5];
-  mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
+  srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
   }
 
@@ -352,5 +421,5 @@
   string opt = "n";
   if (tokens.size() > 5)  opt = tokens[5];
-  mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
+  srvo->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
   }
 
@@ -363,5 +432,5 @@
   if (tokens.size() > 6)  opt = tokens[6];
 
-  mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  srvo->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
   }
 
@@ -374,13 +443,31 @@
   if (tokens.size() > 6)  opt = tokens[6];
 
-  mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  srvo->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
   }
 
 else if (kw == "fillnt" ) {
-  if (tokens.size() < 7) { 
-    cout << "Usage: fillnt nameobj expx expy expz expt expcut nament" << endl;
-    return(0);
-    }
-  mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
+  if (tokens.size() < 6) { 
+    cout << "Usage: fillnt nameobj expx expy expz expt expcut [ntname]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 7)  tokens.push_back("");
+  srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
+  }
+
+else if (kw == "ntloop" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: ntloop nameobj fname funcname [ntname]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 4)  tokens.push_back("");
+  srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3]);
+  }
+
+else if (kw == "ntexpcfile" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
+    return(0);
+    }
+  srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
   }
 
@@ -392,5 +479,5 @@
   string opt = "n";
   if (tokens.size() > 4)  opt = tokens[4];
-  mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
+  srvo->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
   }
 
@@ -403,5 +490,5 @@
   if (tokens.size() > 5) nomgfd = tokens[5];
   string expy = "";
-  mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
+  srvo->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
   }
 
@@ -413,5 +500,5 @@
   string nomgfd = "";
   if (tokens.size() > 6) nomgfd = tokens[6];
-  mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
+  srvo->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
   }
 
@@ -436,5 +523,5 @@
       else if(c[0]=='o') {O += ","; O += c+2;}
     }
-  mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
+  srvo->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
 }
 
@@ -520,7 +607,12 @@
 usage += "\n  Related commands: saveall openfits";  
 mpiac->RegisterCommand(kw, usage, this, "FileIO");
+kw = "saveobjs";
+usage = "Saves objects with names matching a pattern (x?y*) into a PPF file \n";
+usage += "Usage: saveall nameobjpattern filename";
+usage += "\n  Related commands: saveall openppf savefits";  
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
 kw = "saveall";
 usage = "Saves all objects into a PPF file \n Usage: saveall filename";
-usage += "\n  Related commands: openppf savefits";  
+usage += "\n  Related commands: saveobj openppf savefits";  
 mpiac->RegisterCommand(kw, usage, this, "FileIO");
 
@@ -529,14 +621,34 @@
 mpiac->RegisterCommand(kw, usage, this, "FileIO");
 
+kw = "mkdir";
+usage = "Create a directory";
+usage += "\n Usage: mkdir dirname";
+mpiac->RegisterCommand(kw, usage, this, "Object Managment");
+kw = "rmdir";
+usage = "Removes an empty directory";
+usage += "\n Usage: remove dirname";
+mpiac->RegisterCommand(kw, usage, this, "Object Managment");
+kw = "cd";
+usage = "Change current directory";
+usage += "\n Usage: cd [dirname]";
+mpiac->RegisterCommand(kw, usage, this, "Object Managment");
+kw = "pwd";
+usage = "Prints current directory";
+usage += "\n Usage: pwd";
+mpiac->RegisterCommand(kw, usage, this, "Object Managment");
+kw = "listdirs";
+usage = "Prints the list of directories";
+usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
+mpiac->RegisterCommand(kw, usage, this, "Object Managment");
 kw = "listobjs";
-usage = "Prints the list of objects";
-usage += "\n Usage: listobjs";
+usage = "Prints the list of objects (Alias: ls)";
+ usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
 mpiac->RegisterCommand(kw, usage, this, "Object Managment");
 kw = "rename";
-usage = "Rename an object \n Usage: rename nameobj namenew";
+usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
 usage += "\n  Related commands: del delobjs";  
 mpiac->RegisterCommand(kw, usage, this, "Object Managment");
 kw = "del";
-usage = "Deletes an object \n Usage: del nameobj";
+usage = "Deletes an object (Alias: rm) \n Usage: del nameobj";
 usage += "\n  Related commands: delobjs  rename";  
 mpiac->RegisterCommand(kw, usage, this, "Object Managment");
@@ -550,17 +662,25 @@
 usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
 usage += "\n  Related commands: newh2d  newprof  newgfd ";  
-mpiac->RegisterCommand(kw, usage, this, "Histrograms");
+mpiac->RegisterCommand(kw, usage, this, "Objects");
 kw = "newh2d";
 usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
 usage += "\n  Related commands: newh1d  newprof  newgfd ";  
-mpiac->RegisterCommand(kw, usage, this, "Histrograms");
+mpiac->RegisterCommand(kw, usage, this, "Objects");
 kw = "newprof";
 usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
 usage += "\n  Related commands: newh1d  newh2d newgfd ";  
-mpiac->RegisterCommand(kw, usage, this, "Histrograms");
+mpiac->RegisterCommand(kw, usage, this, "Objects");
 kw = "newgfd";
 usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
 usage += "\n  Related commands: newh1d  newh2d  newprof ";  
-mpiac->RegisterCommand(kw, usage, this, "Histrograms");
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newvec";
+usage = "Creates (and fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
+usage += "\n  Related commands: newmtx";  
+mpiac->RegisterCommand(kw, usage, this, "Objets");
+kw = "newmtx";
+usage = "Creates (and fills) a matrix \n Usage: newvec name sizeX sizeY [f(i,j) [dopt] ] ";
+usage += "\n  Related commands: newvec";  
+mpiac->RegisterCommand(kw, usage, this, "Objets");
 
 kw = "disp";
@@ -579,10 +699,15 @@
 usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
 usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
-usage += "\n  Related commands: disp  surf  nt3d  gfd2d ";  
+usage += "\n  Related commands: disp  surf  nt2dw nt3d  gfd2d ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "nt2dw";
+usage = "Displays Points (X-Y) with weight [with error-bars] from an NTuple ";
+usage += "\n Usage : nt2d nameobj varx vary varz [errx erry] [graphic_attributes]";
+usage += "\n  Related commands: disp  surf  nt2d nt3d  gfd2d ";  
 mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
 kw = "nt3d";
 usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
 usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
-usage += "\n  Related commands: disp  surf  nt2d  gfd3d ";  
+usage += "\n  Related commands: disp  surf  nt2d nt2dw  gfd3d ";  
 mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
 kw = "gfd2d";
@@ -623,10 +748,15 @@
 usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
 usage += "\n Usage: plot2d nameobj f_X() g_Y() [ f_ErrX() f_ErrY() ] f_Cut() [graphic_attributes]";
-usage += "\n  Related commands: plot3d  projh1d  projh2d  projprof  fillnt fillvec fillgd1 ";
+usage += "\n  Related commands: plot2dw plot3d  projh1d  projh2d  projprof  fillnt fillvec fillgd1 ";
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "plot2dw";
+usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
+usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() Cut() [graphic_attributes]";
+usage += "\n  Related commands: plot2d  projh1d  projh2d  projprof  fillnt fillvec ";
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 kw = "plot3d";
 usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
-usage += "\n Usage: plot2d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
-usage += "\n  Related commands: plot2d  projh1d  projh2d  projprof  fillnt fillvec ";
+usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
+usage += "\n  Related commands: plot2d plot2dw projh1d  projh2d  projprof  fillnt fillvec ";
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 
@@ -653,6 +783,18 @@
 usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
 usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() Cut() nameNt";
-usage += "\n  Related commands: plot2d  projh1d projh2d projprof ";
-mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+usage += "\n  Related commands: ntloop plot2d projh1d projh2d projprof ";
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "ntloop";
+usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
+usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
+usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName]";
+usage += "\n  Related commands: ntexpcfile fillnt";
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "ntexpcfile";
+usage = "Creates a C-File with declarations suitable to be used for ntloop";
+usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
+usage += "\n  Related commands: ntloop";
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
 kw = "fillvec";
 usage = "Creates and Fills a Vector with X=f(Object)";
@@ -685,5 +827,4 @@
 {
 string cmd;
-int rc;
 
 if (dynlink) delete dynlink;    dynlink = NULL;
