34 #define INCLXX_IN_GEANT4_MODE 1
56 if(pS==
"p" || pS==
"proton") {
60 }
else if(pS==
"n" || pS==
"neutron") {
64 }
else if(pS==
"delta++" || pS==
"deltaplusplus") {
68 }
else if(pS==
"delta+" || pS==
"deltaplus") {
72 }
else if(pS==
"delta0" || pS==
"deltazero") {
76 }
else if(pS==
"delta-" || pS==
"deltaminus") {
80 }
else if(pS==
"pi+" || pS==
"pion+" || pS==
"piplus" || pS==
"pionplus") {
84 }
else if(pS==
"pi0" || pS==
"pion0" || pS==
"pizero" || pS==
"pionzero") {
88 }
else if(pS==
"pi-" || pS==
"pion-" || pS==
"piminus" || pS==
"pionminus") {
92 }
else if(pS==
"d" || pS==
"deuteron") {
96 }
else if(pS==
"t" || pS==
"triton") {
100 }
else if(pS==
"a" || pS==
"alpha") {
104 }
else if(pS==
"eta") {
108 }
else if(pS==
"omega") {
112 }
else if(pS==
"etaprime" || pS==
"etap") {
116 }
else if(pS==
"photon") {
136 void ParticleSpecies::parseNuclide(std::string
const &pS) {
140 const std::string separators(
"-_");
141 std::string
allowed(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
145 if(pS.find_first_not_of(
allowed)!=std::string::npos) {
158 std::size_t firstSeparator = pS.find_first_of(separators);
159 std::size_t lastSeparator = pS.find_last_of(separators);
160 if(firstSeparator!=std::string::npos && firstSeparator!=lastSeparator) {
169 G4bool startsWithAlpha = std::isalpha(pS.at(0));
170 if(startsWithAlpha) {
171 predicate=std::isdigit;
172 }
else if(std::isdigit(pS.at(0))) {
173 predicate=std::isalpha;
182 size_t endFirstSection, beginSecondSection;
183 if(firstSeparator==std::string::npos) {
188 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
190 if(beginSecondSection>=pS.size()) {
191 if(startsWithAlpha) {
202 endFirstSection = beginSecondSection;
206 endFirstSection = firstSeparator;
207 beginSecondSection = firstSeparator+1;
210 std::string firstSection(pS.substr(0,endFirstSection));
211 std::string secondSection(pS.substr(beginSecondSection,std::string::npos));
212 std::stringstream parsingStream;
216 if(startsWithAlpha) {
217 parsingStream.str(secondSection);
218 success = parseElement(firstSection);
220 parsingStream.str(firstSection);
221 success = parseElement(secondSection);
231 parsingStream >>
theA;
232 if(parsingStream.fail()) {
242 if(
theZ>theA && hasIsotope) {
249 if(
theZ==1 && theA==1)
253 G4bool ParticleSpecies::parseElement(std::string
const &
s) {
265 G4bool ParticleSpecies::parseIUPACElement(std::string
const &s) {
315 return theA+
theZ*1000;
318 INCL_ERROR(
"ParticleSpecies::getPDGCode: Unknown particle type." <<
'\n');
G4int getChargeNumber(const ParticleType t)
Get charge number from particle type.
G4int getMassNumber(const ParticleType t)
Get mass number from particle type.
double A(double temperature)
G4int parseElement(std::string pS)
Get the name of the element from the atomic number.
ParticleSpecies()
Convert a string to a particle species.
G4int getPDGCode() const
Set a PDG Code (MONTE CARLO PARTICLE NUMBERING)
G4int parseIUPACElement(std::string const &pS)
Parse a IUPAC element name.