Changeset 373 in PSPA


Ignore:
Timestamp:
Mar 6, 2013, 5:54:55 PM (11 years ago)
Author:
touze
Message:

recupere travail sur elt snapshot

Location:
Interface_Web/trunk/pspaWT/sources/controler
Files:
5 edited

Legend:

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

    r359 r373  
    99class elementSnapshot : public abstractElement
    1010{
    11    
     11  string snapshotFile_;
    1212  void setDefaultValues();
    1313  void setDefaults();
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc

    r371 r373  
    106106}
    107107
    108 trivaluedBool abstractElement::setSoftware(nomDeLogiciel prog) {
    109     if (acceptableSoftware_.size() == 0) {
    110         return TBoolError;
     108trivaluedBool abstractElement::setSoftware(nomDeLogiciel prog)
     109{
     110  trivaluedBool tb = TBoolError;
     111  if (std::find(acceptableSoftware_.begin(),acceptableSoftware_.end(),prog) != acceptableSoftware_.end()) {
     112    tb = TBoolOk;
     113  } else if (std::find(ignoreSoftware_.begin(),ignoreSoftware_.end(),prog) != ignoreSoftware_.end()) {
     114    tb = TBoolIgnore;
     115  } else {
     116    tb = TBoolError;
     117  }
     118 
     119  if ((tb == TBoolOk) || (tb == TBoolIgnore)) {
     120    if (prog == nomDeLogiciel::parmela) {
     121      abstractSoftware_ = new softwareParmela();
     122    } else if (prog == nomDeLogiciel::transport) {
     123      abstractSoftware_ = new softwareTransport();
     124    } else if (prog == nomDeLogiciel::generator) {
     125      abstractSoftware_ = new softwareGenerator();
     126    } else if (prog == nomDeLogiciel::test) {
     127      abstractSoftware_ = new softwareTest();
     128    } else if (prog == nomDeLogiciel::unknownSoftware) {
     129      abstractSoftware_ = NULL;
    111130    }
    112    
    113     trivaluedBool tb = TBoolError;
    114     if ( std::find(acceptableSoftware_.begin(), acceptableSoftware_.end(), prog) != acceptableSoftware_.end()) {
    115         tb = TBoolOk;
    116     } else if ( std::find(ignoreSoftware_.begin(), ignoreSoftware_.end(), prog) != ignoreSoftware_.end()) {
    117         tb =TBoolIgnore;
    118     } else {
    119         tb = TBoolError;
    120     }
    121 
    122     if ((tb == TBoolOk) || (tb == TBoolIgnore)) {
    123       if (prog == nomDeLogiciel::parmela) {
    124         abstractSoftware_ = new softwareParmela();
    125       } else if (prog == nomDeLogiciel::transport) {
    126         abstractSoftware_ = new softwareTransport();
    127       } else if (prog == nomDeLogiciel::generator) {
    128         abstractSoftware_ = new softwareGenerator();
    129       } else if (prog == nomDeLogiciel::test) {
    130         abstractSoftware_ = new softwareTest();
    131       } else if (prog == nomDeLogiciel::unknownSoftware) {
    132         abstractSoftware_ = NULL;
    133       }
    134     }
    135     return tb;
     131  }
     132  return tb;
    136133}
    137134
    138 
    139135void abstractElement::registerAcceptableSoftware(nomDeLogiciel abs,trivaluedBool b) {
    140     if (b == TBoolIgnore) {
    141         ignoreSoftware_.push_back(abs);
    142     } else if (b == TBoolOk){
    143         acceptableSoftware_.push_back(abs);
    144     }
     136  if (b == TBoolIgnore) {
     137    ignoreSoftware_.push_back(abs);
     138  } else if (b == TBoolOk) {
     139    acceptableSoftware_.push_back(abs);
     140  }
    145141}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc

    r369 r373  
    44#include "mixedTools.h"
    55
     6static int incr = 0;
     7
    68elementSnapshot::elementSnapshot() : abstractElement()
    79{
    8     setDefaultValues();
    9     setDefaults();
    10     elementName_ = nomdElements("snapshot");
    11     nbParam_ = elementName_.getElementNbParameters();
    12     parametersString_ = new string[nbParam_+1];
    13     registerAcceptableSoftware(nomDeLogiciel::transport, TBoolIgnore);
    14     registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolIgnore);
    15     registerAcceptableSoftware(nomDeLogiciel::generator, TBoolIgnore);
    16     registerAcceptableSoftware(nomDeLogiciel::test, TBoolIgnore);
     10  setDefaultValues();
     11  setDefaults();
     12  elementName_ = nomdElements("snapshot");
     13  nbParam_ = elementName_.getElementNbParameters();
     14  parametersString_ = new string[nbParam_+1];
     15  registerAcceptableSoftware(nomDeLogiciel::transport, TBoolIgnore);
     16  registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolIgnore);
     17  registerAcceptableSoftware(nomDeLogiciel::generator, TBoolIgnore);
     18  registerAcceptableSoftware(nomDeLogiciel::test, TBoolIgnore);
    1719}
    1820
     
    2527{
    2628  label_ = defaultLabel_;
     29
     30  incr++;
     31  if(incr < 10) {
     32    snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr);
     33  } else if(incr >= 10 && incr < 100) {
     34    snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr);
     35  } else {
     36    snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr);
     37  }
    2738}
    28 
    2939
    3040string* elementSnapshot::getParametersString() const
     
    3343  parametersString_[++compteur] = mixedTools::intToString(nbParam_);
    3444  parametersString_[++compteur] = label_;
     45  parametersString_[++compteur] = snapshotFile_;
    3546 
    3647  if ( compteur != nbParam_ ) {
    37     cerr << " elementSnapshot::getParametersString() : ERROR parameters doesnt match " << endl;
     48    cerr << "ERROR::elementSnapshot::getParametersString() : " << nbParam_ << endl;
    3849    return NULL;
    3950  }
     
    5162  int compteur = -1;
    5263  int nbparam = atoi(param[++compteur].c_str());
    53   if ( nbparam != nbParam_ )
    54     {
    55       cerr << " elementSnaphot:: setParametersString parameters do not match for a DRIFT";
    56       return;
    57     }
    58 
     64  if ( nbparam != nbParam_ )  {
     65    cerr << " elementSnaphot:: setParametersString parameters do not match for a DRIFT";
     66    return;
     67  }
     68 
    5969  label_ = param[++compteur];
    6070}
     
    6575}
    6676
    67 
    6877string elementSnapshot::transportOutputFlow() const
    6978{
    7079  return string(" ");
    7180}
    72 
    7381
    7482string elementSnapshot::FileOutputFlow() const
     
    7785  sortie << elementName_.getElementLabel() << endl;
    7886  sortie  << label_ << endl;
     87  sortie << snapshotFile_ << endl;
    7988  return sortie.str();
    8089}
     
    8392{
    8493  ifs >> label_;
     94  ifs >> snapshotFile_;
    8595}
    8696
     
    8999  string txt = ""; 
    90100  txt += label_;
     101  txt += "\nname of file for snapshot : ";
     102  txt += snapshotFile_;
    91103  return txt;
    92104}
  • Interface_Web/trunk/pspaWT/sources/controler/src/nomdElements.cc

    r369 r373  
    7070  case soleno :   return 5;
    7171  case fit :   return 4;
    72   case snapshot : return 1;
     72  case snapshot : return 2;
    7373  default : return 0;
    7474  }
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc

    r371 r373  
    115115{
    116116  bool result = true;
    117   cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl;
     117  //cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl;
    118118 
    119119  // index du premier element de parmela
     
    123123    {
    124124      abstractElement* elem = dataManager_->getElementPointerFromNumero(k);
    125      
     125   
    126126      // si l'element est un snapshot, recuperer la sortie precedente
    127127      if(elem->getNomdElement().getElementType() == snapshot) {
     
    138138      beams.push_back(particleBeam());
    139139      cout << " creation diagn. no " << beams.size() << " par PARMELA " << endl;
     140
    140141      vector<double> centroid;
    141142      bareParticle refPart;
     
    166167
    167168bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles )
    168 {
    169    
    170     string nomfilefais = workingDir + "parmdesz";
    171     cout << " nom fichier desz : " << nomfilefais << endl;
    172     FILE *filefais = fopen(nomfilefais.c_str(), "r");
    173    
    174     if ( filefais == (FILE*)0 ) {
    175         dataManager_->consoleMessage(" beamFromParmela() erreur a l'ouverture du fichier 'parmdesz'");
    176         cerr << " beamFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;
    177         return false;
    178     } else
    179         cout << " beamFromParmela() : ouverture du fichier " << nomfilefais << endl;
    180    
    181     parmelaParticle partic;
    182     std::vector<parmelaParticle> faisceau;
    183     int testNombrePartRef =0;
    184     double phaseRef = 0.0;
    185    
    186     while( partic.readFromParmelaFile(filefais) > 0 )
    187     {
    188        
    189         if ( partic.ne == (int)numeroParmel ) {
    190             if ( partic.np == 1 ) {
    191                 // en principe on est sur la particule de reference
    192                 if ( fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.xxp) > EPSILON  || fabs(partic.yyp) > EPSILON) {
    193                     printf(" ATTENTION part. reference douteuse  \n");
    194                     partic.imprim();
    195                 }
    196                 phaseRef = partic.phi;
    197                
    198                 // le 'z' est 'absolu' (le long de la trajectoire)
    199                 TRIDVECTOR  posRef(partic.xx,partic.yy,partic.z);
    200                 TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
    201                 refPart = bareParticle(posRef, betagammaRef);
    202                 testNombrePartRef++;
    203                 if ( testNombrePartRef != 1 ) {
    204                     dataManager_->consoleMessage(" beamFromParmela : nombre de part. de ref different de 1 :");
    205                     cerr << " nombre de part. de ref different de 1 : " << testNombrePartRef << " !! " << endl;
    206                     return false;
    207                 }
    208             }
    209             faisceau.push_back(partic);
    210         }
     169{   
     170  string nomfilefais = workingDir + "parmdesz";
     171  cout << " nom fichier desz : " << nomfilefais << endl;
     172  FILE *filefais = fopen(nomfilefais.c_str(), "r");
     173 
     174  if ( filefais == (FILE*)0 ) {
     175    dataManager_->consoleMessage(" beamFromParmela() erreur a l'ouverture du fichier 'parmdesz'");
     176    cerr << " beamFromParmela() erreur a l'ouverture du fichier" << nomfilefais  << endl;
     177    return false;
     178  } else
     179    cout << " beamFromParmela() : ouverture du fichier " << nomfilefais << endl;
     180 
     181  parmelaParticle partic;
     182  std::vector<parmelaParticle> faisceau;
     183  int testNombrePartRef =0;
     184  double phaseRef = 0.0;
     185 
     186  while( partic.readFromParmelaFile(filefais) > 0 )
     187    {
     188     
     189      if ( partic.ne == (int)numeroParmel ) {
     190        if ( partic.np == 1 ) {
     191          // en principe on est sur la particule de reference
     192          if ( fabs(partic.xx) > EPSILON || fabs(partic.yy) > EPSILON || fabs(partic.xxp) > EPSILON  || fabs(partic.yyp) > EPSILON) {
     193            printf(" ATTENTION part. reference douteuse  \n");
     194            partic.imprim();
     195          }
     196          phaseRef = partic.phi;
     197         
     198          // le 'z' est 'absolu' (le long de la trajectoire)
     199          TRIDVECTOR  posRef(partic.xx,partic.yy,partic.z);
     200          TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
     201          refPart = bareParticle(posRef, betagammaRef);
     202          testNombrePartRef++;
     203          if ( testNombrePartRef != 1 ) {
     204            dataManager_->consoleMessage(" beamFromParmela : nombre de part. de ref different de 1 :");
     205            cerr << " nombre de part. de ref different de 1 : " << testNombrePartRef << " !! " << endl;
     206            return false;
     207          }
     208        }
     209        faisceau.push_back(partic);
     210      }
    211211    } //while
    212    
    213     if ( faisceau.size() == 0)
    214     {
    215         string stringNum = mixedTools::intToString( (int)numeroParmel );
    216         dataManager_->consoleMessage("beamFromParmela echec lecture  element numero relatif  parmela : " + stringNum);
    217         cerr << " beamFromParmela echec lecture  element numero relatif  parmela " << numeroParmel << endl;
    218         return false;
    219     }
    220    
    221     // facteur  c/ 360. pour calculer (c dphi) / (360.freq)
    222     // avec freq en Mhz et dphi en degres et résultat en cm:
    223     double FACTEUR =  83.3333;  // ameliorer la precision
    224    
    225     // pour l'instant on choisit un centroid nul;
    226     centroid.clear();
    227     centroid = vector<double>(6,0.0);
    228    
    229     particles.clear();
    230     particles.resize(faisceau.size(), bareParticle());
    231     double x,xp,y,yp;
    232     double betagammaz;
    233     double betaz;
    234     double deltaz;
    235     double dephas;
    236     double g;
    237     TRIDVECTOR  pos;
    238     TRIDVECTOR betagamma;
    239     // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp
    240     // sont donnes en radians
    241     for (unsigned k = 0; k < faisceau.size(); k++) {
    242         x= faisceau.at(k).xx;
    243         xp=faisceau.at(k).xxp;
    244         y= faisceau.at(k).yy;
    245         yp=faisceau.at(k).yyp;
    246         // dephasage par rapport a la reference
    247         dephas = faisceau.at(k).phi - phaseRef; // degrés
    248         g = faisceau.at(k).wz/EREST_MeV;
    249         betagammaz = faisceau.at(k).begamz;
    250         betaz = betagammaz/(g+1.0);
    251         deltaz = FACTEUR * betaz * dephas / referencefrequency;
    252         x += xp * deltaz;
    253         y += yp * deltaz;
    254         pos.setComponents(x,y,deltaz);
    255         betagamma.setComponents(xp*betagammaz, yp*betagammaz, betagammaz);
    256         particles.at(k) = bareParticle(pos,betagamma);
    257     }
    258    
    259     return true;
     212 
     213  if ( faisceau.size() == 0)
     214    {
     215      string stringNum = mixedTools::intToString( (int)numeroParmel );
     216      dataManager_->consoleMessage("beamFromParmela echec lecture  element numero relatif  parmela : " + stringNum);
     217      cerr << " beamFromParmela echec lecture  element numero relatif  parmela " << numeroParmel << endl;
     218      return false;
     219    }
     220 
     221  // facteur  c/ 360. pour calculer (c dphi) / (360.freq)
     222  // avec freq en Mhz et dphi en degres et résultat en cm:
     223  double FACTEUR =  83.3333;  // ameliorer la precision
     224 
     225  // pour l'instant on choisit un centroid nul;
     226  centroid.clear();
     227  centroid = vector<double>(6,0.0);
     228 
     229  particles.clear();
     230  particles.resize(faisceau.size(), bareParticle());
     231  double x,xp,y,yp;
     232  double betagammaz;
     233  double betaz;
     234  double deltaz;
     235  double dephas;
     236  double g;
     237  TRIDVECTOR  pos;
     238  TRIDVECTOR betagamma;
     239  // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp
     240  // sont donnes en radians
     241  for (unsigned k = 0; k < faisceau.size(); k++) {
     242    x= faisceau.at(k).xx;
     243    xp=faisceau.at(k).xxp;
     244    y= faisceau.at(k).yy;
     245    yp=faisceau.at(k).yyp;
     246    // dephasage par rapport a la reference
     247    dephas = faisceau.at(k).phi - phaseRef; // degrés
     248    g = faisceau.at(k).wz/EREST_MeV;
     249    betagammaz = faisceau.at(k).begamz;
     250    betaz = betagammaz/(g+1.0);
     251    deltaz = FACTEUR * betaz * dephas / referencefrequency;
     252    x += xp * deltaz;
     253    y += yp * deltaz;
     254    pos.setComponents(x,y,deltaz);
     255    betagamma.setComponents(xp*betagammaz, yp*betagammaz, betagammaz);
     256    particles.at(k) = bareParticle(pos,betagamma);
     257  }
     258 
     259  return true;
    260260}
    261261
Note: See TracChangeset for help on using the changeset viewer.