34 #define INCLXX_IN_GEANT4_MODE 1
56 std::string pSNorm = pS;
57 std::transform(pSNorm.begin(), pSNorm.end(), pSNorm.begin(), ::tolower);
58 if(pSNorm==
"p" || pSNorm==
"proton") {
62 }
else if(pSNorm==
"n" || pSNorm==
"neutron") {
66 }
else if(pSNorm==
"delta++" || pSNorm==
"deltaplusplus") {
70 }
else if(pSNorm==
"delta+" || pSNorm==
"deltaplus") {
74 }
else if(pSNorm==
"delta0" || pSNorm==
"deltazero") {
78 }
else if(pSNorm==
"delta-" || pSNorm==
"deltaminus") {
82 }
else if(pSNorm==
"pi+" || pSNorm==
"pion+" || pSNorm==
"piplus" || pSNorm==
"pionplus") {
86 }
else if(pSNorm==
"pi0" || pSNorm==
"pion0" || pSNorm==
"pizero" || pSNorm==
"pionzero") {
90 }
else if(pSNorm==
"pi-" || pSNorm==
"pion-" || pSNorm==
"piminus" || pSNorm==
"pionminus") {
94 }
else if(pSNorm==
"d" || pSNorm==
"deuteron") {
98 }
else if(pSNorm==
"t" || pSNorm==
"triton") {
102 }
else if(pSNorm==
"a" || pSNorm==
"alpha") {
126 const std::string separators(
"-_");
127 std::string
allowed(
"0123456789abcdefghijklmnopqrstuvwxyz");
128 allowed += separators;
131 if(pS.find_first_not_of(allowed)!=std::string::npos) {
144 std::size_t firstSeparator = pS.find_first_of(separators);
145 std::size_t lastSeparator = pS.find_last_of(separators);
146 if(firstSeparator!=std::string::npos && firstSeparator!=lastSeparator) {
155 G4bool startsWithAlpha = std::isalpha(pS.at(0));
156 if(startsWithAlpha) {
157 predicate=std::isdigit;
158 }
else if(std::isdigit(pS.at(0))) {
159 predicate=std::isalpha;
168 size_t endFirstSection, beginSecondSection;
169 if(firstSeparator==std::string::npos) {
174 beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
176 if(beginSecondSection>=pS.size()) {
177 if(startsWithAlpha) {
188 endFirstSection = beginSecondSection;
192 endFirstSection = firstSeparator;
193 beginSecondSection = firstSeparator+1;
196 std::string firstSection(pS.substr(0,endFirstSection));
197 std::string secondSection(pS.substr(beginSecondSection,std::string::npos));
198 std::stringstream parsingStream;
202 if(startsWithAlpha) {
203 parsingStream.str(secondSection);
206 parsingStream.str(firstSection);
217 parsingStream >>
theA;
218 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.
G4int parseElement(std::string pS)
Get the name of the element from the atomic number.
ParticleSpecies()
Convert a string to a particle species.
static const G4double A[nN]
G4bool parseElement(std::string const &pS)
Parse an element name.
G4int parseIUPACElement(std::string const &pS)
Parse a IUPAC element name.