Index: trunk/SophyaPI/PIext/cxxexecutor.cc
===================================================================
--- trunk/SophyaPI/PIext/cxxexecutor.cc	(revision 1243)
+++ trunk/SophyaPI/PIext/cxxexecutor.cc	(revision 1247)
@@ -101,15 +101,15 @@
 kw = "c++setvar";
 usage = "c++setvar: Setting test variable \n";
-usage+= "c++setvar varname varcontent ";
+usage+= "Usage: c++setvar varname varcontent ";
 mpiac->RegisterCommand(kw, usage, this, hgrp);
 
 kw = "c++getvar";
 usage = "c++getvar: Getting test variable content\n";
-usage+= "c++getvar varname ";
+usage+= "Usage: c++getvar varname ";
 mpiac->RegisterCommand(kw, usage, this, hgrp);
 
 kw = "c++varlist";
 usage = "c++getvar: Printing test variable list\n";
-usage+= "c++varlist  ";
+usage+= "Usage: c++varlist  ";
 mpiac->RegisterCommand(kw, usage, this, hgrp);
 //// A VIRER quand variable de objmanager OK  --> Pour Reza
Index: trunk/SophyaPI/PIext/pawexecut.cc
===================================================================
--- trunk/SophyaPI/PIext/pawexecut.cc	(revision 1243)
+++ trunk/SophyaPI/PIext/pawexecut.cc	(revision 1247)
@@ -14,4 +14,5 @@
 #include "nobjmgr.h"
 #include "servnobjm.h"
+#include "nomgadapter.h"
 #include "pistdimgapp.h"
 
@@ -55,4 +56,21 @@
 usage += "\n        for default use ! , loop=i1[:i2[:di]]";
 usage += "\n  Related commands: projh1d projh2d projprof";  
+piac->RegisterCommand(kw,usage,this,hgrp);
+
+kw = "n/scan";
+usage = "Scan NTuple a la paw";
+usage += "\n n/scan nameobj[.exp1%exp2%exp3] cut loop";
+usage += "\n               [-f:filename] [list_of_variables]";
+usage += "\n  loop : iev1[:iev2[:diev]] or !";
+usage += "\n  cut  : cut expression or 1. or !";
+usage += "\n  list_of_variables : default is all variables";
+usage += "\n                    : var1 var2 var3 ... varn";
+usage += "\n                    : var1 : var2   (from var1 to var2)";
+usage += "\n                    :  : var2   (from first variable to var2)";
+usage += "\n                    : var1 :    (from var1 to last variable)";
+usage += "\n                  ex: \"v1 : v3 v7 v4 : v6 v2 v9 :\"";
+usage += "\n exp1%exp2%exp3 :";
+usage += "\n           if given add exp1,exp2,exp3 to the variable list";
+usage += "\n -f:filename : write into \"filename\", Default is to stdout";
 piac->RegisterCommand(kw,usage,this,hgrp);
 
@@ -192,4 +210,6 @@
 } else if(kw == "n/proj") {
   n_proj(tokens); return(0);
+} else if(kw == "n/scan") {
+  n_scan(tokens); return(0);
 } else if(kw == "h/integ") {
   h_integ(tokens); return(0);
@@ -275,5 +295,5 @@
 }
 string nameobj,expx,expy,expz;
-int nvar = decodepawstring(tokens[0],nameobj,expx,expy,expz);
+int_4 nvar = decodepawstring(tokens[0],nameobj,expx,expy,expz);
 string expcut = "1"; string expwt = "1."; string loop = "";
 string dopt = ""; string nameproj="";
@@ -327,5 +347,5 @@
 string nameproj = tokens[0];
 string nameobj,expx,expy,expz;
-int nvar = decodepawstring(tokens[1],nameobj,expx,expy,expz);
+int_4 nvar = decodepawstring(tokens[1],nameobj,expx,expy,expz);
 string expcut = "1"; string expwt = "1."; string loop = ""; string dopt = "";
 if(tokens.size()>=3) expcut = tokens[2]; if(expcut=="!") expcut="1";
@@ -354,4 +374,155 @@
 }
 
+return;
+}
+
+/* methode */
+void PAWExecutor::n_scan(vector<string>& tokens)
+{
+if(tokens.size()<3)
+  {cerr<<"Usage: n/scan nameobj[.exp1%exp2%exp3] cut loop\n"
+       <<"       [-f:filename] [list_of_variables]"<<endl; return;}
+
+// decodage des premiers arguments
+string nameobj,expr[4];
+int_4 nexpr = decodepawstring(tokens[0],nameobj,expr[0],expr[1],expr[2]);
+if(nexpr<4) {for(int_4 i=nexpr;i<4;i++) expr[i]="1.";}
+string expcut = tokens[1]; if(expcut=="!") expcut="1";
+string loop   = tokens[2]; if(loop=="!") loop="";
+FILE* fout = NULL;
+uint_4 ldebvar = 3;
+if(tokens.size()>3) {
+  if(tokens[3].find("-f:") == 0) {
+    string filename = tokens[3].substr(3);
+    if(filename.size()>0) {
+      fout = fopen(filename.c_str(),"w");
+      if(fout==NULL) 
+        {cerr<<"PAWExecutor::n_scan Error, file "<<filename
+             <<" not opened"<<endl; return;}
+    }
+    ldebvar++;
+  }
+}
+
+// ntuple adaptateur
+NamedObjMgr omg;
+Services2NObjMgr& srvo = *omg.GetServiceObj();
+NObjMgrAdapter* obja = omg.GetObjAdapter(nameobj); // Ne pas deleter
+if(obja == NULL)
+  {cerr<<"PAWExecutor::n_scan Error, ObjAdapter==NULL for "
+       <<nameobj<<endl; return;}
+bool adel = true;
+NTupleInterface* objnt = obja->GetNTupleInterface(adel);
+if(objnt == NULL)
+  {cerr<<"PAWExecutor::n_scan Error, NTupleInterface==NULL for "
+       <<nameobj<<endl; return;}
+
+// function pour le choix
+string  vardec = objnt->VarList_C("_zz6qi_");
+PlotExprFunc f = srvo.LinkExprFunc(vardec,expr[0],expr[1],expr[2],expr[3],expcut);
+if(!f)
+  {cerr<<"PAWExecutor::n_scan Error, Creation PlotExprFunc"<<endl; 
+   if(adel) delete objnt; if(fout) fclose(fout); return;}
+
+// variables a imprimer
+// "rien"          --> de 0 a ncol-1 (toutes les variables)
+// : v1            --> de 0 a v1
+// v1 :            --> de v1 a ncol-1
+// v1 : v2         --> de v1 a v2 (si v2 apres v1)
+//                     v1 et v2   (si v2 avant v1)
+// v1 v2 v3 v4     --> v1 v2 v3 v4 (ordre indifferent)
+// et toute combinaison : "v1 : v3 v7 v4 : v6 v2 v9 :"
+//        --> v1 v2 v3  v7  v4 v5 v6  v2  v9 v10...v(ncol-1)
+int_4 ncol = objnt->NbColumns();
+if(ncol<=0)
+  {cerr<<"PAWExecutor::n_scan Error, no columns for NTuple"<<endl;
+   return;}
+vector<int_4> varnum;
+if(ldebvar>=tokens.size()) {   // Toutes les variables
+  for(int_4 i=0;i<ncol;i++) varnum.push_back(i);
+} else {   // Choix de certaines variables
+  int_4 k,klast,kk; bool frlast=false;
+  if(tokens[ldebvar]==":") {varnum.push_back(0); frlast=true;}
+  else {k = objnt->ColumnIndex(tokens[ldebvar]); varnum.push_back(k);}
+  ldebvar++;
+  if(ldebvar<tokens.size()) for(uint_4 i=ldebvar;i<tokens.size();i++) {
+    if(tokens[i]!=":") {  // pas un separateur
+      k = klast = objnt->ColumnIndex(tokens[i]);
+      if(frlast) klast = varnum[varnum.size()-1] + 1;
+      if(klast>k) klast=k;
+      for(kk=klast;kk<=k;kk++) varnum.push_back(kk);
+      frlast=false;
+    } else if(i==tokens.size()-1) {  // separateur a la fin
+      k = ncol-1;
+      klast = varnum[varnum.size()-1] + 1;
+      if(klast>k) klast=k;
+      for(kk=klast;kk<=k;kk++) varnum.push_back(kk);
+    } else frlast=true;  // separateur pas a la fin
+  }
+}
+
+vector<string> varname;
+if(varnum.size()>0) for(int_4 i=0;i<(int)varnum.size();i++) {
+  if(varnum[i]<0 || varnum[i]>=ncol)
+    {cerr<<"PAWExecutor::n_scan Error, bad variable name at pos "
+         <<i<<endl; if(adel) delete objnt; if(fout) fclose(fout); return;}
+  string dum = objnt->ColumnName(varnum[i]);
+  varname.push_back(dum);
+}
+
+// evenements a utiliser
+int_4 k1=0, k2=objnt->NbLines(), dk=1;
+srvo.DecodeLoopParameters(loop,k1,k2,dk);
+if (k1<0) k1=0;
+if (k2<0) k2=objnt->NbLines();
+if (k2>(int)objnt->NbLines()) k2=objnt->NbLines();
+if (dk<=0) dk=1;
+
+// boucle sur les evenements et print
+try  {
+  int_4 i;
+  if(fout) fprintf(fout,"#ev "); else printf("#ev ");
+  for(i=0;i<(int)varname.size();i++)
+    if(fout) fprintf(fout,"%s ",varname[i].c_str());
+    else      printf(     "%s ",varname[i].c_str());
+  if(nexpr>0) for(i=0;i<nexpr;i++)
+    if(fout) fprintf(fout,"%s ",expr[i].c_str());
+    else      printf(     "%s ",expr[i].c_str());
+  if(fout) fprintf(fout,"\n"); else printf("\n");
+ 
+  double xnt[5]={0,0,0,0,0};
+  double* xn;
+  for(int_4 k=k1; k<k2; k += dk)    {
+    xn = objnt->GetLineD(k);
+    if(f(xn,xnt,xnt+1,xnt+2,xnt+3) != 0) {
+      if(fout) fprintf(fout,"%d ",k); else printf("%d ",k);
+      for(i=0;i<(int)varnum.size();i++) {
+        if(fout) fprintf(fout,"%g ",*(xn+varnum[i]));
+        else      printf(     "%g ",*(xn+varnum[i]));
+      }
+      if(nexpr>0) for(i=0;i<nexpr;i++) {
+        if(fout) fprintf(fout,"%g ",*(xnt+i));
+        else      printf(     "%g ",*(xnt+i));
+      }
+      if(fout) fprintf(fout,"\n"); else printf("\n");
+    }
+  }
+}   // fin du try
+#ifdef SANS_EVOLPLANCK
+CATCH(merr) {
+  fflush(stdout); cout<<endl; cerr<<endl;
+  string es = PeidaExc(merr);
+  cerr<<"Services2NObjMgr::ComputeExpressions()  Exception :"<<merr<<es;
+} ENDTRY;
+#else
+catch ( PException exc ) {
+  fflush(stdout); cout<<endl; cerr<<endl;
+  cerr<<"Services2NObjMgr::ComputeExpressions()  Exception :"<<exc.Msg()<<endl; 
+}
+#endif
+
+if(adel) delete objnt;
+if(fout) fclose(fout);
+srvo.CloseDLL(); // Fermeture du fichier .so
 return;
 }
@@ -724,5 +895,5 @@
 
 /* methode */
-int PAWExecutor::decodepawstring(string tokens,string& nameobj
+int_4 PAWExecutor::decodepawstring(string tokens,string& nameobj
                                 ,string& xexp,string& yexp,string& zexp)
 // Decodage general de "nameobj.xexp"
@@ -733,5 +904,5 @@
 nameobj = ""; xexp= ""; yexp= ""; zexp= "";
 
-int lt = (int) tokens.length();
+int_4 lt = (int) tokens.length();
 if(lt<=0) return -1;
 
@@ -741,5 +912,5 @@
 //cout<<"chaine1["<<lt<<"] :"<<str<<":"<<endl;
 char *c[3] = {NULL,NULL,NULL};
-int i, np=0; bool namefound = false;
+int_4 i, np=0; bool namefound = false;
 for(i=0;i<lt;i++) {
   if(!namefound && str[i]=='.') {
@@ -769,6 +940,6 @@
              {np++; if(yexp.length()>0)
                       {np++; if(zexp.length()>0) np++;}}}
-cout<<"pawstring["<<np<<"] name="<<nameobj
-    <<" xexp="<<xexp<<" yexp="<<yexp<<" zexp="<<zexp<<endl;
+//cout<<"pawstring["<<np<<"] name="<<nameobj
+//    <<" xexp="<<xexp<<" yexp="<<yexp<<" zexp="<<zexp<<endl;
 return np;
 }
@@ -937,5 +1108,5 @@
 // Le contenu de obj?Dfrom non adresse reste le meme
 {
-int tks = tokens.size();
+int_4 tks = tokens.size();
 if(tks<2)
   {cout<<"Usage: h_copy namefrom nametocopy [i1[:i2]] [j1[:j2]] [ic1[:jc1]]"<<endl;
@@ -1087,5 +1258,5 @@
 //             : e e1:e2  remplacement des bins ayant une erreur dans cet intervalle
 {
-int tks = tokens.size();
+int_4 tks = tokens.size();
 if(tks<3)
   {cout<<"Usage: h/set/[err,cont] namehisto setvalue i1[:i2]  [j1[:j2]]\n"
@@ -1097,5 +1268,5 @@
 bool replerr = false; if(dum=="err") replerr = true;
 r_8 setval = atof(tokens[1].c_str());
-int testcont=0; if(tokens[2]=="v") testcont=1; if(tokens[2]=="e") testcont=2;
+int_4 testcont=0; if(tokens[2]=="v") testcont=1; if(tokens[2]=="e") testcont=2;
 int_4 i1=-1, i2=-1, j1=-1, j2=-1;
 r_8 v1=0., v2=0.;
@@ -1182,5 +1353,5 @@
 // Fonction
 FILE *fip = NULL;
-string expfunc = ""; {for(int i=1;i<(int)tokens.size();i++) expfunc += tokens[i];}
+string expfunc = ""; {for(int_4 i=1;i<(int)tokens.size();i++) expfunc += tokens[i];}
 string fname = "func1or2_pia_dl.c";
 string func = "func1or2_pia_dl_func";
Index: trunk/SophyaPI/PIext/pawexecut.h
===================================================================
--- trunk/SophyaPI/PIext/pawexecut.h	(revision 1243)
+++ trunk/SophyaPI/PIext/pawexecut.h	(revision 1247)
@@ -16,25 +16,26 @@
 class PAWExecutor : public CmdExecutor {
 public:
-                   PAWExecutor(PIACmd* piac, PIStdImgApp* app);
-  virtual          ~PAWExecutor();
-  virtual int      Execute(string& keyw, vector<string>& args);
+              PAWExecutor(PIACmd* piac, PIStdImgApp* app);
+  virtual     ~PAWExecutor();
+  virtual int Execute(string& keyw, vector<string>& args);
 protected:
-  void reset(vector<string>& tokens);
-  void n_plot(vector<string>& tokens);
-  void n_proj(vector<string>& tokens);
-  void h_integ(vector<string>& tokens);
-  void h_deriv(vector<string>& tokens);
-  void h_rebin(vector<string>& tokens);
-  void h_cadd(vector<string>& tokens);
-  void h_cmult(vector<string>& tokens);
-  void h_oper(vector<string>& tokens);
-  void h_plot_2d(vector<string>& tokens);
-  void h_put_vec(vector<string>& tokens);
-  void h_get_vec(vector<string>& tokens);
-  void h_copy(vector<string>& tokens);
-  void h_set(string dum,vector<string>& tokens);
-  void h_err(vector<string>& tokens);
-  int  decodepawstring(string tokens,string& nameobj
-                      ,string& xexp,string& yexp,string& zexp);
+  void  reset(vector<string>& tokens);
+  void  n_plot(vector<string>& tokens);
+  void  n_proj(vector<string>& tokens);
+  void  n_scan(vector<string>& tokens);
+  void  h_integ(vector<string>& tokens);
+  void  h_deriv(vector<string>& tokens);
+  void  h_rebin(vector<string>& tokens);
+  void  h_cadd(vector<string>& tokens);
+  void  h_cmult(vector<string>& tokens);
+  void  h_oper(vector<string>& tokens);
+  void  h_plot_2d(vector<string>& tokens);
+  void  h_put_vec(vector<string>& tokens);
+  void  h_get_vec(vector<string>& tokens);
+  void  h_copy(vector<string>& tokens);
+  void  h_set(string dum,vector<string>& tokens);
+  void  h_err(vector<string>& tokens);
+  int_4 decodepawstring(string tokens,string& nameobj
+                       ,string& xexp,string& yexp,string& zexp);
   PIStdImgApp* mApp;
   static uint_4 autoc_counter_;
