Index: /trunk/SophyaPI/PIext/basexecut.cc
===================================================================
--- /trunk/SophyaPI/PIext/basexecut.cc	(revision 332)
+++ /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;
Index: /trunk/SophyaPI/PIext/dlftypes.h
===================================================================
--- /trunk/SophyaPI/PIext/dlftypes.h	(revision 332)
+++ /trunk/SophyaPI/PIext/dlftypes.h	(revision 333)
@@ -16,5 +16,7 @@
 typedef double (* DlFunctionOfX) (double x);
 typedef double (* DlFunctionOfXY) (double x, double y);
-typedef int (* PlotExprFunc) (double* x, double* rx, double* ry, double* rz, double* wt);
+typedef int (* PlotExprFunc) (double* x, double* rx, double* ry, double* rz, double* rt);
+typedef int (* NTLoopExprFunc) (double* x, double* rx, double* ry, double* rz, 
+                                double* rt, int n, int nmax);
 typedef void (* DlUserProcFunction) (vector<string>& args);
 typedef void (* DlFunction) ();
Index: /trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 333)
@@ -22,7 +22,4 @@
 #include "pistdimgapp.h"
 
-#include "matrix.h"
-#include "cvector.h"
-#include "ntuple.h"
 
 // EVOL-PLANCK
@@ -31,12 +28,7 @@
 #endif
 
-#include "fct1dfit.h"
-#include "fct2dfit.h"
-
 #include "pisurfdr.h"
 #include "pipodrw.h"
-#include "pihisto.h"
-#include "hisprof.h"
-#include "pihisto2d.h"
+
 #include "pintuple.h"
 #include "pintup3d.h"
@@ -75,5 +67,5 @@
   AnyDataObj* obj;
   NObjMgrAdapter* obja;
-  int num;
+  int oid;
   int dirid;
   list<int> wrsid;
@@ -95,4 +87,10 @@
 
 static string* TmpDir;  // Repertoire pour les compilations / link dynamique
+
+// Pour completer le nom de l'objet avec le nom du repertoire
+static void RemoveSpacesFromName(string & nom);
+static bool CheckDirName(string & nom);
+static int  ParseObjectName(string & nom, string & nomrep, string & nomobj);
+// ..................................................................
 
 //++
@@ -111,7 +109,18 @@
 {
 if (fgOInit == 0) { 
+  myNObj = 0;
+  myDirId = 0;
   myDirs = new NObjDirList;
   myObjs = new NObjList;  
   currDir = new string("home");
+  string dirn = "home";
+  CreateDir(dirn);
+  dirn = "tmp";
+  CreateDir(dirn);
+  dirn = "old";
+  CreateDir(dirn);
+  dirn = "home";
+  SetCurrentDir(dirn);
+  myDirId = 50;
   char* varenv;
   TmpDir = new string("");
@@ -120,5 +129,5 @@
   int l = (*TmpDir).length();
   if ( (l>0) && ((*TmpDir)[l-1] != '/') )  (*TmpDir) += '/';
-  servnobjm = new Services2NObjMgr(NULL, (*TmpDir));
+  servnobjm = new Services2NObjMgr(this, (*TmpDir));
   }
 fgOInit++;
@@ -148,4 +157,11 @@
 myImgApp = app;
 servnobjm->SetImgApp(app);
+
+NObjDirList::iterator it;
+string cn;
+for(it= myDirs->begin(); it != myDirs->end(); it++) {
+  cn = '/' + (*it).first;
+  (myImgApp->ObjMgrW())->AddDirectory(cn.c_str(), (*it).second.id);
+  }
 }
 
@@ -163,16 +179,101 @@
 
 /* --Methode-- */
-void NamedObjMgr::CreateDir(string const& dirname)
-{
-}
-
-/* --Methode-- */
-void NamedObjMgr::DeleteDir(string const& dirname)
-{
-}
-
-/* --Methode-- */
-void NamedObjMgr::SetCurrentDir(string const& dirname)
-{
+void NamedObjMgr::CreateDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
+  return; 
+  }
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it != myDirs->end()) {
+  cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
+  return;
+  }
+myDirId++;
+nobj_diritem di;
+di.id = myDirId;
+di.nobj = 0;
+(*myDirs)[dirname] = di;
+if (myImgApp)  { 
+  string str = '/' + dirname;
+  (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
+  }
+cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DeleteDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
+  return; 
+  }
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) {
+  cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
+  return;
+  }
+if ((*it).second.nobj > 0) {
+  cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
+  return;
+  }
+if ((*it).second.id < 50) {
+  cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
+  return;
+  }
+
+if (myImgApp)  
+  (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
+myDirs->erase(it);
+cout << "amedObjMgr::DeleteDir() " << dirname << " deleted " << endl;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::SetCurrentDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
+  return; 
+  }
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) {
+  cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
+  return;
+  }
+*currDir = dirname;
+cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
+}
+
+/* --Methode-- */
+void NamedObjMgr::GetCurrentDir(string & dirname)
+{
+dirname = *currDir;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ListDirs(string & patt)
+{
+NObjDirList::iterator it;
+string cn;
+cout << "NamedObjMgr::ListDirs( " << patt << " ) " << endl;
+int k = 0;
+for(it= myDirs->begin(); it != myDirs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
+  k++;
+  cout << k << "- " << (*it).first << "  (NbObj= " << (*it).second.nobj << ")" << endl; 
+  }
+}
+
+/* --Methode-- */
+void NamedObjMgr::GetDirList(string & patt, vector<string>& lstd)
+{
+NObjDirList::iterator it;
+string cn;
+for(it= myDirs->begin(); it != myDirs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
+  lstd.push_back(cn);
+  }
 }
 
@@ -186,4 +287,5 @@
 {
 }
+
 
 //++
@@ -209,27 +311,48 @@
 
 /* --Methode-- */
-void NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool)
+void NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
 {
 
 if (obj == NULL)  return;
-// on supprime les blancs de debut et de fin 
-size_t p = nom.find_first_not_of(" ");
-if(p>nom.length()) {
-  nom = "";
-} else {
-  nom = nom.substr(p);
-  p = nom.find_first_of(" ");
-  if(p>nom.length()) p=nom.length();
-  nom = nom.substr(0, p);
-}
+// On verifie si l'objet est deja dans la liste 
+NObjList::iterator it;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  if ((*it).second.obj == obj) {
+    cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
+    return;
+    }
+  }
+string nobj;
+string nrep;
+char buff[32];
+int did = ParseObjectName(nom, nrep, nobj);
+if (did == 0) {
+  if (!crd) {
+    cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
+    return;
+    }
+  else { CreateDir(nrep);  did =  myDirId; }
+  }
 
 myNObj++;
-if (nom.length() < 1) nom = typeid(*obj).name();
-NObjList::iterator it = myObjs->find(nom);
+if (nobj.length() < 1) { 
+  sprintf(buff,"O%d", myNObj);
+  nobj = buff;
+  }
+
+nom = '/' + nrep + '/' + nobj;  
+it = myObjs->find(nom);
 if (it != myObjs->end()) { // l'objet existe deja
-  char strg[16];
-  sprintf(strg, "%d", myNObj);
-  string nomnew = nom + strg;
-  RenameObj(nom, nomnew);
+  if (nrep == "tmp") {  // Les objets de /tmp sont jetes
+    cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
+    DelObj(nom);
+    }
+  else {  // On met l'ancien objet dans /old
+    string on,od;
+    ParseObjectName((*it).first, od, on); 
+    sprintf(buff, "%d", (*it).second.oid);
+    string nomnew = "/old/" + on + buff;
+    RenameObj(nom, nomnew);
+    }
   }
 
@@ -237,11 +360,11 @@
 no.obj = obj;
 no.obja = servnobjm->GetAdapter(obj);  // L'adaptateur
-no.num =  myNObj;
+no.oid =  myNObj;
+no.dirid = did;
 (*myObjs)[nom] = no;
-if (myImgApp)  { 
-  string str = nom + "    (T= " + typeid(*obj).name() + ")" ;
-  (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000);
-}
- 
+
+NObjDirList::iterator itr = myDirs->find(nrep);
+(*itr).second.nobj++;
+
 cout << "NamedObjMgr::AddObj()  Object " << nom << " ( "  
      << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;  
@@ -252,8 +375,33 @@
 void NamedObjMgr::RenameObj(string & nom, string& nomnew)
 {
-AnyDataObj* obj = GetObj(nom);
-if (obj == NULL) return;
-DelObj(nom, false);
-AddObj(obj, nomnew);
+string n1,r1,n2,r2;
+ParseObjectName(nom, r1, n1);
+int did = ParseObjectName(nomnew, r2, n2);
+if (did == 0) {
+  cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
+  return;
+  }
+nom = '/' + r1 + '/' + n1;
+nomnew = '/' + r2 + '/' + n2;
+NObjList::iterator it1 = myObjs->find(nom);
+if (it1 == myObjs->end()) {
+  cout << "NamedObjMgr::RenameObj() Error -  No " << nom << " object !" << endl;
+  return;
+  }
+NObjList::iterator it2 = myObjs->find(nomnew);
+if (it2 != myObjs->end()) {
+  cout << "NamedObjMgr::RenameObj() Error -  Object " << nomnew << " exist !" << endl;
+  return;
+  }
+
+nobj_item no = (*it1).second;
+no.dirid = did;
+myObjs->erase(it1);
+NObjDirList::iterator itr = myDirs->find(r1);
+(*itr).second.nobj--;
+(*myObjs)[nomnew] = no;
+itr = myDirs->find(r2);
+(*itr).second.nobj++;
+cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
 return;
 }
@@ -262,4 +410,7 @@
 void NamedObjMgr::DelObj(string & nom, bool fgd)
 {
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
 NObjList::iterator it = myObjs->find(nom);
 if (it == myObjs->end()) return; 
@@ -269,9 +420,12 @@
   for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++) 
       myImgApp->DelWRsId((*ii));
-  (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000);
 }
 delete (*it).second.obja;  // destruction de l'adaptateur 
 if (fgd) delete (*it).second.obj;
+
 myObjs->erase(it);
+NObjDirList::iterator itr = myDirs->find(r1);
+(*itr).second.nobj--;
+
 if (fgd) cout << "NamedObjMgr::DelObj()  Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
 else  cout << "NamedObjMgr::DelObj()  Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
@@ -282,4 +436,13 @@
 void NamedObjMgr::DelObj_Id(int oid)
 {
+NObjList::iterator it;
+string nom;
+bool of = false;
+for(it = myObjs->begin(); it != myObjs->end(); it++) 
+  if ( (*it).second.oid == oid ) { 
+    of = true;  nom = (*it).first;
+    break;
+  }
+if (of) DelObj(nom, true);
 }
 
@@ -287,4 +450,7 @@
 void NamedObjMgr::DelObjects(string & patt, bool fgd)
 {
+string n1,r1;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
 NObjList::iterator it;  
 list<string> odel;
@@ -301,4 +467,7 @@
 AnyDataObj* NamedObjMgr::GetObj(string & nom)
 {
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
 NObjList::iterator it = myObjs->find(nom);
 if (it == myObjs->end()) return(NULL); 
@@ -309,4 +478,7 @@
 NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
 {
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
 NObjList::iterator it = myObjs->find(nom);
 if (it == myObjs->end()) return(NULL); 
@@ -322,9 +494,14 @@
 char strg[256];
 
-cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ;
+string n1,r1;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+ cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
 NObjList::iterator it;  k = 0;
+string cn;
 for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0)  continue;
   obj = (*it).second.obj;
-
   ctyp = typeid(*obj).name();
   sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str()); 
@@ -338,6 +515,22 @@
 
 /* --Methode-- */
-void NamedObjMgr::GetObjList(string & patt, vector<string> &)
-{
+void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
+{
+string n1,r1;
+if (patt.length() < 1)  return;
+bool fgr = (patt[0] == '/') ? true : false;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+NObjList::iterator it;
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0)  continue;
+  if (fgr) lst.push_back(cn);
+  else {
+    ParseObjectName(cn, r1, n1);
+    lst.push_back(n1);
+    }
+  }
 }
 
@@ -372,5 +565,5 @@
 if (!ok)  return;
 if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
-AddObj(obj->DataObj(), nobj);
+AddObj(obj->DataObj(), nobj, true);
 return;
 }
@@ -416,5 +609,5 @@
     ok = false; 
   } ENDTRY;
-  if (ok)  AddObj(obj->DataObj(), nom);  
+  if (ok)  AddObj(obj->DataObj(), nom, true);  
 }
 
@@ -475,13 +668,46 @@
 static int key_for_write = 5000;
 /* --Methode-- */
-void NamedObjMgr::SaveObj(string & nom, POutPersist& s)
-{
+void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
+{
+if (nom.length() < 1) return;
+string nob,rep;
+ParseObjectName(nom, rep, nob);
+nom = '/' + rep + '/' + nob;
 NObjMgrAdapter* obja=NULL;
+string nomf = (keeppath) ? nom : nob;
 obja = GetObjAdapter(nom);
 if (obja == NULL)  return;
 printf("NamedObjMgr::SaveObj(%s, )  (Type=%s) \n",  
        nom.c_str(), typeid(*(obja->GetDataObj())).name());
-obja->SavePPF(s, nom);
+obja->SavePPF(s, nomf);
 return; 
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
+{
+string n1,r1;
+if (patt.length() < 1)  return;
+bool keeppath = (patt[0] == '/') ? true : false;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+
+bool ok = true;
+POutPersist* pout;
+TRY{
+  pout = new POutPersist(flnm);
+}  CATCH(merr) 
+  { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+if (!ok)  return;
+NObjList::iterator it;
+string cn; 
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0)  continue;
+  SaveObj(cn, (*pout), keeppath);
+  }
+delete pout;
+return;
 }
 
@@ -502,5 +728,5 @@
 for(it = myObjs->begin(); it != myObjs->end(); it++) {
   no = (*it).first;
-  SaveObj(no, (*pout));
+  SaveObj(no, (*pout), true);
   }
 delete pout;
@@ -651,5 +877,5 @@
 /* --Methode-- */
 void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
-                            string& erx, string& ery, string& erz, string dopt)
+                            string& erx, string& ery, string& erz, string dopt, bool fg3d)
 {
 AnyDataObj* obj=GetObj(nom);
@@ -673,5 +899,5 @@
 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
 
-if (nmz.length()>0)  { // Display 3D
+if ( fg3d && (nmz.length()>0) )  { // Display 3D
   PINTuple3D* pin = new PINTuple3D(nt, false);
   pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
@@ -684,5 +910,6 @@
   pin->SelectXY(nmx.c_str(), nmy.c_str());
   pin->SelectErrBar(erx.c_str(), ery.c_str());
-  string titre = nmy + "%" + nmz;
+  if ( nmz.length()>0 ) pin->SelectWt(nmz.c_str());
+  string titre = nmy + "%" + nmx;
   wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, nom, opt, titre);
   }
@@ -776,4 +1003,5 @@
 servnobjm->DecodeDispOption(gratt, fg);
 }
+
 /* --Methode-- */
 void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
@@ -785,844 +1013,77 @@
 
 /* --Methode-- */
-void NamedObjMgr::DisplayPoints2D(string& nom,  string& expx, string& expy,
-                                  string& experrx, string& experry,
-                                  string& expcut, string dopt)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-// Creation NTuple 
-char* ntn[4] = {"expx","expy","expex","expey",};
-NTuple* nt = NULL;
-bool haserr = false;
-
-if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) {  haserr = true;   nt = new NTuple(4, ntn); }
-else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
-
-servnobjm->Nobj_ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
-
-if (nt->NEntry() < 1) {
-  cout << "NamedObjMgr::DisplayPoints2D() Warning  Zero points satisfy cut !" << endl; 
-  delete nt;
-  return;
-  }
-
-// nt->Show();
-// nt->Print(0,10);
-PINTuple* pin = new PINTuple(nt, true);
-pin->SelectXY(ntn[0], ntn[1]);
-if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
-
-bool fgsr = true;
-dopt = "defline," + dopt;
-int opt = servnobjm->DecodeDispOption(dopt, fgsr);
-string titre =  nom + ":" + expy + "%" + expx;
-myImgApp->DispScDrawer( (PIDrawer*)pin, titre, opt);
-if (fgsr) myImgApp->RestoreGraphicAtt();
-return;
-}
-
-/* --Methode-- */
-void NamedObjMgr::DisplayPoints3D(string& nom,  string& expx, string& expy, string& expz,
-                                  string& expcut, string dopt)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-char* ntn[3] = {"expx","expy","expz"};
-NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
-
-string expwt = "1.";
-servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
-
-if (nt->NEntry() < 1) {
-  cout << "NamedObjMgr::DisplayPoints3D() Warning  Zero points satisfy cut !" << endl;
-  delete nt;
-  return;
-  }
-nt->Show();
-nt->Print(0,10);
-PINTuple3D* pin = new PINTuple3D(nt, true);
-pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
-bool fgsr = true;
-dopt = "defline," + dopt;
-int opt = servnobjm->DecodeDispOption(dopt, fgsr);
-
-// Pour plot a partir de DispScDrawer
-// string nomdisp = "_NT3D_";
-// myImgApp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
-// Pour plot a partir de Disp3DDrawer
-string titre =  nom + ":" + expy + "%" + expx;
-myImgApp->Disp3DDrawer(pin, titre, opt);
-
-if (fgsr) myImgApp->RestoreGraphicAtt();
-return;
-}
-
-/* --Methode-- */
-void NamedObjMgr::ProjectH1(string& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-Histo* h1 = NULL;
-NTuple* nt = NULL;
-AnyDataObj* oh = NULL; 
-if (nomh1.length() > 0) oh=GetObj(nomh1);
-else nomh1 = "H1Proj";
-if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
+void NamedObjMgr::AddWRsId(string & nom, int wrsid)
+{
+if(wrsid != 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::UpdateObjMgrWindow(int did)
+{
+if (!myImgApp)  return;
+(myImgApp->ObjMgrW())->ClearHelpList();
+
+NObjList::iterator it;  
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  if ((*it).second.dirid != did) continue;
+  cn = (*it).first.substr(1);
+  cn = cn.substr(cn.find('/')+1) + "  (T= " + typeid(*((*it).second.obj)).name() + ")" ;
+  (myImgApp->ObjMgrW())->AddObj(cn.c_str());
+  }
+}
+
+
+/* Nouvelle-Fonction */
+void RemoveSpacesFromName(string & nom)
+{
+// on supprime les blancs de debut et de fin 
+size_t p = nom.find_first_not_of(" ");
+if(p>nom.length()) { nom = ""; return; }
+nom = nom.substr(p);
+p = nom.find(' ');
+if(p>nom.length()) p=nom.length();
+nom = nom.substr(0, p);
+}
+
+/* Nouvelle-Fonction */
+bool CheckDirName(string & nom)
+{
+RemoveSpacesFromName(nom);
+if (nom.length() < 1)  return(false); 
+if (nom[0] == '/') nom = nom.substr(1) ;
+size_t p = nom.find('/');
+if (p < nom.length()) nom = nom.substr(0,p);
+if (nom.length() < 1)  return(false); 
+return(true);
+}
+
+/* Nouvelle-Fonction */
+int ParseObjectName(string & nom, string & nomrep, string & nomobj)
+{
+RemoveSpacesFromName(nom);
+// Si le nom ne commence pas par un slash, c'est le repertoire courant 
+if (nom[0] != '/') { nomrep = *currDir;  nomobj = nom; }
 else {
-  char* ntn[2]= {"hxval", "hwt"};
-  nt = new NTuple(2,ntn);  // Creation NTuple 
-  }
-string expz = "0.";   
-servnobjm->Nobj_ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
-
-if ((!h1) && (!nt)) return;
-if (!h1) {
-  if (nt->NEntry() < 1) {
-    cout << "NamedObjMgr::ProjectH1() Warning  Zero points satisfy cut !" << endl; 
-    delete nt;
-    return;
+  string xx = nom.substr(1);
+  size_t p = xx.find('/');
+  if (p < xx.length())  { 
+    nomrep = xx.substr(0,p); 
+    nomobj = xx.substr(p+1);
     }
-  double xmin, xmax;
-  nt->GetMinMax(0, xmin, xmax);
-  h1 = new Histo(xmin, xmax, 100);
-  int k;
-  float* xn;
-  for(k=0; k<nt->NEntry(); k++)    {
-    xn = nt->GetVec(k);
-    h1->Add(xn[0], xn[1]);    
+  else {
+    nomrep = xx;
+    nomobj = "";
     }
-  delete nt;
-  AddObj(h1, nomh1);
-  }
-
-DisplayObj(nomh1, dopt);
-return;  
-}
-
-/* --Methode-- */
-void NamedObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt, string& expcut, 
-                            string& nomh2, string dopt)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-Histo2D* h2 = NULL;
-NTuple* nt = NULL;
-AnyDataObj* oh = NULL;
-if (nomh2.length() > 0)  oh=GetObj(nomh2);
-else nomh2 = "H2Proj";
-if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
-else {
-  char* ntn[3]= {"hxval", "hyval", "hwt"};
-  nt = new NTuple(3,ntn);  // Creation NTuple 
-  }
-string expz = "0.";   
-servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
-
-if ((!h2) && (!nt)) return;
-if (!h2) {
-  if (nt->NEntry() < 1) {
-    cout << "NamedObjMgr::ProjectH2() Warning  Zero points satisfy cut !" << endl; 
-    delete nt;
-    return;
-    }
-  double xmin, xmax, ymin, ymax;
-  nt->GetMinMax(0, xmin, xmax);
-  nt->GetMinMax(0, ymin, ymax);
-  h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
-  int k;
-  float* xn;
-  for(k=0; k<nt->NEntry(); k++)    {
-    xn = nt->GetVec(k);
-    h2->Add(xn[0], xn[1], xn[2]);    
-    }
-  delete nt;
-  AddObj(h2, nomh2);
-  }
-
-DisplayObj(nomh2, dopt);
-return;  
-
-}
-
-/* --Methode-- cmv 13/10/98 */
-void NamedObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt, string& expcut, 
-                              string& nomprof, string dopt)
-//	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.
-//| expy = expression Y a additionner dans le bin.
-//| expwt = expression W du poids a additionner.
-//| expcut = expression du test de selection.
-//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
-//|           les limites Xmin,Xmax sont calculees automatiquement.
-//|           sinon ce sont celles de l'objet preexistant.
-//| opt = options generales pour le display.
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-HProf* hprof = NULL;
-NTuple* nt = NULL;
-AnyDataObj* oh = NULL;
-if (nomprof.length() > 0)  oh=GetObj(nomprof);
-else nomprof = "ProfProj";
-if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) )  hprof = (HProf*)oh;
-else {
-  char* ntn[3]= {"hxval", "hyval", "hwt"};
-  nt = new NTuple(3,ntn);  // Creation NTuple 
-}
-string expz = "0.";
-servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
-
-if((!hprof) && (!nt)) return;
-if(!hprof) {
-  if (nt->NEntry() < 1) {
-    cout << "NamedObjMgr::ProjectHProf() Warning  Zero points satisfy cut !" << endl;
-    delete nt;
-    return;
-  }
-  double xmin, xmax;
-  nt->GetMinMax(0, xmin, xmax);
-  hprof = new HProf(xmin, xmax, 100);
-  int k;
-  float* xn;
-  for(k=0; k<nt->NEntry(); k++)    {
-    xn = nt->GetVec(k);
-    hprof->Add(xn[0], xn[1], xn[2]);
-    }
-  delete nt;
-  AddObj(hprof, nomprof);
-  }
-hprof->UpdateHisto();
-
-DisplayObj(nomprof, dopt);
-return;
-}
-
-/* --Methode-- */
-void NamedObjMgr::FillVect(string& nom, string& expx, string& expcut, string& nomvec, string dopt)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-NTuple* nt = NULL;
-if (nomvec.length() < 1) nomvec = "VecFill";
-
-char* ntn[2]= {"vecval", "vecwt"};
-nt = new NTuple(1,ntn);  // Creation NTuple
- 
-string expwt = "1.";
-string expz = "0.";   
-servnobjm->Nobj_ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
-
-if (!nt) return;
-if (nt->NEntry() < 1) {
-  cout << "NamedObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
-  delete nt;
-  return;
-  }
-  
-Vector* vec = new Vector(nt->NEntry());
-int k;
-float* xn;
-for(k=0; k<nt->NEntry(); k++)    {
-  xn = nt->GetVec(k);
-  (*vec)(k) = xn[0];
-  }
-delete nt;
-AddObj(vec, nomvec); 
-DisplayObj(nomvec, dopt);
-return;  
-}
-
-/* --Methode-- */
-void NamedObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz, string& expt, 
-                         string& expcut, string& nomnt)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-  }
-if (!myImgApp)  return; 
-
-bool fgnnt = false;
-NTuple* nt = NULL;
-AnyDataObj* oh = NULL;
-if (nomnt.length() > 0)  oh=GetObj(nomnt);
-else nomnt = "NTFill";
-if ( (oh != NULL) && (typeid(*oh) == typeid(HProf)) )  { 
-  nt = (NTuple*)oh;
-  if (nt->NVar() > 10) {
-    cout << "NamedObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
-    nt = NULL;
-    }
-  }  
-if (nt == NULL) {
-  char* ntn[4]= {"x", "y","z","t"};
-  nt = new NTuple(4,ntn);  // Creation NTuple 
-  fgnnt = true;
-  }
-
-servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
-
-if (fgnnt) AddObj(nt, nomnt);
-return;  
-
-}
-
-/* --Methode-- cmv 13/10/98 */
-void NamedObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
-                          string& experr, string& expcut, string& nomgfd)
-//	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) .
-//|       Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
-//| expx = expression X du GeneralFitData (1er abscisse)
-//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
-//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
-//| experr = expression de l'erreur sur l'ordonnee Z
-//| expcut = expression du test de selection
-//| nomgfd = nom du GeneralFitData engendre (optionnel)
-{
-NObjMgrAdapter* obja=NULL;
-obja = GetObjAdapter(nom);
-if (obja == NULL) {
-  cout << "NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
-  return;
-  }
-if(!myImgApp)  return;
-
-// 2D ou 3D?
-int nvar = 2;
-if(expy.length()<=0) {nvar = 1; expy = "0.";}
-
-// $CHECK$ - cmv calculait le nombre d'entree ndata
-// en fonction de chaque objet - Je l'ai vire Reza 11/05/99
-
-// Creation NTuple Buffer
-char* ntn[4]= {"x","y","f","e"};
-NTuple*nt = new NTuple(4,ntn);
-
-// Remplissage NTuple buffer
-servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
-if(nt->NEntry() < 1)
-  {cout<<"NamedObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
-   delete nt; return;}
-
-//Remplissage de la structure GeneraFitData
-if (nt->NEntry() <= 0) {
-  cout<<"NamedObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
-  delete nt;
-  return;
-  }
-
-GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
-int k;
-float* xn;
-for(k=0; k<nt->NEntry(); k++) {
-  xn = nt->GetVec(k);
-  gfd->AddData(xn,xn[2],xn[3]);
-}
-
-// Menage et table d'objets
-delete nt;
-AddObj(gfd, nomgfd);
-return;
-}
-
-
-///////////////////// Fit 1D et 2D //////////////////////////
-/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
-struct DFOptions {
-  int okres, okfun;
-  int polcx,polcy; double xc,yc;
-  double err_e, err_E;
-  double stc2;
-  int lp,lpg;
-  int i1,i2,j1,j2;
-};
-typedef struct DFOptions DFOPTIONS;
-static void DecodeFitsOptions(string par,string step,string min,string max,string opt
-                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
-void DecodeFitsOptions(string par,string step,string min,string max,string opt
-                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
-//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
-{
-// set des vecteurs et decodage des string correspondantes
-int NParMax = 100;
-Par.Realloc(NParMax); Step.Realloc(NParMax);
-Min.Realloc(NParMax); Max.Realloc(NParMax);
-{
-  Vector* v; string* s;
-  {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
-  for(int j=0;j<4;j++) {
-    if(j==0)      {v=&Par; s=&par;}
-    else if(j==1) {v=&Step; s=&step;}
-    else if(j==2) {v=&Min; s=&min;}
-    else if(j==3) {v=&Max; s=&max;}
-    if(s->length()>0) *s += ",";
-    for(int i=0;i<NParMax;i++) {
-      if(s->length()<=0) break;
-      sscanf(s->c_str(),"%lf",&(*v)(i));
-      size_t p = s->find_first_of(',') + 1;
-      if(p>=s->length()) *s = ""; else *s = s->substr(p);
-    }
-  }
-}
-
-// Decodage de options de opt
-O.okres = O.okfun = 0;
-O.polcx = O.polcy = 0;
-O.xc = O.yc = 0.;
-O.stc2 = 1.e-3;
-O.err_e = O.err_E = -1.;
-O.lp = 1; O.lpg = 0;
-O.i1 = O.j1 = O.i2 = O.j2 = -1;
-
-if(opt.length()<=0) return;
-opt = "," + opt + ",";
-
-if(strstr(opt.c_str(),",r,")) O.okres = 1;  // residus
-if(strstr(opt.c_str(),",f,")) O.okfun = 1;  // fonction fittee
-if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
-  O.polcx = 2; // Le centrage est calcule automatiquement
-  size_t p = opt.find(",x");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) {
-    sscanf(dum.c_str(),",x%lf",&O.xc);
-    O.polcx = 1; // Le centrage est fixe par la valeur lue
-  }
-}
-if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
-  O.polcy = 2; // Le centrage est calcule automatiquement
-  size_t p = opt.find(",y");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) {
-    sscanf(dum.c_str(),",y%lf",&O.yc);
-    O.polcy = 1; // Le centrage est fixe par la valeur lue
-  }
-}
-if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
-  size_t p = opt.find(",E");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
-  if(O.err_E<=0.) O.err_E = 1.;
-  O.err_e=-1.;
-}
-if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
-  size_t p = opt.find(",e");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
-  if(O.err_e<=0.) O.err_e = 1.;
-  O.err_E=-1.;
-}
-if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
-  size_t p = opt.find(",X");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
-  if(O.stc2<=0.) O.stc2 = 1.e-3;
-}
-if(strstr(opt.c_str(),",l")) { // niveau de print
-  size_t p = opt.find(",l");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  float ab;
-  if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
-  if(ab<0) ab = 0.;
-  O.lp = (int) ab; O.lpg = (int) 10.*(ab-O.lp);
-}
-if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
-  size_t p = opt.find(",I");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
-}
-if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
-  size_t p = opt.find(",J");
-  size_t q = opt.find_first_of(',',p+1);
-  string dum = opt.substr(p,q-p);
-  if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
-}
-return;
-}
-
-/* --Methode-- cmv 13/10/98 */
-void  NamedObjMgr:: Fit12D(string& nom, string& func,
-                          string par,string step,string min,string max,
-                          string opt)
-//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
-//| nom  : nom de l'objet qui peut etre:
-//|        fit-1D:  Vector,Histo1D,HProf ou GeneraFitData(1D)
-//|        fit-2D:  Matrix,Histo2D,Imagexx ou GeneraFitData(2D)
-//| func : pnn = fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
-//|      : Pnn = fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
-//|      : gnn = fit gaussienne (hauteur) + polynome de degre nn 1D
-//|      : g   = fit gaussienne (hauteur) 1D
-//|      : enn = fit exponentielle + polynome de degre nn 1D
-//|      : e   = fit exponentielle 1D
-//|      : Gnn = fit gaussienne (volume) + polynome de degre nn 1D
-//|      : G   = fit gaussienne (volume) 1D
-//|      :     = fit gaussienne+fond (volume) 2D
-//|      : Gi  = fit gaussienne+fond integree (volume) 2D
-//|      : d   = fit DL de gaussienne+fond (volume) 2D
-//|      : di  = fit DL de gaussienne+fond integree (volume) 2D
-//|      : D   = fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
-//|      : Di  = fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
-//|      : M   = fit Moffat+fond (expos=p6) (volume) 2D
-//|      : Mi  = fit Moffat+fond integree (expos=p6) (volume) 2D
-//| par  : p1,...,pn valeur d'initialisation des parametres (def=0)
-//| step : s1,...,sn valeur des steps de depart (def=1)
-//| min  : m1,...,mn valeur des minima (def=1)
-//| max  : M1,...,Mn valeur des maxima (def=-1) (max<=min : pas de limite)
-//| opt  : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
-//|       f = generation d'un Objet identique contenant la fonction fittee
-//|       r = generation d'un Objet identique contenant les residus
-//|       Xaa.b = aa.b valeur du DXi2 d'arret (def=1.e-3)
-//|       la.b = niveau "a.b" de print: a=niveau de print Fit1/2D
-//|                                     b=niveau de debug GeneralFit
-//|       Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
-//|2D     Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
-//|       - L'erreur est celle associee a l'objet si existe, 1 sinon sauf si
-//|       E = erreur prise comme la racine de la valeur a fitter
-//|       Eaa.b = erreur prise aa.b*sqrt(val)
-//|       e = erreur prise egale a 1 pour toutes les valeurs
-//|       eaa.b = erreur prise egale a aa.b
-//|       xaa.b = demande de centrage: on fit x-aa.b au lieu de x)
-//|       x = demande de centrage: on fit x-xc au lieu de x
-//|           avec xc=abscisse du milieu de l'histogramme
-//|           Actif pour: exp+poly 1D, poly 1D
-//|                       gauss+poly 1D (mais xc est le centre de la gaussienne)
-//|2D     yaa.b et y = idem "xaa.b et x" mais pour y
-{
-AnyDataObj* obj=GetObj(nom);
-if (obj == NULL) {
-  cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
-  return;
-}
-if (!myImgApp)  return;
-if(func.length()<=0)
-  {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
-   return;}
-string ctyp = typeid(*obj).name();
-
-int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
-Vector* v = NULL; Histo* h = NULL;
-Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
-GeneralFitData* g = NULL;
-
-  // 1D
-if (typeid(*obj) == typeid(Vector)) {
-  ndim = 1;
-  v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
-  }
-else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
-  ndim = 1;
-  h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
-  }
-else if (typeid(*obj) == typeid(Matrix)) {
-  ndim = 2;
-  m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
-  }
-else if (typeid(*obj) == typeid(Histo2D)) {
-  ndim = 2;
-  h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
-  }
-else if (typeid(*obj) == typeid(GeneralFitData)) {
-  g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
-  if(     g->NVar()==1) ndim = 1;
-  else if(g->NVar()==2) ndim = 2;
-  else {
-     cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
-         <<((GeneralFitData*) obj)->NVar()<<endl; return; }
-  }
-else if (dynamic_cast<RzImage*>(obj)) {
-  ndim = 2;
-  im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
-  }
-else  {
-  cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
-      <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
-  return; 
-  }
-
-ndata = nbinx*nbiny;
-if(ndata<=0)
-  {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
-
-// Decodage des options et des parametres, mise en forme
-Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
-DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
-O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
-O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
-if(ndim>=2) {
-  O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
-  O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
-} else O.j2 = O.j1 = 0;
-if(O.polcx==2) {
-  if(v||m)    O.xc = (O.i2-O.i1+1)/2.;
-  else if(h)  O.xc = (h->XMin()+h->XMax())/2.;
-  else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
-  else if(g)  {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
-  else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
-}
-if(O.polcy==2 && ndim>=2) {
-  if(m)  O.yc = (O.j2-O.j1+1)/2.;
-  if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
-  if(g)  {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
-  if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
-}
-if(O.lp>0)
-  cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
-      <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
-      <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
-      <<" TypE="<<O.err_e<<","<<O.err_E
-      <<" StpX2="<<O.stc2
-      <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
-
-///////////////////////////////////
-// Remplissage de GeneralFitData //
-///////////////////////////////////
-GeneralFitData mydata(ndim,ndata,0);
-{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
-  double x,y,f,e;
-
-  if(v)
-    {x= (double) i; f=(*v)(i); e=1.;}
-  else if(h)
-    {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
-  else if(m)
-    {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
-  else if(h2)
-    {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
-     f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
-  else if(im)
-    {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
-     f=im->DValue(i,j); e=1.;}
-  else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
-  else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
-  else x=y=f=e=0.;
-
-  // Gestion des erreurs a utiliser
-  if(O.err_e>0.) e=O.err_e;
-  else if(O.err_E>0.) {e=(y<-1.||y>1.)?O.err_E*sqrt(fabs(y)):O.err_E;}
-
-  // Remplissage de generalfit
-  if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
-  if(ndim==1)      mydata.AddData1(x,f,e);
-  else if(ndim==2) mydata.AddData2(x,y,f,e);
-}}
-if(mydata.NData()<=0)
-  {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
-   return;}
-if(O.lpg>1) {
-  mydata.PrintStatus();
-  mydata.PrintData(0);
-  mydata.PrintData(mydata.NData()-1);
-}
-
-////////////////////////////////////////////
-// Identification de la fonction a fitter //
-////////////////////////////////////////////
-GeneralFunction* myfunc = NULL;
-if(func[0]=='p' && ndim==1) {
-  // Fit de polynome sans passer par les GeneralFit
-  int degre = 0;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
-  Poly p1(0);
-  double c2rl = mydata.PolFit(0,p1,degre);
-  cout<<"C2r_lineaire = "<<c2rl<<endl;
-  if(O.lp>0) cout<<p1<<endl;
-  return;
-
-} else if(func[0]=='P' && ndim==1) {
-  // Fit de polynome
-  int degre = 0;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit polynome 1D de degre "<<degre<<endl;
-  Polyn1D* myf = new Polyn1D(degre,O.xc);
-  myfunc = myf;
-
-} else if(func[0]=='e' && ndim==1) {
-  // Fit d'exponentielle
-  int degre =-1;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
-  Exp1DPol* myf;
-  if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
-       else    myf = new Exp1DPol(O.xc);
-  myfunc = myf;
-
-} else if(func[0]=='g' && ndim==1) {
-  // Fit de gaussienne en hauteur
-  int degre =-1;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
-  Gauss1DPol* myf;
-  if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
-  else { bool bfg = (O.polcx)?true:false;   myf = new Gauss1DPol(bfg); }
-  myfunc = myf;
-
-} else if(func[0]=='G' && ndim==1) {
-  // Fit de gaussienne en volume
-  int degre =-1;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
-  GaussN1DPol* myf;
-  if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
-  else  { bool bfg = (O.polcx)?true:false;   myf = new GaussN1DPol(bfg); }
-  myfunc = myf;
-
-} else if(func[0]=='p' && ndim==2) {
-  // Fit de polynome 2D sans passer par les GeneralFit
-  int degre = 0;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
-  Poly2 p2(0);
-  double c2rl = mydata.PolFit(0,1,p2,degre);
-  cout<<"C2r_lineaire = "<<c2rl<<endl;
-  if(O.lp>0) cout<<p2<<endl;
-  return;
-
-} else if(func[0]=='P' && ndim==2) {
-  // Fit de polynome 2D
-  int degre = 0;
-  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
-  cout<<"Fit polynome 2D de degre "<<degre<<endl;
-  Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
-  myfunc = myf;
-
-} else if(func[0]=='G' && ndim==2) {
-  // Fit de gaussienne+fond en volume
-  int integ = 0;
-  if(func.length()>1) if(func[1]=='i') integ=1;
-  cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
-  if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
-    else    {GauRho2D* myf = new GauRho2D; myfunc = myf;}
-
-} else if(func[0]=='d' && ndim==2) {
-  // Fit de DL gaussienne+fond en volume
-  int integ = 0;
-  if(func.length()>1) if(func[1]=='i') integ=1;
-  cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
-  if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
-    else    {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
-
-} else if(func[0]=='D' && ndim==2) {
-  // Fit de DL gaussienne+fond avec coeff variable p6 en volume
-  int integ = 0;
-  if(func.length()>1) if(func[1]=='i') integ=1;
-  cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
-  if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
-    else    {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
-
-} else if(func[0]=='M' && ndim==2) {
-  // Fit de Moffat+fond (volume)
-  int integ = 0;
-  if(func.length()>1) if(func[1]=='i') integ=1;
-  cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
-  if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
-    else    {MofRho2D* myf = new MofRho2D; myfunc = myf;}
-
-} else {
-  cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
-  return;
-}
-
-/////////////////////////
-// Fit avec generalfit //
-/////////////////////////
-if(myfunc->NPar()>Par.NElts())
-  {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
-  if(myfunc) delete myfunc; return;}
-GeneralFit myfit(myfunc);
-myfit.SetDebug(O.lpg);
-myfit.SetData(&mydata);
-myfit.SetStopChi2(O.stc2);
-{for(int i=0;i<myfunc->NPar();i++) {
-  char str[10];
-  sprintf(str,"P%d",i);
-  myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
-}}
-if(O.lp>1) myfit.PrintFit();
-double c2r = (double) myfit.Fit();
-if(O.lp>0) myfit.PrintFit();
-if(c2r>0.) {
-  c2r = myfit.GetChi2Red();
-  cout<<"C2r_Reduit = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
-  Vector ParFit(myfunc->NPar());
-  for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
-} else {
-  cout<<"echec Fit, rc = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
-}
-
-// Mise a disposition des resultats
-if(c2r>=0. && myfunc && (O.okres>0||O.okfun>0)) {
-  string nomres = nom + "res";
-  string nomfun = nom + "fun";
-  if(v) {
-    if(O.okres) {Vector* ob = v->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
-    if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
-  } else if(h) {
-    if(O.okres) {Histo* ob = h->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
-    if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
-  } else if(m) {
-    if(O.okres) {Matrix* ob = m->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
-    if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
-  } else if(h2) {
-    if(O.okres) {Histo2D* ob = h2->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
-    if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
-  } else if(im) {
-    if(O.okres) {RzImage* ob = im->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
-    if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
-  } else if(g) {
-    if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
-    if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
-  }
-}
-
-// Nettoyage
-if(myfunc) delete myfunc;
-return;
-}
-
+  }
+int rc = 0;
+NObjDirList::iterator it = myDirs->find(nomrep);
+if (it != myDirs->end())  rc = (*it).second.id;
+return(rc);
+}
+
Index: /trunk/SophyaPI/PIext/nobjmgr.h
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.h	(revision 332)
+++ /trunk/SophyaPI/PIext/nobjmgr.h	(revision 333)
@@ -32,7 +32,10 @@
 
 // Gestion des repertoires
-  virtual void		CreateDir(string const& dirname);
-  virtual void		DeleteDir(string const& dirname);
-  virtual void		SetCurrentDir(string const& dirname);
+  virtual void		CreateDir(string & dirname);
+  virtual void		DeleteDir(string & dirname);
+  virtual void		SetCurrentDir(string & dirname);
+  virtual void		GetCurrentDir(string & dirname);
+  virtual void		ListDirs(string & patt);
+  virtual void		GetDirList(string & patt, vector<string>& );
   virtual void		CleanTmpDir();
   virtual void		CleanOldDir();
@@ -53,5 +56,6 @@
   virtual void		ReadAll(string const & nomppf);
   virtual void		ReadFits(string const & flnm, string & nobj);
-  virtual void          SaveObj(string & nom, POutPersist& s);
+  virtual void          SaveObj(string & nom, POutPersist& s, bool keeppath=false);
+  virtual void          SaveObjects(string & patt, string const& nomppf);
   virtual void          SaveAll(string const& nomppf);
   virtual void          SaveFits(string & nom, string const & flnm);
@@ -65,35 +69,14 @@
   virtual void          DisplaySurf3D(string & nom, string dopt="");
   virtual void          DisplayNT(string & nom, string& nmx, string& nmy, string& nmz,  
-                                  string& erx, string& ery, string& erz, string dopt="");
-  virtual void          DisplayGFD(string & nom, string& numvarx, string& numvary, string& err, string dopt="");
+                                  string& erx, string& ery, string& erz, 
+                                  string dopt="", bool fg3d=false);
+  virtual void          DisplayGFD(string & nom, string& numvarx, string& numvary, 
+                                   string& err, string dopt="");
 
   virtual void		SetGraphicAttributes(string gratt="");
   virtual void		SetGraphicWinZone(int nzx, int nzy, bool fcr=false);
 
-
-//  Trace d'expression de NTuple, et d'autres objets
-  virtual void          DisplayPoints2D(string & nom, string& expx, string& expy,
-                                        string& experrx, string& experry, 
-                                        string& expcut, string dopt="");
-  virtual void          DisplayPoints3D(string & nom, string& expx, string& expy, string& expz, 
-                                        string& expcut, string dopt="");
-//  Projection d'expressions dans histogramme (et trace) 
-  virtual void          ProjectH1(string & nom, string& expx, string& expwt, string& expcut, 
-                                  string& nomh1, string dopt="");
-  virtual void          ProjectH2(string & nom, string& expx, string& expy, string& expwt, 
-                                  string& expcut, string& nomh2, string dopt="");
-  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="");
-  virtual void          FillNT(string & nom, string& expx, string& expy, string& expz,
-                               string& expt, string& expcut, string& nomnt); 
-  virtual void          FillGFD(string & nom, string& expx, string& expy, string& expz,
-                               string& experr, string& expcut, string& nomgfd);
-
-//   Methodes de fit, a rajouter  (pour CMV , deux methodes H1 H2 ou 1 seule ??) ...
-  virtual void          Fit12D(string & nom, string& func,
-                              string par,string step,string min,string max,string opt);
+// Acces a l'adaptateur
+  virtual NObjMgrAdapter*	GetObjAdapter(string & nom);
 
 // Acces au PIApplication et a la classe de service 
@@ -101,6 +84,7 @@
   virtual Services2NObjMgr* 	GetServiceObj();
 
-protected :
-  virtual NObjMgrAdapter*	GetObjAdapter(string & nom);
+  virtual void		AddWRsId(string & nom, int wrsid);
+// Pour utilisation par ObjMgrWind
+  virtual void		UpdateObjMgrWindow(int did);
 };
 
Index: /trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- /trunk/SophyaPI/PIext/piacmd.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/piacmd.cc	(revision 333)
@@ -141,5 +141,7 @@
 usage += "  set unset listvar listcommands exec shell \n";
 usage += "  > set varname 'string'   # To set a variable, $varname \n";
+usage += "  > setol varname patt     # Fills varname with object list \n";
 usage += "  > unset varname          # clear variable definition \n";
+usage += "  > echo string            # output string \n";
 usage += "  > listvars   # List of variable names and values \n";
 usage += "  > listcommands # List of all known commands \n";
@@ -282,5 +284,5 @@
 int PIACmd::Interpret(string& s)
 {
-
+int rc = 0;
 cmdtok tokens;
 if (s.length() < 1)  return(0);
@@ -334,5 +336,15 @@
 else if (kw == "set") {
   if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: set varname string" << endl;  return(0); }
-  mVars[tokens[0]] = tokens[1];
+  string xx = "";
+  for (int kk=0; kk<tokens.size(); kk++)  xx += (tokens[kk] + ' ');
+  mVars[tokens[0]] = xx;
+  }
+else if (kw == "setol") {
+  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: setol varname objnamepattern" << endl;  return(0); }
+  vector<string> ol;
+  mObjMgr->GetObjList(tokens[1], ol); 
+  string vol = ""; 
+  for (int kk=0; kk<ol.size(); kk++)  vol += (ol[kk] + ' ');
+  mVars[tokens[0]] = vol;
   }
 else if (kw == "unset") {
@@ -341,4 +353,8 @@
   if (it != mVars.end())  mVars.erase(it);
   else cerr << "PIACmd::Interpret() No variable with name " << tokens[0] << endl;
+  }
+else if (kw == "echo") {
+  for (int kk=0; kk<tokens.size(); kk++)  cout << tokens[kk] << " " ;
+  cout << endl;
   }
 else if (kw == "listvars") {
@@ -379,17 +395,51 @@
   }
 //  Execution d'une commande enregistree
-else {
-  CmdExmap::iterator it = cmdexmap.find(kw);
-  if (it == cmdexmap.end())  cout << "No such command : " << kw << " ! " << endl;
+else rc = ExecuteCommand(kw, tokens);
+
+if (timing)  gltimer->Split();
+return(rc);
+}
+
+/* --Methode-- */
+int PIACmd::ExecuteCommandLine(string& line)
+{
+cmdtok tokens;
+if (line.length() < 1)  return(0);
+
+string toks,kw;
+size_t p = line.find_first_not_of(" ");
+line = line.substr(p);
+p = 0;
+size_t q = line.find_first_of(" ");
+size_t l = line.length();
+
+if (q < l)
+  {  kw = line.substr(p,q-p);  toks = line.substr(q, l-q); }
+else { kw = line.substr(p,l-p);  toks = ""; }
+
+q = 0;
+while (q < l)  {
+  p = toks.find_first_not_of(" ",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = toks.find_first_of(" ",p); // la fin du token;
+  string token = toks.substr(p,q-p);
+  tokens.push_back(token);
+  }
+
+return(ExecuteCommand(kw, tokens));  
+}
+
+/* --Methode-- */
+int PIACmd::ExecuteCommand(string& keyw, vector<string>& args)
+{
+  int rc = -1;
+  CmdExmap::iterator it = cmdexmap.find(keyw);
+  if (it == cmdexmap.end())  cout << "No such command : " << keyw << " ! " << endl;
   else { 
-    if ((*it).second.cex) (*it).second.cex->Execute(kw, tokens);
-    else cout << "Dont know how to execute " << kw << " ? " << endl;
+    if ((*it).second.cex) rc = (*it).second.cex->Execute(keyw, args);
+    else cout << "Dont know how to execute " << keyw << " ? " << endl;
     }
-  }
-
-if (timing)  gltimer->Split();
-return(0);
-}
-
+  return(rc);
+}
 
 /* --Methode-- */
Index: /trunk/SophyaPI/PIext/piacmd.h
===================================================================
--- /trunk/SophyaPI/PIext/piacmd.h	(revision 332)
+++ /trunk/SophyaPI/PIext/piacmd.h	(revision 333)
@@ -72,4 +72,6 @@
 
   virtual int		Interpret(string& line);
+  virtual int		ExecuteCommandLine(string& line);
+  virtual int		ExecuteCommand(string& keyw, vector<string>& args);
   virtual int		ExecFile(string& file);
 
Index: /trunk/SophyaPI/PIext/pintup3d.cc
===================================================================
--- /trunk/SophyaPI/PIext/pintup3d.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/pintup3d.cc	(revision 333)
@@ -23,5 +23,4 @@
 string name;
 if (mNT == NULL)  xK = yK = zK = -1;
-if (mNT == NULL)  xK = yK = -1;
 if (px == NULL) xK = -1;
 else { name = px; xK = mNT->ColumnIndex(name); }
Index: /trunk/SophyaPI/PIext/pintuple.cc
===================================================================
--- /trunk/SophyaPI/PIext/pintuple.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/pintuple.cc	(revision 333)
@@ -27,4 +27,15 @@
 if (py == NULL) yK = -1;
 else { name = py; yK = mNT->ColumnIndex(name); }
+}
+
+/* --Methode-- */
+void  PINTuple::SelectWt(const char* pw, int nbins)
+{
+nWbins = (nbins > 0) ? nbins : 10;
+if (pw == NULL) wK = -1;  
+else { string name = pw;   wK = mNT->ColumnIndex(name);  }
+ 
+if (wK >= 0) mNT->GetMinMax(wK, wMin, wMax);
+else  { wMin = 0.; wMax = 1.; }
 }
 
@@ -67,5 +78,5 @@
 void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
 {
-double xp,yp,xer,yer;
+double xp,yp,xer,yer,wp;
 double xl,yl;
 int nok;
@@ -74,4 +85,16 @@
 if ( (xK < 0) || (yK < 0) )  return;
 if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+
+//  Pour tracer des markers avec taille fonction de Wt (poids)
+double dw = (wMax-wMin)/nWbins;
+if (dw < 1.e-19) dw = 1.e19;
+int msz,sz;
+
+PIMarker mrk;
+if (wK >= 0)  mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_CircleMarker;
+else   mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_DotMarker;
+msz = mMSz;
+if (msz < 1) msz = 1;
+g->SelMarker(sz, mrk);
 
 nok = 0;  
@@ -93,4 +116,13 @@
     if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
   }
+  if (wK >= 0) { // Taille de marker en fonction du poids
+    wp = mNT->GetCell(i, wK);
+    sz = (int)((wp-wMin)/dw);
+    if (sz < 0) sz = 0;
+    if (sz > nWbins)  sz = nWbins;
+    sz += msz;
+    if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
+    else g->SelMarker(sz, mrk);
+  }
   g->DrawMarker(xp, yp); 
 }
Index: /trunk/SophyaPI/PIext/pintuple.h
===================================================================
--- /trunk/SophyaPI/PIext/pintuple.h	(revision 332)
+++ /trunk/SophyaPI/PIext/pintuple.h	(revision 333)
@@ -14,4 +14,5 @@
   
           void       SelectXY(const char* px, const char* py);
+          void       SelectWt(const char* pw=NULL, int nbins=10);
           void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
 
@@ -22,4 +23,7 @@
   int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
   int xebK, yebK;      // Index du nom de variable en ErrBarX/Y ds le ntuple
+  int wK;              // Index du nom de variable poids
+  double wMin, wMax;        // Valeurs de poids min/max
+  int nWbins;               // Nombre de bins pour le poids (Wt)
 
 };
Index: /trunk/SophyaPI/PIext/pisiadw.cc
===================================================================
--- /trunk/SophyaPI/PIext/pisiadw.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/pisiadw.cc	(revision 333)
@@ -34,18 +34,21 @@
 // On definit la taille a partir de la taille par defaut des composantes 
 PIApplicationPrefCompSize(bsx, bsy);
-spx = bsx/4;   spy = bsy/3;
-tsx = 5*bsx+6*spx;  tsy = 7*bsy+4*spy;
+spx = bsx/4;   spy = bsy/4;
+tsx = 4.0*bsx+3*spx;  tsy = 6*bsy+7*spy;
 SetSize(tsx,tsy);
-objlist = new PIList(this, "objlist", tsx-spx, tsy-4*spy-bsy, spx/2, spy/2);
+dirlist = new PIOptMenu(this, "dirlist", 2.5*bsx, bsy, spx+0.25*bsx, spy); 
+dirlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+objlist = new PIList(this, "objlist", 3*bsx, tsy-3*spy-bsy, spx, 2*spy+bsy);
 objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
-objlist->SetBorderWidth(2);
-
-int py = tsy-2*spy-bsy;
-int px = spx;
-mBut[0] = new PIButton(this, "Display", 100, bsx, bsy, px, py);   px += (bsx+spx);
-mBut[1] = new PIButton(this, "Print",   200, bsx, bsy, px, py);   px += (bsx+spx);
-mBut[2] = new PIButton(this, "SavePPF", 300, bsx, bsy, px, py);   px += (bsx+spx);
-mBut[3] = new PIButton(this, "Delete",  400, bsx, bsy, px, py);   px += (bsx+spx);
-mBut[4] = new PIButton(this, "Dismiss", 900, bsx, bsy, px, py);   px += (bsx+spx);
+// objlist->SetBorderWidth(2);
+
+int py = spy;
+int px = 2*spx+3*bsx;
+mBut[0] = new PIButton(this, "SetCurDir", 20, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[1] = new PIButton(this, "Display", 20, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[2] = new PIButton(this, "Print",   30, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[3] = new PIButton(this, "SavePPF", 40, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[4] = new PIButton(this, "Delete",  50, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[5] = new PIButton(this, "Dismiss", 90, bsx, bsy, px, py);   py += (bsy+spy);
 
 for(i=0; i<5; i++)
@@ -59,6 +62,7 @@
 {
 int i;
+delete dirlist;
 delete objlist;
-for(i=0; i<5; i++)  delete mBut[i];
+for(i=0; i<6; i++)  delete mBut[i];
 }
 
@@ -67,4 +71,9 @@
 {
 dap->SetBlocked();
+string cdir;
+dap->ObjMgr()->GetCurrentDir(cdir);
+cdir = '/' + cdir;
+dirlist->SetValueStr(cdir);
+dap->ObjMgr()->UpdateObjMgrWindow(dirlist->GetValue()-30000);
 PIWindow::Show();
 return;
@@ -77,12 +86,21 @@
   // PIMessage ssg = ModMsg(msg);
 msg = UserMsg(msg);
-if (msg == 900)  {
+if (msg == 90)  {
   dap->SetReady();
   this->Hide();
   return;
-}
+  }
+else if (msg >= 30000) {
+  dap->ObjMgr()->UpdateObjMgrWindow(msg-30000);
+  return;
+  }
+else if (msg == 10) {
+  string cdir = dirlist->GetValueStr();
+  dap->ObjMgr()->SetCurrentDir(cdir);
+  return;
+  }
 
 string nom = "";
-if ( (msg == 100) || (msg == 200) || (msg == 300) || (msg == 400) ) {
+if ( (msg == 20) || (msg == 30) || (msg == 40) || (msg == 50) ) {
   string sel = objlist->GetSelectionStr();
   //  size_t p = sel.find_first_not_of(" \t");
@@ -91,29 +109,26 @@
   size_t q = sel.find_first_of(" \t");
   if (q > l)   q = l; 
-  nom = sel.substr(0, q);
-}
+  nom = dirlist->GetValueStr() + '/' + sel.substr(0, q);
+  }
 
 NamedObjMgr* om = dap->ObjMgr();
 if (om == NULL)  return;
-if (nom == "")  return;
+if (nom.length() < 1)  return;
 
 switch (msg)
   {
-  case 100:
+  case 20:
     om->DisplayObj(nom);
     break;
-  case 200:
+  case 30:
     om->PrintObj(nom);
     break;
-  case 300:
-    if (dap->mPpfout)  om->SaveObj(nom, *(dap->mPpfout));
-    break;
-  case 400:
+  case 40:
+    if (dap->mPpfout)  om->SaveObj(nom, *(dap->mPpfout), false);
+    break;
+  case 50:
     om->DelObj(nom);
-    break;
-
-  case 900:
-    dap->SetReady();
-    Hide();
+    objlist->DeleteItemMsg(objlist->GetSelection());
+    //    dap->ObjMgr()->UpdateObjMgrWindow(dirlist->GetValue()-30000);
     break;
 
@@ -218,6 +233,6 @@
   if (ln <= 0)  nom = "?";
   else { strncpy(noms, mPin->TagName(i).c_str(), 31);  noms[31] = '\0'; nom = noms; }
-//  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
-  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, " DataObject ?", key);
+  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
+  //  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, " DataObject ?", key);  Attention SANS_EVOLPLANCK
   objlist->AppendItem(strg, 5000+i);
 }
Index: /trunk/SophyaPI/PIext/pisiadw.h
===================================================================
--- /trunk/SophyaPI/PIext/pisiadw.h	(revision 332)
+++ /trunk/SophyaPI/PIext/pisiadw.h	(revision 333)
@@ -1,2 +1,7 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de fenetre pour gestion d'objet et PPF-In
+// Reza      Aout 97 , Juillet,Aout 98, Ete 99
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
 #ifndef PISIADW_H_SEEN
 #define PISIADW_H_SEEN
@@ -25,12 +30,18 @@
   virtual void  Show();
   virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
-  inline void AddObj(const char * objid, PIMessage msg) 
-    { objlist->AppendItem(objid, msg); }
-  inline void DelObj(PIMessage msg) 
-    { objlist->DeleteItemMsg(msg); }
+  inline  void  AddDirectory(const char * dir, int did)
+                    { dirlist->AppendItem(dir, 30000+did); }
+  inline  void  DelDirectory(int did)
+                    { dirlist->Menu()->DeleteItemMsg(30000+did); }
+  inline  void  ClearHelpList() 
+                    { mNitem=0; objlist->DeleteAllItems(); }
+  inline  void	AddObj(const char * objn) 
+		    { mNitem++;  objlist->AppendItem(objn, 100+mNitem); }
 private:
   PIStdImgApp* dap;
+  PIOptMenu* dirlist;
+  int mNitem;
   PIList* objlist;
-  PIButton * mBut[5];
+  PIButton * mBut[6];
 };
 
Index: /trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 333)
@@ -149,5 +149,4 @@
  
 mObjMgr = new NamedObjMgr;
-mObjMgr->SetImgApp(this);
 mCmd = new PIACmd(mObjMgr, this);
 
@@ -161,4 +160,7 @@
 mObjmgrw = new ObjMgrWind(this);
 mPpinmgrw = new PPInMgrWind(this);
+
+// Attention : A faire apres creation de ObjMgrWind !!! 
+mObjMgr->SetImgApp(this);
 
 // Gestion des feneteres widgets et drawers
Index: /trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- /trunk/SophyaPI/PIext/servnobjm.cc	(revision 332)
+++ /trunk/SophyaPI/PIext/servnobjm.cc	(revision 333)
@@ -21,4 +21,12 @@
 #include "pistdimgapp.h"
 
+#include "fct1dfit.h"
+#include "fct2dfit.h"
+
+#include "matrix.h"
+#include "cvector.h"
+#include "ntuple.h"
+#include "cimage.h"
+
 #include "histos.h"
 #include "histos2.h"
@@ -28,4 +36,8 @@
 #include "piscdrawwdg.h"
 #include "pisurfdr.h"
+
+#include "pintuple.h"
+#include "pintup3d.h"
+
 #include "pipodrw.h"
 
@@ -33,9 +45,10 @@
 
 /* --Methode-- */
-Services2NObjMgr::Services2NObjMgr(PIStdImgApp* app, string& tmpdir)
+Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
 {
 TmpDir = tmpdir;
 PDynLinkMgr::SetTmpDir(tmpdir);
-mImgapp = app;
+mImgapp = NULL;
+mOmg = omg;
 dynlink = NULL;
 InitGrAttNames();
@@ -71,15 +84,1217 @@
 
 /* --Methode-- */
-void Services2NObjMgr::Nobj_ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, string& expz, 
-                          string& expwt, string& expcut, NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
+void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
+{
+FILE *fip;
+string fname = TmpDir + "func1_pia_dl.c";
+string  cmd;
+int rc;
+
+if (!mImgapp)  return; 
+
+cmd = "rm -f " + fname;
+rc = system(cmd.c_str());
+// printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "Services2NObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func1_pia_dl_func(double x) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+string func = "func1_pia_dl_func";
+DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
+if (!f) return; 
+PlotFunc(f, nom, xmin, xmax, np, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax, 
+                                  double ymin, double ymax, int npx, int npy, string dopt)
+{
+FILE *fip;
+string fname = TmpDir + "func2_pia_dl.c";
+string cmd;
+int rc;
+
+if (!mImgapp)  return; 
+
+cmd = "rm " + fname;
+rc = system(cmd.c_str());
+// printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "Services2NObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+string func = "func2_pia_dl_func";
+DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
+if (!f)  return;
+PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom, 
+                                       double xmin, double xmax, int np, string dopt)
+{
+DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
+if (!f) return; 
+PlotFunc(f, nom, xmin, xmax, np, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom, 
+                                         double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
+{
+DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
+if (!f)  return;
+PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
+{
+if (!mImgapp)  return; 
+
+int k;
+if (np < 1) np = 1;
+if (xmax <= xmin) xmax = xmin+1.;
+Vector* vpy = new Vector(np);
+
+double xx;
+double dx = (xmax-xmin)/np;
+TRY {
+  for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::PlotFunc()  Exception :" << merr << es;
+  delete vpy;
+  vpy = NULL;
+  } ENDTRY;
+
+
+if (vpy) {
+  string titre = (nom.length() < 1) ? "Function f(x)" : nom;
+  P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
+  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
+  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
+  bool fgsr = true;
+  dopt = "thinline," + dopt;
+  int opt = DecodeDispOption(dopt, fgsr);
+  int rsid = mImgapp->DispScDrawer(dr, titre, opt);
+  if (fgsr) mImgapp->RestoreGraphicAtt(); 
+  if (nom.length() > 0) { 
+    mOmg->AddObj(vpy, nom);
+    mOmg->AddWRsId(nom, rsid);
+    }
+  }
+
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax, 
+                             int npx, int npy, string dopt)
+{
+if (!mImgapp)  return; 
+
+if (npx < 3) npx = 3;
+if (npy < 3) npy = 3;
+if (npx > 250) npx = 250;
+if (npy > 250) npy = 250;
+if (xmax <= xmin) xmax = xmin+1.;
+if (ymax <= ymin) ymax = ymin+1.;
+
+Matrix* mtx = new Matrix(npy, npx);
+
+int i,j;
+double xx, yy;
+double dx = (xmax-xmin)/npx;
+double dy = (ymax-ymin)/npy;
+// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
+TRY {
+  for(j=0; j<npy; j++) {
+    yy = ymin+dy*j; 
+    for(i=0; i<npx; i++) {
+      xx = xmin+dx*i;
+      (*mtx)(j, i) = f(xx, yy);
+    }
+  }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::PlotFunc2D()  Exception :" << merr << es;
+  delete mtx;  mtx = NULL;
+  } ENDTRY;
+
+if (mtx) {
+  string titre = (nom.length() < 1) ? "Function f(x,y)" : nom;  
+  bool fgsr = true;
+  int opt = DecodeDispOption(dopt, fgsr);
+  P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
+  arr->DefineXYCoordinates(xmin, ymin, dx, dy);
+  PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+  int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
+  if (fgsr) mImgapp->RestoreGraphicAtt();
+  if (nom.length() > 0)  { 
+    mOmg->AddObj(mtx, nom);
+    mOmg->AddWRsId(nom, rsid);
+    }
+  }
+
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::DisplayPoints2D(string& nom,  string& expx, string& expy,
+                                       string& experrx, string& experry,
+                                       string& expcut, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+// Creation NTuple 
+char* ntn[4] = {"expx","expy","expex","expey",};
+NTuple* nt = NULL;
+bool haserr = false;
+
+if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) {  haserr = true;   nt = new NTuple(4, ntn); }
+else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
+
+ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::DisplayPoints2D() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+// nt->Show();
+// nt->Print(0,10);
+PINTuple* pin = new PINTuple(nt, true);
+pin->SelectXY(ntn[0], ntn[1]);
+if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
+
+bool fgsr = true;
+dopt = "defline," + dopt;
+int opt = DecodeDispOption(dopt, fgsr);
+string titre =  nom + ":" + expy + "%" + expx;
+mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
+if (fgsr) mImgapp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::DisplayPoints3D(string& nom,  string& expx, string& expy, 
+                                       string& expz, string& expcut, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+char* ntn[3] = {"expx","expy","expz"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
+
+string expwt = "1.";
+ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::DisplayPoints3D() Warning  Zero points satisfy cut !" << endl;
+  delete nt;
+  return;
+  }
+nt->Show();
+nt->Print(0,10);
+PINTuple3D* pin = new PINTuple3D(nt, true);
+pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
+bool fgsr = true;
+dopt = "defline," + dopt;
+int opt = DecodeDispOption(dopt, fgsr);
+
+// Pour plot a partir de DispScDrawer
+// string nomdisp = "_NT3D_";
+// mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
+// Pour plot a partir de Disp3DDrawer
+string titre =  nom + ":" + expy + "%" + expx;
+mImgapp->Disp3DDrawer(pin, titre, opt);
+
+if (fgsr) mImgapp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy, 
+                                        string& expwt, string& expcut, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::DisplayPoints2DW() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+char* ntn[3] = {"expx","expy","expw"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
+
+string exp = "1.";
+ComputeExpressions(obja, expx, expy, expwt, exp, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::DisplayPoints2DW() Warning  Zero points satisfy cut !" << endl;
+  delete nt;
+  return;
+  }
+
+PINTuple* pin = new PINTuple(nt, true);
+pin->SelectXY(ntn[0], ntn[1]);
+pin->SelectWt(ntn[2]);
+
+bool fgsr = true;
+int opt = DecodeDispOption(dopt, fgsr);
+string titre =  nom + ":" + expwt + "_" + expy + "%" + expx ;
+mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
+if (fgsr) mImgapp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt, 
+                                 string& expcut, string& nomh1, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Histo* h1 = NULL;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL; 
+if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
+else nomh1 = "/tmp/projh1d";
+if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
+else {
+  char* ntn[2]= {"hxval", "hwt"};
+  nt = new NTuple(2,ntn);  // Creation NTuple 
+  }
+string expz = "0.";   
+ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
+
+if ((!h1) && (!nt)) return;
+if (!h1) {
+  if (nt->NEntry() < 1) {
+    cout << "Services2NObjMgr::ProjectH1() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  double xmin, xmax;
+  nt->GetMinMax(0, xmin, xmax);
+  h1 = new Histo(xmin, xmax, 100);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    h1->Add(xn[0], xn[1]);    
+    }
+  delete nt;
+  mOmg->AddObj(h1, nomh1);
+  }
+
+mOmg->DisplayObj(nomh1, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt, 
+                                 string& expcut, string& nomh2, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Histo2D* h2 = NULL;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL;
+if (nomh2.length() > 0)  oh=mOmg->GetObj(nomh2);
+else nomh2 = "/tmp/projh2d";
+if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+  }
+string expz = "0.";   
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
+
+if ((!h2) && (!nt)) return;
+if (!h2) {
+  if (nt->NEntry() < 1) {
+    cout << "Services2NObjMgr::ProjectH2() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  double xmin, xmax, ymin, ymax;
+  nt->GetMinMax(0, xmin, xmax);
+  nt->GetMinMax(0, ymin, ymax);
+  h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    h2->Add(xn[0], xn[1], xn[2]);    
+    }
+  delete nt;
+  mOmg->AddObj(h2, nomh2);
+  }
+
+mOmg->DisplayObj(nomh2, dopt);
+return;  
+
+}
+
+/* --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:
+//| nom = nom de l'objet a projeter dans un HProf.
+//| expx = expression X de definition du bin.
+//| expy = expression Y a additionner dans le bin.
+//| expwt = expression W du poids a additionner.
+//| expcut = expression du test de selection.
+//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
+//|           les limites Xmin,Xmax sont calculees automatiquement.
+//|           sinon ce sont celles de l'objet preexistant.
+//| opt = options generales pour le display.
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+HProf* hprof = NULL;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL;
+if (nomprof.length() > 0)  oh=mOmg->GetObj(nomprof);
+else nomprof = "/tmp/projprof";
+if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) )  hprof = (HProf*)oh;
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+}
+string expz = "0.";
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
+
+if((!hprof) && (!nt)) return;
+if(!hprof) {
+  if (nt->NEntry() < 1) {
+    cout << "Services2NObjMgr::ProjectHProf() Warning  Zero points satisfy cut !" << endl;
+    delete nt;
+    return;
+  }
+  double xmin, xmax;
+  nt->GetMinMax(0, xmin, xmax);
+  hprof = new HProf(xmin, xmax, 100);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    hprof->Add(xn[0], xn[1], xn[2]);
+    }
+  delete nt;
+  mOmg->AddObj(hprof, nomprof);
+  }
+hprof->UpdateHisto();
+
+mOmg->DisplayObj(nomprof, dopt);
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillVect(string& nom, string& expx, string& expcut, 
+                                string& nomvec, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+NTuple* nt = NULL;
+if (nomvec.length() < 1) nomvec = "/tmp/fillvec";
+
+char* ntn[2]= {"vecval", "vecwt"};
+nt = new NTuple(1,ntn);  // Creation NTuple
+ 
+string expwt = "1.";
+string expz = "0.";   
+ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+  
+Vector* vec = new Vector(nt->NEntry());
+int k;
+float* xn;
+for(k=0; k<nt->NEntry(); k++)    {
+  xn = nt->GetVec(k);
+  (*vec)(k) = xn[0];
+  }
+delete nt;
+mOmg->AddObj(vec, nomvec); 
+mOmg->DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz, 
+                              string& expt, string& expcut, string& nomnt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+bool fgnnt = false;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL;
+if (nomnt.length() > 0)  oh=mOmg->GetObj(nomnt);
+else nomnt = "/tmp/fillnt";
+if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) )  { 
+  nt = (NTuple*)oh;
+  if (nt->NVar() > 10) {
+    cout << "Services2NObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
+    nt = NULL;
+    }
+  }  
+if (nt == NULL) {
+  char* ntn[4]= {"x", "y","z","t"};
+  nt = new NTuple(4,ntn);  // Creation NTuple 
+  fgnnt = true;
+  }
+
+ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
+
+if (fgnnt) mOmg->AddObj(nt, nomnt);
+return;  
+
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname, 
+                                     string const & funcname, string & nomnt)
+{
+if (!mImgapp)  return; 
+
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
+  return;
+  }
+NTupleInterface* objnt = obja->GetNTupleInterface();
+if (objnt == NULL)  {
+  cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl;
+  return;
+  }
+
+NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
+if (!f) { 
+  cerr << "Services2NObjMgr::FillNTFrCFile Error Creation  NTLoopExprFunc" <<  endl; 
+  return;
+  }
+
+bool fgnnt = false;
+NTuple* nt = NULL;
+if (nomnt.length() > 0) {
+  AnyDataObj* oh = NULL;
+  oh=mOmg->GetObj(nomnt);
+  if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) )  { 
+    nt = (NTuple*)oh;
+    if (nt->NVar() > 10) {
+      cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
+      nt = NULL;
+      }
+    }  
+  if (nt == NULL) {
+    char* ntn[4]= {"x", "y","z","t"};
+    nt = new NTuple(4,ntn);  // Creation NTuple 
+    fgnnt = true;
+    }
+  }
+
+double xnt[10];
+float  fxnt[10];
+
+int i,k;
+for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
+
+
+// $CHECK$ A virer des que possible  - Pb blocage application quand trop d'impression
+// redirige -    On redirige la sortie sur le terminal 
+bool red = mImgapp->HasRedirectedStdOutErr();
+mImgapp->RedirectStdOutErr(false);
+
+TRY  {
+  double* xn;
+  int kmax = objnt->NbLines();
+  for(k=0; k<kmax; k++)    {
+    xn = objnt->GetLineD(k);
+    if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
+      if (nt) { 
+         for(i=0; i<4; i++) fxnt[i] = xnt[i]; 
+         nt->Fill(fxnt);
+         }
+      }
+    }
+ }
+CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::FillNTFrCFile()  Exception :" << merr << es;
+  } ENDTRY;
+ 
+CloseDLL();
+
+// $CHECK$ A virer des que possible  On redirige la sortie sur la fenetre PIConsole 
+mImgapp->RedirectStdOutErr(red);
+
+if (fgnnt) mOmg->AddObj(nt, nomnt);
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname, 
+                                                string const & funcname)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
+  return;
+  }
+NTupleInterface* objnt = obja->GetNTupleInterface();
+if (objnt == NULL)  {
+  cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom 
+       << "...) No NTupleInterface !" <<endl;
+  return;
+  }
+string  vardec = objnt->VarList_C("_xnti_");
+
+FILE *fip;
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl; 
+  return; 
+  }
+// constitution du fichier des decalarations des variables de l'interface NTuple
+fputs("#include <stdlib.h> \n", fip);
+fputs("#include <stdio.h> \n", fip);
+fputs("#include <math.h> \n\n", fip);
+fputs("/* NTupleInterface Variable declaration - Generated by piapp  \n", fip);
+fputs("      -- Services2NObjMgr::PrepareNTExpressionCFile()  --     */ \n\n", fip);
+fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n", 
+        funcname.c_str());
+fprintf(fip,"       double* _rt_, int _n_, int _nmax_) \n");
+fprintf(fip, "{ \n %s \n", vardec.c_str());
+fputs("  if (!1) { /* Cut Expression failed */ \n", fip);
+fputs("    *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.;  return(0);", fip);
+fputs("  } \n  /* Cut expression satisfied */ \n", fip);
+fputs("  *_rx_ = 1.; \n  *_ry_ = 1.; \n  *_rz_ = 1.; \n  *_rt_ = 1.; \n", fip);
+fputs("  return(1); \n} \n", fip);
+
+fclose(fip);
+return;
+}
+
+
+/* --Methode-- cmv 13/10/98 */
+void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
+                               string& experr, string& expcut, string& nomgfd)
+//	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) .
+//|       Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
+//| expx = expression X du GeneralFitData (1er abscisse)
+//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
+//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
+//| experr = expression de l'erreur sur l'ordonnee Z
+//| expcut = expression du test de selection
+//| nomgfd = nom du GeneralFitData engendre (optionnel)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
+  return;
+  }
+if(!mImgapp)  return;
+
+// 2D ou 3D?
+int nvar = 2;
+if(expy.length()<=0) {nvar = 1; expy = "0.";}
+
+// $CHECK$ - cmv calculait le nombre d'entree ndata
+// en fonction de chaque objet - Je l'ai vire Reza 11/05/99
+
+// Creation NTuple Buffer
+char* ntn[4]= {"x","y","f","e"};
+NTuple*nt = new NTuple(4,ntn);
+
+// Remplissage NTuple buffer
+ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
+if(nt->NEntry() < 1)
+  {cout<<"Services2NObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
+   delete nt; return;}
+
+//Remplissage de la structure GeneraFitData
+if (nt->NEntry() <= 0) {
+  cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
+  delete nt;
+  return;
+  }
+
+GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
+int k;
+float* xn;
+for(k=0; k<nt->NEntry(); k++) {
+  xn = nt->GetVec(k);
+  gfd->AddData(xn,xn[2],xn[3]);
+}
+
+// Menage et table d'objets
+delete nt;
+mOmg->AddObj(gfd, nomgfd);
+return;
+}
+
+
+///////////////////// Fit 1D et 2D //////////////////////////
+/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
+struct DFOptions {
+  int okres, okfun;
+  int polcx,polcy; double xc,yc;
+  double err_e, err_E;
+  double stc2;
+  int lp,lpg;
+  int i1,i2,j1,j2;
+};
+typedef struct DFOptions DFOPTIONS;
+static void DecodeFitsOptions(string par,string step,string min,string max,string opt
+                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
+void DecodeFitsOptions(string par,string step,string min,string max,string opt
+                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
+//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
+{
+// set des vecteurs et decodage des string correspondantes
+int NParMax = 100;
+Par.Realloc(NParMax); Step.Realloc(NParMax);
+Min.Realloc(NParMax); Max.Realloc(NParMax);
+{
+  Vector* v=NULL; string* s=NULL;
+  {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
+  for(int j=0;j<4;j++) {
+    if(j==0)      {v=&Par; s=&par;}
+    else if(j==1) {v=&Step; s=&step;}
+    else if(j==2) {v=&Min; s=&min;}
+    else if(j==3) {v=&Max; s=&max;}
+    if(s->length()>0) *s += ",";
+    for(int i=0;i<NParMax;i++) {
+      if(s->length()<=0) break;
+      sscanf(s->c_str(),"%lf",&(*v)(i));
+      size_t p = s->find_first_of(',') + 1;
+      if(p>=s->length()) *s = ""; else *s = s->substr(p);
+    }
+  }
+}
+
+// Decodage de options de opt
+O.okres = O.okfun = 0;
+O.polcx = O.polcy = 0;
+O.xc = O.yc = 0.;
+O.stc2 = 1.e-3;
+O.err_e = O.err_E = -1.;
+O.lp = 1; O.lpg = 0;
+O.i1 = O.j1 = O.i2 = O.j2 = -1;
+
+if(opt.length()<=0) return;
+opt = "," + opt + ",";
+
+if(strstr(opt.c_str(),",r,")) O.okres = 1;  // residus
+if(strstr(opt.c_str(),",f,")) O.okfun = 1;  // fonction fittee
+if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
+  O.polcx = 2; // Le centrage est calcule automatiquement
+  size_t p = opt.find(",x");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",x%lf",&O.xc);
+    O.polcx = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
+  O.polcy = 2; // Le centrage est calcule automatiquement
+  size_t p = opt.find(",y");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",y%lf",&O.yc);
+    O.polcy = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
+  size_t p = opt.find(",E");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
+  if(O.err_E<=0.) O.err_E = 1.;
+  O.err_e=-1.;
+}
+if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
+  size_t p = opt.find(",e");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
+  if(O.err_e<=0.) O.err_e = 1.;
+  O.err_E=-1.;
+}
+if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
+  size_t p = opt.find(",X");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
+  if(O.stc2<=0.) O.stc2 = 1.e-3;
+}
+if(strstr(opt.c_str(),",l")) { // niveau de print
+  size_t p = opt.find(",l");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  float ab;
+  if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
+  if(ab<0) ab = 0.;
+  O.lp = (int) ab; O.lpg = (int) 10.*(ab-O.lp);
+}
+if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
+  size_t p = opt.find(",I");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
+}
+if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
+  size_t p = opt.find(",J");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
+}
+return;
+}
+
+/* --Methode-- cmv 13/10/98 */
+void  Services2NObjMgr::Fit12D(string& nom, string& func,
+                               string par,string step,string min,string max,
+                               string opt)
+//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
+//| nom  : nom de l'objet qui peut etre:
+//|        fit-1D:  Vector,Histo1D,HProf ou GeneraFitData(1D)
+//|        fit-2D:  Matrix,Histo2D,Imagexx ou GeneraFitData(2D)
+//| func : pnn = fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
+//|      : Pnn = fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
+//|      : gnn = fit gaussienne (hauteur) + polynome de degre nn 1D
+//|      : g   = fit gaussienne (hauteur) 1D
+//|      : enn = fit exponentielle + polynome de degre nn 1D
+//|      : e   = fit exponentielle 1D
+//|      : Gnn = fit gaussienne (volume) + polynome de degre nn 1D
+//|      : G   = fit gaussienne (volume) 1D
+//|      :     = fit gaussienne+fond (volume) 2D
+//|      : Gi  = fit gaussienne+fond integree (volume) 2D
+//|      : d   = fit DL de gaussienne+fond (volume) 2D
+//|      : di  = fit DL de gaussienne+fond integree (volume) 2D
+//|      : D   = fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
+//|      : Di  = fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
+//|      : M   = fit Moffat+fond (expos=p6) (volume) 2D
+//|      : Mi  = fit Moffat+fond integree (expos=p6) (volume) 2D
+//| par  : p1,...,pn valeur d'initialisation des parametres (def=0)
+//| step : s1,...,sn valeur des steps de depart (def=1)
+//| min  : m1,...,mn valeur des minima (def=1)
+//| max  : M1,...,Mn valeur des maxima (def=-1) (max<=min : pas de limite)
+//| opt  : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
+//|       f = generation d'un Objet identique contenant la fonction fittee
+//|       r = generation d'un Objet identique contenant les residus
+//|       Xaa.b = aa.b valeur du DXi2 d'arret (def=1.e-3)
+//|       la.b = niveau "a.b" de print: a=niveau de print Fit1/2D
+//|                                     b=niveau de debug GeneralFit
+//|       Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
+//|2D     Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
+//|       - L'erreur est celle associee a l'objet si existe, 1 sinon sauf si
+//|       E = erreur prise comme la racine de la valeur a fitter
+//|       Eaa.b = erreur prise aa.b*sqrt(val)
+//|       e = erreur prise egale a 1 pour toutes les valeurs
+//|       eaa.b = erreur prise egale a aa.b
+//|       xaa.b = demande de centrage: on fit x-aa.b au lieu de x)
+//|       x = demande de centrage: on fit x-xc au lieu de x
+//|           avec xc=abscisse du milieu de l'histogramme
+//|           Actif pour: exp+poly 1D, poly 1D
+//|                       gauss+poly 1D (mais xc est le centre de la gaussienne)
+//|2D     yaa.b et y = idem "xaa.b et x" mais pour y
+{
+AnyDataObj* obj=mOmg->GetObj(nom);
+if (obj == NULL) {
+  cout<<"Services2NObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
+  return;
+}
+if (!mImgapp)  return;
+if(func.length()<=0)
+  {cout<<"Services2NObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
+   return;}
+string ctyp = typeid(*obj).name();
+
+int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
+Vector* v = NULL; Histo* h = NULL;
+Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
+GeneralFitData* g = NULL;
+
+  // 1D
+if (typeid(*obj) == typeid(Vector)) {
+  ndim = 1;
+  v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
+  }
+else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
+  ndim = 1;
+  h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
+  }
+else if (typeid(*obj) == typeid(Matrix)) {
+  ndim = 2;
+  m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
+  }
+else if (typeid(*obj) == typeid(Histo2D)) {
+  ndim = 2;
+  h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
+  }
+else if (typeid(*obj) == typeid(GeneralFitData)) {
+  g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
+  if(     g->NVar()==1) ndim = 1;
+  else if(g->NVar()==2) ndim = 2;
+  else {
+     cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
+         <<((GeneralFitData*) obj)->NVar()<<endl; return; }
+  }
+else if (dynamic_cast<RzImage*>(obj)) {
+  ndim = 2;
+  im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
+  }
+else  {
+  cout<<"Services2NObjMgr::Fit12D() Error , Objet n'est pas un "
+      <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
+  return; 
+  }
+
+ndata = nbinx*nbiny;
+if(ndata<=0)
+  {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
+
+// Decodage des options et des parametres, mise en forme
+Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
+DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
+O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
+O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
+if(ndim>=2) {
+  O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
+  O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
+} else O.j2 = O.j1 = 0;
+if(O.polcx==2) {
+  if(v||m)    O.xc = (O.i2-O.i1+1)/2.;
+  else if(h)  O.xc = (h->XMin()+h->XMax())/2.;
+  else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
+  else if(g)  {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
+  else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
+}
+if(O.polcy==2 && ndim>=2) {
+  if(m)  O.yc = (O.j2-O.j1+1)/2.;
+  if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
+  if(g)  {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
+  if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
+}
+if(O.lp>0)
+  cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
+      <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
+      <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
+      <<" TypE="<<O.err_e<<","<<O.err_E
+      <<" StpX2="<<O.stc2
+      <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
+
+///////////////////////////////////
+// Remplissage de GeneralFitData //
+///////////////////////////////////
+GeneralFitData mydata(ndim,ndata,0);
+{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
+  double x,y,f,e;
+
+  if(v)
+    {x= (double) i; f=(*v)(i); e=1.;}
+  else if(h)
+    {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
+  else if(m)
+    {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
+  else if(h2)
+    {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
+     f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
+  else if(im)
+    {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
+     f=im->DValue(i,j); e=1.;}
+  else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
+  else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
+  else x=y=f=e=0.;
+
+  // Gestion des erreurs a utiliser
+  if(O.err_e>0.) e=O.err_e;
+  else if(O.err_E>0.) {e=(y<-1.||y>1.)?O.err_E*sqrt(fabs(y)):O.err_E;}
+
+  // Remplissage de generalfit
+  if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
+  if(ndim==1)      mydata.AddData1(x,f,e);
+  else if(ndim==2) mydata.AddData2(x,y,f,e);
+}}
+if(mydata.NData()<=0)
+  {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
+   return;}
+if(O.lpg>1) {
+  mydata.PrintStatus();
+  mydata.PrintData(0);
+  mydata.PrintData(mydata.NData()-1);
+}
+
+////////////////////////////////////////////
+// Identification de la fonction a fitter //
+////////////////////////////////////////////
+GeneralFunction* myfunc = NULL;
+if(func[0]=='p' && ndim==1) {
+  // Fit de polynome sans passer par les GeneralFit
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
+  Poly p1(0);
+  double c2rl = mydata.PolFit(0,p1,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(O.lp>0) cout<<p1<<endl;
+  return;
+
+} else if(func[0]=='P' && ndim==1) {
+  // Fit de polynome
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit polynome 1D de degre "<<degre<<endl;
+  Polyn1D* myf = new Polyn1D(degre,O.xc);
+  myfunc = myf;
+
+} else if(func[0]=='e' && ndim==1) {
+  // Fit d'exponentielle
+  int degre =-1;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
+  Exp1DPol* myf;
+  if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
+       else    myf = new Exp1DPol(O.xc);
+  myfunc = myf;
+
+} else if(func[0]=='g' && ndim==1) {
+  // Fit de gaussienne en hauteur
+  int degre =-1;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
+  Gauss1DPol* myf;
+  if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
+  else { bool bfg = (O.polcx)?true:false;   myf = new Gauss1DPol(bfg); }
+  myfunc = myf;
+
+} else if(func[0]=='G' && ndim==1) {
+  // Fit de gaussienne en volume
+  int degre =-1;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
+  GaussN1DPol* myf;
+  if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
+  else  { bool bfg = (O.polcx)?true:false;   myf = new GaussN1DPol(bfg); }
+  myfunc = myf;
+
+} else if(func[0]=='p' && ndim==2) {
+  // Fit de polynome 2D sans passer par les GeneralFit
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
+  Poly2 p2(0);
+  double c2rl = mydata.PolFit(0,1,p2,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(O.lp>0) cout<<p2<<endl;
+  return;
+
+} else if(func[0]=='P' && ndim==2) {
+  // Fit de polynome 2D
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit polynome 2D de degre "<<degre<<endl;
+  Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
+  myfunc = myf;
+
+} else if(func[0]=='G' && ndim==2) {
+  // Fit de gaussienne+fond en volume
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
+  if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
+    else    {GauRho2D* myf = new GauRho2D; myfunc = myf;}
+
+} else if(func[0]=='d' && ndim==2) {
+  // Fit de DL gaussienne+fond en volume
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
+  if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
+    else    {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
+
+} else if(func[0]=='D' && ndim==2) {
+  // Fit de DL gaussienne+fond avec coeff variable p6 en volume
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
+  if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
+    else    {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
+
+} else if(func[0]=='M' && ndim==2) {
+  // Fit de Moffat+fond (volume)
+  int integ = 0;
+  if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
+  if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
+    else    {MofRho2D* myf = new MofRho2D; myfunc = myf;}
+
+} else {
+  cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
+  return;
+}
+
+/////////////////////////
+// Fit avec generalfit //
+/////////////////////////
+if(myfunc->NPar()>Par.NElts())
+  {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
+  if(myfunc) delete myfunc; return;}
+GeneralFit myfit(myfunc);
+myfit.SetDebug(O.lpg);
+myfit.SetData(&mydata);
+myfit.SetStopChi2(O.stc2);
+{for(int i=0;i<myfunc->NPar();i++) {
+  char str[10];
+  sprintf(str,"P%d",i);
+  myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
+}}
+if(O.lp>1) myfit.PrintFit();
+double c2r = (double) myfit.Fit();
+if(O.lp>0) myfit.PrintFit();
+if(c2r>0.) {
+  c2r = myfit.GetChi2Red();
+  cout<<"C2r_Reduit = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
+  Vector ParFit(myfunc->NPar());
+  for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
+} else {
+  cout<<"echec Fit, rc = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
+}
+
+// Mise a disposition des resultats
+if(c2r>=0. && myfunc && (O.okres>0||O.okfun>0)) {
+  string nomres = nom + "res";
+  string nomfun = nom + "fun";
+  if(v) {
+    if(O.okres) {Vector* ob = v->FitResidus(myfit);  if(ob) mOmg->AddObj(ob,nomres);}
+    if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
+  } else if(h) {
+    if(O.okres) {Histo* ob = h->FitResidus(myfit);  if(ob) mOmg->AddObj(ob,nomres);}
+    if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
+  } else if(m) {
+    if(O.okres) {Matrix* ob = m->FitResidus(myfit);  if(ob) mOmg->AddObj(ob,nomres);}
+    if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
+  } else if(h2) {
+    if(O.okres) {Histo2D* ob = h2->FitResidus(myfit);  if(ob) mOmg->AddObj(ob,nomres);}
+    if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
+  } else if(im) {
+    if(O.okres) {RzImage* ob = im->FitResidus(myfit);  if(ob) mOmg->AddObj(ob,nomres);}
+    if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
+  } else if(g) {
+    if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit);  if(ob) mOmg->AddObj(ob,nomres);}
+    if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
+  }
+}
+
+// Nettoyage
+if(myfunc) delete myfunc;
+return;
+}
+
+
+/* --Methode-- */
+void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx, 
+                          string& expy, string& expz, string& expt, string& expcut, 
+                          NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
 {
 if (obja == NULL) return;
 NTupleInterface* objnt = obja->GetNTupleInterface();
 if (objnt == NULL)  return;
-string  vardec = objnt->VarList_C("_zz61qq_");
-
-PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expwt, expcut);
+string  vardec = objnt->VarList_C("_zz6qi_");
+
+PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
 if (!f) { 
-  cerr << "NamedObjMgr_ComputeExpressions() Error Creation PlotExprFunc " <<  endl; 
+  cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " <<  endl; 
   return;
   }
@@ -88,5 +1303,5 @@
 float  fxnt[10];
 
-int i,j,k;
+int i,k;
 for(i=0; i<10; i++) xnt[i] = 0.;
 
@@ -111,5 +1326,5 @@
   cerr << endl;
   string es = PeidaExc(merr);
-  cerr << "NamedObjMgr_ComputeExpressions()  Exception :" << merr << es;
+  cerr << "Services2NObjMgr::ComputeExpressions()  Exception :" << merr << es;
   } ENDTRY;
  
@@ -122,6 +1337,6 @@
 
 /* --Methode-- */
-PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
-                                            string& expwt, string& cut)
+PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, 
+                                            string& expz, string& expt, string& cut)
 {
 FILE *fip;
@@ -136,17 +1351,18 @@
 if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
   string sn = fname; 
-  cout << "NamedObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl; 
+  cout << "Services2NObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl; 
   return(NULL); 
   }
 
 // constitution du fichier a compiler
+fputs("#include <stdlib.h> \n", fip);
 fputs("#include <math.h> \n", fip);
-fputs("int expf_pia_dl_func(double* _zz61qq_, double* _rx_61qq_, double* _ry_61qq_, double* _rz_61qq_, double* _wt_61qq_) \n{\n", fip);
+fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
 fprintf(fip,"%s \n", vardec.c_str());
-fprintf(fip, "if (!(%s)) { *_rx_61qq_ = *_ry_61qq_ = *_rz_61qq_ = *_wt_61qq_ = 0.;  return(0); } \n", cut.c_str());
-fprintf(fip, "*_rx_61qq_ = %s ; \n", expx.c_str());
-fprintf(fip, "*_ry_61qq_ = %s ; \n", expy.c_str());
-fprintf(fip, "*_rz_61qq_ = %s ; \n", expz.c_str());
-fprintf(fip, "*_wt_61qq_ = %s ; \n", expwt.c_str());
+fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.;  return(0); } \n", cut.c_str());
+fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
+fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
+fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
+fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
 fputs("return(1); \n} \n", fip);
 fclose(fip);
@@ -163,5 +1379,5 @@
 dynlink = PDynLinkMgr::BuildFromCFile(fname);
 if (dynlink == NULL) { 
-  cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl; 
+  cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl; 
   return(NULL); 
   }
@@ -170,5 +1386,5 @@
 if (retfunc == NULL) { 
   string sn = funcname; 
-  cerr << "NamedObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl; 
+  cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl; 
   CloseDLL();
   return(NULL); 
@@ -183,186 +1399,4 @@
 }
 
-/* --Methode-- */
-void Services2NObjMgr::PlotFunc(string const & expfunc, float xmin, float xmax, int np, string dopt)
-{
-FILE *fip;
-string fname = TmpDir + "func1_pia_dl.c";
-string  cmd;
-int rc;
-
-if (!mImgapp)  return; 
-
-cmd = "rm -f " + fname;
-rc = system(cmd.c_str());
-// printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
-
-if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
-  string sn = fname; 
-  cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl; 
-  return; 
-  }
-
-// constitution du fichier a compiler
-fputs("#include <math.h> \n", fip);
-fputs("double func1_pia_dl_func(double x) \n{\n", fip);
-fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
-fclose(fip);
-
-string func = "func1_pia_dl_func";
-DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
-if (!f) return; 
-PlotFunc(f, xmin, xmax, np, dopt);
-CloseDLL();
-return;
-}
-
-/* --Methode-- */
-void Services2NObjMgr::PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax, 
-                             int npx, int npy, string dopt)
-{
-FILE *fip;
-string fname = TmpDir + "func2_pia_dl.c";
-string cmd;
-int rc;
-
-if (!mImgapp)  return; 
-
-cmd = "rm " + fname;
-rc = system(cmd.c_str());
-// printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
-
-if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
-  string sn = fname; 
-  cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl; 
-  return; 
-  }
-
-// constitution du fichier a compiler
-fputs("#include <math.h> \n", fip);
-fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
-fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
-fclose(fip);
-
-string func = "func2_pia_dl_func";
-DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
-if (!f)  return;
-PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
-CloseDLL();
-return;
-}
-
-/* --Methode-- */
-void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax, 
-                                       int np, string dopt)
-{
-DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
-if (!f) return; 
-PlotFunc(f, xmin, xmax, np, dopt);
-CloseDLL();
-return;
-}
-
-/* --Methode-- */
-void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax, 
-                                         float ymin, float ymax, int npx, int npy, string dopt)
-{
-DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
-if (!f)  return;
-PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
-CloseDLL();
-return;
-}
-
-/* --Methode-- */
-void Services2NObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
-{
-if (!mImgapp)  return; 
-
-int k;
-if (np < 1) np = 1;
-if (xmax <= xmin) xmax = xmin+1.;
-Vector* vpy = new Vector(np);
-
-double xx;
-double dx = (xmax-xmin)/np;
-TRY {
-  for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
-} CATCH(merr) {
-  fflush(stdout); 
-  cout << endl; 
-  cerr << endl;
-  string es = PeidaExc(merr);
-  cerr << "Services2NObjMgr::PlotFunc()  Exception :" << merr << es;
-  delete vpy;
-  vpy = NULL;
-  } ENDTRY;
-
-
-if (vpy) {
-  string nom = "Func";
-  P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
-  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
-  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
-  bool fgsr = true;
-  dopt = "thinline," + dopt;
-  int opt = DecodeDispOption(dopt, fgsr);
-  int wrsid = mImgapp->DispScDrawer(dr, nom, opt);
-  if (fgsr) mImgapp->RestoreGraphicAtt(); 
-  }
-
-return;
-}
-
-/* --Methode-- */
-void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
-                             int npx, int npy, string dopt)
-{
-if (!mImgapp)  return; 
-
-if (npx < 3) npx = 3;
-if (npy < 3) npy = 3;
-if (npx > 250) npx = 250;
-if (npy > 250) npy = 250;
-if (xmax <= xmin) xmax = xmin+1.;
-if (ymax <= ymin) ymax = ymin+1.;
-
-Matrix* mtx = new Matrix(npy, npx);
-
-int i,j;
-double xx, yy;
-double dx = (xmax-xmin)/npx;
-double dy = (ymax-ymin)/npy;
-// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
-TRY {
-  for(j=0; j<npy; j++) {
-    yy = ymin+dy*j; 
-    for(i=0; i<npx; i++) {
-      xx = xmin+dx*i;
-      (*mtx)(j, i) = f(xx, yy);
-    }
-  }
-} CATCH(merr) {
-  fflush(stdout); 
-  cout << endl; 
-  cerr << endl;
-  string es = PeidaExc(merr);
-  cerr << "Services2NObjMgr::PlotFunc2D()  Exception :" << merr << es;
-  delete mtx;  mtx = NULL;
-  } ENDTRY;
-
-if (mtx) {
-  string nom = "Func2";
-  int wrsid = 0;
-  bool fgsr = true;
-  int opt = DecodeDispOption(dopt, fgsr);
-  P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
-  arr->DefineXYCoordinates(xmin, ymin, dx, dy);
-  PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
-  wrsid = mImgapp->Disp3DDrawer(sdr, nom, opt);
-  if (fgsr) mImgapp->RestoreGraphicAtt();
-  }
-
-return;
-}
 
 /* --Methode-- */
@@ -663,2 +1697,70 @@
                 
 }
+
+
+// SANS_EVOLPLANCK     Attention !
+#include "pclassids.h"
+
+/* --Methode-- */
+char* Services2NObjMgr::PClassIdToClassName(int cid)
+{
+switch (cid) {
+  case ClassId_Poly1 : 
+    return("Poly1");
+  case ClassId_Poly2 : 
+    return("Poly2");
+  case ClassId_Matrix : 
+    return("Matrix");
+  case ClassId_Vector : 
+    return("Vector");
+
+  case ClassId_DVList : 
+    return("DVList");
+
+  case ClassId_Histo1D : 
+    return("Histo1D");
+  case ClassId_Histo2D : 
+    return("Histo2D");
+  case ClassId_HProf : 
+    return("HProf");
+  case ClassId_NTuple : 
+    return("NTuple");
+  case ClassId_GeneralFitData : 
+    return("GeneralFitData");
+
+  case ClassId_Image : 
+    return("RzImage");
+  case ClassId_Image + kuint_1 : 
+    return("ImageU1");
+  case ClassId_Image + kint_1 : 
+    return("ImageI1");
+  case ClassId_Image + kuint_2 : 
+    return("ImageU2");
+  case ClassId_Image + kint_2 : 
+    return("ImageI2");
+  case ClassId_Image + kuint_4 : 
+    return("ImageU4");
+  case ClassId_Image + kint_4 : 
+    return("ImageI4");
+  case ClassId_Image + kr_4 : 
+    return("ImageR4");
+  case ClassId_Image + kr_8 : 
+    return("ImageR8");
+
+  case ClassId_ZFidu : 
+    return("ZFidu");
+
+  case ClassId_StarList : 
+    return("StarList");
+  case ClassId_Transfo : 
+    return("Transfo");
+  case ClassId_PSF : 
+    return("PSF");
+
+
+// - Ajout objet PPF
+  default:
+    return("AnyDataObj");
+  }
+}  
+
Index: /trunk/SophyaPI/PIext/servnobjm.h
===================================================================
--- /trunk/SophyaPI/PIext/servnobjm.h	(revision 332)
+++ /trunk/SophyaPI/PIext/servnobjm.h	(revision 333)
@@ -25,4 +25,5 @@
 class Histo2D;
 class HProf;
+class NamedObjMgr;
 class PIStdImgApp;
 class NObjMgrAdapter;
@@ -30,5 +31,5 @@
 class Services2NObjMgr {
 public:
-         	Services2NObjMgr(PIStdImgApp* app, string& tmpdir);
+         	Services2NObjMgr(NamedObjMgr* omg, string& tmpdir);
   virtual	~Services2NObjMgr();
 
@@ -40,28 +41,64 @@
   inline void   SetImgApp(PIStdImgApp* app) {mImgapp = app; }
 
-  void 		Nobj_ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, string& expz, 
-                                        string& expwt, string& expcut,
-                                        NTuple* nt=NULL, Histo* h1=NULL,
-                                        Histo2D* h2=NULL, HProf* hp=NULL);
-  PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
-                             string& wt, string& cut);
+// Trace de fonctions 1-D , 2-D
+  virtual void  PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, 
+                         int np=100, string dopt="");
+  virtual void  PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax, 
+                           double ymin, double ymax, int npx=50, int npy=50, string dopt="");
+  virtual void  PlotFuncFrCFile(string const & fname, string const & func, string & nom, 
+                                double xmin, double xmax, int np=100, string dopt="");
+  virtual void  PlotFunc2DFrCFile(string const & fname, string const & func, string & nom, 
+                                  double xmin, double xmax, double ymin, double ymax, 
+                                  int npx=50, int npy=50, string dopt="");
+  virtual void  PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, 
+                         int np=100, string dopt="");
+  virtual void  PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, 
+                           double ymin, double ymax, int npx=50, int npy=50, string dopt="");
+
+//  Trace d'expression de NTuple, et d'autres objets
+  virtual void          DisplayPoints2D(string & nom, string& expx, string& expy,
+                                        string& experrx, string& experry, 
+                                        string& expcut, string dopt="");
+  virtual void          DisplayPoints3D(string & nom, string& expx, string& expy, string& expz, 
+                                        string& expcut, string dopt="");
+  virtual void          DisplayPoints2DW(string & nom, string& expx, string& expy, 
+                                         string& expwt, string& expcut, string dopt="");
+//  Projection d'expressions dans histogramme (et trace) 
+  virtual void          ProjectH1(string & nom, string& expx, string& expwt, string& expcut, 
+                                  string& nomh1, string dopt="");
+  virtual void          ProjectH2(string & nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomh2, string dopt="");
+  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="");
+  virtual void          FillNT(string & nom, string& expx, string& expy, string& expz,
+                               string& expt, string& expcut, string& nomnt); 
+  virtual void          FillGFD(string & nom, string& expx, string& expy, string& expz,
+                               string& experr, string& expcut, string& nomgfd);
+  virtual void          FillNTFrCFile(string & nom, string const & fname, 
+                                      string const & funcname, string & nomnt);
+  virtual void		PrepareNTExpressionCFile(string & nomobj, string const & fname, 
+                                                 string const & funcname);
+
+//   Methodes de fit -  CMV , deux methodes H1 H2 ou 1 seule ??) ...
+  virtual void          Fit12D(string & nom, string& func,
+                              string par,string step,string min,string max,string opt);
+
+// Calcul d'expressions d'interface NTuple pour les objets
+  void 		ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, 
+                                   string& expz, string& expt, string& expcut,
+                                   NTuple* nt=NULL, Histo* h1=NULL,
+                                   Histo2D* h2=NULL, HProf* hp=NULL);
+  PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, 
+                             string& expz, string& expt, string& cut);
   DlFunction    LinkFunctionFromFile(string const & fname, string const & funcname);
   void 		CloseDLL();  
-
-// Trace de fonctions 1-D , 2-D
-  virtual void  PlotFunc(string const & expfunc, float xmin, float xmax, int np=100, string dopt="");
-  virtual void  PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax, 
-                           int npx=50, int npy=50, string dopt="");
-  virtual void  PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax, 
-                                int np=100, string dopt="");
-  virtual void  PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax, 
-                                  float ymin, float ymax, int npx=50, int npy=50, string dopt="");
-  virtual void  PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt="");
-  virtual void  PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
-                           int npx=50, int npy=50, string dopt="");
 
 // Utilitaires divers 
   string 	FileName2Name(string const & fn);
   int 		DecodeDispOption(string& dopt, bool& fgsrgr);
+  char* 	PClassIdToClassName(int cid);
 
 protected:
@@ -94,4 +131,5 @@
 
   PIStdImgApp* mImgapp;
+  NamedObjMgr* mOmg;
   
 };
