Garfield++ v2r0
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 std::list<particle_def*>& logbook = particle_def::get_logbook();
123 std::list<particle_def*>::iterator it;
124 std::list<particle_def*>::const_iterator end = logbook.end();
125 for (it = logbook.begin(); it != end; ++it) {
126 particle_def* node = *it;
127 if (!node) continue;
128 if (node->notation == fnotation) return node;
129 }
130 return NULL;
131}
132
133void particle_def::set_mass(const double m) { mass = m * MeV / c_squared; }
134
135void particle_def::set_charge(const double z) { charge = z * eplus; }
136
137void particle_def::print(std::ostream& file, int l) const {
138 if (l > 0) file << (*this);
139}
140void particle_def::printall(std::ostream& file) {
141 Ifile << "particle_def::printall:\n";
142 std::list<particle_def*>& logbook = particle_def::get_logbook();
143 std::list<particle_def*>::const_iterator it;
144 std::list<particle_def*>::const_iterator end;
145 for (it = logbook.begin(); it != end; ++it) {
146 if (*it) file << *it;
147 }
148}
149
150std::ostream& operator<<(std::ostream& file, const particle_def& f) {
151 Ifile << "particle_def: name=" << f.name << " notation=" << f.notation
152 << '\n';
153 Ifile << "mass=" << f.mass
154 << " mass/(GeV/c_squared)=" << f.mass / (GeV / c_squared)
155 << " charge=" << f.charge << " charge/eplus=" << f.charge / eplus
156 << '\n';
157 Ifile << "lepton_n=" << f.lepton_n << " baryon_n=" << f.baryon_n << '\n';
158 Ifile << "spin=" << f.spin << " isospin=" << f.isospin << '\n';
159 return file;
160}
161
162particle_type::particle_type(const char* name, int s) {
163 mfunname("particle_type::particle_type(const char* name, int s)");
164 std::list<particle_def*>& logbook = particle_def::get_logbook();
165 std::list<particle_def*>::iterator it;
166 std::list<particle_def*>::const_iterator end = logbook.end();
167 for (it = logbook.begin(); it != end; ++it) {
168 if (name == (*it)->notation) {
169 pardef = *it;
170 return;
171 }
172 }
173 for (it = logbook.begin(); it != end; ++it) {
174 if (name == (*it)->name) {
175 pardef = *it;
176 return;
177 }
178 }
179 if (s == 0) {
180 mcerr << "this type of particle is absent, name=" << name << '\n';
181 spexit(mcerr);
182 }
183 pardef = NULL;
184}
185
186void particle_type::print_notation(std::ostream& file) const {
187 if (pardef.get() == NULL) {
188 file << "none";
189 } else {
190 file << pardef->notation;
191 }
192}
193
194std::ostream& operator<<(std::ostream& file, const particle_type& f) {
195 if (f.pardef.get() == NULL) {
196 file << "type is not initialized";
197 } else {
198 file << (f.pardef->name);
199 }
200 return file;
201}
202}
#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:106
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:47
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:49
void print_notation(std::ostream &file) const
PassivePtr< particle_def > pardef
Definition: particle_def.h:148
Helper class for definition of spin.
Definition: particle_def.h:12
Definition: BGMesh.cpp:5
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:125
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:123
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:119
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:112
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:131
particle_def anti_proton_def("", "p-", proton_def)
Definition: particle_def.h:115
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:36
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:130
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:114
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:124
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:116
particle_def K_minus_meson_def("K_minus_meson_def", "K-", K_plus_meson_def)
Definition: particle_def.h:128
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:126
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:127
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:118
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:134
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:120
particle_def muon_plus_def("muon_plus", "mu+", muon_minus_def)
Definition: particle_def.h:113
particle_def positron_def("positron", "e+", electron_def)
Definition: particle_def.h:111
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:110
particle_def anti_neutron_def("", "", neutron_def)
Definition: particle_def.h:117
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128