Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
particle_def.cpp
Go to the documentation of this file.
4
5// 1998 - 2004, I. Smirnov
6
7namespace Heed {
8
9using CLHEP::electron_mass_c2;
10using CLHEP::proton_mass_c2;
11using CLHEP::neutron_mass_c2;
12using CLHEP::c_squared;
13using CLHEP::electron_charge;
14using CLHEP::eplus;
15using CLHEP::MeV;
16using CLHEP::GeV;
17
18spin_def::spin_def(float ftotal, float fprojection)
19 : total(ftotal), projection(fprojection) {
20 mfunname("spin_def::spin_def(float ftotal, float fprojection)");
23}
24
25std::ostream& operator<<(std::ostream& file, const spin_def& f) {
26 Ifile << "spin_def: total=" << f.total << " projection=" << f.projection;
27 return file;
28}
29
30particle_def electron_def("electron", "e-", electron_mass_c2 / c_squared,
31 electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0));
32particle_def positron_def("positron", "e+", electron_def);
33
34particle_def muon_minus_def("muon_minus", "mu-", 105.658367 * MeV / c_squared,
35 electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0));
36particle_def muon_plus_def("muon_plus", "mu+", muon_minus_def);
37
38particle_def proton_def("proton", "p+", proton_mass_c2 / c_squared, eplus, 0, 1,
39 0.5, spin_def(0.5, 0.5));
40particle_def anti_proton_def("", "p-", proton_def);
41particle_def neutron_def("neutron", "n", neutron_mass_c2 / c_squared, 0, 0, 1,
42 0.5, spin_def(0.5, -0.5));
43particle_def anti_neutron_def("", "", neutron_def);
44
45particle_def P11_def("P11", "P11", 1440.0 * MeV / c_squared, 1 * eplus, 0, 1,
46 0.5, spin_def(0.5, 0.5));
47particle_def D13_def("D13", "D13", 1520.0 * MeV / c_squared, 1 * eplus, 0, 1,
48 1.5, spin_def(0.5, 0.5));
49particle_def S11_def("S11", "S11", 1535.0 * MeV / c_squared, 1 * eplus, 0, 1,
50 0.5, spin_def(0.5, 0.5));
51
52// light unflavored mesons
53particle_def pi_plus_meson_def("pi_plus_meson", "pi+",
54 139.56755 * MeV / c_squared, eplus, 0, 0, 0.0,
55 spin_def(1.0, 1.0));
56particle_def pi_minus_meson_def("pi_minus_meson", "pi-",
57 139.56755 * MeV / c_squared, -eplus, 0, 0, 0.0,
58 spin_def(1.0, -1.0));
59particle_def pi_0_meson_def("pi_0_meson", "pi0", 134.9734 * MeV / c_squared, 0,
60 0, 0, 0.0, spin_def(1.0, 0.0));
61particle_def eta_meson_def("eta_meson_def", "eta", 548.8 * MeV / c_squared, 0,
62 0, 0, 1.0, spin_def(0.0, 0.0));
63particle_def K_plus_meson_def("K_plus_meson_def", "K+",
64 493.677 * MeV / c_squared, 1, 0, 0, 0.0,
65 spin_def(0.5, -0.5));
66particle_def K_minus_meson_def("K_minus_meson_def", "K-", K_plus_meson_def);
67
68particle_def deuteron_def("deuteron", "dtr", 1875.613 * MeV / c_squared, eplus,
69 0, 2, 0.0, spin_def(0.0, 0.0));
70particle_def alpha_particle_def("alpha_particle", "alpha",
71 3727.417 * MeV / c_squared, 2 * eplus, 0, 4,
72 0.0, spin_def(0.0, 0.0));
73
74particle_def user_particle_def("user_particle", "X",
75 139.56755 * MeV / c_squared, eplus, 0, 0, 0.0,
76 spin_def(0.0, 0.0));
77
78particle_def::particle_def(const std::string& fname,
79 const std::string& fnotation, double fmass,
80 double fcharge, int flepton_n, int fbaryon_n,
81 float fspin, const spin_def& fisospin) {
82 name = fname;
83 notation = fnotation;
84 mass = fmass;
85 charge = fcharge;
86 baryon_n = fbaryon_n;
87 lepton_n = flepton_n;
88 spin = fspin;
89 isospin = fisospin;
90 verify();
91 particle_def::get_logbook().push_back(this);
92}
93
94particle_def::particle_def(const std::string& fname,
95 const std::string& fnotation, particle_def& p) {
96 // creates anti-particle through the call of anti_particle(p)
97 *this = anti_particle(p);
98 // if(strlen(fname) > 0)
99 // strcpy(name,fname);
100 if (!(fname == "" || fname == " ")) name = fname;
101 if (!(fnotation == "" || fnotation == " ")) notation = fnotation;
102 verify();
103 particle_def::get_logbook().push_back(this);
104}
105
107 std::string aname = "anti-" + p.name;
108 std::string anot = "anti-" + p.notation;
109 return particle_def(aname, anot, p.mass, -p.charge, -p.lepton_n, -p.baryon_n,
110 -p.spin, p.isospin);
111}
112std::list<particle_def*>& particle_def::get_logbook() {
113 static std::list<particle_def*> logbook;
114 return logbook;
115}
116
117const std::list<particle_def*>& particle_def::get_const_logbook() {
119}
120
121particle_def* particle_def::get_particle_def(const std::string& fnotation) {
122 for (auto particle : particle_def::get_logbook()) {
123 if (!particle) continue;
124 if (particle->notation == fnotation) return particle;
125 }
126 return nullptr;
127}
128
129void particle_def::set_mass(const double m) { mass = m * MeV / c_squared; }
130
131void particle_def::set_charge(const double z) { charge = z * eplus; }
132
133void particle_def::print(std::ostream& file, int l) const {
134 if (l > 0) file << (*this);
135}
136void particle_def::printall(std::ostream& file) {
137 Ifile << "particle_def::printall:\n";
138 for (auto particle : particle_def::get_logbook()) {
139 if (particle) file << particle;
140 }
141}
142
143std::ostream& operator<<(std::ostream& file, const particle_def& f) {
144 Ifile << "particle_def: name=" << f.name << " notation=" << f.notation
145 << '\n';
146 Ifile << "mass=" << f.mass
147 << " mass/(GeV/c_squared)=" << f.mass / (GeV / c_squared)
148 << " charge=" << f.charge << " charge/eplus=" << f.charge / eplus
149 << '\n';
150 Ifile << "lepton_n=" << f.lepton_n << " baryon_n=" << f.baryon_n << '\n';
151 Ifile << "spin=" << f.spin << " isospin=" << f.isospin << '\n';
152 return file;
153}
154
155particle_type::particle_type(const char* name, int s) {
156 mfunname("particle_type::particle_type(const char* name, int s)");
157 for (auto particle : particle_def::get_logbook()) {
158 if (name == particle->notation) {
159 pardef = particle;
160 return;
161 }
162 }
163 for (auto particle : particle_def::get_logbook()) {
164 if (name == particle->name) {
165 pardef = particle;
166 return;
167 }
168 }
169 if (s == 0) {
170 mcerr << "this type of particle is absent, name=" << name << '\n';
171 spexit(mcerr);
172 }
173 pardef = nullptr;
174}
175
176void particle_type::print_notation(std::ostream& file) const {
177 if (!pardef) {
178 file << "none";
179 } else {
180 file << pardef->notation;
181 }
182}
183
184std::ostream& operator<<(std::ostream& file, const particle_type& f) {
185 if (!f.pardef) {
186 file << "type is not initialized";
187 } else {
188 file << (f.pardef->name);
189 }
190 return file;
191}
192}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define spexit(stream)
Definition: FunNameStack.h:256
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
#define mfunname(string)
Definition: FunNameStack.h:45
static particle_def * get_particle_def(const std::string &fnotation)
void verify()
Check that there is no particle with the same name in the container.
Definition: particle_def.h:95
static const std::list< particle_def * > & get_const_logbook()
void print(std::ostream &file, int l) const
void set_mass(const double m)
std::string name
Definition: particle_def.h:44
static std::list< particle_def * > & get_logbook()
particle_def anti_particle(const particle_def &p)
Function for making an anti-particle.
void set_charge(const double z)
static void printall(std::ostream &file)
std::string notation
Short name to make data summary files short.
Definition: particle_def.h:46
void print_notation(std::ostream &file) const
particle_type()=default
particle_def * pardef
Definition: particle_def.h:137
Helper class for definition of spin.
Definition: particle_def.h:11
spin_def()=default
Definition: BGMesh.cpp:6
particle_def pi_minus_meson_def("pi_minus_meson", "pi-", 139.56755 *MeV/c_squared, -eplus, 0, 0, 0.0, spin_def(1.0, -1.0))
Definition: particle_def.h:114
particle_def pi_plus_meson_def("pi_plus_meson", "pi+", 139.56755 *MeV/c_squared, eplus, 0, 0, 0.0, spin_def(1.0, 1.0))
Definition: particle_def.h:112
particle_def D13_def("D13", "D13", 1520.0 *MeV/c_squared, 1 *eplus, 0, 1, 1.5, spin_def(0.5, 0.5))
Definition: particle_def.h:108
particle_def muon_minus_def("muon_minus", "mu-", 105.658367 *MeV/c_squared, electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0))
Definition: particle_def.h:101
particle_def alpha_particle_def("alpha_particle", "alpha", 3727.417 *MeV/c_squared, 2 *eplus, 0, 4, 0.0, spin_def(0.0, 0.0))
Definition: particle_def.h:120
particle_def anti_proton_def("", "p-", proton_def)
Definition: particle_def.h:104
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
particle_def deuteron_def("deuteron", "dtr", 1875.613 *MeV/c_squared, eplus, 0, 2, 0.0, spin_def(0.0, 0.0))
Definition: particle_def.h:119
particle_def proton_def("proton", "p+", proton_mass_c2/c_squared, eplus, 0, 1, 0.5, spin_def(0.5, 0.5))
Definition: particle_def.h:103
particle_def pi_0_meson_def("pi_0_meson", "pi0", 134.9734 *MeV/c_squared, 0, 0, 0, 0.0, spin_def(1.0, 0.0))
Definition: particle_def.h:113
particle_def neutron_def("neutron", "n", neutron_mass_c2/c_squared, 0, 0, 1, 0.5, spin_def(0.5, -0.5))
Definition: particle_def.h:105
particle_def K_minus_meson_def("K_minus_meson_def", "K-", K_plus_meson_def)
Definition: particle_def.h:117
particle_def eta_meson_def("eta_meson_def", "eta", 548.8 *MeV/c_squared, 0, 0, 0, 1.0, spin_def(0.0, 0.0))
Definition: particle_def.h:115
particle_def K_plus_meson_def("K_plus_meson_def", "K+", 493.677 *MeV/c_squared, 1, 0, 0, 0.0, spin_def(0.5, -0.5))
Definition: particle_def.h:116
particle_def P11_def("P11", "P11", 1440.0 *MeV/c_squared, 1 *eplus, 0, 1, 0.5, spin_def(0.5, 0.5))
Definition: particle_def.h:107
particle_def user_particle_def("user_particle", "X", 139.56755 *MeV/c_squared, eplus, 0, 0, 0.0, spin_def(0.0, 0.0))
Definition: particle_def.h:123
particle_def S11_def("S11", "S11", 1535.0 *MeV/c_squared, 1 *eplus, 0, 1, 0.5, spin_def(0.5, 0.5))
Definition: particle_def.h:109
particle_def muon_plus_def("muon_plus", "mu+", muon_minus_def)
Definition: particle_def.h:102
particle_def positron_def("positron", "e+", electron_def)
Definition: particle_def.h:100
particle_def electron_def("electron", "e-", electron_mass_c2/c_squared, electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0))
Definition: particle_def.h:99
particle_def anti_neutron_def("", "", neutron_def)
Definition: particle_def.h:106
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128