Index: /Interface_Web/trunk/pspaWT/sources/controler/include/PhysicalConstants.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/PhysicalConstants.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/PhysicalConstants.h	(revision 312)
@@ -9,5 +9,7 @@
 #define ELECTRONRADIUS 2.817940325e-13  // cm!
 #define ERESTMeV 0.510998918
+#define ERESTeV 0.510998918e+06
 #define CLIGHT_E8 2.99792458
+#define CLIGHT_m_per_ns 0.299792458
 
 // facteurs de conversion des champs electriques (donnes en MV/cm) 
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h	(revision 312)
@@ -33,5 +33,5 @@
 
 
-  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) = 0;
+  virtual bool  execute(string inputFileName, unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) = 0;
 
  virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) = 0;
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/bareParticle.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/bareParticle.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/bareParticle.h	(revision 312)
@@ -17,6 +17,6 @@
  protected:
 
-  TRIDVECTOR position_;
-  TRIDVECTOR betagamma_;
+  TRIDVECTOR position_;  // cm
+  TRIDVECTOR betagamma_;  // radians
   double gamma_;
 
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h	(revision 312)
@@ -44,5 +44,5 @@
      */
     int getNumeroFromElementLabel(string);
-    abstractElement* getElementPointerFromIndex(int);
+    abstractElement* getElementPointerFromNumero(int);
     
     void initializeExecution();
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/generatorParticle.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/generatorParticle.h	(revision 312)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/generatorParticle.h	(revision 312)
@@ -0,0 +1,24 @@
+#ifndef GENERATORPARTICLE_SEEN
+#define GENERATORPARTICLE_SEEN
+#include <iostream>
+typedef struct 
+{
+  float xx, yy, zz;
+  float px, py, pz;
+  float clock;
+  float macroCharge;
+  int index, flag;
+
+  int readFromGeneratorFile(FILE* fp)
+  {
+    return fscanf(fp, " %e %e %e %e %e %e %e %e %d %d \n", &xx, &yy, &zz,&px,&py,&pz,&clock, &macroCharge,&index,&flag);
+  }
+  void imprim()
+  {
+    std::cout <<  xx << " " <<  yy<< " " << zz << " " << px << " " << py << " " << pz << " " << clock << " " <<  macroCharge << " " << index << " " << flag << std::endl;;
+  }
+
+} generatorParticle;
+
+
+#endif
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h	(revision 312)
@@ -15,20 +15,4 @@
 
 using namespace std;
-
-/* typedef struct  */
-/* { */
-/*   float xx, xxp, begamx,yy,yyp,begamy,z, begamz,phi,wz; */
-/*   float phi0, ksi1,ksi2,ksi3; */
-/*   int ne,np,ngood,npart; */
-
-/*   int readFromParmelaFile(FILE* fp) */
-/*   { */
-/*     return fscanf(fp, " %e %e %e %e %e %e %e %e %e %e %d %d %d %d %e %e %e %e \n", &xx, &xxp, &begamx,&yy,&yyp,&begamy,&z, &begamz,&phi,&wz,&ne,&np,&ngood,&npart,&phi0, &ksi1,&ksi2,&ksi3); */
-/*   } */
-/*   void imprim() */
-/*   { */
-/*     printf( " %e %e %e %e %e %e %e %e %e %e %d %d %d, %d %e %e %e %e \n", xx, xxp, begamx,yy,yyp,begamy,z, begamz,phi,wz,ne,np,ngood,npart,phi0, ksi1,ksi2,ksi3); */
-/*   } */
-/* } parmelaParticle; */
 
 
@@ -63,5 +47,4 @@
   virtual ~particleBeam() {;}
 
-  //  bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);
   void buildMomentRepresentation();
 
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h	(revision 312)
@@ -6,6 +6,6 @@
 typedef struct  
 {
-  unsigned firstElement;
-  unsigned lastElement;
+  unsigned firstElement;  // numero premier element
+  unsigned lastElement;   // numero dernier element
   nomDeLogiciel software;
 }  sectionToExecute;
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h	(revision 312)
@@ -14,4 +14,5 @@
 softwareGenerator();
  
+ bool beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles );
 
  public : 
@@ -26,14 +27,8 @@
 
 
-  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)
-  {
-    return false;
-  }
+  virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
 
 
-virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir)
-{
-  return false;
-}
+  virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir);
 
 };
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h	(revision 312)
@@ -13,4 +13,6 @@
   bool beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles );
 
+  bool beamToParmela(string workingDir, particleBeam* partic );
+
  public : 
   softwareParmela(globalParameters* globals, dataManager* beamLine);
@@ -21,5 +23,5 @@
   virtual bool createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
 
-  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
+  virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
 
 
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h	(revision 312)
@@ -19,5 +19,5 @@
   virtual bool createInputFile(string inputFileName, particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
 
-  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
+  virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
 
 
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/bareParticle.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/bareParticle.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/bareParticle.cc	(revision 312)
@@ -118,4 +118,6 @@
   }
 
+
+
 bool bareParticle::FileInput( ifstream& ifs)
  {
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc	(revision 312)
@@ -55,6 +55,6 @@
 
 
-abstractElement* dataManager::getElementPointerFromIndex(int k){
-    return pspa_->getBeamLine()->getAbstractElement(k);
+abstractElement* dataManager::getElementPointerFromNumero(int k){
+    return pspa_->getBeamLine()->getAbstractElement(k-1);
 }
 
@@ -85,10 +85,10 @@
   unsigned k,j;
   diagnostic.clear();
-  unsigned indexDeb, indexFin;
+  unsigned numeroDeb, numeroFin;
   cout << "controle execution : " << endl;
   for(k = 0; k < jobList_.size(); k++) {
-    indexDeb = jobList_[k]->firstElement;
-    indexFin = jobList_[k]->lastElement;
-    if ( indexFin  < indexDeb )
+    numeroDeb = jobList_[k]->firstElement;
+    numeroFin = jobList_[k]->lastElement;
+    if ( numeroFin  < numeroDeb )
       {
 	diagnostic += " last element before first  for job " + (jobList_[k]->software).getString() + " \n";
@@ -96,11 +96,11 @@
         break;
       }
-    cout << " indexDeb= " << indexDeb << " indexFin= " << indexFin << endl;
-    indexDeb--;
-    indexFin--;
+    cout << " numeroDeb= " << numeroDeb << " numeroFin= " << numeroFin << endl;
+    // indexDeb--;
+    // indexFin--;
     
     abstractElement* elPtr;
     string checkCompatibility;
-    resul = checkElementsForExec(jobList_[k]->software, indexDeb, indexFin, checkCompatibility);
+    resul = checkElementsForExec(jobList_[k]->software, numeroDeb, numeroFin, checkCompatibility);
     diagnostic += checkCompatibility;
   }
@@ -110,5 +110,5 @@
 
 
-trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic)
+trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned numeroDeb, unsigned numeroFin, string& diagnostic)
 {
     trivaluedBool resul = ok;
@@ -116,6 +116,6 @@
     trivaluedBool accepted;
     abstractElement* elPtr;
-    for(unsigned j = indexDeb; j <= indexFin; j++) {
-        elPtr = pspa_->getBeamLine()->getAbstractElement(j);
+    for(unsigned j = numeroDeb; j <= numeroFin; j++) {
+        elPtr = pspa_->getBeamLine()->getAbstractElement(j-1);
         accepted = elPtr->is_accepted_by_software(logiciel);
         if(accepted  == error  ) {
@@ -192,15 +192,20 @@
       	resultatPartiel += " error creating input file \n";
       } else {
-	success = softw->execute(debut,fin,workingDir_,resultatPartiel);
+	success = softw->execute(inputFileName, debut,fin,workingDir_,resultatPartiel);
 	if ( success ) {
 	  success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir_);
 	  if ( !success ) {
-	    resultatPartiel += " readingt results  failed \n";
+	    resultatPartiel += " reading results failed \n";
 	  }
 	}
       }
       delete softw;
-      if ( success ) currentBeam_ = &diagnosticBeam_.back();
-      else currentBeam_ = NULL;
+      if ( success ) {
+	currentBeam_ = &diagnosticBeam_.back();
+	cout << " execute termine avec succes " << endl;
+      } else {
+	currentBeam_ = NULL;
+	cout << " execute termine en ECHEC " << endl;
+      }
       resul += resultatPartiel;
       if ( !success ) break;
@@ -303,8 +308,5 @@
     if ( numeroDeb < 1 ) numeroDeb = 1;
     if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size();
-    
-    unsigned indexDeb = numeroDeb -1;
-    unsigned indexFin = numeroFin -1;
-    
+        
     double longueur = 0.0;
     double valeur = 0.0;
@@ -313,9 +315,9 @@
     if ( type == "x" )
     {
-        for (k= indexDeb; k <= indexFin; k++)
+        for (k= numeroDeb; k <= numeroFin; k++)
         {
-            if ( !diagnosticBeam_.at(k).momentRepresentationOk() ) diagnosticBeam_.at(k).buildMomentRepresentation();
-            longueur += pspa_->getBeamLine()->getAbstractElement(k)->getLenghtOfElement();
-            valeur = diagnosticBeam_.at(k).getXmaxRms();
+            if ( !diagnosticBeam_.at(k-1).momentRepresentationOk() ) diagnosticBeam_.at(k-1).buildMomentRepresentation();
+            longueur += pspa_->getBeamLine()->getAbstractElement(k-1)->getLenghtOfElement();
+            valeur = diagnosticBeam_.at(k-1).getXmaxRms();
             xcor.push_back(longueur);
             ycor.push_back(valeur);
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc	(revision 312)
@@ -81,4 +81,5 @@
 
 void particleBeam::setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles) {
+  cout << " particleBeam::setWithParticles taille vect. part. " << particles.size() << endl;
   centroid_.clear();
   centroid_ = centroid;
@@ -86,4 +87,6 @@
   goodPartic_.clear();
   goodPartic_ = particles;
+  cout << " particleBeam::setWithParticles taille vect. part. ENREGISTRE " << goodPartic_.size() << endl;
+  //  printAllXYZ();
   particleRepresentationOk_ = true;
 }
@@ -112,206 +115,4 @@
 
 
-// bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
-// {
-//   string elementLabel = elLab;
-//   // transformer le label en majuscules ; je ne suis pas sur que ca 
-//   // marchera a tous les coups (glm)
-//   std::transform(elementLabel.begin(), elementLabel.end(), elementLabel.begin(), (int (*)(int))std::toupper);
-
-//   cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl;
-//   string buf;
-//   ifstream infile;
-//   //  string nameIn = WORKINGAREA + "transport.output";
-//   string nameIn = workingDir + "transport.output";
-//   infile.open(nameIn.c_str(), ios::in);
-//   if (!infile) {
-//     cerr << " particleBeam::setFromTransport : error re-opening transport output stream " << nameIn << endl;
-//     return false;
-//   }
-//   //  else cout << " particleBeam::setFromTransport() : ouverture du fichier " << nameIn << endl; 
-
-//   string::size_type nn = string::npos;
-//   while ( getline(infile, buf) ) {
-//     //      cout << " buf= "  << buf << endl;
-//     nn = buf.find(elementLabel);
-//     //     cout << " string::npos= " << string::npos << " nn= " << nn << endl;
-//     if ( nn != string::npos ) {
-//       //	  cout << " particleBeam::setFromTransport : element " << elementLabel << " trouve " << endl;
-//       break;
-//     }
-//   }
-
-//   if ( nn == string::npos ) {
-//     cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier  " << nameIn << endl;
-//     return false;
-//   }
-//   if (elem.getElementType() == bend ) {
-//     getline(infile, buf);
-//     getline(infile, buf);
-//   }
-//   readTransportMoments(infile);
-//   impressionDesMoments();
-//   infile.close();
-//   momentRepresentationOk_ = true;
-//   return true;
-// }
-
-// bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
-// {
-//   string elementLabel = elLab;
-//   // transformer le label en majuscules ; je ne suis pas sur que ca 
-//   // marchera a tous les coups (glm)
-//   std::transform(elementLabel.begin(), elementLabel.end(), elementLabel.begin(), (int (*)(int))std::toupper);
-
-//   cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl;
-//   ifstream infile;
-//   //  string nameIn = WORKINGAREA + "transport.output";
-//   string nameIn = workingDir + "transport.output";
-//   infile.open(nameIn.c_str(), ios::in);
-//   if (!infile) {
-//     cerr << " particleBeam::setFromTransport : error re-opening transport output stream " << nameIn << endl;
-//     return false;
-//   }
-//   //  else cout << " particleBeam::setFromTransport() : ouverture du fichier " << nameIn << endl; 
-
-//   string::size_type nn = string::npos;
-//   string  fichier;
-//   string buf;
-//   unsigned compteur = 0;
-//   while ( getline(infile, buf) ) {
-//       fichier += buf+"\n";
-//     nn = buf.find(elementLabel);
-//     if ( nn != string::npos ) {
-//       compteur++;
-//       //      break;
-//     }
-//   }
-//   infile.close();
-//   cout << " compteur= " << compteur << endl;
-//   if ( compteur == 0 ) {
-//     cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier  " << nameIn << endl;
-//     return false;
-//   }
-
-
-//   stringstream fichierStream(fichier);
-//   buf.clear();
-//   unsigned relu = 0;
-//   while ( std::getline(fichierStream, buf) ) {
-//     //    cout << " relecture buffer : " << buf << endl;
-//     nn = buf.find(elementLabel);
-//     if ( nn != string::npos ) {
-//       relu++;
-//       if ( relu == compteur ) {
-// 	cout << " TROUVE !" << endl;
-// 	break;
-//       }
-//     }
-//   }
-//
-//   readTransportMoments(fichierStream);
-//   //  impressionDesMoments();
-//   momentRepresentationOk_ = true;
-//   return true;
-// }
-
-
-// bool particleBeam::setFromParmela(string workingDir,unsigned numeroElement, double referencefrequency) {
-//   unsigned  k;
-//   FILE* filefais;
-//   string nomfilefais = workingDir + "parmdesz";
-//   cout << " nom fichier desz : " << nomfilefais << endl;
-//   filefais = fopen(nomfilefais.c_str(), "r");
-
-//   if ( filefais == (FILE*)0 ) {
-//     cerr << " particleBeam::setFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;; 
-//     return false;
-//   }
-//   else cout << " particleBeam::setFromParmela() : ouverture du fichier " << nomfilefais << endl; 
-
-//   parmelaParticle partic;
-//   std::vector<parmelaParticle> faisceau;
-
-//   cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;
-//   unsigned indexElement = numeroElement-1;
- 
-
-
-
-//   int testNombrePartRef =0;
-//   double phaseRef;
-
-//   while( partic.readFromParmelaFile(filefais) > 0 ) {
-//     if ( partic.ne == (int)indexElement )
-//       {
-// 	faisceau.push_back(partic);
-
-// 	if ( partic.np == 1 ) {
-// 	  // en principe on est sur la particule de reference
-// 	  if ( fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.xxp) > EPSILON  || fabs(partic.yyp) > EPSILON) {
-// 	    printf(" ATTENTION part. reference douteuse  \n");
-// 	    partic.imprim();
-// 	  }
-// 	  phaseRef = partic.phi;
-// 	  TRIDVECTOR  posRef(partic.xx,partic.yy,0.0);
-// 	  TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
-// 	  referenceParticle_ = bareParticle(posRef, betagammaRef);
-// 	  testNombrePartRef++;
-// 	  if ( testNombrePartRef != 1 ) {
-// 	    cerr << " TROP DE PART. DE REF : " << testNombrePartRef << " !! " << endl;
-// 	    return false;
-// 	  }
-// 	}
-//       }
-//   }
-
-//   if ( faisceau.size() == 0) 
-//     {
-//       cerr << " particleBeam::setFromParmela echec lecture  element " << numeroElement << endl;
-//       return false;
-//     }
-  
-//   // facteur  c/ 360. pour calculer (c dphi) / (360.freq) 
-//   // avec freq en Mhz et dphi en degres et rÃ©sultat en cm: 
-//   double FACTEUR =  83.3333;  // ameliorer la precision
-
-
-
-//   // pour l'instant on choisit un centroid nul;
-//   centroid_ = vector<double>(6,0.0);
-
-//   goodPartic_.clear();
-//   goodPartic_.resize(faisceau.size(), bareParticle());
-//   double x,xp,y,yp;
-//   double betagammaz;
-//   double betaz;
-//   double deltaz;
-//   double dephas;
-//   double g;
-//   TRIDVECTOR  pos;
-//   TRIDVECTOR betagamma;
-//   // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp 
-//   // sont donnes en radians
-//   for ( k=0; k < faisceau.size(); k++) {
-//     x=faisceau.at(k).xx;
-//     xp=faisceau.at(k).xxp;
-//     y=faisceau.at(k).yy;
-//     yp=faisceau.at(k).yyp;
-
-//     // dephasage par rapport a la reference  
-//     dephas = faisceau.at(k).phi - phaseRef; // degrÃ©s
-//     g = faisceau.at(k).wz/ERESTMeV;
-//     betagammaz = faisceau.at(k).begamz;
-//     betaz = betagammaz/(g+1.0);
-//     deltaz = FACTEUR * betaz * dephas / referencefrequency;
-//     x += xp * deltaz;
-//     y += yp * deltaz;
-//     pos.setComponents(x,y,deltaz);
-//     betagamma.setComponents(xp*betagammaz, yp*betagammaz, betagammaz);
-//     goodPartic_.at(k) = bareParticle(pos,betagamma);
-//   }
-//   particleRepresentationOk_ = true;
-//   return true;
-// }
 
 
@@ -358,5 +159,7 @@
       double xx,yy,zz;
       goodPartic_.at(k).getPosition().getComponents(xx,yy,zz);
-      cout << " part. numero " << k << "  x= " << xx << " y= " << yy  << " z= " << zz << endl;
+      double betgamx, betgamy, betgamz;
+      goodPartic_.at(k).getBetaGamma().getComponents(betgamx, betgamy, betgamz);
+      cout << " part. numero " << k << "  x= " << xx << " y= " << yy  << " z= " << zz << "  betgamx= " << betgamx << " betgamy= " << betgamy  << " betgamz= " << betgamz << endl;
     }
 }
@@ -421,4 +224,7 @@
   double P_reference_MeV_sur_c = sqrt( gref*(gref+2) );
 
+  cout << " gref = " << gref << " P_reference_MeV_sur_c = " << P_reference_MeV_sur_c << endl;
+
+
   // initialisation des moments
   razDesMoments();
@@ -432,5 +238,5 @@
   double PMeVsc;
   double del;
-  vector<double> part(6);
+  vector<double> part(6, 0.0);
 
     vector< vector<double> >& matrice = rij_.getMatrix();
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc	(revision 312)
@@ -1,5 +1,7 @@
 #include "softwareGenerator.h"
 #include "abstractElement.h"
-#include "parmelaParticle.h"
+#include "generatorParticle.h"
+#include "mathematicalConstants.h"
+#include "PhysicalConstants.h"
 #include "dataManager.h"
 
@@ -21,9 +23,8 @@
 bool softwareGenerator::createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
 {
-
   if ( numeroDeb != numeroFin ) return false;
 
   abstractElement* elPtr;
-  elPtr = dataManager_->getElementPointerFromIndex(numeroDeb);
+  elPtr = dataManager_->getElementPointerFromNumero(numeroDeb);
 
   if ( elPtr->getNomdElement().getElementType() != RFgun ) {
@@ -31,5 +32,4 @@
     return false;
   }
-
   ofstream outfile;
   string name = workingDir + inputFileName;
@@ -39,5 +39,4 @@
     return false;
   }
-
   outfile << "&INPUT" << endl;
   string fichier = "'" + workingDir + "faisceau.ini" + "'";
@@ -50,2 +49,171 @@
   return true;
 }
+
+
+bool  softwareGenerator::execute(string inputFileName, unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) {
+  ostringstream sortie;
+  bool ExecuteStatus = true;
+  resul.clear();
+  sortie << " EXECUTION DE GENERATOR DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl;
+
+  char buf[132];
+  string generatorJob = workingDir + "generator";
+  generatorJob += string("   ");
+  generatorJob += workingDir + inputFileName;
+
+
+  ofstream outfile;
+  string nameOut = workingDir + "generator.output";
+  string resultOfRun;
+  bool success = launchJob(generatorJob, resultOfRun);
+  sortie << resultOfRun << endl;
+  if ( !success) {
+    sortie << " launching of generator failed " << endl;
+    ExecuteStatus = false;
+  }
+  else {
+    cout << " execution generator MARCHE " << endl;
+    sortie << resultOfRun;
+    outfile.open(nameOut.c_str(), ios::out);
+    if (!outfile) 
+      {
+	sortie << " error first opening transport output stream " << nameOut << endl;
+	ExecuteStatus = false;
+      }
+    else {
+      // on copie la sortie dans un fichier 'generator.out'
+      outfile << resultOfRun << endl;
+      outfile.close();
+    }
+  }
+  resul =  sortie.str();
+  return ExecuteStatus;
+}
+
+bool  softwareGenerator::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) {
+
+  bool result = true;
+  if ( numeroDeb != numeroFin ) return false;
+
+  beams.push_back(particleBeam());
+  vector<double> centroid;
+  bareParticle refPart;
+  vector<bareParticle> particles;
+  vector<bareParticle> particlesPassives; // on ne fait rien de ces particules pour l'instant
+  if (beamFromGenerator(string("faisceau.ini"),workingDir, centroid, refPart,particles, particlesPassives )) {
+    beams.back().setWithParticles(centroid, refPart,particles); 
+  } else {
+    result = false;
+  }
+  return result;
+}
+
+bool softwareGenerator::beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles ) {
+  unsigned  k;
+  FILE* filefais;
+  string nomfilefais = workingDir + beamFileName;
+  cout << " nom fichier sortie generator : " << nomfilefais << endl;
+  filefais = fopen(nomfilefais.c_str(), "r");
+  if ( filefais == (FILE*)0 ) {
+    cerr << " beamFromGenerator() erreur a l'ouverture du fichier" << nomfilefais  << endl;; 
+    return false;
+  }
+  else cout << " beamFromGenerator() : ouverture du fichier " << nomfilefais << endl; 
+
+  generatorParticle partic;
+  std::vector<generatorParticle> faisceau;
+  int nbProbPart =0;
+  double timeRef = 0.0;
+  double betagammaZRef = 0.0;
+  // lecture part. de reference 
+  if ( partic.readFromGeneratorFile(filefais) > 0 )
+    {
+         if ( partic.index != 1 ) {
+	cout << " ERROR softwareGenerator::beamFromGenerator : particles are not electrons, we have to reconsider this method " << endl;
+	return false;
+      }
+   
+      if ( partic.flag != -1 ) {
+	cout << " ATTENTION softwareGenerator::beamFromGenerator : flag different de -1 " << endl;
+      }
+      if (fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.px) > EPSILON  || fabs(partic.py) > EPSILON) {
+	printf(" ATTENTION softwareGenerator::beamFromGenerator : part. reference douteuse  \n");
+	partic.imprim();
+      }
+      timeRef = partic.clock;
+      TRIDVECTOR  posRef(100.*partic.xx,100.*partic.yy,100.*partic.zz); // en cm
+      betagammaZRef = partic.pz/ERESTeV;
+      // l'impulsion donnee par generator est en eV/c
+      TRIDVECTOR betagammaRef(partic.px/ERESTeV , partic.py/ERESTeV, betagammaZRef);
+      refPart = bareParticle(posRef, betagammaRef);
+
+      // seule la part. de reference a un pz absolu (les autres pat. on un pz relatif a la ref)
+      // je mets ici a zero, pour homogeneiser
+      partic.pz = 0.0;
+      faisceau.push_back(partic);
+    }
+
+  while( partic.readFromGeneratorFile(filefais) > 0 ) {
+    faisceau.push_back(partic);
+    if ( partic.flag != -1 ) nbProbPart++;
+  }
+
+  if ( faisceau.size() == 0) 
+    {
+      cerr << " softwareGenerator::beamFromGenerator echec lecture " << endl;
+      return false;
+    }
+  // pour l'instant on choisit un centroid nul;
+  centroid.clear();
+  centroid = vector<double>(6,0.0);
+
+  particles.clear();
+  passiveParticles.clear();
+  //  particles.resize(faisceau.size() - nbProbPart, bareParticle());
+  //  passiveParticles.resize(nbProbPart, bareParticle());
+  double x,y;
+  double deltaz;
+  double deltat;
+  TRIDVECTOR  pos;
+  TRIDVECTOR betagamma;
+  double pxPart;
+  double pyPart;
+  double pzPartRel;
+  double deltaPzPart;
+
+  for ( k=0; k < faisceau.size(); k++) {
+
+    pxPart = faisceau.at(k).px;
+    pyPart = faisceau.at(k).py;
+    pzPartRel = faisceau.at(k).pz;
+    deltaPzPart = faisceau.at(k).pz;
+    x=faisceau.at(k).xx;
+    y=faisceau.at(k).yy;
+
+    // tout ce qui suit sera a clarifier
+    double betaGammax = pxPart/ERESTeV;
+    double betaGammay = pyPart/ERESTeV;
+    double betaGammaz = betagammaZRef + pzPartRel/ERESTeV;
+    betagamma.setComponents(betaGammax, betaGammay, betaGammaz);
+    double gamma = sqrt(1.0 + betagamma.norm2());
+
+    // decalage temporel par rapport a la reference  
+    deltat = faisceau.at(k).clock - timeRef; // nanoseondes
+    double ds = CLIGHT_m_per_ns * deltat /gamma;
+    x += betaGammax * ds;  // en metres
+    y += betaGammay * ds;
+
+    // ici on neglige la difference entre gamma de la part. et gamma de la ref.
+    deltaz = (pzPartRel/ERESTeV) * CLIGHT_m_per_ns * deltat; // en metres
+
+    pos.setComponents(100.*x,100.*y,100.*deltaz);  // en cm
+    if ( faisceau.at(k).flag == -1 ) {
+      particles.push_back(bareParticle(pos,betagamma));
+    } else {
+      passiveParticles.push_back(bareParticle(pos,betagamma));
+    }
+  }
+
+
+  return true;
+}
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc	(revision 312)
@@ -22,11 +22,11 @@
 
   if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) {
-    cerr << " index of element out of limits " << endl;
-    return false;
-  }
-
-
-    unsigned indexDeb = numeroDeb - 1;
-    unsigned indexFin = numeroFin - 1;
+    cerr << " numero of element out of limits " << endl;
+    return false;
+  }
+
+
+    // unsigned indexDeb = numeroDeb - 1;
+    // unsigned indexFin = numeroFin - 1;
 
   ofstream outfile;
@@ -40,8 +40,11 @@
   abstractElement* elPtr;
   double initalKineticEnergy = 0.0;
-  elPtr = dataManager_->getElementPointerFromIndex(indexDeb);
-  if ( elPtr->getNomdElement().getElementType() != RFgun ) {
-    cerr << " dataManager::createInputFileParmela : the first element should be rfgun" << endl;
-    return false;
+  elPtr = dataManager_->getElementPointerFromNumero(numeroDeb);
+  bool there_is_rfgun = ( elPtr->getNomdElement().getElementType() == RFgun ); 
+  if ( !there_is_rfgun ) {
+    if ( !beamToParmela(workingDir, beamBefore ) ) return false;
+    cout << " softwareParmela::createInputFile PROGRAMMER LA RECHERCHE D'EC " << endl;
+    //    cerr << " dataManager::createInputFileParmela : the first element should be rfgun" << endl;
+    //    return false;
   }
   else {
@@ -55,8 +58,14 @@
   outfile << "RUN /n0=1 /ip=999 /freq=" << globParamPtr_->getFrequency() << "  /z0=0.0 /W0=" << initalKineticEnergy << "  /itype=1" << endl;
   outfile << "OUTPUT 0" << endl;
-    
-  for ( k = indexDeb; k <= indexFin; k++)
+  unsigned int premier = numeroDeb ;
+  if ( there_is_rfgun ) {
+      outfile << dataManager_->getElementPointerFromNumero(numeroDeb)->parmelaOutputFlow() << endl;
+      premier++;
+  } else {
+    outfile << "INPUT 0 /NP=" << beamBefore->getNbParticles() << endl;
+  }
+  for ( k = premier; k <= numeroFin; k++)
     {
-      elPtr = dataManager_->getElementPointerFromIndex(k);
+      elPtr = dataManager_->getElementPointerFromNumero(k);
       outfile << elPtr->parmelaOutputFlow() << endl;
     }
@@ -70,16 +79,9 @@
 
 
-bool  softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)
+bool  softwareParmela::execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)
 {
   ostringstream sortie;
   bool ExecuteStatus = true;
   resul.clear();
-  // if ( !createInputFile(NULL,numeroDeb,numeroFin, workingDir) )
-  //   {
-  //     sortie << " error creating parmela input file "  << endl;
-  //     resul = sortie.str();
-  //     return false;
-  //   }
-
   sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl;
 
@@ -106,12 +108,4 @@
 	ExecuteStatus = false;
       }
-    // else
-    //   {
-    // 	ExecuteStatus = buildBeamAfterElements(numeroDeb,numeroFin, beamAfterElement, workingDir);
-    // 	if ( !ExecuteStatus ) {
-    // 		  sortie << " reading parmdesz  failed " << endl;
-    // 	}
-
-    //   }
   }
 
@@ -132,5 +126,5 @@
 	    if (!beamFromParmela(workingDir,k, globParamPtr_->getFrequency(), centroid, refPart,particles ))
 	      {
-		abstractElement* elem = dataManager_->getElementPointerFromIndex(k);
+		abstractElement* elem = dataManager_->getElementPointerFromNumero(k);
 		if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) {
 		  int avantDernier = beams.size() -2;
@@ -160,13 +154,13 @@
 
   if ( filefais == (FILE*)0 ) {
-    cerr << " particleBeam::setFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;; 
-    return false;
-  }
-  else cout << " particleBeam::setFromParmela() : ouverture du fichier " << nomfilefais << endl; 
+    cerr << " beamFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;; 
+    return false;
+  }
+  else cout << " beamFromParmela() : ouverture du fichier " << nomfilefais << endl; 
 
   parmelaParticle partic;
   std::vector<parmelaParticle> faisceau;
 
-  cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;
+  cout << " beamFromParmela : numeroElement = " << numeroElement << endl;
   unsigned indexElement = numeroElement-1;
  
@@ -203,5 +197,5 @@
   if ( faisceau.size() == 0) 
     {
-      cerr << " particleBeam::setFromParmela echec lecture  element " << numeroElement << endl;
+      cerr << " beamFromParmela echec lecture  element " << numeroElement << endl;
       return false;
     }
@@ -249,2 +243,29 @@
   return true;
 }
+
+
+// sauvegarde d'un 'particleBeam' sur un fichier parmela, en guise d'INPUT
+// pour l'instant de nom standard 'parin.input0'
+bool softwareParmela::beamToParmela(string workingDir, particleBeam* beam ) {
+  if ( !beam->particleRepresentationOk() ) {
+    cout << " softwareParmela::beamToParmela : beam not in particles form : not yet programmed " << endl;
+    return false;
+  }
+  ofstream outfile;
+  string name = workingDir + "parin.input0";
+  outfile.open(name.c_str(), ios::out);
+  if (!outfile) {
+    cerr << " softwareParmela::beamToParmela : error opening output stream " << name << endl;
+    return false;
+  }
+
+  const vector<bareParticle>& partic = beam->getParticleVector();
+  unsigned k;
+  double weight = 1.0;
+  for ( k=0; k < partic.size(); k++) {
+    outfile << partic.at(k).getPosition().output_flow() << partic.at(k).getBetaGamma().output_flow()<< weight << endl;
+  }
+    return true;
+}
+
+
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc	(revision 312)
@@ -25,9 +25,9 @@
   }
 
-    unsigned indexDeb = numeroDeb - 1;
-    unsigned indexFin = numeroFin - 1;
+    // unsigned indexDeb = numeroDeb - 1;
+    // unsigned indexFin = numeroFin - 1;
 
   abstractElement* premierEl = NULL;
-  premierEl = dataManager_->getElementPointerFromIndex(indexDeb);
+  premierEl = dataManager_->getElementPointerFromNumero(numeroDeb);
 
   // ceinture et bretelles
@@ -89,7 +89,7 @@
 
   abstractElement* elPtr;
-  for ( k=indexDeb; k <= indexFin; k++)
+  for ( k=numeroDeb; k <= numeroFin; k++)
     {
-      elPtr = dataManager_->getElementPointerFromIndex(k);
+      elPtr = dataManager_->getElementPointerFromNumero(k);
       outfile << elPtr->transportOutputFlow() << endl;
     }
@@ -104,5 +104,5 @@
 
 
-bool softwareTransport::execute( unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul)
+bool softwareTransport::execute(string inputFileName, unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul)
 {
   ostringstream sortie;
@@ -121,5 +121,5 @@
   string transportJob = workingDir + "transport";
   transportJob += string(" <  ");
-  transportJob += workingDir + "transport.input";
+  transportJob += workingDir + inputFileName;
   cout << " job transport= " << transportJob << endl;
 
@@ -165,9 +165,10 @@
 	    //	    string elemLabel = getLabelFromElementNumero (k);
 
-	    abstractElement* ptr = dataManager_->getElementPointerFromIndex(k);
+	    abstractElement* ptr = dataManager_->getElementPointerFromNumero(k);
 
 	    if ( ptr == NULL ) {
-		result = false;
-		break;	      
+	      cout << " softwareTransport::buildBeamAfterElements pointeur nul sur element " << endl;
+	      result = false;
+	      break;	      
 	    }
 
@@ -178,4 +179,5 @@
 	    if (!moments2FromTransport(workingDir, elemLabel, ptr->getNomdElement(),transpMoments )  )
 	      {
+	      cout << " softwareTransport::buildBeamAfterElements plantage dans lecture moments " << endl;
 		result = false;
 		break;
Index: /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc	(revision 312)
@@ -446,4 +446,6 @@
     choixElementDessin_->clear();
     int nombre = dtmanage_->getBeamLineSize();
+    cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl;
+
     for ( int numero =1; numero <= nombre; numero++)
     {
@@ -553,5 +555,10 @@
         double x= partic.at(i).getPosition().getComponent(0);
         double begamz = partic.at(i).getBetaGamma().getComponent(2);
-        double xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;
+	double xp;
+	if ( begamz != 0.0) {
+	  xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;
+	} else {
+	  xp = 0.0;
+	}
         //    cout << "x = " << x << " xp= " << xp << endl;
         model->setData(i, 0, x);
Index: /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc	(revision 311)
+++ /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc	(revision 312)
@@ -288,5 +288,5 @@
         warningDialog.exec();
     }
-    //  cout << " PspaApplication : retour d'execution resultat =  " << resultat << endl;
+    cout << " PspaApplication : retour d'execution resultat =  " << resultat << endl;
     if (console) {
         console->addConsoleMessage(resultat);
