Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/inclxx/utils/src/G4INCLParticleSpecies.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/inclxx/utils/src/G4INCLParticleSpecies.cc (Version 11.3.0) and /processes/hadronic/models/inclxx/utils/src/G4INCLParticleSpecies.cc (Version 10.7.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // INCL++ intra-nuclear cascade model              26 // INCL++ intra-nuclear cascade model
 27 // Alain Boudard, CEA-Saclay, France               27 // Alain Boudard, CEA-Saclay, France
 28 // Joseph Cugnon, University of Liege, Belgium     28 // Joseph Cugnon, University of Liege, Belgium
 29 // Jean-Christophe David, CEA-Saclay, France       29 // Jean-Christophe David, CEA-Saclay, France
 30 // Pekka Kaitaniemi, CEA-Saclay, France, and H     30 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
 31 // Sylvie Leray, CEA-Saclay, France                31 // Sylvie Leray, CEA-Saclay, France
 32 // Davide Mancusi, CEA-Saclay, France              32 // Davide Mancusi, CEA-Saclay, France
 33 //                                                 33 //
 34 #define INCLXX_IN_GEANT4_MODE 1                    34 #define INCLXX_IN_GEANT4_MODE 1
 35                                                    35 
 36 #include "globals.hh"                              36 #include "globals.hh"
 37                                                    37 
 38 /*                                                 38 /*
 39  * G4INCLParticleSpecies.cc                        39  * G4INCLParticleSpecies.cc
 40  *                                                 40  *
 41  *  \date Nov 25, 2011                             41  *  \date Nov 25, 2011
 42  * \author Davide Mancusi                          42  * \author Davide Mancusi
 43  */                                                43  */
 44                                                    44 
 45 #include "G4INCLParticleSpecies.hh"                45 #include "G4INCLParticleSpecies.hh"
 46 #include "G4INCLParticleTable.hh"                  46 #include "G4INCLParticleTable.hh"
 47 #include <algorithm>                               47 #include <algorithm>
 48 #include <cctype>                                  48 #include <cctype>
 49 #include <sstream>                                 49 #include <sstream>
 50 #include <algorithm>                               50 #include <algorithm>
 51                                                    51 
 52 namespace G4INCL {                                 52 namespace G4INCL {
 53                                                    53 
 54   ParticleSpecies::ParticleSpecies(std::string     54   ParticleSpecies::ParticleSpecies(std::string const &pS) {
 55     // Normalise the string to lower case          55     // Normalise the string to lower case
 56     if(pS=="p" || pS=="proton") {                  56     if(pS=="p" || pS=="proton") {
 57       theA = 1;                                    57       theA = 1;
 58       theZ = 1;                                    58       theZ = 1;
 59       theS = 0;                                    59       theS = 0;
 60       theType = G4INCL::Proton;                    60       theType = G4INCL::Proton;
 61     } else if(pS=="n" || pS=="neutron") {          61     } else if(pS=="n" || pS=="neutron") {
 62       theA = 1;                                    62       theA = 1;
 63       theZ = 0;                                    63       theZ = 0;
 64       theS = 0;                                    64       theS = 0;
 65       theType = G4INCL::Neutron;                   65       theType = G4INCL::Neutron;
 66     } else if(pS=="delta++" || pS=="deltaplusp     66     } else if(pS=="delta++" || pS=="deltaplusplus") {
 67       theA = 1;                                    67       theA = 1;
 68       theZ = 2;                                    68       theZ = 2;
 69       theS = 0;                                    69       theS = 0;
 70       theType = G4INCL::DeltaPlusPlus;             70       theType = G4INCL::DeltaPlusPlus;
 71     } else if(pS=="delta+" || pS=="deltaplus")     71     } else if(pS=="delta+" || pS=="deltaplus") {
 72       theA = 1;                                    72       theA = 1;
 73       theZ = 1;                                    73       theZ = 1;
 74       theS = 0;                                    74       theS = 0;
 75       theType = G4INCL::DeltaPlus;                 75       theType = G4INCL::DeltaPlus;
 76     } else if(pS=="delta0" || pS=="deltazero")     76     } else if(pS=="delta0" || pS=="deltazero") {
 77       theA = 1;                                    77       theA = 1;
 78       theZ = 0;                                    78       theZ = 0;
 79       theS = 0;                                    79       theS = 0;
 80       theType = G4INCL::DeltaZero;                 80       theType = G4INCL::DeltaZero;
 81     } else if(pS=="delta-" || pS=="deltaminus"     81     } else if(pS=="delta-" || pS=="deltaminus") {
 82       theA = 1;                                    82       theA = 1;
 83       theZ = -1;                                   83       theZ = -1;
 84       theS = 0;                                    84       theS = 0;
 85       theType = G4INCL::DeltaMinus;                85       theType = G4INCL::DeltaMinus;
 86     } else if(pS=="pi+" || pS=="pion+" || pS==     86     } else if(pS=="pi+" || pS=="pion+" || pS=="piplus" || pS=="pionplus") {
 87       theA = 0;                                    87       theA = 0;
 88       theZ = 1;                                    88       theZ = 1;
 89       theS = 0;                                    89       theS = 0;
 90       theType = G4INCL::PiPlus;                    90       theType = G4INCL::PiPlus;
 91     } else if(pS=="pi0" || pS=="pion0" || pS==     91     } else if(pS=="pi0" || pS=="pion0" || pS=="pizero" || pS=="pionzero") {
 92       theA = 0;                                    92       theA = 0;
 93       theZ = 0;                                    93       theZ = 0;
 94       theS = 0;                                    94       theS = 0;
 95       theType = G4INCL::PiZero;                    95       theType = G4INCL::PiZero;
 96     } else if(pS=="pi-" || pS=="pion-" || pS==     96     } else if(pS=="pi-" || pS=="pion-" || pS=="piminus" || pS=="pionminus") {
 97       theA = 0;                                    97       theA = 0;
 98       theZ = -1;                                   98       theZ = -1;
 99       theS = 0;                                    99       theS = 0;
100       theType = G4INCL::PiMinus;                  100       theType = G4INCL::PiMinus;
101     } else if(pS=="lambda" || pS=="l" || pS=="    101     } else if(pS=="lambda" || pS=="l" || pS=="l0")  {
102       theA = 1;                                   102       theA = 1;
103       theZ = 0;                                   103       theZ = 0;
104       theS = -1;                                  104       theS = -1;
105       theType = G4INCL::Lambda;                   105       theType = G4INCL::Lambda;
106     } else if(pS=="s+" || pS=="sigma+" || pS==    106     } else if(pS=="s+" || pS=="sigma+" || pS=="sigmaplus")  {
107       theA = 1;                                   107       theA = 1;
108       theZ = 1;                                   108       theZ = 1;
109       theS = -1;                                  109       theS = -1;
110       theType = G4INCL::SigmaPlus;                110       theType = G4INCL::SigmaPlus;
111     } else if(pS=="s0" || pS=="sigma0" || pS==    111     } else if(pS=="s0" || pS=="sigma0" || pS=="sigmazero")  {
112       theA = 1;                                   112       theA = 1;
113       theZ = 0;                                   113       theZ = 0;
114       theS = -1;                                  114       theS = -1;
115       theType = G4INCL::SigmaZero;                115       theType = G4INCL::SigmaZero;
116     } else if(pS=="s-" || pS=="sigma-" || pS==    116     } else if(pS=="s-" || pS=="sigma-" || pS=="sigmaminus")  { //Sm = Samarium
117       theA = 1;                                   117       theA = 1;
118       theZ = -1;                                  118       theZ = -1;
119       theS = -1;                                  119       theS = -1;
120       theType = G4INCL::SigmaMinus;            << 120       theType = G4INCL::SigmaMinus;
121     } else if(pS=="xi-" || pS=="x-") {         << 
122       theA = 1;                                << 
123       theZ = -1;                               << 
124       theS = -2;                               << 
125       theType = G4INCL::XiMinus;               << 
126     } else if(pS=="xi0" || pS=="x0") {         << 
127       theA = 1;                                << 
128       theZ = 0;                                << 
129       theS = -2;                               << 
130       theType = G4INCL::XiZero;                << 
131     } else if(pS=="pb" || pS=="antiproton") {  << 
132       theA = -1;                               << 
133       theZ = -1;                               << 
134       theS = 0;                                << 
135       theType = G4INCL::antiProton;            << 
136     } else if(pS=="nb" || pS=="antineutron") { << 
137       theA = -1;                               << 
138       theZ = 0;                                << 
139       theS = 0;                                << 
140       theType = G4INCL::antiNeutron;           << 
141     } else if(pS=="s+b" || pS=="antisigma+" || << 
142       theA = -1;                               << 
143       theZ = -1;                               << 
144       theS = 1;                                << 
145       theType = G4INCL::antiSigmaPlus;         << 
146     } else if(pS=="s0b" || pS=="antisigma0" || << 
147       theA = -1;                               << 
148       theZ = 0;                                << 
149       theS = 1;                                << 
150       theType = G4INCL::antiSigmaZero;         << 
151     } else if(pS=="s-b" || pS=="antisigma-" || << 
152       theA = -1;                               << 
153       theZ = 1;                                << 
154       theS = 1;                                << 
155       theType = G4INCL::antiSigmaMinus;        << 
156     } else if(pS=="antilambda" || pS=="lb" ||  << 
157       theA = -1;                               << 
158       theZ = 0;                                << 
159       theS = 1;                                << 
160       theType = G4INCL::antiLambda;            << 
161     } else if(pS=="antixi-" || pS=="x-b") {    << 
162       theA = -1;                               << 
163       theZ = 1;                                << 
164       theS = 2;                                << 
165       theType = G4INCL::antiXiMinus;           << 
166     } else if(pS=="antixi0" || pS=="x0b") {    << 
167       theA = -1;                               << 
168       theZ = 0;                                << 
169       theS = 2;                                << 
170       theType = G4INCL::antiXiZero;            << 
171     } else if(pS=="k+" || pS=="kaon+" || pS=="    121     } else if(pS=="k+" || pS=="kaon+" || pS=="kplus" || pS=="kaonplus") {
172       theA = 0;                                   122       theA = 0;
173       theZ = 1;                                   123       theZ = 1;
174       theS = 1;                                   124       theS = 1;
175       theType = G4INCL::KPlus;                    125       theType = G4INCL::KPlus;
176     } else if(pS=="k0" || pS=="kaon0" || pS=="    126     } else if(pS=="k0" || pS=="kaon0" || pS=="kzero" || pS=="kaonzero") {
177       theA = 0;                                   127       theA = 0;
178       theZ = 0;                                   128       theZ = 0;
179       theS = 1;                                   129       theS = 1;
180       theType = G4INCL::KZero;                    130       theType = G4INCL::KZero;
181     } else if(pS=="k0b" || pS=="kzb" || pS=="k    131     } else if(pS=="k0b" || pS=="kzb" || pS=="kaon0bar" || pS=="kzerobar" || pS=="kaonzerobar") {
182       theA = 0;                                   132       theA = 0;
183       theZ = 0;                                   133       theZ = 0;
184       theS = -1;                                  134       theS = -1;
185       theType = G4INCL::KZeroBar;                 135       theType = G4INCL::KZeroBar;
186     } else if(pS=="k-" || pS=="kaon-" || pS=="    136     } else if(pS=="k-" || pS=="kaon-" || pS=="kminus" || pS=="kaonminus") {
187       theA = 0;                                   137       theA = 0;
188       theZ = -1;                                  138       theZ = -1;
189       theS = -1;                                  139       theS = -1;
190       theType = G4INCL::KMinus;                   140       theType = G4INCL::KMinus;
191     } else if(pS=="k0s" || pS=="kshort" || pS=    141     } else if(pS=="k0s" || pS=="kshort" || pS=="ks" || pS=="kaonshort") {
192       theA = 0;                                   142       theA = 0;
193       theZ = 0;                                   143       theZ = 0;
194 //    theS not defined                            144 //    theS not defined
195       theType = G4INCL::KShort;                   145       theType = G4INCL::KShort;
196     } else if(pS=="k0l" || pS=="klong" || pS==    146     } else if(pS=="k0l" || pS=="klong" || pS=="kl" || pS=="kaonlong") {
197       theA = 0;                                   147       theA = 0;
198       theZ = 0;                                   148       theZ = 0;
199 //    theS not defined                            149 //    theS not defined
200       theType = G4INCL::KLong;                    150       theType = G4INCL::KLong;
201     } else if(pS=="d" || pS=="deuteron") {        151     } else if(pS=="d" || pS=="deuteron") {
202       theA = 2;                                   152       theA = 2;
203       theZ = 1;                                   153       theZ = 1;
204       theS = 0;                                   154       theS = 0;
205       theType = G4INCL::Composite;                155       theType = G4INCL::Composite;
206     } else if(pS=="t" || pS=="triton") {          156     } else if(pS=="t" || pS=="triton") {
207       theA = 3;                                   157       theA = 3;
208       theZ = 1;                                   158       theZ = 1;
209       theS = 0;                                   159       theS = 0;
210       theType = G4INCL::Composite;                160       theType = G4INCL::Composite;
211     } else if(pS=="a" || pS=="alpha") {           161     } else if(pS=="a" || pS=="alpha") {
212       theA = 4;                                   162       theA = 4;
213       theZ = 2;                                   163       theZ = 2;
214       theS = 0;                                   164       theS = 0;
215       theType = G4INCL::Composite;                165       theType = G4INCL::Composite;
216     } else if(pS=="eta") {                        166     } else if(pS=="eta") {
217       theA = 0;                                   167       theA = 0;
218       theZ = 0;                                   168       theZ = 0;
219       theS = 0;                                   169       theS = 0;
220       theType = G4INCL::Eta;                      170       theType = G4INCL::Eta;
221     } else if(pS=="omega") {                      171     } else if(pS=="omega") {
222       theA = 0;                                   172       theA = 0;
223       theZ = 0;                                   173       theZ = 0;
224       theS = 0;                                   174       theS = 0;
225       theType = G4INCL::Omega;                    175       theType = G4INCL::Omega;
226     } else if(pS=="etaprime" || pS=="etap") {     176     } else if(pS=="etaprime" || pS=="etap") {
227       theA = 0;                                   177       theA = 0;
228       theZ = 0;                                   178       theZ = 0;
229       theS = 0;                                   179       theS = 0;
230       theType = G4INCL::EtaPrime;                 180       theType = G4INCL::EtaPrime;
231     } else if(pS=="photon") {                     181     } else if(pS=="photon") {
232       theA = 0;                                   182       theA = 0;
233       theZ = 0;                                   183       theZ = 0;
234       theS = 0;                                   184       theS = 0;
235       theType = G4INCL::Photon;                << 185       theType = G4INCL::Photon;
236     } else                                        186     } else
237       parseNuclide(pS);                           187       parseNuclide(pS);
238   }                                               188   }
239                                                   189 
240   ParticleSpecies::ParticleSpecies(ParticleTyp    190   ParticleSpecies::ParticleSpecies(ParticleType const t) :
241     theType(t),                                   191     theType(t),
242     theA(ParticleTable::getMassNumber(theType)    192     theA(ParticleTable::getMassNumber(theType)),
243     theZ(ParticleTable::getChargeNumber(theTyp    193     theZ(ParticleTable::getChargeNumber(theType)),
244     theS(ParticleTable::getStrangenessNumber(t    194     theS(ParticleTable::getStrangenessNumber(theType))
245   {}                                              195   {}
246                                                   196 
247   ParticleSpecies::ParticleSpecies(const G4int    197   ParticleSpecies::ParticleSpecies(const G4int A, const G4int Z) :
248     theType(Composite),                           198     theType(Composite),
249     theA(A),                                      199     theA(A),
250     theZ(Z),                                      200     theZ(Z),
251     theS(0)                                       201     theS(0)
252   {}                                              202   {}
253                                                   203 
254   ParticleSpecies::ParticleSpecies(const G4int    204   ParticleSpecies::ParticleSpecies(const G4int A, const G4int Z, const G4int S) :
255     theType(Composite),                           205     theType(Composite),
256     theA(A),                                      206     theA(A),
257     theZ(Z),                                      207     theZ(Z),
258     theS(S)                                       208     theS(S)
259   {}                                              209   {}
260                                                   210 
261   void ParticleSpecies::parseNuclide(std::stri    211   void ParticleSpecies::parseNuclide(std::string const &pS) {
262     theType = Composite;                          212     theType = Composite;
263     theS = 0; // no hypernuclei projectile or     213     theS = 0; // no hypernuclei projectile or target for now
264                                                   214 
265     // Allowed characters                         215     // Allowed characters
266     const std::string separators("-_");           216     const std::string separators("-_");
267     std::string allowed("0123456789abcdefghijk    217     std::string allowed("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
268     allowed += separators;                        218     allowed += separators;
269                                                   219 
270     // There must be at least one character       220     // There must be at least one character
271     if(pS.find_first_not_of(allowed)!=std::str    221     if(pS.find_first_not_of(allowed)!=std::string::npos) {
272       // Malformed input string                   222       // Malformed input string
273       // Setting unknown particle species         223       // Setting unknown particle species
274       (*this) = ParticleSpecies(UnknownParticl    224       (*this) = ParticleSpecies(UnknownParticle);
275       return;                                     225       return;
276     }                                             226     }
277     if(pS.size()<1) {                             227     if(pS.size()<1) {
278       // Malformed input string                   228       // Malformed input string
279       // Setting unknown particle species         229       // Setting unknown particle species
280       (*this) = ParticleSpecies(UnknownParticl    230       (*this) = ParticleSpecies(UnknownParticle);
281       return;                                     231       return;
282     }                                             232     }
283                                                   233 
284     std::size_t firstSeparator = pS.find_first    234     std::size_t firstSeparator = pS.find_first_of(separators);
285     std::size_t lastSeparator = pS.find_last_o    235     std::size_t lastSeparator = pS.find_last_of(separators);
286     if(firstSeparator!=std::string::npos && fi    236     if(firstSeparator!=std::string::npos && firstSeparator!=lastSeparator) {
287       // Several separators in malformed input    237       // Several separators in malformed input string
288       // Setting unknown particle species         238       // Setting unknown particle species
289       (*this) = ParticleSpecies(UnknownParticl    239       (*this) = ParticleSpecies(UnknownParticle);
290       return;                                     240       return;
291     }                                             241     }
292                                                   242 
293     // Identify the type of the first characte    243     // Identify the type of the first character
294     G4int (*predicate)(G4int);                    244     G4int (*predicate)(G4int);
295     G4bool startsWithAlpha = std::isalpha(pS.a    245     G4bool startsWithAlpha = std::isalpha(pS.at(0));
296     if(startsWithAlpha) {                         246     if(startsWithAlpha) {
297       predicate=std::isdigit;                     247       predicate=std::isdigit;
298     } else if(std::isdigit(pS.at(0))) {           248     } else if(std::isdigit(pS.at(0))) {
299       predicate=std::isalpha;                     249       predicate=std::isalpha;
300     } else {                                      250     } else {
301       // Non-alphanumeric character in string     251       // Non-alphanumeric character in string
302       // Setting unknown particle species         252       // Setting unknown particle species
303       (*this) = ParticleSpecies(UnknownParticl    253       (*this) = ParticleSpecies(UnknownParticle);
304       return;                                     254       return;
305     }                                             255     }
306                                                   256 
307     G4bool hasIsotope = true;                     257     G4bool hasIsotope = true;
308     size_t endFirstSection, beginSecondSection    258     size_t endFirstSection, beginSecondSection;
309     if(firstSeparator==std::string::npos) {       259     if(firstSeparator==std::string::npos) {
310       // No separator, Fe56 or 56Fe style         260       // No separator, Fe56 or 56Fe style
311       // Identify the end of the first section    261       // Identify the end of the first section
312                                                   262 
313       // Find the first character that is not     263       // Find the first character that is not of the same type as the first one
314       beginSecondSection = std::find_if(pS.beg    264       beginSecondSection = std::find_if(pS.begin()+1, pS.end(), predicate) - pS.begin();
315                                                   265 
316       if(beginSecondSection>=pS.size()) {         266       if(beginSecondSection>=pS.size()) {
317         if(startsWithAlpha) {                     267         if(startsWithAlpha) {
318           // Only alphabetic characters are pr    268           // Only alphabetic characters are present -- must be an element name
319           hasIsotope = false;                     269           hasIsotope = false;
320         } else {                                  270         } else {
321           // Only numeric characters in the st    271           // Only numeric characters in the string
322           // Setting unknown particle species     272           // Setting unknown particle species
323           (*this) = ParticleSpecies(UnknownPar    273           (*this) = ParticleSpecies(UnknownParticle);
324           return;                                 274           return;
325         }                                         275         }
326       }                                           276       }
327                                                   277 
328       endFirstSection = beginSecondSection;       278       endFirstSection = beginSecondSection;
329                                                   279 
330     } else {                                      280     } else {
331       // One separator, Fe-56 or 56-Fe style o << 281       // One separator, Fe-56 or 56-Fe style
332       endFirstSection = firstSeparator;           282       endFirstSection = firstSeparator;
333       beginSecondSection = firstSeparator+1;      283       beginSecondSection = firstSeparator+1;
334     }                                             284     }
335                                                   285 
336     std::string firstSection(pS.substr(0,endFi    286     std::string firstSection(pS.substr(0,endFirstSection));
337     std::string secondSection(pS.substr(beginS    287     std::string secondSection(pS.substr(beginSecondSection,std::string::npos));
338     std::stringstream parsingStream;              288     std::stringstream parsingStream;
339                                                   289 
340     if(std::isalpha(firstSection.at(0)) && std << 
341       std::stringstream parseStrangeness;      << 
342       parseStrangeness.str(secondSection);     << 
343       parseStrangeness >> theS;                << 
344       if(parsingStream.fail()) {               << 
345         // Couldn't parse the strange charge s << 
346         // Setting unknown particle species    << 
347         (*this) = ParticleSpecies(UnknownParti << 
348         return;                                << 
349       }                                        << 
350       theS *= (-1);                            << 
351       beginSecondSection = std::find_if(pS.beg << 
352       firstSection = pS.substr(0, beginSecondS << 
353       secondSection = pS.substr(beginSecondSec << 
354     }                                          << 
355                                                << 
356     // Parse the sections                         290     // Parse the sections
357     G4bool success;                               291     G4bool success;
358     if(startsWithAlpha) {                         292     if(startsWithAlpha) {
359       parsingStream.str(secondSection);           293       parsingStream.str(secondSection);
360       success = parseElement(firstSection);       294       success = parseElement(firstSection);
361     } else {                                      295     } else {
362       parsingStream.str(firstSection);            296       parsingStream.str(firstSection);
363       success = parseElement(secondSection);      297       success = parseElement(secondSection);
364     }                                             298     }
365     if(!success) {                                299     if(!success) {
366       // Couldn't parse the element section       300       // Couldn't parse the element section
367       // Setting unknown particle species         301       // Setting unknown particle species
368       (*this) = ParticleSpecies(UnknownParticl    302       (*this) = ParticleSpecies(UnknownParticle);
369       return;                                     303       return;
370     }                                             304     }
371                                                   305 
372     if(hasIsotope) {                              306     if(hasIsotope) {
373       parsingStream >> theA;                      307       parsingStream >> theA;
374       if(parsingStream.fail()) {                  308       if(parsingStream.fail()) {
375         // Couldn't parse the mass section        309         // Couldn't parse the mass section
376         // Setting unknown particle species       310         // Setting unknown particle species
377         (*this) = ParticleSpecies(UnknownParti    311         (*this) = ParticleSpecies(UnknownParticle);
378         return;                                   312         return;
379       }                                           313       }
380     } else                                        314     } else
381       theA = 0;                                   315       theA = 0;
382                                                   316 
383     // Check that Z<=A                            317     // Check that Z<=A
384     if(theZ>theA && hasIsotope) {                 318     if(theZ>theA && hasIsotope) {
385       // Setting unknown particle species         319       // Setting unknown particle species
386       (*this) = ParticleSpecies(UnknownParticl    320       (*this) = ParticleSpecies(UnknownParticle);
387       return;                                     321       return;
388     }                                             322     }
389                                                   323 
390     // Special particle type for protons          324     // Special particle type for protons
391     if(theZ==1 && theA==1)                        325     if(theZ==1 && theA==1)
392       theType = Proton;                           326       theType = Proton;
393   }                                               327   }
394                                                   328 
395   G4bool ParticleSpecies::parseElement(std::st    329   G4bool ParticleSpecies::parseElement(std::string const &s) {
396     theZ = ParticleTable::parseElement(s);        330     theZ = ParticleTable::parseElement(s);
397                                                   331 
398     if(theZ<0)                                    332     if(theZ<0)
399       theZ = ParticleTable::parseIUPACElement(    333       theZ = ParticleTable::parseIUPACElement(s);
400                                                   334 
401     if(theZ<0)                                    335     if(theZ<0)
402       return false;                               336       return false;
403     else                                          337     else
404       return true;                                338       return true;
405   }                                               339   }
406                                                   340 
407   G4bool ParticleSpecies::parseIUPACElement(st    341   G4bool ParticleSpecies::parseIUPACElement(std::string const &s) {
408     theZ = ParticleTable::parseIUPACElement(s)    342     theZ = ParticleTable::parseIUPACElement(s);
409     if(theZ==0)                                   343     if(theZ==0)
410       return false;                               344       return false;
411     else                                          345     else
412       return true;                                346       return true;
413   }                                               347   }
414                                                   348   
415   G4int ParticleSpecies::getPDGCode() const {     349   G4int ParticleSpecies::getPDGCode() const {
416     switch (theType) {                            350     switch (theType) {
417     case Proton:                                  351     case Proton:
418         return 2212;                              352         return 2212;
419       break;                                      353       break;
420     case Neutron:                                 354     case Neutron:
421         return 2112;                              355         return 2112;
422       break;                                      356       break;
423     case DeltaPlusPlus:                           357     case DeltaPlusPlus:
424         return 2224;                              358         return 2224;
425       break;                                      359       break;
426     case DeltaPlus:                               360     case DeltaPlus:
427         return 2214;                              361         return 2214;
428       break;                                      362       break;
429     case DeltaZero:                               363     case DeltaZero:
430         return 2114;                              364         return 2114;
431       break;                                      365       break;
432     case DeltaMinus:                              366     case DeltaMinus:
433         return 1114;                              367         return 1114;
434       break;                                      368       break;
435     case PiPlus:                                  369     case PiPlus:
436         return 211;                               370         return 211;
437       break;                                      371       break;
438     case PiZero:                                  372     case PiZero:
439         return 111;                               373         return 111;
440       break;                                      374       break;
441     case PiMinus:                                 375     case PiMinus:
442         return -211;                              376         return -211;
443       break;                                      377       break;
444     case Eta:                                     378     case Eta:
445         return 221;                               379         return 221;
446       break;                                      380       break;
447     case Omega:                                   381     case Omega:
448         return 223;                               382         return 223;
449       break;                                      383       break;
450     case EtaPrime:                                384     case EtaPrime:
451         return 331;                               385         return 331;
452       break;                                      386       break;
453     case Photon:                                  387     case Photon:
454         return 22;                                388         return 22;
455       break;                                      389       break;
456     case Lambda:                                  390     case Lambda:
457         return 3122;                              391         return 3122;
458       break;                                      392       break;
459     case SigmaPlus:                               393     case SigmaPlus:
460         return 3222;                              394         return 3222;
461       break;                                      395       break;
462     case SigmaZero:                               396     case SigmaZero:
463         return 3212;                              397         return 3212;
464       break;                                      398       break;
465     case SigmaMinus:                              399     case SigmaMinus:
466         return 3112;                              400         return 3112;
467       break;                                   << 401       break;
468       case antiProton:                         << 
469         return -2212;                          << 
470       break;                                   << 
471     case XiMinus:                              << 
472         return 3312;                           << 
473       break;                                   << 
474     case XiZero:                               << 
475         return 3322;                           << 
476       break;                                   << 
477     case antiNeutron:                          << 
478         return -2112;                          << 
479       break;                                   << 
480     case antiLambda:                           << 
481         return -3122;                          << 
482       break;                                   << 
483     case antiSigmaPlus:                        << 
484         return -3222;                          << 
485       break;                                   << 
486     case antiSigmaZero:                        << 
487         return -3212;                          << 
488       break;                                   << 
489     case antiSigmaMinus:                       << 
490         return -3112;                          << 
491       break;                                   << 
492     case antiXiMinus:                          << 
493         return -3312;                          << 
494       break;                                   << 
495     case antiXiZero:                           << 
496         return -3322;                          << 
497       break;                                   << 
498     case KPlus:                                   402     case KPlus:
499         return 321;                               403         return 321;
500       break;                                      404       break;
501     case KZero:                                   405     case KZero:
502         return 311;                               406         return 311;
503       break;                                      407       break;
504     case KZeroBar:                                408     case KZeroBar:
505         return -311;                              409         return -311;
506       break;                                      410       break;
507     case KShort:                                  411     case KShort:
508         return 310;                               412         return 310;
509       break;                                      413       break;
510     case KLong:                                   414     case KLong:
511         return 130;                               415         return 130;
512       break;                                      416       break;
513     case KMinus:                                  417     case KMinus:
514         return -321;                              418         return -321;
515       break;                                   << 419       break;
516     case Composite:                               420     case Composite:
517       if(theA == 1 && theZ == 1 && theS == 0)     421       if(theA == 1 && theZ == 1 && theS == 0) return 2212;
518       else if(theA == 1 && theZ == 0 && theS =    422       else if(theA == 1 && theZ == 0 && theS == 0) return 2112;
519       else if(theA == 1 && theZ == 0 && theS =    423       else if(theA == 1 && theZ == 0 && theS == -1) return 3122;
520       else return theA+theZ*1000-theS*1e6; //     424       else return theA+theZ*1000-theS*1e6; // Here -theS because hyper-nucleus -> theS < 0
521       break;                                      425       break;
522     default:                                      426     default:
523       INCL_ERROR("ParticleSpecies::getPDGCode:    427       INCL_ERROR("ParticleSpecies::getPDGCode: Unknown particle type." << '\n');
524       return 0;                                   428       return 0;
525       break;                                      429       break;
526   }                                               430   } 
527   }                                               431   }
528 }                                                 432 }
529                                                   433 
530                                                   434