Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::AtomDef Class Reference

#include <AtomDef.h>

Public Member Functions

 AtomDef ()
 Default constructor.
 
 AtomDef (const std::string &fnameh, const std::string &fnotationh, int fZh, double fAh)
 Constructor.
 
 ~AtomDef ()
 Destructor.
 
const std::string & name () const
 
const std::string & notation () const
 
int Z () const
 
double A () const
 
void verify ()
 Check that there is no atom with the same name in the container.
 
void print (std::ostream &file, int l=0) const
 
AtomDefcopy () const
 

Static Public Member Functions

static void printall (std::ostream &file)
 Print all registered atoms.
 
static std::list< AtomDef * > & get_logbook ()
 
static const std::list< AtomDef * > & get_const_logbook ()
 
static AtomDefget_AtomDef (const std::string &fnotation)
 
static double get_A (int fZ)
 
static AtomDefget_AtomDef (int fZ)
 

Detailed Description

Definition of atoms. Only the basic information: name, notation, atomic weight and charge.

The principle of definitions of atoms is dictionary or a database: the atoms are not repeated, each atom is presented in the total system no more than one time. The system knows each atom presented in it. The atom characteristics can be obtained by literal notation. The system declines the secondary initialization. The copying is not declined. When the user program wants to refer to atom, it has to use either char* (string) notation, or pointer (or reference) to one of these objects. The user pogram can initialize the new atoms. The standard atoms are initiated in files GasLib.h and GasLib.c.

In principle I am going to initiate all atoms from Mendeleev's table, but I haven't finished yet. Only its first half is filled at the moment.

The atoms are registered in the static element of class AtomDef private: static std::list<AtomDef*> logbook; The can be obtained by notations by: public: static const std::list<AtomDef*>& get_AtomDefLogbook(); static AtomDef* get_AtomDef(const std::string& fnotation); returns the address of atom with this name if it is registered in system, or NULL otherwise.

In these files and in the other components of the matter package the principles are similar. This is the principle of database, the principle of the strict protection of internal data (variables marked by suffix 'h') and granting access though the functions which have similar names without this suffix 'h'.

1998-2004, I. Smirnov.

Definition at line 47 of file AtomDef.h.

Constructor & Destructor Documentation

◆ AtomDef() [1/2]

Heed::AtomDef::AtomDef ( )

Default constructor.

Definition at line 23 of file AtomDef.cpp.

23 {
24 AtomDef::get_logbook().push_back(this);
25}
static std::list< AtomDef * > & get_logbook()
Definition: AtomDef.cpp:78

Referenced by copy().

◆ AtomDef() [2/2]

Heed::AtomDef::AtomDef ( const std::string &  fnameh,
const std::string &  fnotationh,
int  fZh,
double  fAh 
)

Constructor.

Definition at line 27 of file AtomDef.cpp.

29 : nameh(fnameh), notationh(fnotationh), Zh(fZh), Ah(fAh) {
30 mfunname("AtomDef::AtomDef(...)");
31 check_econd21(fZh, < 1 ||, > max_poss_atom_z, mcerr);
32 verify();
33 AtomDef::get_logbook().push_back(this);
34}
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
Definition: FunNameStack.h:191
#define mfunname(string)
Definition: FunNameStack.h:45
void verify()
Check that there is no atom with the same name in the container.
Definition: AtomDef.cpp:58
#define mcerr
Definition: prstream.h:128

◆ ~AtomDef()

Heed::AtomDef::~AtomDef ( )

Destructor.

Definition at line 94 of file AtomDef.cpp.

94{ AtomDef::get_logbook().remove(this); }

Member Function Documentation

◆ A()

double Heed::AtomDef::A ( ) const
inline

Definition at line 68 of file AtomDef.h.

68{ return Ah; }

Referenced by Heed::operator<<().

◆ copy()

AtomDef * Heed::AtomDef::copy ( ) const
inline

Definition at line 90 of file AtomDef.h.

90{ return new AtomDef(*this); }
AtomDef()
Default constructor.
Definition: AtomDef.cpp:23

◆ get_A()

double Heed::AtomDef::get_A ( int  fZ)
static

Return the atomic number corresponding to a given Z. If the atom is not registered, the current version terminates the program through spexit(). Be careful!

Definition at line 36 of file AtomDef.cpp.

36 {
37 mfunnamep("double AtomDef::get_A(int fZ)");
38 for (auto atom : AtomDef::get_logbook()) {
39 if (atom->Z() == fZ) return atom->A();
40 }
41 funnw.ehdr(mcerr);
42 mcerr << "Atom is not found, Z=" << fZ << '\n';
44 return 0.0;
45}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256

◆ get_AtomDef() [1/2]

AtomDef * Heed::AtomDef::get_AtomDef ( const std::string &  fnotation)
static

Return the address of atom with this name if it is registered in system, or NULL otherwise

Definition at line 87 of file AtomDef.cpp.

87 {
88 for (auto atom : AtomDef::get_logbook()) {
89 if (atom->notation() == fnotation) return atom;
90 }
91 return nullptr;
92}

Referenced by Heed::AtomMixDef::AtomMixDef().

◆ get_AtomDef() [2/2]

AtomDef * Heed::AtomDef::get_AtomDef ( int  fZ)
static

Return the address of atom corresponding to a given Z. If the atom is not registered, the current version terminates the program through spexit(). Be careful!

Definition at line 47 of file AtomDef.cpp.

47 {
48 mfunnamep("AtomDef* AtomDef::get_AtomDef(int fZ)");
49 for (auto atom : AtomDef::get_logbook()) {
50 if (atom->Z() == fZ) return atom;
51 }
52 funnw.ehdr(mcerr);
53 mcerr << "Atom is not found, Z=" << fZ << '\n';
55 return nullptr;
56}

◆ get_const_logbook()

const std::list< AtomDef * > & Heed::AtomDef::get_const_logbook ( )
static

Definition at line 83 of file AtomDef.cpp.

83 {
84 return AtomDef::get_logbook();
85}

◆ get_logbook()

std::list< AtomDef * > & Heed::AtomDef::get_logbook ( )
static

Initialize the logbook at the first request and keep it as internal static variable.

Definition at line 78 of file AtomDef.cpp.

78 {
79 static std::list<AtomDef*> logbook;
80 return logbook;
81}

Referenced by AtomDef(), get_A(), get_AtomDef(), get_const_logbook(), printall(), verify(), and ~AtomDef().

◆ name()

const std::string & Heed::AtomDef::name ( ) const
inline

Definition at line 65 of file AtomDef.h.

65{ return nameh; }

Referenced by Heed::operator<<().

◆ notation()

const std::string & Heed::AtomDef::notation ( ) const
inline

Definition at line 66 of file AtomDef.h.

66{ return notationh; }

Referenced by Heed::operator<<().

◆ print()

void Heed::AtomDef::print ( std::ostream &  file,
int  l = 0 
) const

Definition at line 14 of file AtomDef.cpp.

14 {
15 if (l > 0) file << (*this);
16}

◆ printall()

void Heed::AtomDef::printall ( std::ostream &  file)
static

Print all registered atoms.

Definition at line 18 of file AtomDef.cpp.

18 {
19 Ifile << "AtomDef::printall:\n";
20 for (auto atom : AtomDef::get_logbook()) file << atom;
21}
#define Ifile
Definition: prstream.h:196

◆ verify()

void Heed::AtomDef::verify ( )

Check that there is no atom with the same name in the container.

Definition at line 58 of file AtomDef.cpp.

58 {
59 mfunnamep("void AtomDef::verify()");
60 if (nameh == "none" && notationh == "none") return;
61 for (auto atom : AtomDef::get_logbook()) {
62 if (atom->nameh != nameh && atom->notationh != notationh) continue;
63 funnw.ehdr(mcerr);
64 mcerr << "cannot initialize two atoms with the same name or notation\n";
65 mcerr << "name=" << nameh << " notation=" << notationh << '\n';
67 }
68}

Referenced by AtomDef().

◆ Z()

int Heed::AtomDef::Z ( ) const
inline

Definition at line 67 of file AtomDef.h.

67{ return Zh; }

Referenced by Heed::operator<<().


The documentation for this class was generated from the following files: