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==
"xi-" || pS==
"x-") {
126 }
else if(pS==
"xi0" || pS==
"x0") {
131 }
else if(pS==
"pb" || pS==
"antiproton") {
136 }
else if(pS==
"nb" || pS==
"antineutron") {
141 }
else if(pS==
"s+b" || pS==
"antisigma+" || pS==
"antisigmaplus") {
146 }
else if(pS==
"s0b" || pS==
"antisigma0" || pS==
"antisigmazero") {
151 }
else if(pS==
"s-b" || pS==
"antisigma-" || pS==
"antisigmaminus") {
156 }
else if(pS==
"antilambda" || pS==
"lb" || pS==
"l0b") {
161 }
else if(pS==
"antixi-" || pS==
"x-b") {
166 }
else if(pS==
"antixi0" || pS==
"x0b") {
171 }
else if(pS==
"k+" || pS==
"kaon+" || pS==
"kplus" || pS==
"kaonplus") {
176 }
else if(pS==
"k0" || pS==
"kaon0" || pS==
"kzero" || pS==
"kaonzero") {
181 }
else if(pS==
"k0b" || pS==
"kzb" || pS==
"kaon0bar" || pS==
"kzerobar" || pS==
"kaonzerobar") {
186 }
else if(pS==
"k-" || pS==
"kaon-" || pS==
"kminus" || pS==
"kaonminus") {
191 }
else if(pS==
"k0s" || pS==
"kshort" || pS==
"ks" || pS==
"kaonshort") {
196 }
else if(pS==
"k0l" || pS==
"klong" || pS==
"kl" || pS==
"kaonlong") {
201 }
else if(pS==
"d" || pS==
"deuteron") {
206 }
else if(pS==
"t" || pS==
"triton") {
211 }
else if(pS==
"a" || pS==
"alpha") {
216 }
else if(pS==
"eta") {
221 }
else if(pS==
"omega") {
226 }
else if(pS==
"etaprime" || pS==
"etap") {
231 }
else if(pS==
"photon") {
242 theA(ParticleTable::getMassNumber(theType)),
243 theZ(ParticleTable::getChargeNumber(theType)),
244 theS(ParticleTable::getStrangenessNumber(theType))
261 void ParticleSpecies::parseNuclide(std::string
const &pS) {
266 const std::string separators(
"-_");
267 std::string
allowed(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
271 if(pS.find_first_not_of(
allowed)!=std::string::npos) {
284 std::size_t firstSeparator = pS.find_first_of(separators);
285 std::size_t lastSeparator = pS.find_last_of(separators);
286 if(firstSeparator!=std::string::npos && firstSeparator!=lastSeparator) {
295 G4bool startsWithAlpha = std::isalpha(pS.at(0));
296 if(startsWithAlpha) {
297 predicate=std::isdigit;
298 }
else if(std::isdigit(pS.at(0))) {
299 predicate=std::isalpha;
308 size_t endFirstSection, beginSecondSection;
309 if(firstSeparator==std::string::npos) {
314 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
316 if(beginSecondSection>=pS.size()) {
317 if(startsWithAlpha) {
328 endFirstSection = beginSecondSection;
332 endFirstSection = firstSeparator;
333 beginSecondSection = firstSeparator+1;
336 std::string firstSection(pS.substr(0,endFirstSection));
337 std::string secondSection(pS.substr(beginSecondSection,std::string::npos));
338 std::stringstream parsingStream;
340 if(std::isalpha(firstSection.at(0)) && std::isdigit(firstSection.at(endFirstSection-1))) {
341 std::stringstream parseStrangeness;
342 parseStrangeness.str(secondSection);
343 parseStrangeness >>
theS;
344 if(parsingStream.fail()) {
351 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
352 firstSection = pS.substr(0, beginSecondSection);
353 secondSection = pS.substr(beginSecondSection, endFirstSection);
358 if(startsWithAlpha) {
359 parsingStream.str(secondSection);
360 success = parseElement(firstSection);
362 parsingStream.str(firstSection);
363 success = parseElement(secondSection);
373 parsingStream >>
theA;
374 if(parsingStream.fail()) {
395 G4bool ParticleSpecies::parseElement(std::string
const &s) {
407 G4bool ParticleSpecies::parseIUPACElement(std::string
const &s) {
518 else if(
theA == 1 &&
theZ == 0 &&
theS == 0)
return 2112;
519 else if(
theA == 1 &&
theZ == 0 &&
theS == -1)
return 3122;
523 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.