Changeset 373 in PSPA for Interface_Web
- Timestamp:
- Mar 6, 2013, 5:54:55 PM (11 years ago)
- 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 9 9 class elementSnapshot : public abstractElement 10 10 { 11 11 string snapshotFile_; 12 12 void setDefaultValues(); 13 13 void setDefaults(); -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc
r371 r373 106 106 } 107 107 108 trivaluedBool abstractElement::setSoftware(nomDeLogiciel prog) { 109 if (acceptableSoftware_.size() == 0) { 110 return TBoolError; 108 trivaluedBool 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; 111 130 } 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; 136 133 } 137 134 138 139 135 void abstractElement::registerAcceptableSoftware(nomDeLogiciel abs,trivaluedBool b) { 140 141 142 } else if (b == TBoolOk){143 144 136 if (b == TBoolIgnore) { 137 ignoreSoftware_.push_back(abs); 138 } else if (b == TBoolOk) { 139 acceptableSoftware_.push_back(abs); 140 } 145 141 } -
Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc
r369 r373 4 4 #include "mixedTools.h" 5 5 6 static int incr = 0; 7 6 8 elementSnapshot::elementSnapshot() : abstractElement() 7 9 { 8 9 10 11 12 13 14 15 16 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); 17 19 } 18 20 … … 25 27 { 26 28 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 } 27 38 } 28 29 39 30 40 string* elementSnapshot::getParametersString() const … … 33 43 parametersString_[++compteur] = mixedTools::intToString(nbParam_); 34 44 parametersString_[++compteur] = label_; 45 parametersString_[++compteur] = snapshotFile_; 35 46 36 47 if ( compteur != nbParam_ ) { 37 cerr << " elementSnapshot::getParametersString() : ERROR parameters doesnt match "<< endl;48 cerr << "ERROR::elementSnapshot::getParametersString() : " << nbParam_ << endl; 38 49 return NULL; 39 50 } … … 51 62 int compteur = -1; 52 63 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 59 69 label_ = param[++compteur]; 60 70 } … … 65 75 } 66 76 67 68 77 string elementSnapshot::transportOutputFlow() const 69 78 { 70 79 return string(" "); 71 80 } 72 73 81 74 82 string elementSnapshot::FileOutputFlow() const … … 77 85 sortie << elementName_.getElementLabel() << endl; 78 86 sortie << label_ << endl; 87 sortie << snapshotFile_ << endl; 79 88 return sortie.str(); 80 89 } … … 83 92 { 84 93 ifs >> label_; 94 ifs >> snapshotFile_; 85 95 } 86 96 … … 89 99 string txt = ""; 90 100 txt += label_; 101 txt += "\nname of file for snapshot : "; 102 txt += snapshotFile_; 91 103 return txt; 92 104 } -
Interface_Web/trunk/pspaWT/sources/controler/src/nomdElements.cc
r369 r373 70 70 case soleno : return 5; 71 71 case fit : return 4; 72 case snapshot : return 1;72 case snapshot : return 2; 73 73 default : return 0; 74 74 } -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
r371 r373 115 115 { 116 116 bool result = true; 117 cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl;117 //cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl; 118 118 119 119 // index du premier element de parmela … … 123 123 { 124 124 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 125 125 126 126 // si l'element est un snapshot, recuperer la sortie precedente 127 127 if(elem->getNomdElement().getElementType() == snapshot) { … … 138 138 beams.push_back(particleBeam()); 139 139 cout << " creation diagn. no " << beams.size() << " par PARMELA " << endl; 140 140 141 vector<double> centroid; 141 142 bareParticle refPart; … … 166 167 167 168 bool 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 } 211 211 } //while 212 213 214 { 215 216 217 218 219 } 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 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; 260 260 } 261 261
Note: See TracChangeset
for help on using the changeset viewer.