34#define INCLXX_IN_GEANT4_MODE 1
56 if(pS==
"p" || pS==
"proton") {
61 }
else if(pS==
"n" || pS==
"neutron") {
66 }
else if(pS==
"delta++" || pS==
"deltaplusplus") {
71 }
else if(pS==
"delta+" || pS==
"deltaplus") {
76 }
else if(pS==
"delta0" || pS==
"deltazero") {
81 }
else if(pS==
"delta-" || pS==
"deltaminus") {
86 }
else if(pS==
"pi+" || pS==
"pion+" || pS==
"piplus" || pS==
"pionplus") {
91 }
else if(pS==
"pi0" || pS==
"pion0" || pS==
"pizero" || pS==
"pionzero") {
96 }
else if(pS==
"pi-" || pS==
"pion-" || pS==
"piminus" || pS==
"pionminus") {
101 }
else if(pS==
"lambda" || pS==
"l" || pS==
"l0") {
106 }
else if(pS==
"s+" || pS==
"sigma+" || pS==
"sigmaplus") {
111 }
else if(pS==
"s0" || pS==
"sigma0" || pS==
"sigmazero") {
116 }
else if(pS==
"s-" || pS==
"sigma-" || pS==
"sigmaminus") {
121 }
else if(pS==
"k+" || pS==
"kaon+" || pS==
"kplus" || pS==
"kaonplus") {
126 }
else if(pS==
"k0" || pS==
"kaon0" || pS==
"kzero" || pS==
"kaonzero") {
131 }
else if(pS==
"k0b" || pS==
"kzb" || pS==
"kaon0bar" || pS==
"kzerobar" || pS==
"kaonzerobar") {
136 }
else if(pS==
"k-" || pS==
"kaon-" || pS==
"kminus" || pS==
"kaonminus") {
141 }
else if(pS==
"k0s" || pS==
"kshort" || pS==
"ks" || pS==
"kaonshort") {
146 }
else if(pS==
"k0l" || pS==
"klong" || pS==
"kl" || pS==
"kaonlong") {
151 }
else if(pS==
"d" || pS==
"deuteron") {
156 }
else if(pS==
"t" || pS==
"triton") {
161 }
else if(pS==
"a" || pS==
"alpha") {
166 }
else if(pS==
"eta") {
171 }
else if(pS==
"omega") {
176 }
else if(pS==
"etaprime" || pS==
"etap") {
181 }
else if(pS==
"photon") {
192 theA(ParticleTable::getMassNumber(theType)),
193 theZ(ParticleTable::getChargeNumber(theType)),
194 theS(ParticleTable::getStrangenessNumber(theType))
211 void ParticleSpecies::parseNuclide(std::string
const &pS) {
216 const std::string separators(
"-_");
217 std::string
allowed(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
221 if(pS.find_first_not_of(
allowed)!=std::string::npos) {
234 std::size_t firstSeparator = pS.find_first_of(separators);
235 std::size_t lastSeparator = pS.find_last_of(separators);
236 if(firstSeparator!=std::string::npos && firstSeparator!=lastSeparator) {
245 G4bool startsWithAlpha = std::isalpha(pS.at(0));
246 if(startsWithAlpha) {
247 predicate=std::isdigit;
248 }
else if(std::isdigit(pS.at(0))) {
249 predicate=std::isalpha;
258 size_t endFirstSection, beginSecondSection;
259 if(firstSeparator==std::string::npos) {
264 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
266 if(beginSecondSection>=pS.size()) {
267 if(startsWithAlpha) {
278 endFirstSection = beginSecondSection;
282 endFirstSection = firstSeparator;
283 beginSecondSection = firstSeparator+1;
286 std::string firstSection(pS.substr(0,endFirstSection));
287 std::string secondSection(pS.substr(beginSecondSection,std::string::npos));
288 std::stringstream parsingStream;
290 if(std::isalpha(firstSection.at(0)) && std::isdigit(firstSection.at(endFirstSection-1))) {
291 std::stringstream parseStrangeness;
292 parseStrangeness.str(secondSection);
293 parseStrangeness >>
theS;
294 if(parsingStream.fail()) {
301 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
302 firstSection = pS.substr(0, beginSecondSection);
303 secondSection = pS.substr(beginSecondSection, endFirstSection);
308 if(startsWithAlpha) {
309 parsingStream.str(secondSection);
310 success = parseElement(firstSection);
312 parsingStream.str(firstSection);
313 success = parseElement(secondSection);
323 parsingStream >>
theA;
324 if(parsingStream.fail()) {
345 G4bool ParticleSpecies::parseElement(std::string
const &s) {
357 G4bool ParticleSpecies::parseIUPACElement(std::string
const &s) {
438 else if(
theA == 1 &&
theZ == 0 &&
theS == 0)
return 2112;
439 else if(
theA == 1 &&
theZ == 0 &&
theS == -1)
return 3122;
443 INCL_ERROR(
"ParticleSpecies::getPDGCode: Unknown particle type." <<
'\n');
G4double S(G4double temp)
G4int getPDGCode() const
Set a PDG Code (MONTE CARLO PARTICLE NUMBERING)
ParticleSpecies()
Convert a string to a particle species.
G4int parseElement(std::string pS)
Get the name of the element from the atomic number.
G4int parseIUPACElement(std::string const &pS)
Parse a IUPAC element name.