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") {
124 const std::string separators(
"-_");
125 std::string
allowed(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
126 allowed += separators;
129 if(pS.find_first_not_of(allowed)!=std::string::npos) {
142 std::size_t firstSeparator = pS.find_first_of(separators);
143 std::size_t lastSeparator = pS.find_last_of(separators);
144 if(firstSeparator!=std::string::npos && firstSeparator!=lastSeparator) {
153 G4bool startsWithAlpha = std::isalpha(pS.at(0));
154 if(startsWithAlpha) {
155 predicate=std::isdigit;
156 }
else if(std::isdigit(pS.at(0))) {
157 predicate=std::isalpha;
166 size_t endFirstSection, beginSecondSection;
167 if(firstSeparator==std::string::npos) {
172 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
174 if(beginSecondSection>=pS.size()) {
175 if(startsWithAlpha) {
186 endFirstSection = beginSecondSection;
190 endFirstSection = firstSeparator;
191 beginSecondSection = firstSeparator+1;
194 std::string firstSection(pS.substr(0,endFirstSection));
195 std::string secondSection(pS.substr(beginSecondSection,std::string::npos));
196 std::stringstream parsingStream;
200 if(startsWithAlpha) {
201 parsingStream.str(secondSection);
204 parsingStream.str(firstSection);
215 parsingStream >>
theA;
216 if(parsingStream.fail()) {
G4bool parseIUPACElement(std::string const &s)
Parse a IUPAC element name.
void parseNuclide(std::string const &pS)
Parse a nuclide name.
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.
G4bool parseElement(std::string const &pS)
Parse an element name.
G4int parseIUPACElement(std::string const &pS)
Parse a IUPAC element name.