Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
MatterDef.cpp
Go to the documentation of this file.
1#include <iomanip>
5/*
61998-2004 I. Smirnov
7*/
8
9namespace Heed {
10
11void MatterDef::calc_I_eff(void) { I_effh = Z_mean() * 12.0 * eV; }
12
13MatterDef::MatterDef(void) : nameh("none"), notationh("none") {
14 MatterDef::get_logbook().append(this);
15}
16
17MatterDef::MatterDef(const String& fname, const String& fnotation, long fqatom,
18 const DynLinArr<String>& fatom_not,
19 const DynLinArr<double>& fweight_quan, double fdensity,
20 double ftemperature)
21 : AtomMixDef(fqatom, fatom_not, fweight_quan),
22 nameh(fname),
23 notationh(fnotation),
24 temperatureh(ftemperature),
25 densityh(fdensity) {
26 mfunname("MatterDef::MatterDef(...many atoms...)");
27 calc_I_eff();
28 verify();
29 MatterDef::get_logbook().append(this);
30}
31
32MatterDef::MatterDef(const String& fname, const String& fnotation,
33 const String& fatom_not, double fdensity,
34 double ftemperature)
35 : AtomMixDef(fatom_not),
36 nameh(fname),
37 notationh(fnotation),
38 temperatureh(ftemperature),
39 densityh(fdensity) {
40 mfunname("MatterDef::MatterDef(...1 atom...)");
41 calc_I_eff();
42 verify();
43 MatterDef::get_logbook().append(this);
44}
45
46MatterDef::MatterDef(const String& fname, const String& fnotation,
47 const String& fatom_not1, double fweight_quan1,
48 const String& fatom_not2, double fweight_quan2,
49 double fdensity, double ftemperature)
50 : AtomMixDef(fatom_not1, fweight_quan1, fatom_not2, fweight_quan2),
51 nameh(fname),
52 notationh(fnotation),
53 temperatureh(ftemperature),
54 densityh(fdensity) {
55 mfunname("MatterDef::MatterDef(...2 atoms...)");
56 calc_I_eff();
57 verify();
58 MatterDef::get_logbook().append(this);
59}
60
61MatterDef::MatterDef(const String& fname, const String& fnotation,
62 const String& fatom_not1, double fweight_quan1,
63 const String& fatom_not2, double fweight_quan2,
64 const String& fatom_not3, double fweight_quan3,
65 double fdensity, double ftemperature)
66 : AtomMixDef(fatom_not1, fweight_quan1, fatom_not2, fweight_quan2,
67 fatom_not3, fweight_quan3),
68 nameh(fname),
69 notationh(fnotation),
70 temperatureh(ftemperature),
71 densityh(fdensity) {
72 mfunname("MatterDef::MatterDef(...2 atoms...)");
73 calc_I_eff();
74 verify();
75 MatterDef::get_logbook().append(this);
76}
77
79 mfunnamep("void MatterDef::verify(void)");
80 if (nameh == "none" && notationh == "none") return;
82 AbsListNode<MatterDef*>* an = NULL;
83 while ((an = logbook.get_next_node(an)) != NULL) {
84 if (an->el->nameh == nameh || an->el->notationh == notationh) {
85 funnw.ehdr(mcerr);
86 mcerr << "cannot initialize two matters "
87 << "with the same name or notation\n";
88 mcerr << "name=" << nameh << " notation=" << notationh << '\n';
90 }
91 }
92}
93
94void MatterDef::verify(const String& fname, const String& fnotation) {
96 "void MatterDef::verify(const String& fname, const String& fnotation)");
98 AbsListNode<MatterDef*>* an = NULL;
99 while ((an = logbook.get_next_node(an)) != NULL) {
100 if (an->el->nameh == fname || an->el->notationh == fnotation) {
101 funnw.ehdr(mcerr);
102 mcerr << "cannot initialize two matters "
103 << "with the same name or notation\n";
104 mcerr << "name=" << fname << " notation=" << fnotation << '\n';
105 spexit(mcerr);
106 }
107 }
108}
109
110void MatterDef::print(std::ostream& file, int l) const {
111 if (l > 0) file << (*this);
112}
113
114void MatterDef::printall(std::ostream& file) {
115 Ifile << "MatterDef::printall:\n";
117 AbsListNode<MatterDef*>* an = NULL;
118 while ((an = logbook.get_next_node(an)) != NULL) {
119 an->el->print(file, 1);
120 }
121}
122
124 static AbsList<MatterDef*> logbook;
125 return logbook;
126}
127
129 return MatterDef::get_logbook();
130}
131
134 AbsListNode<MatterDef*>* an = NULL;
135 while ((an = logbook.get_next_node(an)) != NULL) {
136 if (an->el->notation() == fnotation) return an->el;
137 }
138 return NULL;
139}
140
141std::ostream& operator<<(std::ostream& file, const MatterDef& f) {
142 mfunname(
143 "std::ostream& operator << (std::ostream& file, const MatterDef& f)");
144 Ifile << "MatterDef: name=" << std::setw(10) << f.name()
145 << " notation=" << std::setw(3) << f.notation() << '\n';
146 indn.n += 2;
147 Ifile << "density/(gram/cm3)=" << f.density() / (gram / cm3)
148 << " temperature/kelvin=" << f.temperature() / kelvin
149 << " I_eff/eV=" << f.I_eff() / eV << '\n';
150 f.AtomMixDef::print(file, 1);
151 indn.n -= 2;
152 return file;
153}
154
155std::ostream& operator<<(std::ostream& file, const MatterType& f) {
156 mfunname(
157 "std::ostream& operator << (std::ostream& file, const MatterType& f)");
158 if (f.matdef.get() == NULL) {
159 Ifile << "MatterType: type is not initialized\n";
160 } else {
161 Ifile << "MatterType: notation=" << f.matdef->notation() << '\n';
162 }
163 return file;
164}
165
167
168}
#define mfunnamep(string)
Definition: FunNameStack.h:77
#define spexit(stream)
Definition: FunNameStack.h:536
#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
double Z_mean(void) const
Definition: AtomDef.h:149
static AbsList< MatterDef * > & get_logbook(void)
Definition: MatterDef.cpp:123
static MatterDef * get_MatterDef(const String &fnotation)
Definition: MatterDef.cpp:132
double I_eff(void) const
Definition: MatterDef.h:54
const String & notation(void) const
Definition: MatterDef.h:51
double density(void) const
Definition: MatterDef.h:52
virtual void print(std::ostream &file, int l) const
Definition: MatterDef.cpp:110
static const AbsList< MatterDef * > & get_const_logbook(void)
Definition: MatterDef.cpp:128
double temperature(void) const
Definition: MatterDef.h:53
const String & name(void) const
Definition: MatterDef.h:50
void verify(void)
Definition: MatterDef.cpp:78
static void printall(std::ostream &file)
Definition: MatterDef.cpp:114
PassivePtr< MatterDef > matdef
Definition: MatterDef.h:72
Definition: BGMesh.cpp:3
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:22
indentation indn
Definition: prstream.cpp:13
#define Ifile
Definition: prstream.h:207
#define mcerr
Definition: prstream.h:135