Garfield++ v2r0
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
6// 1998-2004 I. Smirnov
7
8namespace Heed {
9
10void MatterDef::calc_I_eff() { I_effh = Z_mean() * 12.0 * CLHEP::eV; }
11
12MatterDef::MatterDef() : nameh("none"), notationh("none") {
13 MatterDef::get_logbook().push_back(this);
14}
15
16MatterDef::MatterDef(const std::string& fname, const std::string& fnotation,
17 long fqatom, const std::vector<std::string>& fatom_not,
18 const std::vector<double>& fweight_quan, double fdensity,
19 double ftemperature)
20 : AtomMixDef(fqatom, fatom_not, fweight_quan),
21 nameh(fname),
22 notationh(fnotation),
23 temperatureh(ftemperature),
24 densityh(fdensity) {
25 mfunname("MatterDef::MatterDef(...many atoms...)");
26 calc_I_eff();
27 verify();
28 MatterDef::get_logbook().push_back(this);
29}
30
31MatterDef::MatterDef(const std::string& fname, const std::string& fnotation,
32 const std::string& fatom_not, double fdensity,
33 double ftemperature)
34 : AtomMixDef(fatom_not),
35 nameh(fname),
36 notationh(fnotation),
37 temperatureh(ftemperature),
38 densityh(fdensity) {
39 mfunname("MatterDef::MatterDef(...1 atom...)");
40 calc_I_eff();
41 verify();
42 MatterDef::get_logbook().push_back(this);
43}
44
45MatterDef::MatterDef(const std::string& fname, const std::string& fnotation,
46 const std::string& fatom_not1, double fweight_quan1,
47 const std::string& fatom_not2, double fweight_quan2,
48 double fdensity, double ftemperature)
49 : AtomMixDef(fatom_not1, fweight_quan1, fatom_not2, fweight_quan2),
50 nameh(fname),
51 notationh(fnotation),
52 temperatureh(ftemperature),
53 densityh(fdensity) {
54 mfunname("MatterDef::MatterDef(...2 atoms...)");
55 calc_I_eff();
56 verify();
57 MatterDef::get_logbook().push_back(this);
58}
59
60MatterDef::MatterDef(const std::string& fname, const std::string& fnotation,
61 const std::string& fatom_not1, double fweight_quan1,
62 const std::string& fatom_not2, double fweight_quan2,
63 const std::string& fatom_not3, double fweight_quan3,
64 double fdensity, double ftemperature)
65 : AtomMixDef(fatom_not1, fweight_quan1, fatom_not2, fweight_quan2,
66 fatom_not3, fweight_quan3),
67 nameh(fname),
68 notationh(fnotation),
69 temperatureh(ftemperature),
70 densityh(fdensity) {
71 mfunname("MatterDef::MatterDef(...2 atoms...)");
72 calc_I_eff();
73 verify();
74 MatterDef::get_logbook().push_back(this);
75}
76
78 mfunnamep("void MatterDef::verify(void)");
79 if (nameh == "none" && notationh == "none") return;
80 std::list<MatterDef*>& logbook = MatterDef::get_logbook();
81 std::list<MatterDef*>::const_iterator it;
82 std::list<MatterDef*>::const_iterator end = logbook.end();
83 for (it = logbook.begin(); it != end; ++it) {
84 if ((*it)->nameh == nameh || (*it)->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 std::string& fname, const std::string& fnotation) {
96 "void MatterDef::verify(const std::string& fname, const std::string& "
97 "fnotation)");
98 std::list<MatterDef*>& logbook = MatterDef::get_logbook();
99 std::list<MatterDef*>::const_iterator it;
100 std::list<MatterDef*>::const_iterator end = logbook.end();
101 for (it = logbook.begin(); it != end; ++it) {
102 if ((*it)->nameh == fname || (*it)->notationh == fnotation) {
103 funnw.ehdr(mcerr);
104 mcerr << "cannot initialize two matters "
105 << "with the same name or notation\n";
106 mcerr << "name=" << fname << " notation=" << fnotation << '\n';
107 spexit(mcerr);
108 }
109 }
110}
111
112void MatterDef::print(std::ostream& file, int l) const {
113 if (l > 0) file << (*this);
114}
115
116void MatterDef::printall(std::ostream& file) {
117 Ifile << "MatterDef::printall:\n";
118 std::list<MatterDef*>& logbook = MatterDef::get_logbook();
119 std::list<MatterDef*>::const_iterator it;
120 std::list<MatterDef*>::const_iterator end = logbook.end();
121 for (it = logbook.begin(); it != end; ++it) {
122 (*it)->print(file, 1);
123 }
124}
125
126std::list<MatterDef*>& MatterDef::get_logbook() {
127 static std::list<MatterDef*> logbook;
128 return logbook;
129}
130
131const std::list<MatterDef*>& MatterDef::get_const_logbook() {
132 return MatterDef::get_logbook();
133}
134
135MatterDef* MatterDef::get_MatterDef(const std::string& fnotation) {
136 std::list<MatterDef*>& logbook = MatterDef::get_logbook();
137 std::list<MatterDef*>::const_iterator it;
138 std::list<MatterDef*>::const_iterator end = logbook.end();
139 for (it = logbook.begin(); it != end; ++it) {
140 if ((*it)->notation() == fnotation) return *it;
141 }
142 return NULL;
143}
144
145std::ostream& operator<<(std::ostream& file, const MatterDef& f) {
146 mfunname("ostream& operator << (ostream& file, const MatterDef& f)");
147 Ifile << "MatterDef: name=" << std::setw(10) << f.name()
148 << " notation=" << std::setw(3) << f.notation() << '\n';
149 indn.n += 2;
150 Ifile << "density/(gram/cm3)=" << f.density() / (CLHEP::gram / CLHEP::cm3)
151 << " temperature/kelvin=" << f.temperature() / CLHEP::kelvin
152 << " I_eff/eV=" << f.I_eff() / CLHEP::eV << '\n';
153 f.AtomMixDef::print(file, 1);
154 indn.n -= 2;
155 return file;
156}
157
159}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
#define mfunname(string)
Definition: FunNameStack.h:45
double Z_mean() const
Definition: AtomDef.h:150
static const std::list< MatterDef * > & get_const_logbook()
Definition: MatterDef.cpp:131
const std::string & notation() const
Definition: MatterDef.h:50
const std::string & name() const
Definition: MatterDef.h:49
double I_eff() const
Definition: MatterDef.h:53
static std::list< MatterDef * > & get_logbook()
Definition: MatterDef.cpp:126
static MatterDef * get_MatterDef(const std::string &fnotation)
Definition: MatterDef.cpp:135
double temperature() const
Definition: MatterDef.h:52
void verify()
Check that there is no matter with the same name in the container.
Definition: MatterDef.cpp:77
virtual void print(std::ostream &file, int l) const
Definition: MatterDef.cpp:112
double density() const
Definition: MatterDef.h:51
static void printall(std::ostream &file)
Definition: MatterDef.cpp:116
Definition: BGMesh.cpp:5
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:36
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128