Changeset 243 in PSPA
- Timestamp:
- Jan 18, 2013, 10:02:58 PM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/cmt/requirements
r241 r243 17 17 18 18 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" 20 20 21 #macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DPSPA_DEBUG" Linux-x86_64 " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD "21 macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DPSPA_DEBUG" Linux-x86_64 " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD " 22 22 23 23 -
Interface_Web/trunk/pspaWT/include/GWt_abstractElement.h
r239 r243 5 5 #include "GWt_draggableImage.h" 6 6 #include "abstractElement.h" 7 #include "GWt_console.h" 7 8 8 9 #include <Wt/WDialog> -
Interface_Web/trunk/pspaWT/include/abstractElement.h
r229 r243 7 7 8 8 #include "nomdElements.h" 9 #include "nomDeLogiciel.h" 10 #include "trivaluedBool.h" 9 11 10 12 using namespace std; … … 14 16 protected : 15 17 16 bool parmelaOk_;17 bool parmelaIgnored_;18 bool transportOk_;18 /* bool parmelaOk_; */ 19 /* bool parmelaIgnored_; */ 20 /* bool transportOk_; */ 19 21 int nbParam_; 20 22 string* parametersString_; … … 50 52 51 53 /* string getElementImage() const; */ 52 53 54 /* string getElementName() const; */ 54 55 55 56 double getLenghtOfElement() const; 56 57 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; 61 62 virtual void setPhaseStep(double); 62 63 virtual double getInitialKineticEnergy() const; -
Interface_Web/trunk/pspaWT/include/dataManager.h
r236 r243 12 12 #include "beam2Moments.h" 13 13 14 typedef 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; 14 29 15 30 … … 31 46 void clearSectionToExecute(); 32 47 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 ); 34 49 public: 35 50 … … 56 71 void initializeExecution(string workingDir); 57 72 trivaluedBool checkExecute(string& diagnostic); 73 trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic); 58 74 bool executeTransport( unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul); 59 75 bool executeParmela( unsigned int numeroDeb, unsigned int numeroFin, string workingDir, string& resul); 76 bool launchJob(string commandLine, string& resul); 60 77 bool executeAll(string workingDir, string& resul); 61 78 void saveConfiguration(string workingDir, string nameOfFile); -
Interface_Web/trunk/pspaWT/include/elementBeam.h
r180 r243 30 30 ~elementBeam(); 31 31 32 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 32 33 33 34 -
Interface_Web/trunk/pspaWT/include/elementBend.h
r202 r243 43 43 double getLenghtOfElement() const; 44 44 45 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 46 45 47 46 48 virtual void setParametersString(string* param); -
Interface_Web/trunk/pspaWT/include/elementCell.h
r107 r243 46 46 ~elementCell() { ;} 47 47 48 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 48 49 49 50 virtual string* getParametersString() const; -
Interface_Web/trunk/pspaWT/include/elementDrift.h
r84 r243 18 18 ~elementDrift() {;} 19 19 20 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 21 22 20 23 virtual string* getParametersString() const; 21 24 -
Interface_Web/trunk/pspaWT/include/elementFit.h
r225 r243 29 29 ~elementFit() {;} 30 30 31 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 32 31 33 32 34 virtual void setParametersString(string* param); -
Interface_Web/trunk/pspaWT/include/elementRfgun.h
r155 r243 42 42 ~elementRfgun() {;} 43 43 44 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 45 44 46 virtual void setPhaseStep(double ph) { phaseStep_ = ph;} 45 47 -
Interface_Web/trunk/pspaWT/include/elementSoleno.h
r229 r243 32 32 ~elementSoleno() {;} 33 33 34 virtual trivaluedBool is_accepted_by_software(nomDeLogiciel soft) const; 35 34 36 virtual void setParametersString(string* param); 35 37 -
Interface_Web/trunk/pspaWT/include/particleBeam.h
r236 r243 10 10 11 11 #include "bareParticle.h" 12 #include "mathematicalTools.h"12 //#include "mathematicalTools.h" 13 13 #include "nomdElements.h" 14 14 #include "beam2Moments.h" … … 16 16 using namespace std; 17 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; 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 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; 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 33 34 34 … … 63 63 virtual ~particleBeam() {;} 64 64 65 bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);65 // bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency); 66 66 void buildMomentRepresentation(); 67 67 … … 92 92 93 93 void set2Moments(beam2Moments& moments); 94 94 void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles); 95 95 void printAllXYZ() const; 96 96 -
Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc
r240 r243 14 14 #include "mixedTools.h" 15 15 #include "nomdElements.h" 16 #include "GWt_tools.h"17 16 18 17 #include <Wt/WText> -
Interface_Web/trunk/pspaWT/src/GWt_dropZoneLigneFaiseau.cc
r242 r243 360 360 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 361 361 console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut"); 362 console->addConsoleMessage("remove from drag Zone");362 console->addConsoleMessage("remove from drag Zone"); 363 363 } 364 364 cout << "remove from drag Zone id" << layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) << " count:" << layout->count()<< endl; … … 369 369 layout->removeItem (layout->itemAt(2)); 370 370 #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 } 374 376 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 } 384 388 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 } 392 398 393 399 394 395 396 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 } 401 407 void GWt_dropZoneLigneFaiseau::addElement(WContainerWidget* elem){ 402 408 -
Interface_Web/trunk/pspaWT/src/abstractElement.cc
r229 r243 37 37 lenghtElem_ = defaultLength_; 38 38 aperture_ = defaultAperture_; 39 parmelaOk_ = false;40 parmelaIgnored_ = false;41 transportOk_ = false;39 // parmelaOk_ = false; 40 // parmelaIgnored_ = false; 41 // transportOk_ = false; 42 42 } 43 43 … … 102 102 } 103 103 104 bool abstractElement::is_parmela_element() const { 105 return parmelaOk_; 104 trivaluedBool abstractElement::is_accepted_by_software(nomDeLogiciel soft) const { 105 cout << " abstractElement : is_accepted_by_software suspect " << endl; 106 107 return error; 106 108 } 107 109 108 bool abstractElement::is_parmela_ignored() const {109 return parmelaIgnored_;110 }111 112 bool abstractElement::is_transport_element() const {113 return transportOk_;114 }115 110 116 111 double abstractElement::getInitialKineticEnergy() const { -
Interface_Web/trunk/pspaWT/src/beam2Moments.cc
r239 r243 90 90 getline(inp, buf); 91 91 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; 93 93 cout << " beam2Moments::readFromTransportOutput TEST= " << test << endl; 94 94 } -
Interface_Web/trunk/pspaWT/src/dataManager.cc
r237 r243 1 1 #include "dataManager.h" 2 #include "mathematicalConstants.h" 3 #include "PhysicalConstants.h" 2 4 3 5 #include <stdio.h> … … 49 51 if ( indexFin <= indexDeb ) 50 52 { 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"; 52 54 resul = error; 53 55 break; … … 56 58 indexDeb--; 57 59 indexFin--; 60 58 61 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; 95 65 } 96 66 cout << " data manager renvoie resul = " << resul << endl; 97 67 return resul; 68 } 69 70 trivaluedBool 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 91 bool 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; 98 112 } 99 113 … … 120 134 cout << " job transport= " << transportJob << endl; 121 135 122 ofstream outfile;136 ofstream outfile; 123 137 string nameOut = workingDir + "transport.output"; 124 138 125 139 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) { 128 147 sortie << " launching of transport failed " << endl; 129 148 ExecuteStatus = false; … … 133 152 outfile.open(nameOut.c_str(), ios::out); 134 153 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 } 139 158 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(); 152 169 unsigned k; 153 170 for ( k= numeroDeb; k <= numeroFin; k++) … … 161 178 162 179 if (!moments2FromTransport(workingDir, elemLabel, ptr->getNomdElement(),transpMoments ) ) 163 // if (!diagnosticBeam_.back().setFromTransport(workingDir, elemLabel, ptr->getNomdElement() ) )164 180 { 165 181 sortie << " reading transport output failed " << endl; … … 172 188 else currentBeam_ = NULL; 173 189 } 174 pclose(pp);190 // pclose(pp); 175 191 } 176 192 resul = sortie.str(); … … 196 212 parmelaJob += string(" "); 197 213 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) { 202 220 sortie << " launching of parmela failed " << endl; 203 221 ExecuteStatus = false; … … 205 223 else { 206 224 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"); 212 227 if ( nn == string::npos ) 213 228 { … … 221 236 { 222 237 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 )) 224 242 { 225 243 abstractElement* elem = elementsGallery_.getElementPointerFromNumero(k); 226 if ( elem->is_ parmela_ignored()) {244 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 227 245 int avantDernier = diagnosticBeam_.size() -2; 228 246 diagnosticBeam_.back() = diagnosticBeam_.at(avantDernier); … … 233 251 } 234 252 } 253 diagnosticBeam_.back().setWithParticles(centroid, refPart,particles); 235 254 } 236 255 … … 238 257 else currentBeam_ = NULL; 239 258 } 240 pclose(pp);259 // pclose(pp); 241 260 } 242 261 … … 606 625 607 626 } 627 628 629 bool 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 11 11 nbParam_ = elementName_.getElementNbParameters(); 12 12 parametersString_ = new string[nbParam_+1]; 13 transportOk_ = true;13 // transportOk_ = true; 14 14 } 15 15 … … 35 35 p0_ = p0Def_; 36 36 } 37 38 trivaluedBool elementBeam::is_accepted_by_software(nomDeLogiciel soft) const { 39 if ( soft == nomDeLogiciel::transport ) return ok; 40 else return error; 41 } 37 42 38 43 string* elementBeam::getParametersString() const { -
Interface_Web/trunk/pspaWT/src/elementBend.cc
r225 r243 10 10 nbParam_ = elementName_.getElementNbParameters(); 11 11 parametersString_ = new string[nbParam_+1]; 12 transportOk_ = true;13 parmelaOk_ = true;12 // transportOk_ = true; 13 // parmelaOk_ = true; 14 14 } 15 15 … … 55 55 } 56 56 57 trivaluedBool 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 } 57 62 58 63 -
Interface_Web/trunk/pspaWT/src/elementCell.cc
r225 r243 15 15 nbParam_ = elementName_.getElementNbParameters(); 16 16 parametersString_ = new string[nbParam_+1]; 17 parmelaOk_ = true;17 // parmelaOk_ = true; 18 18 } 19 19 … … 37 37 scaleFactor_ = scaleFactorDef_; 38 38 } 39 40 trivaluedBool elementCell::is_accepted_by_software(nomDeLogiciel soft) const { 41 if ( soft == nomDeLogiciel::parmela ) return ok; 42 else return error; 43 } 39 44 40 45 string* elementCell::getParametersString() const -
Interface_Web/trunk/pspaWT/src/elementDrift.cc
r225 r243 11 11 nbParam_ = elementName_.getElementNbParameters(); 12 12 parametersString_ = new string[nbParam_+1]; 13 parmelaOk_ = true;14 transportOk_ = true;13 // parmelaOk_ = true; 14 // transportOk_ = true; 15 15 // transportElementName_ = "*DRIFT*"; 16 16 } 17 18 trivaluedBool 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 17 24 18 25 string* elementDrift::getParametersString() const -
Interface_Web/trunk/pspaWT/src/elementFit.cc
r230 r243 9 9 nbParam_ = elementName_.getElementNbParameters(); 10 10 parametersString_ = new string[nbParam_+1]; 11 transportOk_ = true;12 parmelaIgnored_ = true;11 // transportOk_ = true; 12 // parmelaIgnored_ = true; 13 13 } 14 14 … … 26 26 tolerance_ = toleranceDef_; 27 27 } 28 29 trivaluedBool 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 28 35 29 36 string* elementFit::getParametersString() const -
Interface_Web/trunk/pspaWT/src/elementRfgun.cc
r225 r243 14 14 nbParam_ = elementName_.getElementNbParameters(); 15 15 parametersString_ = new string[nbParam_+1]; 16 parmelaOk_ = true;16 // parmelaOk_ = true; 17 17 } 18 18 … … 38 38 nb_true_particles_ = defaultNb_true_particles_ ; 39 39 } 40 41 trivaluedBool 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 } 40 46 41 47 string* elementRfgun::getParametersString() const -
Interface_Web/trunk/pspaWT/src/elementSoleno.cc
r229 r243 12 12 nbParam_ = elementName_.getElementNbParameters(); 13 13 parametersString_ = new string[nbParam_+1]; 14 transportOk_ = true;15 parmelaOk_ = true;14 // transportOk_ = true; 15 // parmelaOk_ = true; 16 16 // transportElementName_ = "*SOLE*"; 17 17 } … … 30 30 } 31 31 32 trivaluedBool 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 } 32 37 33 38 -
Interface_Web/trunk/pspaWT/src/particleBeam.cc
r236 r243 2 2 #include "mathematicalConstants.h" 3 3 #include "PhysicalConstants.h" 4 #include "mathematicalTools.h" 4 5 //#include <string> 5 6 #include <stdio.h> … … 79 80 } 80 81 82 void 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 } 81 90 82 91 … … 208 217 209 218 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; 228 237 229 238 230 239 231 240 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 reference242 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 // } 264 273 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 precision268 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 yp285 // sont donnes en radians286 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 reference293 dephas = faisceau.at(k).phi - phaseRef; // degrés294 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 // } 307 316 308 317
Note: See TracChangeset
for help on using the changeset viewer.