Index: trunk/SophyaPI/PIext/basexecut.cc
===================================================================
--- trunk/SophyaPI/PIext/basexecut.cc	(revision 353)
+++ trunk/SophyaPI/PIext/basexecut.cc	(revision 357)
@@ -255,11 +255,16 @@
   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]); 
+  if (tokens.size() < 3)  { 
+    Vector* v = new Vector(n);
+    mObjMgr->AddObj(v, tokens[0]);
+    }
+  else {
+    if (tokens.size() < 4)  tokens.push_back("");
+    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); 
+    cout << "Usage: newvec name sizeX(Col) sizeY(Lines) [f(i,j) dopt] " << endl; return(0); 
     }
   int nx = atoi(tokens[1].c_str());
@@ -268,8 +273,13 @@
   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]);
+  if (tokens.size() < 4)  {
+    Matrix* mtx = new Matrix(ny,nx);
+    mObjMgr->AddObj(mtx, tokens[0]);
+    }
+  else {
+    if (tokens.size() < 5)  tokens.push_back("n");
+    mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax, 
+                                         nx, ny, tokens[4]);
+    }
   }
 
@@ -333,5 +343,5 @@
 else if ( (kw == "func") ) {
   if (tokens.size() < 4) { cout << "Usage: func f(x) xmin xmax npt [opt]" << endl; return(0); }
-  string opt = "n";
+  string opt = "";
   if (tokens.size() > 4)  opt = tokens[4];
   int np;
@@ -346,5 +356,5 @@
 else if ( (kw == "funcff") ) {
   if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); }
-  string opt = "n";
+  string opt = "";
   if (tokens.size() > 5)  opt = tokens[5];
   int np;
@@ -359,5 +369,5 @@
 else if ( (kw == "func2d") ) {
   if (tokens.size() < 7) {
-    cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty opt" << endl;
+    cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [opt]" << endl;
     return(0);
     }
@@ -372,5 +382,5 @@
   xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
   ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
-  string opt = "n";
+  string opt = "";
   if (tokens.size() > 7)  opt = tokens[7];
   string nom = "";
@@ -379,5 +389,5 @@
 else if ( (kw == "func2dff") ) {
   if (tokens.size() < 8) {
-    cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty opt" << endl;
+    cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty [opt]" << endl;
     return(0);
     }
@@ -392,5 +402,5 @@
   xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
   ymin = atof(tokens[5].c_str());   ymax = atof(tokens[6].c_str());
-  string opt = "n";
+  string opt = "";
   if (tokens.size() > 8)  opt = tokens[8];
   string nom = "";
@@ -400,95 +410,120 @@
 // >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ...
 else if (kw == "plot2d" ) {
-  if (tokens.size() < 4) {
-    cout << "Usage: plot2d nameobj expx expy [experrx experry] expcut [opt]" << endl;
+  if (tokens.size() < 3) {
+    cout << "Usage: plot2d nameobj expx expy [expcut opt loop_par]" << endl;
     return(0); 
     }
-  string errx = ""; string erry = ""; string ecut = "1";
-  string opt = "n";
-  if (tokens.size() < 6) { // Plot sans les erreurs
-    ecut = tokens[3];
-    if (tokens.size() > 4)  opt = tokens[4];
-    }
-  else {                 // Plot avec les erreurs
-    errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
-    if (tokens.size() > 6)  opt = tokens[6];
-    }
-  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
-  }
-
-else if (kw == "plot2dw" ) {
+  string errx = ""; string erry = ""; 
+  if (tokens.size() < 4) tokens.push_back("1");
+  while (tokens.size() < 6) tokens.push_back("");
+  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,tokens[3],tokens[4],tokens[5]);
+  }
+
+else if (kw == "plot2de" ) {  // Plot2D avec les erreurs 
+  if (tokens.size() < 5) {
+    cout << "Usage: plot2de nameobj expx expy experrx experry [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4],
+                        tokens[5],tokens[6],tokens[7]);
+  }
+
+else if (kw == "plot2dw" ) {   // Plot2d avec poids
+  if (tokens.size() < 4) { 
+    cout << "Usage: plot2dw nomobj expx expy expwt [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
+  }
+else if (kw == "plot3d" ) {  
+  if (tokens.size() < 4) { 
+    cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
+  }
+
+else if (kw == "projh1d" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 4) tokens.push_back("1.");
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->ProjectH1(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
+  }
+
+
+// Projection dans histogrammes
+else if (kw == "projh2d" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 5) tokens.push_back("1.");
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->ProjectH2(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
+                  tokens[6], tokens[7] );
+  }
+
+else if (kw == "projprof" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 5) tokens.push_back("1.");
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->ProjectHProf(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
+                    tokens[6], tokens[7] );
+  }
+
+// Projection dans vector/matrix
+else if (kw == "fillvec" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: fillvec nomvec nomobj expx expv [expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->FillVect(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
+  }
+
+else if (kw == "fillmtx" ) {
   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" ) {
+    cout << "Usage: fillmtx nommtx nomobj expx expy expv [expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->FillMatx(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
+                    tokens[6], tokens[7] );
+  }
+
+// Remplissage NTuple,Vecteurs, ... , boucle de NTuple
+else if (kw == "fillnt" ) {
   if (tokens.size() < 5) { 
-    cout << "Usage: plot3d nomobj expx expy expz expcut opt" << endl;
-    return(0); 
-    }
-  string opt = "n";
-  if (tokens.size() > 5)  opt = tokens[5];
-  srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
-  }
-
-else if (kw == "projh1d" ) {
-  if (tokens.size() < 5) { 
-    cout << "Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 5)  opt = tokens[5];
-  srvo->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
-  }
-
-else if (kw == "projh2d" ) {
-  if (tokens.size() < 6) { 
-    cout << "Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 6)  opt = tokens[6];
-
-  srvo->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
-  }
-
-else if (kw == "projprof" ) {
-  if (tokens.size() < 6) { 
-    cout << "Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 6)  opt = tokens[6];
-
-  srvo->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
-  }
-
-else if (kw == "fillnt" ) {
-  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] );
+    cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl;
+    return(0);
+    }
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], tokens[7] );
   }
 
 else if (kw == "ntloop" ) {
   if (tokens.size() < 3) { 
-    cout << "Usage: ntloop nameobj fname funcname [ntname [N1 N2] ]" << endl;
-    return(0);
-    }
-  if (tokens.size() < 4)  tokens.push_back("");
-  if (tokens[3] == "!") tokens[3] = "";
-  int nl1 = -1;
-  int nl2 = -1;
-  if (tokens.size() > 5) { 
-    nl1 = atoi(tokens[4].c_str()); 
-    nl2 = atoi(tokens[5].c_str());
-    }
-  srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], nl1, nl2);
+    cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl;
+    return(0);
+    }
+  while (tokens.size() < 5) tokens.push_back("");
+  srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]);
   }
 
@@ -501,33 +536,32 @@
   }
 
-else if (kw == "fillvec" ) {
-  if (tokens.size() < 4) { 
-    cout << "Usage: fillvec nameobj expx expcut nomvec opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 4)  opt = tokens[4];
-  srvo->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
+else if (kw == "exptovec" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl;
+    return(0);
+    }
+  while (tokens.size() < 6) tokens.push_back("");
+  srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]);
   }
 
 else if (kw == "fillgd1" ) {
   if (tokens.size() < 5) {
-    cout << "Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
-    return(0);
-    }
-  string nomgfd = "";
-  if (tokens.size() > 5) nomgfd = tokens[5];
+    cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl;
+    return(0);
+    }
+  if (tokens.size() < 6) tokens.push_back("1");
+  if (tokens.size() < 7) tokens.push_back("");
   string expy = "";
-  srvo->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
+  srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]);
   }
 
 else if (kw == "fillgd2" ) {
   if (tokens.size() < 6) {
-    cout << "Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
-    return(0);
-    }
-  string nomgfd = "";
-  if (tokens.size() > 6) nomgfd = tokens[6];
-  srvo->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
+    cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 7) tokens.push_back("1");
+  if (tokens.size() < 8) tokens.push_back("");
+  srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]);
   }
 
@@ -713,11 +747,12 @@
 mpiac->RegisterCommand(kw, usage, this, "Objects");
 kw = "newvec";
-usage = "Creates (and fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
+usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
 usage += "\n  Related commands: newmtx";  
-mpiac->RegisterCommand(kw, usage, this, "Objets");
+mpiac->RegisterCommand(kw, usage, this, "Objects");
 kw = "newmtx";
-usage = "Creates (and fills) a matrix \n Usage: newvec name sizeX sizeY [f(i,j) [dopt] ] ";
+usage = "Creates (and optionaly fills) a matrix \n";
+usage +="  Usage: newvec name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] ";
 usage += "\n  Related commands: newvec";  
-mpiac->RegisterCommand(kw, usage, this, "Objets");
+mpiac->RegisterCommand(kw, usage, this, "Objects");
 
 kw = "disp";
@@ -785,53 +820,80 @@
 mpiac->RegisterCommand(kw, usage, this, "Func Plot");
 
+kw = "ObjectExpressions";
+usage = "Any mathematical expression (math.h) with object variables can be used";
+usage += "\n  ------ Object Variable names (double) -------- ";
+usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
+usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
+usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)"; 
+usage += "\nThe default Cut() expression in true (=1) for all"; 
+usage += "\n  Related commands: plot2d plot2de plot2dw plot3d "; 
+usage += "\n        projh1d projh2d  projprof fillvec fillmtx "; 
+usage += "\n        fillnt fillgd1 fillgd2 ntloop exptovec ... ";
+mpiac->RegisterCommand(kw, usage, NULL, "Expr. Plotting");
 kw = "plot2d";
 usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
-usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
-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: plot2dw plot3d  projh1d  projh2d  projprof  fillnt fillvec fillgd1 ";
+usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2de plot2dw plot3d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "plot2de";
+usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) ";
+usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; 
 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 ";
+usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; 
 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: plot3d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
-usage += "\n  Related commands: plot2d plot2dw projh1d  projh2d  projprof  fillnt fillvec ";
+usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2d plot2dw plot2de plot3d ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 
 kw = "projh1d";
 usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
-usage += "\n Usage: projh1d nameobj f_X() h_WT() Cut() nameh1d [graphic_attributes]";
+usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]";
 usage += "\n   Histo1D nameh1d is created if necessary ";
-usage += "\n  Related commands: plot2d  projh2d  projprof fillnt  fillvec ";
+usage += "\n  Related commands: projh2d projprof ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 kw = "projh2d";
 usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
-usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameh2d [graphic_attributes]";
+usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
 usage += "\n   Histo2D nameh2d is created if necessary ";
-usage += "\n  Related commands: plot2d  projh1d projprof ";
+usage += "\n  Related commands: projh1d projprof ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 kw = "projprof";
 usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
-usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameprof [graphic_attributes]";
+usage += "\n Usage: projh2d nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
 usage += "\n   HProf nameprof is created if necessary ";
-usage += "\n  Related commands: plot2d  projh2d  ";
+usage += "\n  Related commands: projh1d projh2d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "fillvec";
+usage = "Fills a Vector V((int)(f_X(Object)+0.5)) =  h_V(Object) ";
+usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: fillmtx fillnt ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "fillmtx";
+usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) =  h_V(Object) ";
+usage += "\n Usage: fillvec namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: fillvec fillnt ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 
 kw = "fillnt";
 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 Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]";
 usage += "\n  Related commands: ntloop plot2d projh1d projh2d projprof ";
-mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+usage += "\n  Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ..."; 
+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 [N1 N2] ]";
-usage += "\n Or:    ntloop nameobj CFileName FuncName ! N1 N2 ";
+usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]";
+usage += "\n  Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ..."; 
 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";
@@ -840,18 +902,18 @@
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 
-kw = "fillvec";
+kw = "exptovec";
 usage = "Creates and Fills a Vector with X=f(Object)";
-usage += "\n Usage: fillvec nameobj f_X() Cut() nameVec [graphic_attributes]";
-usage += "\n  Related commands: plot2d  projh1d  fillnt ";
+usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 kw = "fillgd1";
 usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
-usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_ErrY() Cut() nameGfd";
-usage += "\n  Related commands: plot2d  fillnt ";
+usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]";
+usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 kw = "fillgd2";
 usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
-usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_Z() k_ErrZ() Cut() nameGfd";
-usage += "\n  Related commands: plot2d  fillgd2 ";
+usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]";
+usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; 
 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
 
Index: trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- trunk/SophyaPI/PIext/piacmd.cc	(revision 353)
+++ trunk/SophyaPI/PIext/piacmd.cc	(revision 357)
@@ -435,4 +435,17 @@
 typedef vector<string> cmdtok;
 
+/* Fonction */
+static string GetStringFrStdin()
+{
+#ifndef __mac__
+/* On vide le buffer X-Window */
+XFlush(PIXDisplay());
+#endif
+char buff[128];
+fgets(buff, 128, stdin);
+buff[127] = '\0';
+return((string)buff);
+}
+
 /* --Methode-- */
 int PIACmd::Interpret(string& s)
@@ -683,8 +696,7 @@
     return(0);
     }
-  char buff[128];
-  fgets(buff, 128, stdin);
-  buff[127] = '\0';
-  mVars[tokens[0]] = buff;
+  mImgApp->GetConsole()->AddStr(">>> Reading From StdIn \n", PIVA_Magenta);
+  cout << tokens[0] << " ? " << endl;
+  mVars[tokens[0]] = GetStringFrStdin();
   }
 
@@ -833,5 +845,5 @@
   Interpret(line);
   }
-histon = false; 
+histon = true; 
 
 // hist << "### End of Exec( " << file << " ) " << endl;
@@ -870,2 +882,4 @@
 helpwin->Show();
 }
+
+
Index: trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.cc	(revision 353)
+++ trunk/SophyaPI/PIext/servnobjm.cc	(revision 357)
@@ -203,5 +203,5 @@
   if (nom.length() < 1) {
      titre = "Function f(x)";
-     nom = "/tmp/func";
+     nom = "/home/func";
     }
   else titre = nom;
@@ -265,5 +265,5 @@
   if (nom.length() < 1) {
      titre = "Function f(x,y)";
-     nom = "/tmp/func2d";
+     nom = "/home/func2d";
     }
   else titre = nom;
@@ -287,5 +287,5 @@
 void Services2NObjMgr::DisplayPoints2D(string& nom,  string& expx, string& expy,
                                        string& experrx, string& experry,
-                                       string& expcut, string dopt)
+                                       string& expcut, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -305,5 +305,5 @@
 else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
 
-ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, experrx, experry, expcut, loop, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -330,5 +330,5 @@
 /* --Methode-- */
 void Services2NObjMgr::DisplayPoints3D(string& nom,  string& expx, string& expy, 
-                                       string& expz, string& expcut, string dopt)
+                                       string& expz, string& expcut, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -344,5 +344,5 @@
 
 string expwt = "1.";
-ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -372,5 +372,5 @@
 /* --Methode-- */
 void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy, 
-                                        string& expwt, string& expcut, string dopt)
+                                        string& expwt, string& expcut, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -386,5 +386,5 @@
 
 string exp = "1.";
-ComputeExpressions(obja, expx, expy, expwt, exp, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expwt, exp, expcut, loop, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -408,5 +408,5 @@
 /* --Methode-- */
 void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt, 
-                                 string& expcut, string& nomh1, string dopt)
+                                 string& expcut, string& nomh1, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -429,5 +429,5 @@
   }
 string expz = "0.";   
-ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
+ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, loop, nt, h1, NULL);
 
 if ((!h1) && (!nt)) return;
@@ -457,5 +457,5 @@
 /* --Methode-- */
 void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt, 
-                                 string& expcut, string& nomh2, string dopt)
+                                 string& expcut, string& nomh2, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -478,5 +478,5 @@
   }
 string expz = "0.";   
-ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, h2);
 
 if ((!h2) && (!nt)) return;
@@ -508,6 +508,6 @@
 /* --Methode-- cmv 13/10/98 */
 void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
-                                    string& expcut, string& nomprof, string dopt)
-//	Pour remplir un ``GeneralFitData'' a partir de divers objets:
+                                    string& expcut, string& nomprof, string dopt, string loop)
+//	Pour remplir un ``GeneralFitData'' a partir de divers objets: 
 //| nom = nom de l'objet a projeter dans un HProf.
 //| expx = expression X de definition du bin.
@@ -539,5 +539,5 @@
 }
 string expz = "0.";
-ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, NULL, hprof);
 
 if((!hprof) && (!nt)) return;
@@ -566,18 +566,120 @@
 }
 
-/* --Methode-- */
-void Services2NObjMgr::FillVect(string& nom, string& expx, string& expcut, 
-                                string& nomvec, string dopt)
+
+/* --Methode-- */
+void Services2NObjMgr::FillVect(string& nom, string& expx, string& expv, 
+                                   string& expcut, string& nomvec, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
 obja = mOmg->GetObjAdapter(nom);
 if (obja == NULL) {
-  cout << "Services2NObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
+  cout << "Services2NObjMgr::FillVect() Error , No such object: " << nom << endl; 
   return;
   }
 if (!mImgapp)  return; 
 
+Vector* v1 = NULL;
+AnyDataObj* ov = NULL; 
+ov=mOmg->GetObj(nomvec);
+if (ov != NULL) v1 = dynamic_cast<Vector *>(ov);
+if (v1 == NULL) {
+  cout << "Services2NObjMgr::FillVect() Error , No such object or not a vector: " << nomvec << endl; 
+  return;
+  }
+
+char* ntn[2]= {"vi", "vv"};
+NTuple* nt = new NTuple(2,ntn);  // Creation NTuple 
+
+string expz = "0.";   
+ComputeExpressions(obja, expx, expv, expz, expz, expcut, loop, nt);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+  int i,k;
+  double* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetLineD(k);
+    i = xn[0]+0.5;
+    if ( (i < 0) || i >= v1->NElts() ) continue;
+    (*v1)(i) = xn[1];
+    }
+  delete nt;
+  
+
+mOmg->DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillMatx(string& nom, string& expx, string& expy, string& expv, 
+                                string& expcut, string& nommtx, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillMatx() Error , No such objet " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Matrix* mtx = NULL;
+AnyDataObj* om = NULL; 
+om=mOmg->GetObj(nommtx);
+if (om != NULL) mtx = dynamic_cast<Matrix *>(om);
+if (mtx == NULL) {
+  cout << "Services2NObjMgr::FillMatx() Error , No such object or not a matrix " << nommtx << endl; 
+  return;
+  }
+
+char* ntn[3]= {"mi", "mj", "mv"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple 
+
+string expz = "0.";   
+ComputeExpressions(obja, expx, expy, expv, expz, expcut, loop, nt);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillMatx() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+  int ic, jl, k;
+  double* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetLineD(k);
+    ic = xn[0]+0.5;
+    jl = xn[1]+0.5;
+    if ( (ic < 0) || ic >= mtx->NCol() ) continue;
+    if ( (jl < 0) || jl >= mtx->NRows() ) continue;
+    (*mtx)(jl, ic) = xn[2];
+    }
+  delete nt;
+  
+
+mOmg->DisplayObj(nommtx, dopt);
+return;  
+
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ExpressionToVector(string& nom, string& expx, string& expcut, 
+                                          string& nomvec, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ExpressionToVector() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
 NTuple* nt = NULL;
-if (nomvec.length() < 1) nomvec = "/tmp/fillvec";
+if (nomvec.length() < 1) nomvec = "/tmp/expvec";
 
 char* ntn[2]= {"vecval", "vecwt"};
@@ -586,9 +688,9 @@
 string expwt = "1.";
 string expz = "0.";   
-ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expz, expz, expwt, expcut, loop, nt, NULL, NULL);
 
 if (!nt) return;
 if (nt->NEntry() < 1) {
-  cout << "Services2NObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  cout << "Services2NObjMgr::ExpressionToVector() Warning  Zero points satisfy cut !" << endl; 
   delete nt;
   return;
@@ -610,5 +712,5 @@
 /* --Methode-- */
 void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz, 
-                              string& expt, string& expcut, string& nomnt)
+                              string& expt, string& expcut, string& nomnt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -638,5 +740,5 @@
   }
 
-ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
 
 if (fgnnt) mOmg->AddObj(nt, nomnt);
@@ -647,6 +749,5 @@
 /* --Methode-- */
 void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname, 
-                                     string const & funcname, string & nomnt,
-                                     int nl1, int nl2)
+                                     string const & funcname, string & nomnt, string loop)
 {
 if (!mImgapp)  return; 
@@ -703,11 +804,16 @@
 mImgapp->RedirectStdOutErr(false);
 
+int k1,k2,dk;
+k1 = 0;  k2 = objnt->NbLines();  dk = 1;
+DecodeLoopParameters(loop, k1, k2, dk);
+if (k1 < 0) k1 = 0;
+if (k2 < 0) k2 = objnt->NbLines();
+if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
+if (dk <= 0) dk = 1;
+
 TRY  {
   double* xn;
-  if (nl1 < 0) nl1 = 0;
-  if (nl2 < 0) nl2 = objnt->NbLines();
-  if (nl2 > objnt->NbLines()) nl2 = objnt->NbLines();
-  int kmax = nl2;
-  for(k=nl1; k<kmax; k++)    {
+  int kmax = k2;
+  for(k=k1; k<kmax; k+=dk)    {
     xn = objnt->GetLineD(k);
     if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
@@ -804,5 +910,5 @@
 /* --Methode-- cmv 13/10/98 */
 void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
-                               string& experr, string& expcut, string& nomgfd)
+                               string& experr, string& expcut, string& nomgfd, string loop)
 //	Pour remplir un ``GeneralFitData'' a partir de divers objets:
 //| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
@@ -832,5 +938,5 @@
 
 // Remplissage NTuple buffer
-ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
 if(nt->NEntry() < 1)
   {cout<<"Services2NObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
@@ -1339,5 +1445,5 @@
 /* --Methode-- */
 void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx, 
-                          string& expy, string& expz, string& expt, string& expcut, 
+                          string& expy, string& expz, string& expt, string& expcut, string& loop, 
                           NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
 {
@@ -1360,8 +1466,14 @@
 int i,k;
 for(i=0; i<10; i++) xnt[i] = 0.;
-
+int k1,k2,dk;
+k1 = 0;  k2 = objnt->NbLines();  dk = 1;
+DecodeLoopParameters(loop, k1, k2, dk);
+if (k1 < 0) k1 = 0;
+if (k2 < 0) k2 = objnt->NbLines();
+if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
+if (dk <= 0) dk = 1;
 TRY  {
   double* xn;
-  for(k=0; k<objnt->NbLines(); k++)    {
+  for(k=k1; k<k2; k += dk)    {
     xn = objnt->GetLineD(k);
     if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
@@ -1471,4 +1583,26 @@
 }
 
+// Fonction static
+/* --Methode-- */
+void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
+{
+// Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies 
+// sous forme i1[:i2[:di]]
+// cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di; 
+size_t l = loop.length();
+if (l < 1) return;
+size_t p = loop.find(':');
+if (p >= l) { i1 = atoi(loop.c_str()); return; }
+i1 = atoi(loop.substr(0, p).c_str());
+string aa = loop.substr(p+1);
+p = aa.find(':');
+if (p < aa.length() ) { 
+  i2 = atoi(aa.substr(0,p).c_str());
+  di = atoi(aa.substr(p+1).c_str());
+  }
+else i2 = atoi(aa.c_str());
+// cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl; 
+return;
+}
 
 /* --Methode-- */
Index: trunk/SophyaPI/PIext/servnobjm.h
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.h	(revision 353)
+++ trunk/SophyaPI/PIext/servnobjm.h	(revision 357)
@@ -61,26 +61,31 @@
   virtual void          DisplayPoints2D(string & nom, string& expx, string& expy,
                                         string& experrx, string& experry, 
-                                        string& expcut, string dopt="");
+                                        string& expcut, string dopt="", string loop="");
   virtual void          DisplayPoints3D(string & nom, string& expx, string& expy, string& expz, 
-                                        string& expcut, string dopt="");
+                                        string& expcut, string dopt="", string loop="");
   virtual void          DisplayPoints2DW(string & nom, string& expx, string& expy, 
-                                         string& expwt, string& expcut, string dopt="");
-//  Projection d'expressions dans histogramme (et trace) 
+                                         string& expwt, string& expcut, string dopt="", string loop="");
+//  Projection d'expressions dans histogramme, vecteur/matrices (et trace) 
   virtual void          ProjectH1(string & nom, string& expx, string& expwt, string& expcut, 
-                                  string& nomh1, string dopt="");
+                                  string& nomh1, string dopt="", string loop="");
   virtual void          ProjectH2(string & nom, string& expx, string& expy, string& expwt, 
-                                  string& expcut, string& nomh2, string dopt="");
+                                  string& expcut, string& nomh2, string dopt="", string loop="");
   virtual void          ProjectHProf(string & nom, string& expx, string& expy, string& expwt, 
-                                  string& expcut, string& nomprof, string dopt="");
-//  Projection d'expression dans vecteurs et dans n-tuple
-  virtual void          FillVect(string & nom, string& expx, string& expcut, 
-                                 string& nomvec, string dopt="");
+                                  string& expcut, string& nomprof, string dopt="", string loop="");
+
+//  Remplissage de vecteurs, ntuples, GFD 
+  virtual void          FillVect(string & nom, string& expx, string& expv, string& expcut, 
+                                  string& nomvec, string dopt="", string loop="");
+  virtual void          FillMatx(string & nom, string& expx, string& expy, string& expv, 
+                                  string& expcut, string& nommtx, string dopt="", string loop="");
+
+  virtual void          ExpressionToVector(string & nom, string& expx, string& expcut, 
+                                           string& nomvec, string dopt="", string loop="");
   virtual void          FillNT(string & nom, string& expx, string& expy, string& expz,
-                               string& expt, string& expcut, string& nomnt); 
+                               string& expt, string& expcut, string& nomnt, string loop=""); 
   virtual void          FillGFD(string & nom, string& expx, string& expy, string& expz,
-                               string& experr, string& expcut, string& nomgfd);
+                               string& experr, string& expcut, string& nomgfd, string loop="");
   virtual void          FillNTFrCFile(string & nom, string const & fname, 
-                                      string const & funcname, string & nomnt,
-                                      int nl1=-1, int nl2=-1);
+                                      string const & funcname, string & nomnt, string loop="");
   virtual void		PrepareNTExpressionCFile(string & nomobj, string const & fname, 
                                                  string const & funcname);
@@ -92,5 +97,5 @@
 // Calcul d'expressions d'interface NTuple pour les objets
   void 		ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, 
-                                   string& expz, string& expt, string& expcut,
+                                   string& expz, string& expt, string& expcut, string& loop,
                                    NTuple* nt=NULL, Histo* h1=NULL,
                                    Histo2D* h2=NULL, HProf* hp=NULL);
@@ -101,6 +106,7 @@
 
 // Utilitaires divers 
+  static void   DecodeLoopParameters(string& loop, int& i1, int& i2, int& di);
+  int 		DecodeDispOption(string& dopt, bool& fgsrgr);
   string 	FileName2Name(string const & fn);
-  int 		DecodeDispOption(string& dopt, bool& fgsrgr);
   char* 	PClassIdToClassName(int cid);
 
