Changeset 243 in PSPA


Ignore:
Timestamp:
Jan 18, 2013, 10:02:58 PM (11 years ago)
Author:
lemeur
Message:

rationalisation pour introduire nouveau logiciel

Location:
Interface_Web/trunk/pspaWT
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/cmt/requirements

    r241 r243  
    1717
    1818
    19 macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD  -DHAS_IMAGEMAGIC -DPSPA_DEBUG" Linux-x86_64  " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DHAS_IMAGEMAGIC"
     19#macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD  -DHAS_IMAGEMAGIC -DPSPA_DEBUG" Linux-x86_64  " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DHAS_IMAGEMAGIC"
    2020
    21 #macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD  -DPSPA_DEBUG" Linux-x86_64  " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD "
     21macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD  -DPSPA_DEBUG" Linux-x86_64  " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD "
    2222
    2323
  • Interface_Web/trunk/pspaWT/include/GWt_abstractElement.h

    r239 r243  
    55#include "GWt_draggableImage.h"
    66#include "abstractElement.h"
     7#include "GWt_console.h"
    78
    89#include <Wt/WDialog>
  • Interface_Web/trunk/pspaWT/include/abstractElement.h

    r229 r243  
    77
    88#include "nomdElements.h"
     9#include "nomDeLogiciel.h"
     10#include "trivaluedBool.h"
    911
    1012using namespace std;
     
    1416 protected :
    1517 
    16   bool parmelaOk_;
    17   bool parmelaIgnored_;
    18   bool transportOk_;
     18  /* bool parmelaOk_; */
     19  /* bool parmelaIgnored_; */
     20  /* bool transportOk_; */
    1921  int nbParam_;
    2022  string* parametersString_;
     
    5052
    5153  /* string getElementImage() const; */
    52 
    5354  /* string getElementName() const; */
    5455
    5556  double getLenghtOfElement() const;
    5657  int getNbParams() const; 
    57   bool is_parmela_ignored() const;
    58   bool is_parmela_element() const;
    59   bool is_transport_element() const;
    60 
     58  /* bool is_parmela_ignored() const; */
     59  /* bool is_parmela_element() const; */
     60  /* bool is_transport_element() const; */
     61  virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
    6162  virtual void setPhaseStep(double);
    6263  virtual double getInitialKineticEnergy() const;
  • Interface_Web/trunk/pspaWT/include/dataManager.h

    r236 r243  
    1212#include "beam2Moments.h"
    1313
     14typedef struct
     15{
     16  float xx, xxp, begamx,yy,yyp,begamy,z, begamz,phi,wz;
     17  float phi0, ksi1,ksi2,ksi3;
     18  int ne,np,ngood,npart;
     19
     20  int readFromParmelaFile(FILE* fp)
     21  {
     22    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);
     23  }
     24  void imprim()
     25  {
     26    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);
     27  }
     28} parmelaParticle;
    1429
    1530
     
    3146  void clearSectionToExecute();
    3247  bool  moments2FromTransport(string workingDir, string elLab, const nomdElements elem, beam2Moments& moments) const;
    33 
     48  bool beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles );
    3449 public:
    3550
     
    5671  void initializeExecution(string workingDir);
    5772  trivaluedBool checkExecute(string& diagnostic);
     73  trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic);
    5874  bool executeTransport( unsigned int numeroDeb, unsigned int numeroFin, string workingDir,  string& resul);
    5975  bool executeParmela( unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul);
     76  bool launchJob(string commandLine, string& resul);
    6077  bool executeAll(string workingDir, string& resul);
    6178  void saveConfiguration(string workingDir, string nameOfFile);
  • Interface_Web/trunk/pspaWT/include/elementBeam.h

    r180 r243  
    3030~elementBeam();
    3131
     32virtual  trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
    3233
    3334
  • Interface_Web/trunk/pspaWT/include/elementBend.h

    r202 r243  
    4343  double getLenghtOfElement() const;
    4444
     45 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
     46
    4547
    4648  virtual void setParametersString(string* param);
  • Interface_Web/trunk/pspaWT/include/elementCell.h

    r107 r243  
    4646  ~elementCell() { ;}
    4747
     48 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
    4849
    4950  virtual string* getParametersString() const;
  • Interface_Web/trunk/pspaWT/include/elementDrift.h

    r84 r243  
    1818  ~elementDrift() {;}
    1919
     20 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
     21
     22
    2023  virtual string* getParametersString() const;
    2124
  • Interface_Web/trunk/pspaWT/include/elementFit.h

    r225 r243  
    2929  ~elementFit() {;}
    3030
     31 virtual  trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
     32
    3133
    3234  virtual void setParametersString(string* param);
  • Interface_Web/trunk/pspaWT/include/elementRfgun.h

    r155 r243  
    4242  ~elementRfgun() {;}
    4343
     44 virtual  trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
     45
    4446  virtual void setPhaseStep(double ph) { phaseStep_ = ph;}
    4547 
  • Interface_Web/trunk/pspaWT/include/elementSoleno.h

    r229 r243  
    3232  ~elementSoleno() {;}
    3333
     34  virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const;
     35
    3436 virtual void setParametersString(string* param);
    3537
  • Interface_Web/trunk/pspaWT/include/particleBeam.h

    r236 r243  
    1010
    1111#include "bareParticle.h"
    12 #include "mathematicalTools.h"
     12//#include "mathematicalTools.h"
    1313#include "nomdElements.h"
    1414#include "beam2Moments.h"
     
    1616using namespace std;
    1717
    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;
     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; */
    2323
    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;
     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; */
    3333
    3434
     
    6363  virtual ~particleBeam() {;}
    6464
    65   bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);
     65  //  bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);
    6666  void buildMomentRepresentation();
    6767
     
    9292 
    9393  void set2Moments(beam2Moments& moments);
    94 
     94  void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles);
    9595  void printAllXYZ() const;
    9696
  • Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc

    r240 r243  
    1414#include "mixedTools.h"
    1515#include "nomdElements.h"
    16 #include "GWt_tools.h"
    1716
    1817#include <Wt/WText>
  • Interface_Web/trunk/pspaWT/src/GWt_dropZoneLigneFaiseau.cc

    r242 r243  
    360360    GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    361361    console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut");
    362   console->addConsoleMessage("remove from drag Zone");
     362    console->addConsoleMessage("remove from drag Zone");
    363363  }
    364364  cout << "remove from drag Zone id" << layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) << " count:" << layout->count()<< endl;
     
    369369      layout->removeItem (layout->itemAt(2));
    370370#ifdef PSPA_DEBUG
    371   console->addConsoleMessage("remove first link");
    372 #endif
    373     }
     371      if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     372        GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     373        console->addConsoleMessage(" remove first link ");
     374#endif
     375      }
    374376   
    375     // last and middle
    376   } else if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == layout->count()-2) {
    377     if (layout->itemAt (layout->count()-3)) {
    378       layout->removeItem (layout->itemAt(layout->count()-3));
    379 #ifdef PSPA_DEBUG
    380   console->addConsoleMessage("remove last link");
    381 #endif
    382     }
    383   }
     377      // last and middle
     378    } else if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == layout->count()-2) {
     379      if (layout->itemAt (layout->count()-3)) {
     380        layout->removeItem (layout->itemAt(layout->count()-3));
     381#ifdef PSPA_DEBUG
     382        if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     383          GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     384          console->addConsoleMessage(" remove first link ");
     385#endif
     386        }
     387      }
    384388 
    385   // remove the drop zone
    386   if (layout->findWidgetItem (other)) {
    387     layout->removeItem (layout->itemAt(layout->indexOf((WLayoutItem*)(layout->findWidgetItem (other)))));
    388 #ifdef PSPA_DEBUG
    389     console->addConsoleMessage("remove drop zone");
    390 #endif
    391   }
     389      // remove the drop zone
     390      if (layout->findWidgetItem (other)) {
     391        layout->removeItem (layout->itemAt(layout->indexOf((WLayoutItem*)(layout->findWidgetItem (other)))));
     392#ifdef PSPA_DEBUG
     393        if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     394          GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     395          console->addConsoleMessage(" remove drop zone ");
     396#endif
     397        }
    392398
    393399 
    394   // FIXME ne mas passer par un label mais par un abstrastElement
    395   //  pspa_->getDataManager()->getCollection()->eraseElement(label);
    396   pspa_->updateSelections();
    397 }
    398 
    399 
    400 
     400        // FIXME ne mas passer par un label mais par un abstrastElement
     401        //  pspa_->getDataManager()->getCollection()->eraseElement(label);
     402        pspa_->updateSelections();
     403      }
     404    }
     405  }
     406}
    401407void GWt_dropZoneLigneFaiseau::addElement(WContainerWidget* elem){
    402408
  • Interface_Web/trunk/pspaWT/src/abstractElement.cc

    r229 r243  
    3737  lenghtElem_ = defaultLength_;
    3838  aperture_ = defaultAperture_;
    39   parmelaOk_ = false;
    40   parmelaIgnored_ = false;
    41   transportOk_ = false;
     39  // parmelaOk_ = false;
     40  // parmelaIgnored_ = false;
     41  // transportOk_ = false;
    4242}
    4343
     
    102102}
    103103
    104 bool abstractElement::is_parmela_element() const {
    105   return parmelaOk_;
     104trivaluedBool abstractElement::is_accepted_by_software(nomDeLogiciel soft) const {
     105    cout << " abstractElement :  is_accepted_by_software suspect  " << endl;
     106
     107  return error;
    106108}
    107109
    108 bool abstractElement::is_parmela_ignored() const {
    109   return parmelaIgnored_;
    110 }
    111 
    112 bool abstractElement::is_transport_element() const {
    113   return transportOk_;
    114 }
    115110
    116111double abstractElement::getInitialKineticEnergy() const {
  • Interface_Web/trunk/pspaWT/src/beam2Moments.cc

    r239 r243  
    9090    getline(inp, buf);
    9191    stringstream str(buf);
    92 //    test = str >> bidon >>  bidString >>  bidon >>  ( rij_secondOrderMoments_.at(0) ).at(0) >> bidString;
     92    test = str >> bidon >>  bidString >>  bidon >>  ( rij_secondOrderMoments_.at(0) ).at(0) >> bidString;
    9393    cout << " beam2Moments::readFromTransportOutput TEST= " << test << endl;
    9494  }
  • Interface_Web/trunk/pspaWT/src/dataManager.cc

    r237 r243  
    11#include "dataManager.h"
     2#include "mathematicalConstants.h"
     3#include "PhysicalConstants.h"
    24
    35#include <stdio.h>
     
    4951    if ( indexFin  <= indexDeb )
    5052      {
    51         diagnostic += " first and last elements are the same \n";
     53        diagnostic += " first and last elements are the same for job " + (jobList_[k]->software).getString() + " \n";
    5254        resul = error;
    5355        break;
     
    5658    indexDeb--;
    5759    indexFin--;
     60   
    5861    abstractElement* elPtr;
    59     if(jobList_[k]->software == nomDeLogiciel::parmela ) {
    60       for(j = indexDeb; j <= indexFin; j++) {
    61         elPtr = elementsGallery_.getElementPointerFromIndex(j);
    62 
    63         cout << "elPtr parmela: " << elPtr->getLabel() << endl;
    64 
    65         if(!elPtr->is_parmela_element()) {
    66           cout << " el non parmela : " << elPtr->getLabel()  << " ignored ? " << elPtr->is_parmela_ignored() << endl;
    67           if ( elPtr->is_parmela_ignored() ) {
    68             cout << " element ignore " << elPtr->getLabel() << endl;
    69             diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is ignored by PARMELA \n";
    70             resul = warning;
    71           } else {
    72             diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed for PARMELA \n";
    73             resul =error;
    74           }
    75         }           
    76       }
    77     }
    78     else if (jobList_[k]->software == nomDeLogiciel::transport) {
    79       for(j = indexDeb; j <= indexFin; j++) {
    80         elPtr = elementsGallery_.getElementPointerFromIndex(j);
    81 
    82         cout << "elPtr transp: " << elPtr->getLabel() << endl;
    83 
    84         if (!elPtr->is_transport_element()) {
    85           diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed for TRANSPORT \n";
    86           resul = error;
    87         }
    88       }     
    89     }
    90     else
    91       {
    92         diagnostic += (jobList_[k]->software).getString() + " : unknown software \n ";
    93         resul = error;
    94       }
     62    string checkCompatibility;
     63    resul = checkElementsForExec(jobList_[k]->software, indexDeb, indexFin, checkCompatibility);
     64    diagnostic += checkCompatibility;
    9565  }
    9666  cout << " data manager renvoie resul = " << resul << endl;
    9767  return resul;
     68}
     69
     70trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic)
     71{
     72  trivaluedBool resul = ok;
     73  diagnostic.clear();
     74  trivaluedBool accepted;
     75  abstractElement* elPtr;
     76  for(unsigned j = indexDeb; j <= indexFin; j++) {
     77    elPtr = elementsGallery_.getElementPointerFromIndex(j);
     78    accepted = elPtr->is_accepted_by_software(logiciel);
     79    if(accepted  == error  ) {
     80      diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed with " + logiciel.getString() + " \n";
     81      resul = error;
     82    } else if ( accepted  == warning ) {
     83      diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " will be ignored by " + logiciel.getString() + " \n";
     84      if ( resul != error ) resul = warning;
     85    }
     86  }
     87  return resul;
     88}
     89
     90
     91bool dataManager::launchJob(string commandLine, string& resul)
     92{
     93  ostringstream sortie;
     94  bool ExecuteStatus = true;
     95  FILE* pp = popen(commandLine.c_str(), "r");
     96  if (pp == NULL) {
     97    sortie << " launching  failed : " << commandLine << endl;
     98    ExecuteStatus = false;
     99  }
     100  else {
     101    cout << " executind command :  "  << commandLine << endl;
     102    // on copie la sortie dans le fichier assigne
     103    char buf[132];
     104    while (fgets(buf, sizeof buf, pp))
     105      {
     106        sortie << buf;
     107      }
     108    pclose(pp);
     109  }
     110  resul =  sortie.str();
     111  return ExecuteStatus;
    98112}
    99113
     
    120134  cout << " job transport= " << transportJob << endl;
    121135
    122   ofstream outfile;
     136    ofstream outfile;
    123137  string nameOut = workingDir + "transport.output";
    124138
    125139
    126   FILE* pp = popen(transportJob.c_str(), "r");
    127   if (pp == NULL) {
     140  //  FILE* pp = popen(transportJob.c_str(), "r");
     141
     142  string resultOfRun;
     143  // if (pp == NULL) {
     144  bool success = launchJob(transportJob, resultOfRun);
     145  sortie << resultOfRun << endl;
     146  if ( !success) {
    128147    sortie << " launching of transport failed " << endl;
    129148    ExecuteStatus = false;
     
    133152      outfile.open(nameOut.c_str(), ios::out);
    134153      if (!outfile)
    135         {
    136           sortie << " error first opening transport output stream " << nameOut << endl;
    137           ExecuteStatus = false;
    138         }
     154        {
     155          sortie << " error first opening transport output stream " << nameOut << endl;
     156          ExecuteStatus = false;
     157        }
    139158      else {
    140         unsigned nbl = 0;
    141         while (fgets(buf, sizeof buf, pp))
    142           {
    143             //    cout << " buf= " << buf << endl;
    144             sortie << buf;
    145             outfile << buf;
    146             nbl++;
    147           }
    148         outfile.close();
    149         ifstream infile;
    150         infile.open(nameOut.c_str(), ios::in);
    151 
     159        // on copie la sortie dans un fichier 'transport.out'
     160        outfile << resultOfRun << endl;
     161        // while (fgets(buf, sizeof buf, pp))
     162        //   {
     163        //     //         cout << " buf= " << buf << endl;
     164        //     sortie << buf;
     165        //     outfile << buf;
     166        //     //           nbl++;
     167        //   }
     168         outfile.close();
    152169        unsigned k;
    153170        for ( k= numeroDeb; k <= numeroFin; k++)
     
    161178
    162179            if (!moments2FromTransport(workingDir, elemLabel, ptr->getNomdElement(),transpMoments )  )
    163               //            if (!diagnosticBeam_.back().setFromTransport(workingDir, elemLabel, ptr->getNomdElement() )  )
    164180              {
    165181                sortie << " reading transport output  failed " << endl;
     
    172188        else currentBeam_ = NULL;
    173189      }
    174       pclose(pp);
     190        //      pclose(pp);
    175191  }
    176192  resul =  sortie.str();
     
    196212  parmelaJob += string("   ");
    197213  parmelaJob += workingDir;
    198   cout << " job parmela= " << parmelaJob << endl;
    199   FILE* pp = popen(parmelaJob.c_str(), "r");
    200 
    201   if (pp == NULL) {
     214  //  cout << " job parmela= " << parmelaJob << endl;
     215
     216  string resultOfRun;
     217  bool success = launchJob(parmelaJob, resultOfRun);
     218  sortie << resultOfRun << endl;
     219  if ( !success) {
    202220    sortie << " launching of parmela failed " << endl;
    203221    ExecuteStatus = false;
     
    205223  else {
    206224    cout << " execution parmela MARCHE " << endl;
    207     while (fgets(buf, sizeof buf, pp))
    208       {
    209         sortie << buf;
    210       }
    211     string::size_type nn = (sortie.str()).find("normal");
     225    sortie << resultOfRun;
     226    string::size_type nn = (resultOfRun).find("normal");
    212227    if ( nn == string::npos )
    213228      {
     
    221236          {
    222237            diagnosticBeam_.push_back(particleBeam());
    223             if (! diagnosticBeam_.back().setFromParmela(workingDir, k, globParam_.getFrequency()) )
     238            vector<double> centroid;
     239            bareParticle refPart;
     240            vector<bareParticle> particles;
     241            if (!beamFromParmela(workingDir,k, globParam_.getFrequency(), centroid, refPart,particles ))
    224242              {
    225243                abstractElement* elem = elementsGallery_.getElementPointerFromNumero(k);
    226                 if ( elem->is_parmela_ignored() ) {
     244                if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) {
    227245                  int avantDernier = diagnosticBeam_.size() -2;
    228246                  diagnosticBeam_.back() = diagnosticBeam_.at(avantDernier);
     
    233251                }
    234252              }
     253            diagnosticBeam_.back().setWithParticles(centroid, refPart,particles);
    235254          }
    236255
     
    238257        else currentBeam_ = NULL;
    239258      }
    240     pclose(pp);
     259    //    pclose(pp);
    241260  }
    242261
     
    606625
    607626}
     627
     628
     629bool dataManager::beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ) {
     630  unsigned  k;
     631  FILE* filefais;
     632  string nomfilefais = workingDir + "parmdesz";
     633  cout << " nom fichier desz : " << nomfilefais << endl;
     634  filefais = fopen(nomfilefais.c_str(), "r");
     635
     636  if ( filefais == (FILE*)0 ) {
     637    cerr << " particleBeam::setFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;;
     638    return false;
     639  }
     640  else cout << " particleBeam::setFromParmela() : ouverture du fichier " << nomfilefais << endl;
     641
     642  parmelaParticle partic;
     643  std::vector<parmelaParticle> faisceau;
     644
     645  cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;
     646  unsigned indexElement = numeroElement-1;
     647 
     648
     649
     650
     651  int testNombrePartRef =0;
     652  double phaseRef;
     653
     654  while( partic.readFromParmelaFile(filefais) > 0 ) {
     655    if ( partic.ne == (int)indexElement )
     656      {
     657        faisceau.push_back(partic);
     658
     659        if ( partic.np == 1 ) {
     660          // en principe on est sur la particule de reference
     661          if ( fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.xxp) > EPSILON  || fabs(partic.yyp) > EPSILON) {
     662            printf(" ATTENTION part. reference douteuse  \n");
     663            partic.imprim();
     664          }
     665          phaseRef = partic.phi;
     666          TRIDVECTOR  posRef(partic.xx,partic.yy,0.0);
     667          TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
     668          refPart = bareParticle(posRef, betagammaRef);
     669          testNombrePartRef++;
     670          if ( testNombrePartRef != 1 ) {
     671            cerr << " TROP DE PART. DE REF : " << testNombrePartRef << " !! " << endl;
     672            return false;
     673          }
     674        }
     675      }
     676  }
     677
     678  if ( faisceau.size() == 0)
     679    {
     680      cerr << " particleBeam::setFromParmela echec lecture  element " << numeroElement << endl;
     681      return false;
     682    }
     683 
     684  // facteur  c/ 360. pour calculer (c dphi) / (360.freq)
     685  // avec freq en Mhz et dphi en degres et résultat en cm:
     686  double FACTEUR =  83.3333;  // ameliorer la precision
     687
     688
     689
     690  // pour l'instant on choisit un centroid nul;
     691  centroid.clear();
     692  centroid = vector<double>(6,0.0);
     693
     694  particles.clear();
     695  particles.resize(faisceau.size(), bareParticle());
     696  double x,xp,y,yp;
     697  double betagammaz;
     698  double betaz;
     699  double deltaz;
     700  double dephas;
     701  double g;
     702  TRIDVECTOR  pos;
     703  TRIDVECTOR betagamma;
     704  // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp
     705  // sont donnes en radians
     706  for ( k=0; k < faisceau.size(); k++) {
     707    x=faisceau.at(k).xx;
     708    xp=faisceau.at(k).xxp;
     709    y=faisceau.at(k).yy;
     710    yp=faisceau.at(k).yyp;
     711
     712    // dephasage par rapport a la reference 
     713    dephas = faisceau.at(k).phi - phaseRef; // degrés
     714    g = faisceau.at(k).wz/ERESTMeV;
     715    betagammaz = faisceau.at(k).begamz;
     716    betaz = betagammaz/(g+1.0);
     717    deltaz = FACTEUR * betaz * dephas / referencefrequency;
     718    x += xp * deltaz;
     719    y += yp * deltaz;
     720    pos.setComponents(x,y,deltaz);
     721    betagamma.setComponents(xp*betagammaz, yp*betagammaz, betagammaz);
     722    particles.at(k) = bareParticle(pos,betagamma);
     723  }
     724  return true;
     725}
  • Interface_Web/trunk/pspaWT/src/elementBeam.cc

    r236 r243  
    1111  nbParam_ = elementName_.getElementNbParameters();
    1212  parametersString_ = new string[nbParam_+1];
    13   transportOk_ = true;
     13  //  transportOk_ = true;
    1414}
    1515
     
    3535    p0_ = p0Def_;
    3636  }
     37
     38trivaluedBool elementBeam::is_accepted_by_software(nomDeLogiciel soft) const {
     39  if ( soft == nomDeLogiciel::transport ) return ok;
     40  else return error;
     41}
    3742
    3843string* elementBeam::getParametersString() const {
  • Interface_Web/trunk/pspaWT/src/elementBend.cc

    r225 r243  
    1010  nbParam_ = elementName_.getElementNbParameters();
    1111  parametersString_ = new string[nbParam_+1];
    12   transportOk_ = true;
    13   parmelaOk_ = true;
     12  // transportOk_ = true;
     13  // parmelaOk_ = true;
    1414}
    1515
     
    5555}
    5656
     57trivaluedBool elementBend::is_accepted_by_software(nomDeLogiciel soft) const {
     58  if ( soft == nomDeLogiciel::transport  ) return ok;
     59  else if ( soft == nomDeLogiciel::parmela ) return ok;
     60  else return error;
     61}
    5762
    5863
  • Interface_Web/trunk/pspaWT/src/elementCell.cc

    r225 r243  
    1515      nbParam_ = elementName_.getElementNbParameters();
    1616      parametersString_ = new string[nbParam_+1];
    17       parmelaOk_ = true;
     17      //      parmelaOk_ = true;
    1818    }
    1919
     
    3737    scaleFactor_ = scaleFactorDef_;
    3838  }
     39
     40trivaluedBool elementCell::is_accepted_by_software(nomDeLogiciel soft) const {
     41  if ( soft == nomDeLogiciel::parmela ) return ok;
     42  else return error;
     43}
    3944
    4045  string* elementCell::getParametersString() const
  • Interface_Web/trunk/pspaWT/src/elementDrift.cc

    r225 r243  
    1111  nbParam_ = elementName_.getElementNbParameters();
    1212  parametersString_ = new string[nbParam_+1];
    13   parmelaOk_ = true;
    14   transportOk_ = true;
     13  // parmelaOk_ = true;
     14  // transportOk_ = true;
    1515  //  transportElementName_ = "*DRIFT*";
    1616}
     17
     18trivaluedBool elementDrift::is_accepted_by_software(nomDeLogiciel soft) const {
     19  if ( soft == nomDeLogiciel::transport  ) return ok;
     20  else if ( soft == nomDeLogiciel::parmela ) return ok;
     21  else return error;
     22}
     23
    1724
    1825 string* elementDrift::getParametersString() const
  • Interface_Web/trunk/pspaWT/src/elementFit.cc

    r230 r243  
    99  nbParam_ = elementName_.getElementNbParameters();
    1010  parametersString_ = new string[nbParam_+1];
    11   transportOk_ = true;
    12   parmelaIgnored_ = true;
     11  // transportOk_ = true;
     12  // parmelaIgnored_ = true;
    1313}
    1414
     
    2626    tolerance_ = toleranceDef_;
    2727  }
     28
     29trivaluedBool elementFit::is_accepted_by_software(nomDeLogiciel soft) const {
     30  if ( soft == nomDeLogiciel::transport ) return ok;
     31  else if ( soft == nomDeLogiciel::parmela ) return warning;
     32  else return error;
     33}
     34
    2835
    2936 string* elementFit::getParametersString() const
  • Interface_Web/trunk/pspaWT/src/elementRfgun.cc

    r225 r243  
    1414      nbParam_ = elementName_.getElementNbParameters();
    1515      parametersString_ = new string[nbParam_+1];
    16       parmelaOk_ = true;
     16      //      parmelaOk_ = true;
    1717    }
    1818
     
    3838    nb_true_particles_ = defaultNb_true_particles_ ;
    3939  }
     40
     41trivaluedBool elementRfgun::is_accepted_by_software(nomDeLogiciel soft) const {
     42  cout << " elementRfgun : c'est le bon is_accepted_by_software " << endl;
     43  if ( soft == nomDeLogiciel::parmela ) return ok;
     44  else return error;
     45}
    4046
    4147 string* elementRfgun::getParametersString() const
  • Interface_Web/trunk/pspaWT/src/elementSoleno.cc

    r229 r243  
    1212  nbParam_ = elementName_.getElementNbParameters();
    1313  parametersString_ = new string[nbParam_+1];
    14   transportOk_ = true;
    15   parmelaOk_ = true;
     14  // transportOk_ = true;
     15  // parmelaOk_ = true;
    1616  //  transportElementName_ = "*SOLE*";
    1717}
     
    3030  }
    3131
     32trivaluedBool elementSoleno::is_accepted_by_software(nomDeLogiciel soft) const {
     33  if ( soft == nomDeLogiciel::transport ) return ok;
     34  else if ( soft == nomDeLogiciel::parmela ) return ok;
     35  else return error;
     36}
    3237
    3338
  • Interface_Web/trunk/pspaWT/src/particleBeam.cc

    r236 r243  
    22#include "mathematicalConstants.h"
    33#include "PhysicalConstants.h"
     4#include "mathematicalTools.h"
    45//#include <string>
    56#include <stdio.h>
     
    7980}
    8081
     82void particleBeam::setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles) {
     83  centroid_.clear();
     84  centroid_ = centroid;
     85  referenceParticle_ = referencePart;
     86  goodPartic_.clear();
     87  goodPartic_ = particles;
     88  particleRepresentationOk_ = true;
     89}
    8190
    8291
     
    208217
    209218
    210 bool particleBeam::setFromParmela(string workingDir,unsigned numeroElement, double referencefrequency) {
    211   unsigned  k;
    212   FILE* filefais;
    213   string nomfilefais = workingDir + "parmdesz";
    214   cout << " nom fichier desz : " << nomfilefais << endl;
    215   filefais = fopen(nomfilefais.c_str(), "r");
    216 
    217   if ( filefais == (FILE*)0 ) {
    218     cerr << " particleBeam::setFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;;
    219     return false;
    220   }
    221   else cout << " particleBeam::setFromParmela() : ouverture du fichier " << nomfilefais << endl;
    222 
    223   parmelaParticle partic;
    224   std::vector<parmelaParticle> faisceau;
    225 
    226   cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;
    227   unsigned indexElement = numeroElement-1;
     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;
    228237 
    229238
    230239
    231240
    232   int testNombrePartRef =0;
    233   double phaseRef;
    234 
    235   while( partic.readFromParmelaFile(filefais) > 0 ) {
    236     if ( partic.ne == (int)indexElement )
    237       {
    238         faisceau.push_back(partic);
    239 
    240         if ( partic.np == 1 ) {
    241           // en principe on est sur la particule de reference
    242           if ( fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.xxp) > EPSILON  || fabs(partic.yyp) > EPSILON) {
    243             printf(" ATTENTION part. reference douteuse  \n");
    244             partic.imprim();
    245           }
    246           phaseRef = partic.phi;
    247           TRIDVECTOR  posRef(partic.xx,partic.yy,0.0);
    248           TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
    249           referenceParticle_ = bareParticle(posRef, betagammaRef);
    250           testNombrePartRef++;
    251           if ( testNombrePartRef != 1 ) {
    252             cerr << " TROP DE PART. DE REF : " << testNombrePartRef << " !! " << endl;
    253             return false;
    254           }
    255         }
    256       }
    257   }
    258 
    259   if ( faisceau.size() == 0)
    260     {
    261       cerr << " particleBeam::setFromParmela echec lecture  element " << numeroElement << endl;
    262       return false;
    263     }
     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//     }
    264273 
    265   // facteur  c/ 360. pour calculer (c dphi) / (360.freq)
    266   // avec freq en Mhz et dphi en degres et résultat en cm:
    267   double FACTEUR =  83.3333;  // ameliorer la precision
    268 
    269 
    270 
    271   // pour l'instant on choisit un centroid nul;
    272   centroid_ = vector<double>(6,0.0);
    273 
    274   goodPartic_.clear();
    275   goodPartic_.resize(faisceau.size(), bareParticle());
    276   double x,xp,y,yp;
    277   double betagammaz;
    278   double betaz;
    279   double deltaz;
    280   double dephas;
    281   double g;
    282   TRIDVECTOR  pos;
    283   TRIDVECTOR betagamma;
    284   // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp
    285   // sont donnes en radians
    286   for ( k=0; k < faisceau.size(); k++) {
    287     x=faisceau.at(k).xx;
    288     xp=faisceau.at(k).xxp;
    289     y=faisceau.at(k).yy;
    290     yp=faisceau.at(k).yyp;
    291 
    292     // dephasage par rapport a la reference 
    293     dephas = faisceau.at(k).phi - phaseRef; // degrés
    294     g = faisceau.at(k).wz/ERESTMeV;
    295     betagammaz = faisceau.at(k).begamz;
    296     betaz = betagammaz/(g+1.0);
    297     deltaz = FACTEUR * betaz * dephas / referencefrequency;
    298     x += xp * deltaz;
    299     y += yp * deltaz;
    300     pos.setComponents(x,y,deltaz);
    301     betagamma.setComponents(xp*betagammaz, yp*betagammaz, betagammaz);
    302     goodPartic_.at(k) = bareParticle(pos,betagamma);
    303   }
    304   particleRepresentationOk_ = true;
    305   return true;
    306 }
     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// }
    307316
    308317
Note: See TracChangeset for help on using the changeset viewer.