Garfield++ 4.0
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 for (auto matter : MatterDef::get_logbook()) {
81 if (matter->nameh != nameh && matter->notationh != notationh) continue;
82 funnw.ehdr(mcerr);
83 mcerr << "cannot initialize two matters with the same name or notation\n";
84 mcerr << "name=" << nameh << " notation=" << notationh << '\n';
86 }
87}
88
89void MatterDef::verify(const std::string& fname, const std::string& fnotation) {
90 mfunnamep("void MatterDef::verify(const std::string& const std::string&)");
91 for (auto matter : MatterDef::get_logbook()) {
92 if (matter->nameh != fname && matter->notationh != fnotation) continue;
93 funnw.ehdr(mcerr);
94 mcerr << "cannot initialize two matters with the same name or notation\n";
95 mcerr << "name=" << fname << " notation=" << fnotation << '\n';
97 }
98}
99
100void MatterDef::print(std::ostream& file, int l) const {
101 if (l > 0) file << (*this);
102}
103
104void MatterDef::printall(std::ostream& file) {
105 Ifile << "MatterDef::printall:\n";
106 for (auto matter : MatterDef::get_logbook()) {
107 matter->print(file, 1);
108 }
109}
110
111std::list<MatterDef*>& MatterDef::get_logbook() {
112 static std::list<MatterDef*> logbook;
113 return logbook;
114}
115
116const std::list<MatterDef*>& MatterDef::get_const_logbook() {
117 return MatterDef::get_logbook();
118}
119
120MatterDef* MatterDef::get_MatterDef(const std::string& fnotation) {
121 for (auto matter : MatterDef::get_logbook()) {
122 if (matter->notation() == fnotation) return matter;
123 }
124 return nullptr;
125}
126
127std::ostream& operator<<(std::ostream& file, const MatterDef& f) {
128 mfunname("ostream& operator << (ostream& file, const MatterDef& f)");
129 Ifile << "MatterDef: name=" << std::setw(10) << f.name()
130 << " notation=" << std::setw(3) << f.notation() << '\n';
131 indn.n += 2;
132 Ifile << "density/(gram/cm3)=" << f.density() / (CLHEP::gram / CLHEP::cm3)
133 << " temperature/kelvin=" << f.temperature() / CLHEP::kelvin
134 << " I_eff/eV=" << f.I_eff() / CLHEP::eV << '\n';
135 f.AtomMixDef::print(file, 1);
136 indn.n -= 2;
137 return file;
138}
139
141}
#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:140
static const std::list< MatterDef * > & get_const_logbook()
Definition: MatterDef.cpp:116
const std::string & notation() const
Definition: MatterDef.h:50
virtual ~MatterDef()
Definition: MatterDef.cpp:140
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:111
static MatterDef * get_MatterDef(const std::string &fnotation)
Definition: MatterDef.cpp:120
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
void print(std::ostream &file, int l) const
Definition: MatterDef.cpp:100
double density() const
Definition: MatterDef.h:51
static void printall(std::ostream &file)
Definition: MatterDef.cpp:104
Definition: BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:195
#define mcerr
Definition: prstream.h:128