Changeset 482 in PSPA for Interface_Web/trunk/pspaWT/sources/controler
- Timestamp:
- Jan 21, 2014, 1:52:16 PM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources/controler
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/beam2Moments.h
r386 r482 19 19 20 20 public : 21 21 22 22 beam2Moments(); 23 24 ~beam2Moments();23 24 ~beam2Moments(); 25 25 26 26 27 beam2Moments( beam2Moments& tm);27 beam2Moments( beam2Moments& tm); 28 28 29 beam2Moments(const beam2Moments& tm);29 beam2Moments(const beam2Moments& tm); 30 30 31 beam2Moments(double x, double xp, double y, double yp, double dl, double del);31 beam2Moments(double x, double xp, double y, double yp, double dl, double del); 32 32 33 // const vector< vector<double> >& getMoments() const;34 vector< vector<double> >& getMatrix();35 void raz();33 // const vector< vector<double> >& getMoments() const; 34 vector< vector<double> >& getMatrix(); 35 const vector< vector<double> >& getMoments() const; 36 36 37 // void readFromTransportOutput(ifstream& inp); 38 bool readFromTransportOutput(stringstream& inp); 39 string writeToTransportInput(double P0) const; 37 void raz(); 40 38 41 void impression() const; 39 // void readFromTransportOutput(ifstream& inp); 40 bool readFromTransportOutput(stringstream& inp); 41 string writeToTransportInput(double P0) const; 42 43 void impression() const; 42 44 43 45 // operators -
Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h
r480 r482 39 39 inline std::vector< abstractElement* > getElements() {return elements_;}; 40 40 41 inline sector* getSector() const {return sector_;}; 42 41 43 /** 42 44 Get the last element of this section -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareMadx.h
r472 r482 8 8 class softwareMadx : public abstractSoftware 9 9 { 10 string BEAMcommand(particleBeam*) const; 11 string RFGunData(const vector<statements>&) const; 10 12 string inputFormat(const vector<statements>&) const; 11 13 … … 13 15 14 16 softwareMadx(); 15 softwareMadx(string,sectionToExecute*, 17 softwareMadx(string,sectionToExecute*,dataManager*); 16 18 virtual ~softwareMadx() {;} 17 19 18 virtual bool createInputFile(particleBeam*, 20 virtual bool createInputFile(particleBeam*,string); 19 21 virtual bool execute(string); 20 22 virtual bool buildBeamAfterElements(string); -
Interface_Web/trunk/pspaWT/sources/controler/src/beam2Moments.cc
r386 r482 49 49 } 50 50 51 const vector< vector<double> >& beam2Moments::getMoments() const 52 { 53 return rij_secondOrderMoments_; 54 } 51 55 52 56 void beam2Moments::impression() const { -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r481 r482 78 78 string workingDir = pspa_->getWorkingDir(); 79 79 80 81 80 // Main loop ! 82 for(unsigned k = 0; k < jobList_.size(); k++) { 83 sector* sector = jobList_[k]; 84 85 // for the moment, we put everything in one line without loops 86 for (unsigned int l=0; l <sector->getSectionsToExecute().size(); l++) { 87 sectionToExecute* section = sector->getSectionsToExecute()[l]; 88 abstractSoftware* softw = section->getSoftware(); 81 cout << " dataManager::executeAll #jobList_= " << jobList_.size() << endl; 82 for(unsigned k = 0; k < jobList_.size(); k++) 83 { 84 sector* sector = jobList_[k]; 85 cout << " dataManager::executeAll sector name= " << sector->getName() << endl; 86 cout << " dataManager::executeAll #sectionsToExecute= " << sector->getSectionsToExecute().size() << endl; 89 87 90 #if BAVARD > 0 91 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl; 92 #endif 93 88 // for the moment, we put everything in one line without loops 89 for(unsigned int l = 0; l < sector->getSectionsToExecute().size(); l++) 90 { 91 sectionToExecute* section = sector->getSectionsToExecute()[l]; 92 abstractSoftware* softw = section->getSoftware(); 93 94 94 //cout << "k= " << k << ", de " << jobList_[k]->getFirstElement()->getLabel() << " Ã " << jobList_[k]->getLastElement()->getLabel() << " avec " << softw->getName() << endl; 95 95 … … 99 99 break; 100 100 } 101 // END OF FIXME102 101 102 success = softw->createInputFile(sector->getParticleBeam(),workingDir); 103 103 if ( success ) { 104 104 success = softw->execute(workingDir); … … 110 110 if ( success && (diagnosticBeam_.size() > 0)) { 111 111 sector->setParticleBeam(&diagnosticBeam_.at(indexElementToIndexDiag_.back())); 112 cout << " executetermine avec succes " << endl;112 cout << " dataManager::executeAll termine avec succes " << endl; 113 113 } else { 114 114 sector->setParticleBeam(NULL); 115 cout << " executetermine en ECHEC " << endl;115 cout << " dataManager::executeAll termine en ECHEC " << endl; 116 116 } 117 117 if ( !success ) break; 118 118 119 119 #if BAVARD > 0 120 121 122 123 124 125 120 cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; 121 cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; 122 std::vector< abstractElement* > elements = section->getElements(); 123 for (unsigned j = 0; j < elements.size(); j++) { 124 cout << "[" << j << "] " << elements[j]->getNomdElement().getExpandedName() << endl; 125 } 126 126 #endif 127 } //l 128 } //k 127 } //l 128 } //k 129 129 130 // if ( currentBeam_deprecated_ ) { 130 131 // string aml_file = workingDir + "/" + "faisceau_final" + ".aml"; … … 133 134 // currentBeam_deprecated_->readFromAMLFile(aml_file); 134 135 // } 135 cout << " dataManager::executeAll() " << endl; 136 136 137 137 return success; 138 138 } -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r455 r482 357 357 vector<double> part(6, 0.0); 358 358 359 359 vector< vector<double> >& matrice = rij_.getMatrix(); 360 360 361 361 TRIDVECTOR positionDeployee; -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareMadx.cc
r472 r482 3 3 #include "dataManager.h" 4 4 5 #include "mathematicalConstants.h" 6 #include "PhysicalConstants.h" 7 5 8 softwareMadx::softwareMadx() : abstractSoftware() 6 9 { … … 12 15 nameOfSoftware_ = nomDeLogiciel("madx"); 13 16 17 registerElement(nomdElements::RFgun,TBoolOk); 14 18 registerElement(nomdElements::drift,TBoolOk); 15 19 registerElement(nomdElements::mpole,TBoolOk); 16 20 } 17 21 18 bool softwareMadx::createInputFile(particleBeam* beamBefore, 22 bool softwareMadx::createInputFile(particleBeam* beamBefore,string workingDir) 19 23 { 20 24 cout << "***********************************" << endl; 21 25 cout << " softwareMadx::createInputFile(...) " << endl << endl; 22 23 26 dataManager_->consoleMessage(" softwareMadx::createInputFile"); 24 27 … … 32 35 } 33 36 34 cout << " softwareMadx::createInputFile(...) lecture des elts " << endl; 35 37 sector* sector= getSectionToExecute()->getSector(); 38 cout << " softwareMadx::createInputFile sector " << sector->getName() << endl; 39 /////////////////////////////////////////// 40 41 unsigned firstIndex= 0; 42 string sbeam; 43 abstractElement* elPtr; 44 elPtr = getSectionToExecute()->getElements().front(); 45 46 // le 1er elt n'est pas RFGun 47 if(elPtr->getNomdElement().getElementType() != nomdElements::RFgun) { 48 49 if(beamBefore == NULL) { 50 // il n'y a pas de faisceau : erreur 51 dataManager_->consoleMessage(" softwareMadx::createInputFile : no input beam, input file not created"); 52 return false; 53 } else { 54 // il y a un faisceau : on le met au format madx 55 dataManager_->consoleMessage(" softwareMadx::createInputFile : extract from input beam the quantities to be supplied to the madx BEAM command"); 56 57 if (beamBefore->particleRepresentationOk()) { 58 // le faisceau est représenté à la "parmela" 59 cout << "passsage de la représentation macroparticules à la representation moments" << endl; 60 beamBefore->buildMomentRepresentation(); 61 } else if(beamBefore->momentRepresentationOk()) { 62 // le faisceau est représenté à la "transport" 63 cout << "le faisceau est représenté par moments" << endl; 64 } else { 65 // représentation ni "macroparticules" ni "moments" 66 dataManager_->consoleMessage(" softwareMadx::createInputFile : that's unclear: the beam is represented neither by macroparticles neither by moments"); 67 return false; 68 } 69 70 sbeam = BEAMcommand(beamBefore); 71 } 72 73 // le 1er elt est RFGun 74 } else { 75 firstIndex = 1; 76 dataManager_->consoleMessage(" softwareMadx::createInputFile : set from RF cavity the quantities to be supplied to the madx BEAM command"); 77 sbeam = RFGunData(elPtr->parametersToSoftware()); 78 } 79 /////////////////////////////////////////// 80 36 81 // element label ////////////////////////// 37 38 82 outfile << endl; // saut de ligne 39 83 40 abstractElement* elPtr; 41 std::vector <abstractElement*> elements = getSectionToExecute()->getElements(); 42 for(unsigned k = 0; k < elements.size(); k++) 84 ostringstream os; 85 os << "L: line=("; 86 unsigned nElts= getSectionToExecute()->getElements().size(); 87 for(unsigned k = firstIndex; k < nElts; k++) 43 88 { 44 elPtr = elements[k];45 //cout << " debug:: element [" << k << "] " << elPtr->getNomdElement().getExpandedName() << endl;89 elPtr = getSectionToExecute()->getElements()[k]; 90 cout << " debug:: element [" << k << "] " << elPtr->getNomdElement().getExpandedName() << endl; 46 91 vector<statements> v= elPtr->parametersToSoftware(); 47 92 outfile << inputFormat(v); 48 } 49 50 // sublines /////////////////////////////// 51 93 94 if(k < nElts-1) 95 os << elPtr->getLabel() << ","; 96 else 97 os << elPtr->getLabel() << ");" << endl; 98 } 99 100 // lines/sublines /////////////////////////////// 52 101 outfile << endl; // saut de ligne 53 54 //_______________________________________________________ 55 // FIXME Francois !!!!! 56 //_______________________________________________________ 57 /* 58 vector<statements> u = sectParamPtr_->getSectors(); 59 for(unsigned int i = 0; i < u.size(); i++) { 60 ostringstream os; 61 os << u.at(i).first << ": line=("; 62 unsigned ai = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(0)); 63 unsigned bi = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(1)); 64 65 std::vector <abstractElement*> elements = getSectionToExecute()->getElements(); 66 for(unsigned k = 0; k < elements.size(); k++) { 67 elPtr = elements[k]; 68 69 if(k >= ai && k <= bi) { 70 if(k == bi) 71 os << elPtr->getLabel() <<");"; 72 else 73 os << elPtr->getLabel() <<","; 74 } 75 }// k 76 77 outfile << os.str() << endl; 78 }// i 79 102 80 103 // relection and repetition /////////////// 81 104 os << "all: " << "line=(" << sector->getRepetitionNumber() << "*L);"; 105 /////////////////////////////////////////// 106 107 outfile << os.str() << endl; 82 108 outfile << endl; // saut de ligne 83 84 string *str= NULL; 85 if(u.size() > 0) { 86 str = new string[u.size()]; 87 for(unsigned int i = 0; i < u.size(); i++) str[i]= "false"; 88 } 89 90 ostringstream os; 91 os << "all: " << "line=("; 92 for(unsigned k = 0; k < elements.size(); k++) { 93 elPtr = elements[k]; 94 bool isMember = false; 95 96 for(unsigned int i = 0; i < u.size(); i++) { 97 unsigned ai = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(0)); 98 unsigned bi = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(1)); 99 if(k >= ai && k <= bi) { 100 isMember = true; 101 102 if(str[i] == "false") { 103 //int reflection = atoi(u.at(i).second.at(2).c_str()); 104 int reflection = ( (u.at(i).second.at(2) == "Unchecked") ? 0:1 ); 105 int repeat = atoi(u.at(i).second.at(3).c_str()); 106 if(reflection > 0) 107 os << "-" << repeat << "*" << u.at(i).first; 108 else 109 os << repeat << "*" << u.at(i).first; 110 111 if(i < u.size()-1) os << ", "; 112 } 113 114 str[i] = "true"; 115 break; 116 } 117 }// i 118 119 if(isMember && k == (elements.size()-1)) os << ");"; 120 121 if(!isMember) { 122 if(k == (elements.size()-1)) os << elPtr->getLabel() << ");"; 123 else os << elPtr->getLabel() << ","; 124 } 125 }// k 126 127 outfile << os.str() << endl; 128 /////////////////////////////////////////// 129 130 outfile << endl; // saut de ligne 131 132 outfile << "beam;" << endl; // beam data p46 109 /////////////////////////////////////////// 110 111 outfile << sbeam << endl; // beam commnd p46 133 112 outfile << "use, period = all;" << endl << endl; // action commands p45 134 113 … … 137 116 outfile << "stop;" << endl; 138 117 139 */140 //_______________________________________________________141 // FIXME Francois !!!!!142 //_______________________________________________________143 144 118 outfile.close(); 145 119 dataManager_->consoleMessage("input file done for madx"); 146 120 return true; 121 } 122 123 string softwareMadx::BEAMcommand(particleBeam* beam) const 124 { 125 // le 20 décembre : les commandes BEAM de madx sont : 126 // PARTICLE (defaut POSITRON) 127 // ENERGY (defaut 1 GeV) ou bien PC GeV/c 128 // EX et EY (defaut 1 m.rad) 129 // ET (defaut 1 m) 130 131 ostringstream os; 132 os << "beam, PARTICLE = ELECTRON"; 133 134 double pc = beam->getP0Transport(); 135 os << ", ENERGY = " << pc; // en GeV 136 137 const beam2Moments& mts = beam->getTransportMoments(); 138 const vector< vector<double> > rij= mts.getMoments(); 139 140 // emittance (x,x') 141 double r10= rij.at(1).at(0); // r10 et s10 = s01= r10*r00*r11 142 double rac= 0.0; 143 if(r10*r10 < 1.0) rac= sqrt(1.0-r10*r10); 144 double EX = rij.at(0).at(0)*rij.at(1).at(1)*rac; // r00*r11*sqrt(1-s01*s10) 145 // r00 en cm (= 1E-02 m) et r11 en mrad (= 1E-03 rad) 146 os << ", EX = " << EX*1.E-05; 147 148 // emittance (y,y') 149 double r32= rij.at(3).at(2); // r32 et s32 = s23= r32*r22*r33 150 rac= 0.0; 151 if(r32*r32 < 1.0) rac= sqrt(1.0-r32*r32); 152 double EY = rij.at(2).at(2)*rij.at(3).at(3)*rac; // r22*r33*sqrt(1-s23*s32) 153 os << ", EY = " << EY*1.E-05; 154 155 os << ";"; 156 return os.str(); 157 } 158 159 string softwareMadx::RFGunData(const vector<statements>& v) const 160 { 161 //NPART = v.at(1).second.at(0); 162 //SIGT (m) = v.at(2).second.at(0) (ps) 163 //?? = sigma_r = v.at(2).second.at(1); en cm 164 //EX (m.rad) = v.at(3).second.at(0) (pi.mm.mrad) 165 //EY (m.rad) = v.at(3).second.at(1) (pi.mm.mrad) 166 //ENERGY (GeV) = v.at(4).second.at(0) (MeV) 167 //SIGE (GeV) = v.at(4).second.at(1) (MeV) 168 //CHARGE = v.at(6).second.at(0); 169 170 ostringstream os; 171 os << "beam, PARTICLE = ELECTRON"; 172 173 // masse au repos (en GeV) E0 = 1.E-03*EREST_MeV 174 // energie cinetique (en GeV) T = 1.E-03*E_cin 175 // l'energie totale (en Gev) W = E0+T 176 double W = 1.E-03*(EREST_MeV + atof(v.at(4).second.at(0).c_str())); 177 os << ", ENERGY = " << W; // total energy in [Gev] 178 179 // pi*EX = 1E-06*emit_x en pi.m.rad 180 double EX = 1.E-06*atof(v.at(3).second.at(0).c_str())/PI; 181 os << ", EX = " << EX; // horizontal emittance in [rad.m] 182 double EY = 1.E-06*atof(v.at(3).second.at(1).c_str())/PI; 183 os << ", EY = " << EY; // vertical emittance in [rad.m] 184 185 // SIGT = c*sigma_t*1E-12 186 double SIGT = 1.E-04*CLIGHT_E8*atof(v.at(2).second.at(0).c_str()); 187 os << ", SIGT = " << SIGT; // bunch length in [m] 188 189 // SIGE = sigma_Ecin/(p0*c) ou p0 impulsion de la paricule de réf. 190 // os << ", SIGE = " << atof(v.at(4).second.at(1).c_str()); 191 192 os << ";"; 193 return os.str(); 147 194 } 148 195 … … 216 263 } 217 264 265 // bool softwareMadx::execute(string workingDir) 266 // { 267 // cout << "***********************************" << endl; 268 // cout << " softwareMadx::execute(...) " << endl << endl; 269 270 // dataManager_->consoleMessage(" softwareMadx::execute"); 271 // return false; 272 // } 273 218 274 bool softwareMadx::buildBeamAfterElements(string workingDir) 219 275 { … … 221 277 cout << " softwareMadx::buildBeamAfterElements(...) " << endl << endl; 222 278 223 dataManager_->consoleMessage(" softwareMadx::buildBeamAfterElements ");279 dataManager_->consoleMessage(" softwareMadx::buildBeamAfterElements: not programmed :O(("); 224 280 return false; 225 281 }
Note: See TracChangeset
for help on using the changeset viewer.