Changeset 312 in PSPA


Ignore:
Timestamp:
Feb 5, 2013, 2:23:23 PM (11 years ago)
Author:
lemeur
Message:

suppression designation elements par index + fin generator

Location:
Interface_Web/trunk/pspaWT/sources
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/PhysicalConstants.h

    r304 r312  
    99#define ELECTRONRADIUS 2.817940325e-13  // cm!
    1010#define ERESTMeV 0.510998918
     11#define ERESTeV 0.510998918e+06
    1112#define CLIGHT_E8 2.99792458
     13#define CLIGHT_m_per_ns 0.299792458
    1214
    1315// facteurs de conversion des champs electriques (donnes en MV/cm)
  • Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h

    r306 r312  
    3333
    3434
    35   virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) = 0;
     35  virtual bool  execute(string inputFileName, unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) = 0;
    3636
    3737 virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) = 0;
  • Interface_Web/trunk/pspaWT/sources/controler/include/bareParticle.h

    r257 r312  
    1717 protected:
    1818
    19   TRIDVECTOR position_;
    20   TRIDVECTOR betagamma_;
     19  TRIDVECTOR position_;  // cm
     20  TRIDVECTOR betagamma_;  // radians
    2121  double gamma_;
    2222
  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r306 r312  
    4444     */
    4545    int getNumeroFromElementLabel(string);
    46     abstractElement* getElementPointerFromIndex(int);
     46    abstractElement* getElementPointerFromNumero(int);
    4747   
    4848    void initializeExecution();
  • Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h

    r257 r312  
    1515
    1616using namespace std;
    17 
    18 /* typedef struct  */
    19 /* { */
    20 /*   float xx, xxp, begamx,yy,yyp,begamy,z, begamz,phi,wz; */
    21 /*   float phi0, ksi1,ksi2,ksi3; */
    22 /*   int ne,np,ngood,npart; */
    23 
    24 /*   int readFromParmelaFile(FILE* fp) */
    25 /*   { */
    26 /*     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); */
    27 /*   } */
    28 /*   void imprim() */
    29 /*   { */
    30 /*     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); */
    31 /*   } */
    32 /* } parmelaParticle; */
    3317
    3418
     
    6347  virtual ~particleBeam() {;}
    6448
    65   //  bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);
    6649  void buildMomentRepresentation();
    6750
  • Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h

    r257 r312  
    66typedef struct 
    77{
    8   unsigned firstElement;
    9   unsigned lastElement;
     8  unsigned firstElement;  // numero premier element
     9  unsigned lastElement;   // numero dernier element
    1010  nomDeLogiciel software;
    1111}  sectionToExecute;
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h

    r305 r312  
    1414softwareGenerator();
    1515 
     16 bool beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles );
    1617
    1718 public :
     
    2627
    2728
    28   virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)
    29   {
    30     return false;
    31   }
     29  virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
    3230
    3331
    34 virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir)
    35 {
    36   return false;
    37 }
     32  virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir);
    3833
    3934};
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h

    r305 r312  
    1313  bool beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles );
    1414
     15  bool beamToParmela(string workingDir, particleBeam* partic );
     16
    1517 public :
    1618  softwareParmela(globalParameters* globals, dataManager* beamLine);
     
    2123  virtual bool createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    2224
    23   virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
     25  virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
    2426
    2527
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h

    r305 r312  
    1919  virtual bool createInputFile(string inputFileName, particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    2020
    21   virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
     21  virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul);
    2222
    2323
  • Interface_Web/trunk/pspaWT/sources/controler/src/bareParticle.cc

    r257 r312  
    118118  }
    119119
     120
     121
    120122bool bareParticle::FileInput( ifstream& ifs)
    121123 {
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r308 r312  
    5555
    5656
    57 abstractElement* dataManager::getElementPointerFromIndex(int k){
    58     return pspa_->getBeamLine()->getAbstractElement(k);
     57abstractElement* dataManager::getElementPointerFromNumero(int k){
     58    return pspa_->getBeamLine()->getAbstractElement(k-1);
    5959}
    6060
     
    8585  unsigned k,j;
    8686  diagnostic.clear();
    87   unsigned indexDeb, indexFin;
     87  unsigned numeroDeb, numeroFin;
    8888  cout << "controle execution : " << endl;
    8989  for(k = 0; k < jobList_.size(); k++) {
    90     indexDeb = jobList_[k]->firstElement;
    91     indexFin = jobList_[k]->lastElement;
    92     if ( indexFin  < indexDeb )
     90    numeroDeb = jobList_[k]->firstElement;
     91    numeroFin = jobList_[k]->lastElement;
     92    if ( numeroFin  < numeroDeb )
    9393      {
    9494        diagnostic += " last element before first  for job " + (jobList_[k]->software).getString() + " \n";
     
    9696        break;
    9797      }
    98     cout << " indexDeb= " << indexDeb << " indexFin= " << indexFin << endl;
    99     indexDeb--;
    100     indexFin--;
     98    cout << " numeroDeb= " << numeroDeb << " numeroFin= " << numeroFin << endl;
     99    // indexDeb--;
     100    // indexFin--;
    101101   
    102102    abstractElement* elPtr;
    103103    string checkCompatibility;
    104     resul = checkElementsForExec(jobList_[k]->software, indexDeb, indexFin, checkCompatibility);
     104    resul = checkElementsForExec(jobList_[k]->software, numeroDeb, numeroFin, checkCompatibility);
    105105    diagnostic += checkCompatibility;
    106106  }
     
    110110
    111111
    112 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic)
     112trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned numeroDeb, unsigned numeroFin, string& diagnostic)
    113113{
    114114    trivaluedBool resul = ok;
     
    116116    trivaluedBool accepted;
    117117    abstractElement* elPtr;
    118     for(unsigned j = indexDeb; j <= indexFin; j++) {
    119         elPtr = pspa_->getBeamLine()->getAbstractElement(j);
     118    for(unsigned j = numeroDeb; j <= numeroFin; j++) {
     119        elPtr = pspa_->getBeamLine()->getAbstractElement(j-1);
    120120        accepted = elPtr->is_accepted_by_software(logiciel);
    121121        if(accepted  == error  ) {
     
    192192        resultatPartiel += " error creating input file \n";
    193193      } else {
    194         success = softw->execute(debut,fin,workingDir_,resultatPartiel);
     194        success = softw->execute(inputFileName, debut,fin,workingDir_,resultatPartiel);
    195195        if ( success ) {
    196196          success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir_);
    197197          if ( !success ) {
    198             resultatPartiel += " readingt results failed \n";
     198            resultatPartiel += " reading results failed \n";
    199199          }
    200200        }
    201201      }
    202202      delete softw;
    203       if ( success ) currentBeam_ = &diagnosticBeam_.back();
    204       else currentBeam_ = NULL;
     203      if ( success ) {
     204        currentBeam_ = &diagnosticBeam_.back();
     205        cout << " execute termine avec succes " << endl;
     206      } else {
     207        currentBeam_ = NULL;
     208        cout << " execute termine en ECHEC " << endl;
     209      }
    205210      resul += resultatPartiel;
    206211      if ( !success ) break;
     
    303308    if ( numeroDeb < 1 ) numeroDeb = 1;
    304309    if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size();
    305    
    306     unsigned indexDeb = numeroDeb -1;
    307     unsigned indexFin = numeroFin -1;
    308    
     310       
    309311    double longueur = 0.0;
    310312    double valeur = 0.0;
     
    313315    if ( type == "x" )
    314316    {
    315         for (k= indexDeb; k <= indexFin; k++)
     317        for (k= numeroDeb; k <= numeroFin; k++)
    316318        {
    317             if ( !diagnosticBeam_.at(k).momentRepresentationOk() ) diagnosticBeam_.at(k).buildMomentRepresentation();
    318             longueur += pspa_->getBeamLine()->getAbstractElement(k)->getLenghtOfElement();
    319             valeur = diagnosticBeam_.at(k).getXmaxRms();
     319            if ( !diagnosticBeam_.at(k-1).momentRepresentationOk() ) diagnosticBeam_.at(k-1).buildMomentRepresentation();
     320            longueur += pspa_->getBeamLine()->getAbstractElement(k-1)->getLenghtOfElement();
     321            valeur = diagnosticBeam_.at(k-1).getXmaxRms();
    320322            xcor.push_back(longueur);
    321323            ycor.push_back(valeur);
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r257 r312  
    8181
    8282void particleBeam::setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles) {
     83  cout << " particleBeam::setWithParticles taille vect. part. " << particles.size() << endl;
    8384  centroid_.clear();
    8485  centroid_ = centroid;
     
    8687  goodPartic_.clear();
    8788  goodPartic_ = particles;
     89  cout << " particleBeam::setWithParticles taille vect. part. ENREGISTRE " << goodPartic_.size() << endl;
     90  //  printAllXYZ();
    8891  particleRepresentationOk_ = true;
    8992}
     
    112115
    113116
    114 // bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
    115 // {
    116 //   string elementLabel = elLab;
    117 //   // transformer le label en majuscules ; je ne suis pas sur que ca
    118 //   // marchera a tous les coups (glm)
    119 //   std::transform(elementLabel.begin(), elementLabel.end(), elementLabel.begin(), (int (*)(int))std::toupper);
    120 
    121 //   cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl;
    122 //   string buf;
    123 //   ifstream infile;
    124 //   //  string nameIn = WORKINGAREA + "transport.output";
    125 //   string nameIn = workingDir + "transport.output";
    126 //   infile.open(nameIn.c_str(), ios::in);
    127 //   if (!infile) {
    128 //     cerr << " particleBeam::setFromTransport : error re-opening transport output stream " << nameIn << endl;
    129 //     return false;
    130 //   }
    131 //   //  else cout << " particleBeam::setFromTransport() : ouverture du fichier " << nameIn << endl;
    132 
    133 //   string::size_type nn = string::npos;
    134 //   while ( getline(infile, buf) ) {
    135 //     //      cout << " buf= "  << buf << endl;
    136 //     nn = buf.find(elementLabel);
    137 //     //     cout << " string::npos= " << string::npos << " nn= " << nn << endl;
    138 //     if ( nn != string::npos ) {
    139 //       //       cout << " particleBeam::setFromTransport : element " << elementLabel << " trouve " << endl;
    140 //       break;
    141 //     }
    142 //   }
    143 
    144 //   if ( nn == string::npos ) {
    145 //     cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier  " << nameIn << endl;
    146 //     return false;
    147 //   }
    148 //   if (elem.getElementType() == bend ) {
    149 //     getline(infile, buf);
    150 //     getline(infile, buf);
    151 //   }
    152 //   readTransportMoments(infile);
    153 //   impressionDesMoments();
    154 //   infile.close();
    155 //   momentRepresentationOk_ = true;
    156 //   return true;
    157 // }
    158 
    159 // bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
    160 // {
    161 //   string elementLabel = elLab;
    162 //   // transformer le label en majuscules ; je ne suis pas sur que ca
    163 //   // marchera a tous les coups (glm)
    164 //   std::transform(elementLabel.begin(), elementLabel.end(), elementLabel.begin(), (int (*)(int))std::toupper);
    165 
    166 //   cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl;
    167 //   ifstream infile;
    168 //   //  string nameIn = WORKINGAREA + "transport.output";
    169 //   string nameIn = workingDir + "transport.output";
    170 //   infile.open(nameIn.c_str(), ios::in);
    171 //   if (!infile) {
    172 //     cerr << " particleBeam::setFromTransport : error re-opening transport output stream " << nameIn << endl;
    173 //     return false;
    174 //   }
    175 //   //  else cout << " particleBeam::setFromTransport() : ouverture du fichier " << nameIn << endl;
    176 
    177 //   string::size_type nn = string::npos;
    178 //   string  fichier;
    179 //   string buf;
    180 //   unsigned compteur = 0;
    181 //   while ( getline(infile, buf) ) {
    182 //       fichier += buf+"\n";
    183 //     nn = buf.find(elementLabel);
    184 //     if ( nn != string::npos ) {
    185 //       compteur++;
    186 //       //      break;
    187 //     }
    188 //   }
    189 //   infile.close();
    190 //   cout << " compteur= " << compteur << endl;
    191 //   if ( compteur == 0 ) {
    192 //     cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier  " << nameIn << endl;
    193 //     return false;
    194 //   }
    195 
    196 
    197 //   stringstream fichierStream(fichier);
    198 //   buf.clear();
    199 //   unsigned relu = 0;
    200 //   while ( std::getline(fichierStream, buf) ) {
    201 //     //    cout << " relecture buffer : " << buf << endl;
    202 //     nn = buf.find(elementLabel);
    203 //     if ( nn != string::npos ) {
    204 //       relu++;
    205 //       if ( relu == compteur ) {
    206 //      cout << " TROUVE !" << endl;
    207 //      break;
    208 //       }
    209 //     }
    210 //   }
    211 //
    212 //   readTransportMoments(fichierStream);
    213 //   //  impressionDesMoments();
    214 //   momentRepresentationOk_ = true;
    215 //   return true;
    216 // }
    217 
    218 
    219 // bool particleBeam::setFromParmela(string workingDir,unsigned numeroElement, double referencefrequency) {
    220 //   unsigned  k;
    221 //   FILE* filefais;
    222 //   string nomfilefais = workingDir + "parmdesz";
    223 //   cout << " nom fichier desz : " << nomfilefais << endl;
    224 //   filefais = fopen(nomfilefais.c_str(), "r");
    225 
    226 //   if ( filefais == (FILE*)0 ) {
    227 //     cerr << " particleBeam::setFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;;
    228 //     return false;
    229 //   }
    230 //   else cout << " particleBeam::setFromParmela() : ouverture du fichier " << nomfilefais << endl;
    231 
    232 //   parmelaParticle partic;
    233 //   std::vector<parmelaParticle> faisceau;
    234 
    235 //   cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;
    236 //   unsigned indexElement = numeroElement-1;
    237  
    238 
    239 
    240 
    241 //   int testNombrePartRef =0;
    242 //   double phaseRef;
    243 
    244 //   while( partic.readFromParmelaFile(filefais) > 0 ) {
    245 //     if ( partic.ne == (int)indexElement )
    246 //       {
    247 //      faisceau.push_back(partic);
    248 
    249 //      if ( partic.np == 1 ) {
    250 //        // en principe on est sur la particule de reference
    251 //        if ( fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.xxp) > EPSILON  || fabs(partic.yyp) > EPSILON) {
    252 //          printf(" ATTENTION part. reference douteuse  \n");
    253 //          partic.imprim();
    254 //        }
    255 //        phaseRef = partic.phi;
    256 //        TRIDVECTOR  posRef(partic.xx,partic.yy,0.0);
    257 //        TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
    258 //        referenceParticle_ = bareParticle(posRef, betagammaRef);
    259 //        testNombrePartRef++;
    260 //        if ( testNombrePartRef != 1 ) {
    261 //          cerr << " TROP DE PART. DE REF : " << testNombrePartRef << " !! " << endl;
    262 //          return false;
    263 //        }
    264 //      }
    265 //       }
    266 //   }
    267 
    268 //   if ( faisceau.size() == 0)
    269 //     {
    270 //       cerr << " particleBeam::setFromParmela echec lecture  element " << numeroElement << endl;
    271 //       return false;
    272 //     }
    273  
    274 //   // facteur  c/ 360. pour calculer (c dphi) / (360.freq)
    275 //   // avec freq en Mhz et dphi en degres et résultat en cm:
    276 //   double FACTEUR =  83.3333;  // ameliorer la precision
    277 
    278 
    279 
    280 //   // pour l'instant on choisit un centroid nul;
    281 //   centroid_ = vector<double>(6,0.0);
    282 
    283 //   goodPartic_.clear();
    284 //   goodPartic_.resize(faisceau.size(), bareParticle());
    285 //   double x,xp,y,yp;
    286 //   double betagammaz;
    287 //   double betaz;
    288 //   double deltaz;
    289 //   double dephas;
    290 //   double g;
    291 //   TRIDVECTOR  pos;
    292 //   TRIDVECTOR betagamma;
    293 //   // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp
    294 //   // sont donnes en radians
    295 //   for ( k=0; k < faisceau.size(); k++) {
    296 //     x=faisceau.at(k).xx;
    297 //     xp=faisceau.at(k).xxp;
    298 //     y=faisceau.at(k).yy;
    299 //     yp=faisceau.at(k).yyp;
    300 
    301 //     // dephasage par rapport a la reference 
    302 //     dephas = faisceau.at(k).phi - phaseRef; // degrés
    303 //     g = faisceau.at(k).wz/ERESTMeV;
    304 //     betagammaz = faisceau.at(k).begamz;
    305 //     betaz = betagammaz/(g+1.0);
    306 //     deltaz = FACTEUR * betaz * dephas / referencefrequency;
    307 //     x += xp * deltaz;
    308 //     y += yp * deltaz;
    309 //     pos.setComponents(x,y,deltaz);
    310 //     betagamma.setComponents(xp*betagammaz, yp*betagammaz, betagammaz);
    311 //     goodPartic_.at(k) = bareParticle(pos,betagamma);
    312 //   }
    313 //   particleRepresentationOk_ = true;
    314 //   return true;
    315 // }
    316117
    317118
     
    358159      double xx,yy,zz;
    359160      goodPartic_.at(k).getPosition().getComponents(xx,yy,zz);
    360       cout << " part. numero " << k << "  x= " << xx << " y= " << yy  << " z= " << zz << endl;
     161      double betgamx, betgamy, betgamz;
     162      goodPartic_.at(k).getBetaGamma().getComponents(betgamx, betgamy, betgamz);
     163      cout << " part. numero " << k << "  x= " << xx << " y= " << yy  << " z= " << zz << "  betgamx= " << betgamx << " betgamy= " << betgamy  << " betgamz= " << betgamz << endl;
    361164    }
    362165}
     
    421224  double P_reference_MeV_sur_c = sqrt( gref*(gref+2) );
    422225
     226  cout << " gref = " << gref << " P_reference_MeV_sur_c = " << P_reference_MeV_sur_c << endl;
     227
     228
    423229  // initialisation des moments
    424230  razDesMoments();
     
    432238  double PMeVsc;
    433239  double del;
    434   vector<double> part(6);
     240  vector<double> part(6, 0.0);
    435241
    436242    vector< vector<double> >& matrice = rij_.getMatrix();
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc

    r305 r312  
    11#include "softwareGenerator.h"
    22#include "abstractElement.h"
    3 #include "parmelaParticle.h"
     3#include "generatorParticle.h"
     4#include "mathematicalConstants.h"
     5#include "PhysicalConstants.h"
    46#include "dataManager.h"
    57
     
    2123bool softwareGenerator::createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    2224{
    23 
    2425  if ( numeroDeb != numeroFin ) return false;
    2526
    2627  abstractElement* elPtr;
    27   elPtr = dataManager_->getElementPointerFromIndex(numeroDeb);
     28  elPtr = dataManager_->getElementPointerFromNumero(numeroDeb);
    2829
    2930  if ( elPtr->getNomdElement().getElementType() != RFgun ) {
     
    3132    return false;
    3233  }
    33 
    3434  ofstream outfile;
    3535  string name = workingDir + inputFileName;
     
    3939    return false;
    4040  }
    41 
    4241  outfile << "&INPUT" << endl;
    4342  string fichier = "'" + workingDir + "faisceau.ini" + "'";
     
    5049  return true;
    5150}
     51
     52
     53bool  softwareGenerator::execute(string inputFileName, unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) {
     54  ostringstream sortie;
     55  bool ExecuteStatus = true;
     56  resul.clear();
     57  sortie << " EXECUTION DE GENERATOR DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl;
     58
     59  char buf[132];
     60  string generatorJob = workingDir + "generator";
     61  generatorJob += string("   ");
     62  generatorJob += workingDir + inputFileName;
     63
     64
     65  ofstream outfile;
     66  string nameOut = workingDir + "generator.output";
     67  string resultOfRun;
     68  bool success = launchJob(generatorJob, resultOfRun);
     69  sortie << resultOfRun << endl;
     70  if ( !success) {
     71    sortie << " launching of generator failed " << endl;
     72    ExecuteStatus = false;
     73  }
     74  else {
     75    cout << " execution generator MARCHE " << endl;
     76    sortie << resultOfRun;
     77    outfile.open(nameOut.c_str(), ios::out);
     78    if (!outfile)
     79      {
     80        sortie << " error first opening transport output stream " << nameOut << endl;
     81        ExecuteStatus = false;
     82      }
     83    else {
     84      // on copie la sortie dans un fichier 'generator.out'
     85      outfile << resultOfRun << endl;
     86      outfile.close();
     87    }
     88  }
     89  resul =  sortie.str();
     90  return ExecuteStatus;
     91}
     92
     93bool  softwareGenerator::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) {
     94
     95  bool result = true;
     96  if ( numeroDeb != numeroFin ) return false;
     97
     98  beams.push_back(particleBeam());
     99  vector<double> centroid;
     100  bareParticle refPart;
     101  vector<bareParticle> particles;
     102  vector<bareParticle> particlesPassives; // on ne fait rien de ces particules pour l'instant
     103  if (beamFromGenerator(string("faisceau.ini"),workingDir, centroid, refPart,particles, particlesPassives )) {
     104    beams.back().setWithParticles(centroid, refPart,particles);
     105  } else {
     106    result = false;
     107  }
     108  return result;
     109}
     110
     111bool softwareGenerator::beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles ) {
     112  unsigned  k;
     113  FILE* filefais;
     114  string nomfilefais = workingDir + beamFileName;
     115  cout << " nom fichier sortie generator : " << nomfilefais << endl;
     116  filefais = fopen(nomfilefais.c_str(), "r");
     117  if ( filefais == (FILE*)0 ) {
     118    cerr << " beamFromGenerator() erreur a l'ouverture du fichier" << nomfilefais  << endl;;
     119    return false;
     120  }
     121  else cout << " beamFromGenerator() : ouverture du fichier " << nomfilefais << endl;
     122
     123  generatorParticle partic;
     124  std::vector<generatorParticle> faisceau;
     125  int nbProbPart =0;
     126  double timeRef = 0.0;
     127  double betagammaZRef = 0.0;
     128  // lecture part. de reference
     129  if ( partic.readFromGeneratorFile(filefais) > 0 )
     130    {
     131         if ( partic.index != 1 ) {
     132        cout << " ERROR softwareGenerator::beamFromGenerator : particles are not electrons, we have to reconsider this method " << endl;
     133        return false;
     134      }
     135   
     136      if ( partic.flag != -1 ) {
     137        cout << " ATTENTION softwareGenerator::beamFromGenerator : flag different de -1 " << endl;
     138      }
     139      if (fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.px) > EPSILON  || fabs(partic.py) > EPSILON) {
     140        printf(" ATTENTION softwareGenerator::beamFromGenerator : part. reference douteuse  \n");
     141        partic.imprim();
     142      }
     143      timeRef = partic.clock;
     144      TRIDVECTOR  posRef(100.*partic.xx,100.*partic.yy,100.*partic.zz); // en cm
     145      betagammaZRef = partic.pz/ERESTeV;
     146      // l'impulsion donnee par generator est en eV/c
     147      TRIDVECTOR betagammaRef(partic.px/ERESTeV , partic.py/ERESTeV, betagammaZRef);
     148      refPart = bareParticle(posRef, betagammaRef);
     149
     150      // seule la part. de reference a un pz absolu (les autres pat. on un pz relatif a la ref)
     151      // je mets ici a zero, pour homogeneiser
     152      partic.pz = 0.0;
     153      faisceau.push_back(partic);
     154    }
     155
     156  while( partic.readFromGeneratorFile(filefais) > 0 ) {
     157    faisceau.push_back(partic);
     158    if ( partic.flag != -1 ) nbProbPart++;
     159  }
     160
     161  if ( faisceau.size() == 0)
     162    {
     163      cerr << " softwareGenerator::beamFromGenerator echec lecture " << endl;
     164      return false;
     165    }
     166  // pour l'instant on choisit un centroid nul;
     167  centroid.clear();
     168  centroid = vector<double>(6,0.0);
     169
     170  particles.clear();
     171  passiveParticles.clear();
     172  //  particles.resize(faisceau.size() - nbProbPart, bareParticle());
     173  //  passiveParticles.resize(nbProbPart, bareParticle());
     174  double x,y;
     175  double deltaz;
     176  double deltat;
     177  TRIDVECTOR  pos;
     178  TRIDVECTOR betagamma;
     179  double pxPart;
     180  double pyPart;
     181  double pzPartRel;
     182  double deltaPzPart;
     183
     184  for ( k=0; k < faisceau.size(); k++) {
     185
     186    pxPart = faisceau.at(k).px;
     187    pyPart = faisceau.at(k).py;
     188    pzPartRel = faisceau.at(k).pz;
     189    deltaPzPart = faisceau.at(k).pz;
     190    x=faisceau.at(k).xx;
     191    y=faisceau.at(k).yy;
     192
     193    // tout ce qui suit sera a clarifier
     194    double betaGammax = pxPart/ERESTeV;
     195    double betaGammay = pyPart/ERESTeV;
     196    double betaGammaz = betagammaZRef + pzPartRel/ERESTeV;
     197    betagamma.setComponents(betaGammax, betaGammay, betaGammaz);
     198    double gamma = sqrt(1.0 + betagamma.norm2());
     199
     200    // decalage temporel par rapport a la reference 
     201    deltat = faisceau.at(k).clock - timeRef; // nanoseondes
     202    double ds = CLIGHT_m_per_ns * deltat /gamma;
     203    x += betaGammax * ds;  // en metres
     204    y += betaGammay * ds;
     205
     206    // ici on neglige la difference entre gamma de la part. et gamma de la ref.
     207    deltaz = (pzPartRel/ERESTeV) * CLIGHT_m_per_ns * deltat; // en metres
     208
     209    pos.setComponents(100.*x,100.*y,100.*deltaz);  // en cm
     210    if ( faisceau.at(k).flag == -1 ) {
     211      particles.push_back(bareParticle(pos,betagamma));
     212    } else {
     213      passiveParticles.push_back(bareParticle(pos,betagamma));
     214    }
     215  }
     216
     217
     218  return true;
     219}
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc

    r305 r312  
    2222
    2323  if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) {
    24     cerr << " index of element out of limits " << endl;
    25     return false;
    26   }
    27 
    28 
    29     unsigned indexDeb = numeroDeb - 1;
    30     unsigned indexFin = numeroFin - 1;
     24    cerr << " numero of element out of limits " << endl;
     25    return false;
     26  }
     27
     28
     29    // unsigned indexDeb = numeroDeb - 1;
     30    // unsigned indexFin = numeroFin - 1;
    3131
    3232  ofstream outfile;
     
    4040  abstractElement* elPtr;
    4141  double initalKineticEnergy = 0.0;
    42   elPtr = dataManager_->getElementPointerFromIndex(indexDeb);
    43   if ( elPtr->getNomdElement().getElementType() != RFgun ) {
    44     cerr << " dataManager::createInputFileParmela : the first element should be rfgun" << endl;
    45     return false;
     42  elPtr = dataManager_->getElementPointerFromNumero(numeroDeb);
     43  bool there_is_rfgun = ( elPtr->getNomdElement().getElementType() == RFgun );
     44  if ( !there_is_rfgun ) {
     45    if ( !beamToParmela(workingDir, beamBefore ) ) return false;
     46    cout << " softwareParmela::createInputFile PROGRAMMER LA RECHERCHE D'EC " << endl;
     47    //    cerr << " dataManager::createInputFileParmela : the first element should be rfgun" << endl;
     48    //    return false;
    4649  }
    4750  else {
     
    5558  outfile << "RUN /n0=1 /ip=999 /freq=" << globParamPtr_->getFrequency() << "  /z0=0.0 /W0=" << initalKineticEnergy << "  /itype=1" << endl;
    5659  outfile << "OUTPUT 0" << endl;
    57    
    58   for ( k = indexDeb; k <= indexFin; k++)
     60  unsigned int premier = numeroDeb ;
     61  if ( there_is_rfgun ) {
     62      outfile << dataManager_->getElementPointerFromNumero(numeroDeb)->parmelaOutputFlow() << endl;
     63      premier++;
     64  } else {
     65    outfile << "INPUT 0 /NP=" << beamBefore->getNbParticles() << endl;
     66  }
     67  for ( k = premier; k <= numeroFin; k++)
    5968    {
    60       elPtr = dataManager_->getElementPointerFromIndex(k);
     69      elPtr = dataManager_->getElementPointerFromNumero(k);
    6170      outfile << elPtr->parmelaOutputFlow() << endl;
    6271    }
     
    7079
    7180
    72 bool  softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)
     81bool  softwareParmela::execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)
    7382{
    7483  ostringstream sortie;
    7584  bool ExecuteStatus = true;
    7685  resul.clear();
    77   // if ( !createInputFile(NULL,numeroDeb,numeroFin, workingDir) )
    78   //   {
    79   //     sortie << " error creating parmela input file "  << endl;
    80   //     resul = sortie.str();
    81   //     return false;
    82   //   }
    83 
    8486  sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl;
    8587
     
    106108        ExecuteStatus = false;
    107109      }
    108     // else
    109     //   {
    110     //  ExecuteStatus = buildBeamAfterElements(numeroDeb,numeroFin, beamAfterElement, workingDir);
    111     //  if ( !ExecuteStatus ) {
    112     //            sortie << " reading parmdesz  failed " << endl;
    113     //  }
    114 
    115     //   }
    116110  }
    117111
     
    132126            if (!beamFromParmela(workingDir,k, globParamPtr_->getFrequency(), centroid, refPart,particles ))
    133127              {
    134                 abstractElement* elem = dataManager_->getElementPointerFromIndex(k);
     128                abstractElement* elem = dataManager_->getElementPointerFromNumero(k);
    135129                if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) {
    136130                  int avantDernier = beams.size() -2;
     
    160154
    161155  if ( filefais == (FILE*)0 ) {
    162     cerr << " particleBeam::setFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;;
    163     return false;
    164   }
    165   else cout << " particleBeam::setFromParmela() : ouverture du fichier " << nomfilefais << endl;
     156    cerr << " beamFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;;
     157    return false;
     158  }
     159  else cout << " beamFromParmela() : ouverture du fichier " << nomfilefais << endl;
    166160
    167161  parmelaParticle partic;
    168162  std::vector<parmelaParticle> faisceau;
    169163
    170   cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;
     164  cout << " beamFromParmela : numeroElement = " << numeroElement << endl;
    171165  unsigned indexElement = numeroElement-1;
    172166 
     
    203197  if ( faisceau.size() == 0)
    204198    {
    205       cerr << " particleBeam::setFromParmela echec lecture  element " << numeroElement << endl;
     199      cerr << " beamFromParmela echec lecture  element " << numeroElement << endl;
    206200      return false;
    207201    }
     
    249243  return true;
    250244}
     245
     246
     247// sauvegarde d'un 'particleBeam' sur un fichier parmela, en guise d'INPUT
     248// pour l'instant de nom standard 'parin.input0'
     249bool softwareParmela::beamToParmela(string workingDir, particleBeam* beam ) {
     250  if ( !beam->particleRepresentationOk() ) {
     251    cout << " softwareParmela::beamToParmela : beam not in particles form : not yet programmed " << endl;
     252    return false;
     253  }
     254  ofstream outfile;
     255  string name = workingDir + "parin.input0";
     256  outfile.open(name.c_str(), ios::out);
     257  if (!outfile) {
     258    cerr << " softwareParmela::beamToParmela : error opening output stream " << name << endl;
     259    return false;
     260  }
     261
     262  const vector<bareParticle>& partic = beam->getParticleVector();
     263  unsigned k;
     264  double weight = 1.0;
     265  for ( k=0; k < partic.size(); k++) {
     266    outfile << partic.at(k).getPosition().output_flow() << partic.at(k).getBetaGamma().output_flow()<< weight << endl;
     267  }
     268    return true;
     269}
     270
     271
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc

    r305 r312  
    2525  }
    2626
    27     unsigned indexDeb = numeroDeb - 1;
    28     unsigned indexFin = numeroFin - 1;
     27    // unsigned indexDeb = numeroDeb - 1;
     28    // unsigned indexFin = numeroFin - 1;
    2929
    3030  abstractElement* premierEl = NULL;
    31   premierEl = dataManager_->getElementPointerFromIndex(indexDeb);
     31  premierEl = dataManager_->getElementPointerFromNumero(numeroDeb);
    3232
    3333  // ceinture et bretelles
     
    8989
    9090  abstractElement* elPtr;
    91   for ( k=indexDeb; k <= indexFin; k++)
     91  for ( k=numeroDeb; k <= numeroFin; k++)
    9292    {
    93       elPtr = dataManager_->getElementPointerFromIndex(k);
     93      elPtr = dataManager_->getElementPointerFromNumero(k);
    9494      outfile << elPtr->transportOutputFlow() << endl;
    9595    }
     
    104104
    105105
    106 bool softwareTransport::execute( unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul)
     106bool softwareTransport::execute(string inputFileName, unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul)
    107107{
    108108  ostringstream sortie;
     
    121121  string transportJob = workingDir + "transport";
    122122  transportJob += string(" <  ");
    123   transportJob += workingDir + "transport.input";
     123  transportJob += workingDir + inputFileName;
    124124  cout << " job transport= " << transportJob << endl;
    125125
     
    165165            //      string elemLabel = getLabelFromElementNumero (k);
    166166
    167             abstractElement* ptr = dataManager_->getElementPointerFromIndex(k);
     167            abstractElement* ptr = dataManager_->getElementPointerFromNumero(k);
    168168
    169169            if ( ptr == NULL ) {
    170                 result = false;
    171                 break;       
     170              cout << " softwareTransport::buildBeamAfterElements pointeur nul sur element " << endl;
     171              result = false;
     172              break;         
    172173            }
    173174
     
    178179            if (!moments2FromTransport(workingDir, elemLabel, ptr->getNomdElement(),transpMoments )  )
    179180              {
     181              cout << " softwareTransport::buildBeamAfterElements plantage dans lecture moments " << endl;
    180182                result = false;
    181183                break;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r311 r312  
    446446    choixElementDessin_->clear();
    447447    int nombre = dtmanage_->getBeamLineSize();
     448    cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl;
     449
    448450    for ( int numero =1; numero <= nombre; numero++)
    449451    {
     
    553555        double x= partic.at(i).getPosition().getComponent(0);
    554556        double begamz = partic.at(i).getBetaGamma().getComponent(2);
    555         double xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;
     557        double xp;
     558        if ( begamz != 0.0) {
     559          xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;
     560        } else {
     561          xp = 0.0;
     562        }
    556563        //    cout << "x = " << x << " xp= " << xp << endl;
    557564        model->setData(i, 0, x);
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r305 r312  
    288288        warningDialog.exec();
    289289    }
    290     //  cout << " PspaApplication : retour d'execution resultat =  " << resultat << endl;
     290    cout << " PspaApplication : retour d'execution resultat =  " << resultat << endl;
    291291    if (console) {
    292292        console->addConsoleMessage(resultat);
Note: See TracChangeset for help on using the changeset viewer.