PyNE C++
particle.h
1 
3 // defines the primary particle types that are allowed by most monte carlo codes
4 // some monte carlo codes allow us to score so called "heavy ions", in fact we
5 // define heavy ions to be particles with more than one neutron or proton
6 
7 #ifndef PYNE_UWPOP4EE6BEB5CZK4BQQHYTCEI
8 #define PYNE_UWPOP4EE6BEB5CZK4BQQHYTCEI
9 
10 #include <string>
11 #include <map>
12 #include <set>
13 
14 #ifndef PYNE_IS_AMALGAMATED
15  #include "nucname.h"
16 #endif
17 
19 #define NUM_PARTICLES 32
20 
21 namespace pyne
22 {
24 namespace particle
25 {
26  extern int _pdcids[NUM_PARTICLES];
27  extern std::string _docs[NUM_PARTICLES];
30  extern std::string _names[NUM_PARTICLES];
32  extern std::set<std::string> names;
34  extern std::set<int> pdc_nums;
36  extern std::map<std::string,int> name_id;
38  extern std::map<int,std::string> id_name;
40  extern std::map<std::string,std::string> docs;
42  extern std::map<std::string,int> altnames;
44  extern std::map<std::string,std::string> part_to_mcnp;
46  extern std::map<std::string,std::string> part_to_mcnp6;
48  extern std::map<std::string,std::string> part_to_fluka;
50  extern std::map<std::string,std::string> part_to_geant4;
52 
53 
62  bool is_hydrogen(int n);
63  bool is_hydrogen(char *s);
64  bool is_hydrogen(std::string s);
66 
74  bool is_heavy_ion(int s);
75  bool is_heavy_ion(char *s);
76  bool is_heavy_ion(std::string s);
78 
86  bool is_valid(int n);
87  bool is_valid(char *s);
88  bool is_valid(std::string s);
90 
97  int id(int n);
98  int id(char *s);
99  int id(std::string s);
101 
109  std::string name(int s);
110  std::string name(char *s);
111  std::string name(std::string s);
113 
118  std::string mcnp(int s);
119  std::string mcnp(char *s);
120  std::string mcnp(std::string s);
122 
127  std::string mcnp6(int s);
128  std::string mcnp6(char *s);
129  std::string mcnp6(std::string s);
131 
136  std::string fluka(int s);
137  std::string fluka(char *s);
138  std::string fluka(std::string s);
140 
145  std::string geant4(int s);
146  std::string geant4(char *s);
147  std::string geant4(std::string s);
149 
150 
157  std::string describe(int s);
158  std::string describe(char *s);
159  std::string describe(std::string s);
160 
162  void * _fill_maps();
163  extern void * filler;
164 
165 
167  class NotAParticle : public std::exception
168  {
169  public:
172 
174  ~NotAParticle () throw () {};
175 
178  NotAParticle(std::string particle_name)
179  {
180  part_name = particle_name;
181  }
182 
184  virtual const char* what() const throw()
185  {
186  std::string pname ("Not a valid particle name ");
187  if(!part_name.empty())
188  pname += part_name;
189  const char *pname_rtn = pname.c_str();
190  return pname_rtn;
191  }
192 
193  private:
194  std::string part_name;
195 
196 
197  };
198 }
199 }
200 
201 #endif
std::set< int > pdc_nums
set of valid names
Custom excpeption for failed particle types.
Definition: particle.h:167
virtual const char * what() const
raises error message
Definition: particle.h:184
std::map< std::string, int > altnames
map of name to doc string
Definition: particle.cpp:94
std::set< std::string > names
set of name strings that are the particle types
~NotAParticle()
Default destructor.
Definition: particle.h:174
std::string _docs[NUM_PARTICLES]
set of Particle Data Centre integer id numbers
std::map< std::string, std::string > part_to_mcnp
map of alternative name to pdc number
Definition: particle.cpp:100
std::map< std::string, std::string > docs
map of pdc number to name
Definition: particle.cpp:97
std::map< int, std::string > id_name
map of name to pdc number
Definition: particle.cpp:95
std::map< std::string, std::string > part_to_mcnp6
map of name to mcnp string
Definition: particle.cpp:101
NotAParticle()
Default constructor.
Definition: particle.h:171
void * filler
A dummy variable used when calling _fill_maps().
Definition: particle.cpp:256
NotAParticle(std::string particle_name)
Definition: particle.h:178
std::map< std::string, int > name_id
set of valid pdc numbers
Definition: particle.cpp:96
A container representing enrichment cascades.
Definition: _atomic_data.h:16
std::map< std::string, std::string > part_to_fluka
map of name to mcnp6 string
Definition: particle.cpp:99
std::map< std::string, std::string > part_to_geant4
map of name to fluka string
Definition: particle.cpp:102
void * _fill_maps()
A helper function to set the contents of the variables in this library.
Definition: particle.cpp:105
std::string _names[NUM_PARTICLES]
set of doc strings that describe the particle types
Definition: particle.cpp:5