VGM
Version 5.5
Toggle main menu visibility
Loading...
Searching...
No Matches
packages
Geant4GM
source
materials
Element.cxx
Go to the documentation of this file.
1
// $Id$
2
3
// -----------------------------------------------------------------------
4
// The Geant4GM package of the Virtual Geometry Model
5
// Copyright (C) 2007, Ivana Hrivnacova
6
// All rights reserved.
7
//
8
// For the licensing terms see vgm/LICENSE.
9
// Contact: ivana@ipno.in2p3.fr
10
// -----------------------------------------------------------------------
11
12
//
13
// Class Element
14
// ---------------
15
// VGM implementation for Geant4 element.
16
//
17
// Author: Ivana Hrivnacova; IPN Orsay
18
19
#include "
ClhepVGM/Units.h
"
20
21
#include "
Geant4GM/materials/Element.h
"
22
#include "
Geant4GM/materials/ElementMap.h
"
23
#include "
Geant4GM/materials/Isotope.h
"
24
#include "
Geant4GM/materials/IsotopeMap.h
"
25
26
#include "G4Element.hh"
27
28
//_____________________________________________________________________________
29
Geant4GM::Element::Element
(
30
const
std::string& name,
const
std::string& symbol,
double
z,
double
a)
31
:
VGM
::IElement(),
32
fElement(
33
new G4Element(name, symbol, z, a /
ClhepVGM
::Units::AtomicWeight()))
34
{
41
42
// Register element in the map
43
ElementMap::Instance
()->
AddElement
(
this
, fElement);
44
}
45
46
//_____________________________________________________________________________
47
Geant4GM::Element::Element
(
const
std::string& name,
const
std::string& symbol,
48
const
VGM::IsotopeVector
& isotopes,
49
const
VGM::RelAbundanceVector
& relAbundances)
50
:
VGM
::IElement(), fElement(0)
51
{
58
59
if
(!isotopes.size()) {
60
std::cerr <<
" Geant4GM::Element::Element: "
<< std::endl;
61
std::cerr <<
" No isotopes defined."
;
62
std::cerr <<
"*** Error: Aborting execution ***"
<< std::endl;
63
exit(1);
64
}
65
66
// Check coherence
67
if (isotopes.size() != relAbundances.size()) {
68
std::cerr <<
" Geant4GM::Element::Element: "
<< std::endl;
69
std::cerr <<
" Isotopes size and relAbundances size differ."
;
70
std::cerr <<
"*** Error: Aborting execution ***"
<< std::endl;
71
exit(1);
72
}
73
74
// Create element
75
fElement =
new
G4Element(name, symbol, isotopes.size());
76
77
// Add isotopes
78
for (
unsigned
int
i = 0; i < isotopes.size(); i++) {
79
G4Isotope* g4Isotope =
IsotopeMap::Instance
()->
GetIsotope
(isotopes[i]);
80
fElement->AddIsotope(g4Isotope, relAbundances[i]);
81
}
82
83
// Register element in the map
84
ElementMap::Instance
()->
AddElement
(
this
, fElement);
85
}
86
87
//_____________________________________________________________________________
88
Geant4GM::Element::Element
(G4Element* element)
89
:
VGM
::IElement(), fElement(element)
90
{
92
93
// Register element in the map
94
ElementMap::Instance
()->
AddElement
(
this
, fElement);
95
}
96
97
//_____________________________________________________________________________
98
Geant4GM::Element::Element
() :
VGM
::IElement()
99
{
101
}
102
103
//_____________________________________________________________________________
104
Geant4GM::Element::Element
(
const
Element
& rhs) :
VGM
::IElement(rhs)
105
{
107
}
108
109
//_____________________________________________________________________________
110
Geant4GM::Element::~Element
()
111
{
112
//
113
}
114
115
//
116
// private functions
117
//
118
119
//_____________________________________________________________________________
120
void
Geant4GM::Element::CheckIndex(
int
i)
const
121
{
122
if
(i < 0 || i >= NofIsotopes()) {
123
std::cerr <<
" Geant4GM::Element::CheckIndex: "
<< std::endl;
124
std::cerr <<
" Index of isotope outside limits."
<< std::endl;
125
std::cerr <<
"*** Error: Aborting execution ***"
<< std::endl;
126
exit(1);
127
}
128
}
129
130
//
131
// public functions
132
//
133
134
//_____________________________________________________________________________
135
std::string
Geant4GM::Element::Name
()
const
{
return
fElement->GetName(); }
136
137
//_____________________________________________________________________________
138
std::string
Geant4GM::Element::Symbol
()
const
{
return
fElement->GetSymbol(); }
139
140
//_____________________________________________________________________________
141
double
Geant4GM::Element::Z
()
const
{
return
fElement->GetZ(); }
142
143
//_____________________________________________________________________________
144
double
Geant4GM::Element::N
()
const
{
return
fElement->GetN(); }
145
146
//_____________________________________________________________________________
147
double
Geant4GM::Element::A
()
const
148
{
149
return
fElement->GetA() *
ClhepVGM::Units::AtomicWeight
();
150
}
151
152
//_____________________________________________________________________________
153
int
Geant4GM::Element::NofIsotopes
()
const
154
{
155
return
fElement->GetNumberOfIsotopes();
156
}
157
158
//_____________________________________________________________________________
159
VGM::IIsotope
*
Geant4GM::Element::Isotope
(
int
i)
const
160
{
161
CheckIndex(i);
162
163
const
G4Isotope* g4Isotope = fElement->GetIsotope(i);
164
return
IsotopeMap::Instance
()->
GetIsotope
(
const_cast<
G4Isotope*
>
(g4Isotope));
165
}
166
167
//_____________________________________________________________________________
168
double
Geant4GM::Element::RelAbundance
(
int
i)
const
169
{
170
CheckIndex(i);
171
172
return
fElement->GetRelativeAbundanceVector()[i];
173
}
Units.h
ElementMap.h
Element.h
IsotopeMap.h
Isotope.h
ClhepVGM::Units::AtomicWeight
static double AtomicWeight()
Return CLHEP default atomic weight unit in VGM units.
Definition
Units.cxx:107
Geant4GM::ElementMap::AddElement
void AddElement(VGM::IElement *, G4Element *)
Definition
ElementMap.cxx:63
Geant4GM::ElementMap::Instance
static ElementMap * Instance()
Definition
ElementMap.cxx:28
Geant4GM::Element::N
virtual double N() const
Return the effective number of nucleons.
Definition
Element.cxx:144
Geant4GM::Element::NofIsotopes
virtual int NofIsotopes() const
Return the number of isotopes constituing this element.
Definition
Element.cxx:153
Geant4GM::Element::Element
Element()
Definition
Element.cxx:98
Geant4GM::Element::Z
virtual double Z() const
Return the effective atomic number.
Definition
Element.cxx:141
Geant4GM::Element::Isotope
virtual VGM::IIsotope * Isotope(int i) const
Return the i-th isotope constituing this element.
Definition
Element.cxx:159
Geant4GM::Element::Symbol
virtual std::string Symbol() const
Return the symbol of this element.
Definition
Element.cxx:138
Geant4GM::Element::Name
virtual std::string Name() const
Return the name of this element.
Definition
Element.cxx:135
Geant4GM::Element::~Element
virtual ~Element()
Definition
Element.cxx:110
Geant4GM::Element::Element
Element(const std::string &name, const std::string &symbol, double z, double a)
Definition
Element.cxx:29
Geant4GM::Element::A
virtual double A() const
Return the effective effective mass of a mole in g/mole.
Definition
Element.cxx:147
Geant4GM::Element::RelAbundance
virtual double RelAbundance(int i) const
Return the relative abundance (the fraction of nb of atomes per volume) of the i-th isotope constitui...
Definition
Element.cxx:168
Geant4GM::IsotopeMap::Instance
static IsotopeMap * Instance()
Definition
IsotopeMap.cxx:28
Geant4GM::IsotopeMap::GetIsotope
G4Isotope * GetIsotope(VGM::IIsotope *iIsotope) const
Definition
IsotopeMap.cxx:93
VGM::IIsotope
The VGM interface to elements.
Definition
IIsotope.h:28
ClhepVGM
ClhepVGM utilities.
Definition
transform.h:29
VGM
VGM interfaces.
Definition
VMedium.h:28
VGM::RelAbundanceVector
std::vector< double > RelAbundanceVector
Definition
IElement.h:31
VGM::IsotopeVector
std::vector< IIsotope * > IsotopeVector
Definition
IElement.h:30
Generated on
for VGM by
1.17.0