Changeset 312 in PSPA
- Timestamp:
- Feb 5, 2013, 2:23:23 PM (11 years ago)
- 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 9 9 #define ELECTRONRADIUS 2.817940325e-13 // cm! 10 10 #define ERESTMeV 0.510998918 11 #define ERESTeV 0.510998918e+06 11 12 #define CLIGHT_E8 2.99792458 13 #define CLIGHT_m_per_ns 0.299792458 12 14 13 15 // facteurs de conversion des champs electriques (donnes en MV/cm) -
Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h
r306 r312 33 33 34 34 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; 36 36 37 37 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 17 17 protected: 18 18 19 TRIDVECTOR position_; 20 TRIDVECTOR betagamma_; 19 TRIDVECTOR position_; // cm 20 TRIDVECTOR betagamma_; // radians 21 21 double gamma_; 22 22 -
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r306 r312 44 44 */ 45 45 int getNumeroFromElementLabel(string); 46 abstractElement* getElementPointerFrom Index(int);46 abstractElement* getElementPointerFromNumero(int); 47 47 48 48 void initializeExecution(); -
Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
r257 r312 15 15 16 16 using 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; */33 17 34 18 … … 63 47 virtual ~particleBeam() {;} 64 48 65 // bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);66 49 void buildMomentRepresentation(); 67 50 -
Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h
r257 r312 6 6 typedef struct 7 7 { 8 unsigned firstElement; 9 unsigned lastElement; 8 unsigned firstElement; // numero premier element 9 unsigned lastElement; // numero dernier element 10 10 nomDeLogiciel software; 11 11 } sectionToExecute; -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h
r305 r312 14 14 softwareGenerator(); 15 15 16 bool beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles ); 16 17 17 18 public : … … 26 27 27 28 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); 32 30 33 31 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); 38 33 39 34 }; -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h
r305 r312 13 13 bool beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ); 14 14 15 bool beamToParmela(string workingDir, particleBeam* partic ); 16 15 17 public : 16 18 softwareParmela(globalParameters* globals, dataManager* beamLine); … … 21 23 virtual bool createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir); 22 24 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); 24 26 25 27 -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h
r305 r312 19 19 virtual bool createInputFile(string inputFileName, particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir); 20 20 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); 22 22 23 23 -
Interface_Web/trunk/pspaWT/sources/controler/src/bareParticle.cc
r257 r312 118 118 } 119 119 120 121 120 122 bool bareParticle::FileInput( ifstream& ifs) 121 123 { -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r308 r312 55 55 56 56 57 abstractElement* dataManager::getElementPointerFrom Index(int k){58 return pspa_->getBeamLine()->getAbstractElement(k );57 abstractElement* dataManager::getElementPointerFromNumero(int k){ 58 return pspa_->getBeamLine()->getAbstractElement(k-1); 59 59 } 60 60 … … 85 85 unsigned k,j; 86 86 diagnostic.clear(); 87 unsigned indexDeb, indexFin;87 unsigned numeroDeb, numeroFin; 88 88 cout << "controle execution : " << endl; 89 89 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 ) 93 93 { 94 94 diagnostic += " last element before first for job " + (jobList_[k]->software).getString() + " \n"; … … 96 96 break; 97 97 } 98 cout << " indexDeb= " << indexDeb << " indexFin= " << indexFin << endl;99 indexDeb--;100 indexFin--;98 cout << " numeroDeb= " << numeroDeb << " numeroFin= " << numeroFin << endl; 99 // indexDeb--; 100 // indexFin--; 101 101 102 102 abstractElement* elPtr; 103 103 string checkCompatibility; 104 resul = checkElementsForExec(jobList_[k]->software, indexDeb, indexFin, checkCompatibility);104 resul = checkElementsForExec(jobList_[k]->software, numeroDeb, numeroFin, checkCompatibility); 105 105 diagnostic += checkCompatibility; 106 106 } … … 110 110 111 111 112 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic)112 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned numeroDeb, unsigned numeroFin, string& diagnostic) 113 113 { 114 114 trivaluedBool resul = ok; … … 116 116 trivaluedBool accepted; 117 117 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); 120 120 accepted = elPtr->is_accepted_by_software(logiciel); 121 121 if(accepted == error ) { … … 192 192 resultatPartiel += " error creating input file \n"; 193 193 } else { 194 success = softw->execute( debut,fin,workingDir_,resultatPartiel);194 success = softw->execute(inputFileName, debut,fin,workingDir_,resultatPartiel); 195 195 if ( success ) { 196 196 success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir_); 197 197 if ( !success ) { 198 resultatPartiel += " reading t resultsfailed \n";198 resultatPartiel += " reading results failed \n"; 199 199 } 200 200 } 201 201 } 202 202 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 } 205 210 resul += resultatPartiel; 206 211 if ( !success ) break; … … 303 308 if ( numeroDeb < 1 ) numeroDeb = 1; 304 309 if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size(); 305 306 unsigned indexDeb = numeroDeb -1; 307 unsigned indexFin = numeroFin -1; 308 310 309 311 double longueur = 0.0; 310 312 double valeur = 0.0; … … 313 315 if ( type == "x" ) 314 316 { 315 for (k= indexDeb; k <= indexFin; k++)317 for (k= numeroDeb; k <= numeroFin; k++) 316 318 { 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(); 320 322 xcor.push_back(longueur); 321 323 ycor.push_back(valeur); -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r257 r312 81 81 82 82 void particleBeam::setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles) { 83 cout << " particleBeam::setWithParticles taille vect. part. " << particles.size() << endl; 83 84 centroid_.clear(); 84 85 centroid_ = centroid; … … 86 87 goodPartic_.clear(); 87 88 goodPartic_ = particles; 89 cout << " particleBeam::setWithParticles taille vect. part. ENREGISTRE " << goodPartic_.size() << endl; 90 // printAllXYZ(); 88 91 particleRepresentationOk_ = true; 89 92 } … … 112 115 113 116 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 ca118 // // 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 ca163 // // 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 reference251 // 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 precision277 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 yp294 // // sont donnes en radians295 // 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 reference302 // dephas = faisceau.at(k).phi - phaseRef; // degrés303 // 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 // }316 117 317 118 … … 358 159 double xx,yy,zz; 359 160 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; 361 164 } 362 165 } … … 421 224 double P_reference_MeV_sur_c = sqrt( gref*(gref+2) ); 422 225 226 cout << " gref = " << gref << " P_reference_MeV_sur_c = " << P_reference_MeV_sur_c << endl; 227 228 423 229 // initialisation des moments 424 230 razDesMoments(); … … 432 238 double PMeVsc; 433 239 double del; 434 vector<double> part(6 );240 vector<double> part(6, 0.0); 435 241 436 242 vector< vector<double> >& matrice = rij_.getMatrix(); -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc
r305 r312 1 1 #include "softwareGenerator.h" 2 2 #include "abstractElement.h" 3 #include "parmelaParticle.h" 3 #include "generatorParticle.h" 4 #include "mathematicalConstants.h" 5 #include "PhysicalConstants.h" 4 6 #include "dataManager.h" 5 7 … … 21 23 bool softwareGenerator::createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir) 22 24 { 23 24 25 if ( numeroDeb != numeroFin ) return false; 25 26 26 27 abstractElement* elPtr; 27 elPtr = dataManager_->getElementPointerFrom Index(numeroDeb);28 elPtr = dataManager_->getElementPointerFromNumero(numeroDeb); 28 29 29 30 if ( elPtr->getNomdElement().getElementType() != RFgun ) { … … 31 32 return false; 32 33 } 33 34 34 ofstream outfile; 35 35 string name = workingDir + inputFileName; … … 39 39 return false; 40 40 } 41 42 41 outfile << "&INPUT" << endl; 43 42 string fichier = "'" + workingDir + "faisceau.ini" + "'"; … … 50 49 return true; 51 50 } 51 52 53 bool 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 93 bool 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 111 bool 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 22 22 23 23 if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) { 24 cerr << " indexof 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; 31 31 32 32 ofstream outfile; … … 40 40 abstractElement* elPtr; 41 41 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; 46 49 } 47 50 else { … … 55 58 outfile << "RUN /n0=1 /ip=999 /freq=" << globParamPtr_->getFrequency() << " /z0=0.0 /W0=" << initalKineticEnergy << " /itype=1" << endl; 56 59 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++) 59 68 { 60 elPtr = dataManager_->getElementPointerFrom Index(k);69 elPtr = dataManager_->getElementPointerFromNumero(k); 61 70 outfile << elPtr->parmelaOutputFlow() << endl; 62 71 } … … 70 79 71 80 72 bool softwareParmela::execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul)81 bool softwareParmela::execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir,string& resul) 73 82 { 74 83 ostringstream sortie; 75 84 bool ExecuteStatus = true; 76 85 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 84 86 sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl; 85 87 … … 106 108 ExecuteStatus = false; 107 109 } 108 // else109 // {110 // ExecuteStatus = buildBeamAfterElements(numeroDeb,numeroFin, beamAfterElement, workingDir);111 // if ( !ExecuteStatus ) {112 // sortie << " reading parmdesz failed " << endl;113 // }114 115 // }116 110 } 117 111 … … 132 126 if (!beamFromParmela(workingDir,k, globParamPtr_->getFrequency(), centroid, refPart,particles )) 133 127 { 134 abstractElement* elem = dataManager_->getElementPointerFrom Index(k);128 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 135 129 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 136 130 int avantDernier = beams.size() -2; … … 160 154 161 155 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; 166 160 167 161 parmelaParticle partic; 168 162 std::vector<parmelaParticle> faisceau; 169 163 170 cout << " particleBeam::setFromParmela : numeroElement = " << numeroElement << endl;164 cout << " beamFromParmela : numeroElement = " << numeroElement << endl; 171 165 unsigned indexElement = numeroElement-1; 172 166 … … 203 197 if ( faisceau.size() == 0) 204 198 { 205 cerr << " particleBeam::setFromParmela echec lecture element " << numeroElement << endl;199 cerr << " beamFromParmela echec lecture element " << numeroElement << endl; 206 200 return false; 207 201 } … … 249 243 return true; 250 244 } 245 246 247 // sauvegarde d'un 'particleBeam' sur un fichier parmela, en guise d'INPUT 248 // pour l'instant de nom standard 'parin.input0' 249 bool 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 25 25 } 26 26 27 unsigned indexDeb = numeroDeb - 1;28 unsigned indexFin = numeroFin - 1;27 // unsigned indexDeb = numeroDeb - 1; 28 // unsigned indexFin = numeroFin - 1; 29 29 30 30 abstractElement* premierEl = NULL; 31 premierEl = dataManager_->getElementPointerFrom Index(indexDeb);31 premierEl = dataManager_->getElementPointerFromNumero(numeroDeb); 32 32 33 33 // ceinture et bretelles … … 89 89 90 90 abstractElement* elPtr; 91 for ( k= indexDeb; k <= indexFin; k++)91 for ( k=numeroDeb; k <= numeroFin; k++) 92 92 { 93 elPtr = dataManager_->getElementPointerFrom Index(k);93 elPtr = dataManager_->getElementPointerFromNumero(k); 94 94 outfile << elPtr->transportOutputFlow() << endl; 95 95 } … … 104 104 105 105 106 bool softwareTransport::execute( unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul)106 bool softwareTransport::execute(string inputFileName, unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul) 107 107 { 108 108 ostringstream sortie; … … 121 121 string transportJob = workingDir + "transport"; 122 122 transportJob += string(" < "); 123 transportJob += workingDir + "transport.input";123 transportJob += workingDir + inputFileName; 124 124 cout << " job transport= " << transportJob << endl; 125 125 … … 165 165 // string elemLabel = getLabelFromElementNumero (k); 166 166 167 abstractElement* ptr = dataManager_->getElementPointerFrom Index(k);167 abstractElement* ptr = dataManager_->getElementPointerFromNumero(k); 168 168 169 169 if ( ptr == NULL ) { 170 result = false; 171 break; 170 cout << " softwareTransport::buildBeamAfterElements pointeur nul sur element " << endl; 171 result = false; 172 break; 172 173 } 173 174 … … 178 179 if (!moments2FromTransport(workingDir, elemLabel, ptr->getNomdElement(),transpMoments ) ) 179 180 { 181 cout << " softwareTransport::buildBeamAfterElements plantage dans lecture moments " << endl; 180 182 result = false; 181 183 break; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r311 r312 446 446 choixElementDessin_->clear(); 447 447 int nombre = dtmanage_->getBeamLineSize(); 448 cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl; 449 448 450 for ( int numero =1; numero <= nombre; numero++) 449 451 { … … 553 555 double x= partic.at(i).getPosition().getComponent(0); 554 556 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 } 556 563 // cout << "x = " << x << " xp= " << xp << endl; 557 564 model->setData(i, 0, x); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r305 r312 288 288 warningDialog.exec(); 289 289 } 290 //cout << " PspaApplication : retour d'execution resultat = " << resultat << endl;290 cout << " PspaApplication : retour d'execution resultat = " << resultat << endl; 291 291 if (console) { 292 292 console->addConsoleMessage(resultat);
Note: See TracChangeset
for help on using the changeset viewer.