Garfield++ v1r0
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.
1#include <stdlib.h>
2#include <string.h>
7/*
81998 - 2004, I. Smirnov
9*/
10
11namespace Heed {
12
13spin_def::spin_def(float ftotal, float fprojection)
14 : total(ftotal), projection(fprojection) {
15 mfunname("spin_def::spin_def(float ftotal, float fprojection)");
18}
19
20std::ostream& operator<<(std::ostream& file, const spin_def& f) {
21 Ifile << "spin_def: total=" << f.total << " projection=" << f.projection;
22 return file;
23}
24
25particle_def electron_def("electron", "e-", electron_mass_c2 / c_squared,
26 electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0));
27particle_def positron_def("positron", "e+", electron_def);
28
29particle_def muon_minus_def("muon_minus", "mu-", 105.658367 * MeV / c_squared,
30 electron_charge, 1, 0, 0.5, spin_def(0.0, 0.0));
31particle_def muon_plus_def("muon_plus", "mu+", muon_minus_def);
32
33particle_def proton_def("proton", "p+", proton_mass_c2 / c_squared, eplus, 0, 1,
34 0.5, spin_def(0.5, 0.5));
35particle_def anti_proton_def("", "p-", proton_def);
36particle_def neutron_def("neutron", "n", neutron_mass_c2 / c_squared, 0, 0, 1,
37 0.5, spin_def(0.5, -0.5));
38particle_def anti_neutron_def("", "", neutron_def);
39
40particle_def P11_def("P11", "P11", 1440.0 * MeV / c_squared, 1 * eplus, 0, 1,
41 0.5, spin_def(0.5, 0.5));
42particle_def D13_def("D13", "D13", 1520.0 * MeV / c_squared, 1 * eplus, 0, 1,
43 1.5, spin_def(0.5, 0.5));
44particle_def S11_def("S11", "S11", 1535.0 * MeV / c_squared, 1 * eplus, 0, 1,
45 0.5, spin_def(0.5, 0.5));
46
47// light unflavored mesons
48particle_def pi_plus_meson_def("pi_plus_meson", "pi+",
49 139.56755 * MeV / c_squared, eplus, 0, 0, 0.0,
50 spin_def(1.0, 1.0));
51particle_def pi_minus_meson_def("pi_minus_meson", "pi-",
52 139.56755 * MeV / c_squared, -eplus, 0, 0, 0.0,
53 spin_def(1.0, -1.0));
54particle_def pi_0_meson_def("pi_0_meson", "pi0", 134.9734 * MeV / c_squared, 0,
55 0, 0, 0.0, spin_def(1.0, 0.0));
56particle_def eta_meson_def("eta_meson_def", "eta", 548.8 * MeV / c_squared, 0,
57 0, 0, 1.0, spin_def(0.0, 0.0));
58particle_def K_plus_meson_def("K_plus_meson_def", "K+",
59 493.677 * MeV / c_squared, 1, 0, 0, 0.0,
60 spin_def(0.5, -0.5));
61particle_def K_minus_meson_def("K_minus_meson_def", "K-", K_plus_meson_def);
62
63particle_def deuteron_def("deuteron", "dtr", 1875.613 * MeV / c_squared, eplus,
64 0, 2, 0.0, spin_def(0.0, 0.0));
65particle_def alpha_particle_def("alpha_particle", "alpha",
66 3727.417 * MeV / c_squared, 2 * eplus, 0, 4,
67 0.0, spin_def(0.0, 0.0));
68
69particle_def user_particle_def("user_particle", "X",
70 139.56755 * MeV / c_squared, eplus, 0, 0, 0.0,
71 spin_def(0.0, 0.0));
72
73particle_def::particle_def(const String& fname, const String& fnotation,
74 double fmass, double fcharge, int flepton_n,
75 int fbarion_n, float fspin,
76 const spin_def& fisospin) {
77 name = fname;
78 notation = fnotation;
79 //mcout<<"particle_def::particle_def: name="<<name<<'\n';
80 mass = fmass;
81 charge = fcharge;
82 barion_n = fbarion_n;
83 lepton_n = flepton_n;
84 spin = fspin;
85 isospin = fisospin;
86 verify();
87 particle_def::get_logbook().append(this);
88 //printall(mcout);
89}
90
91particle_def::particle_def(const String& fname, const String& fnotation,
92 particle_def& p) {
93 // creates anti-particle through the call of anti_particle(p)
94 *this = anti_particle(p);
95 //if(strlen(fname) > 0)
96 //strcpy(name,fname);
97 if (!(fname == "" || fname == " ")) name = fname;
98 if (!(fnotation == "" || fnotation == " ")) notation = fnotation;
99 verify();
100 particle_def::get_logbook().append(this);
101}
102
104 String aname = String("anti-") + p.name;
105 String anot = String("anti-") + p.notation;
106 return particle_def(aname, anot, p.mass, -p.charge, -p.lepton_n, -p.barion_n,
107 -p.spin, p.isospin);
108}
110 static AbsList<particle_def*> logbook;
111 return logbook;
112}
113
116}
117
121 while ((an = logbook.get_next_node(an)) != NULL) {
122 if (an->el->notation == fnotation) return an->el;
123 }
124 return NULL;
125}
126
127void particle_def::set_mass(const double m) { mass = m * MeV / c_squared; }
128
129void particle_def::set_charge(const double z) { charge = z * eplus; }
130
131void particle_def::print(std::ostream& file, int l) const {
132 if (l > 0) {
133 file << (*this);
134 /*
135 file<<name<<" mass="<<mass<<" mass/(GeV/c_squared)="<<mass/(GeV/c_squared)
136 <<" charge="<<charge<<" charge/eplus="<<charge/eplus
137 <<" lepton_n="<<lepton_n<<" barion_n="<<barion_n
138 <<" spin="<<spin<<" isospin="<<isospin<<'\n';
139 */
140 }
141}
142void particle_def::printall(std::ostream& file) {
143 Ifile << "particle_def::printall:\n";
146 while ((an = logbook.get_next_node(an)) != NULL) {
147 file << (*(an->el));
148 }
149}
150
151/*
152void particle_def::verify(void)
153{
154 mfunname("void particle_def::verify(void)");
155 if (name != "none") {
156 particle_def* apd = NULL;
157 int n;
158 for (n = 0; (apd = cont[n]) != NULL ; n++) {
159 if (name == apd->name) {
160 funnw.ehdr(mcerr);
161 mcerr<<"another registered particle definition with the same name
162found\n";
163 spexit(mcerr);
164 }
165 }
166 }
167}
168*/
169std::ostream& operator<<(std::ostream& file, const particle_def& f) {
170 Ifile << "particle_def: name=" << f.name << " notation=" << f.notation
171 << '\n';
172 Ifile << "mass=" << f.mass
173 << " mass/(GeV/c_squared)=" << f.mass / (GeV / c_squared)
174 << " charge=" << f.charge << " charge/eplus=" << f.charge / eplus
175 << '\n';
176 Ifile << "lepton_n=" << f.lepton_n << " barion_n=" << f.barion_n << '\n';
177 Ifile << "spin=" << f.spin << " isospin=" << f.isospin << '\n';
178 return file;
179}
180
181particle_type::particle_type(const char* name, int s) {
182 mfunname("particle_type::particle_type(const char* name, int s)");
183 //mcout<<"particle_type::particle_type(char* name):\n";
184 //particle_def::printall(mcout);
187 while ((an = logbook.get_next_node(an)) != NULL) {
188 if (name == an->el->notation) {
189 pardef = an->el;
190 return;
191 }
192 }
193 an = NULL; // to start from beginning
194 while ((an = logbook.get_next_node(an)) != NULL) {
195 if (name == an->el->name) {
196 pardef = an->el;
197 return;
198 }
199 }
200 if (s == 0) {
201 mcerr << "this type of particle is absent, name=" << name << '\n';
202 spexit(mcerr);
203 }
204 pardef = NULL;
205}
206
207void particle_type::print_notation(std::ostream& file) const {
208 if (pardef.get() == NULL) {
209 file << "none";
210 } else {
211 file << pardef->notation;
212 }
213}
214
215std::ostream& operator<<(std::ostream& file, const particle_type& f) {
216 if (f.pardef.get() == NULL) {
217 file << "type is not initialized";
218 } else {
219 file << (f.pardef->name);
220 }
221 return file;
222}
223
224}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:366
#define spexit(stream)
Definition: FunNameStack.h:536
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:380
#define mfunname(string)
Definition: FunNameStack.h:67
std::string String
Definition: String.h:75
AbsListNode< T > * get_next_node(AbsListNode< T > *an) const
Definition: AbsList.h:175
static AbsList< particle_def * > & get_logbook(void)
void print(std::ostream &file, int l) const
static const AbsList< particle_def * > & get_const_logbook(void)
void set_mass(const double m)
particle_def anti_particle(const particle_def &p)
void set_charge(const double z)
static particle_def * get_particle_def(const String &fnotation)
static void printall(std::ostream &file)
void print_notation(std::ostream &file) const
PassivePtr< particle_def > pardef
Definition: particle_def.h:150
Definition: BGMesh.cpp:3
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:137
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:135
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:131
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:124
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:143
particle_def anti_proton_def("", "p-", proton_def)
Definition: particle_def.h:127
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:22
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:142
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:126
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:136
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:128
particle_def K_minus_meson_def("K_minus_meson_def", "K-", K_plus_meson_def)
Definition: particle_def.h:140
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:138
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:139
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:130
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:146
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:132
particle_def muon_plus_def("muon_plus", "mu+", muon_minus_def)
Definition: particle_def.h:125
particle_def positron_def("positron", "e+", electron_def)
Definition: particle_def.h:123
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:122
particle_def anti_neutron_def("", "", neutron_def)
Definition: particle_def.h:129
#define Ifile
Definition: prstream.h:207
#define mcerr
Definition: prstream.h:135