VGM
Version 5.5
Toggle main menu visibility
Loading...
Searching...
No Matches
packages
RootGM
source
materials
Element.cxx
Go to the documentation of this file.
1
// $Id$
2
3
// -----------------------------------------------------------------------
4
// The RootGM 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 implementations for Root element.
16
//
17
// Author: Ivana Hrivnacova; IPN Orsay
18
19
#include "
RootGM/materials/Element.h
"
20
#include "
RootGM/common/Units.h
"
21
#include "
RootGM/materials/ElementMap.h
"
22
#include "
RootGM/materials/Isotope.h
"
23
#include "
RootGM/materials/IsotopeMap.h
"
24
25
#include "TGeoElement.h"
26
#include "TGeoManager.h"
27
28
#include <cstdlib>
29
#include <math.h>
30
31
//_____________________________________________________________________________
32
RootGM::Element::Element
(
33
const
std::string& name,
const
std::string& symbol,
double
z,
double
a)
34
:
VGM
::IElement(),
35
fElement(new TGeoElement(
36
name.data(), symbol.data(), z, a /
RootGM
::
Units
::AtomicWeight()))
37
{
44
45
// Register element in the map
46
ElementMap::Instance
()->
AddElement
(
this
, fElement);
47
}
48
49
//_____________________________________________________________________________
50
RootGM::Element::Element
(
const
std::string& name,
const
std::string& symbol,
51
const
VGM::IsotopeVector
& isotopes,
52
const
VGM::RelAbundanceVector
& relAbundances)
53
:
VGM
::IElement(), fElement(0)
54
{
61
62
if
(!isotopes.size()) {
63
std::cerr <<
" RootGM::Element::Element: "
<< std::endl;
64
std::cerr <<
" No isotopes defined."
;
65
std::cerr <<
"*** Error: Aborting execution ***"
<< std::endl;
66
exit(1);
67
}
68
69
// Check coherence
70
if (isotopes.size() != relAbundances.size()) {
71
std::cerr <<
" RootGM::Element::Element: "
<< std::endl;
72
std::cerr <<
" Isotopes size and relAbundances size differ."
;
73
std::cerr <<
"*** Error: Aborting execution ***"
<< std::endl;
74
exit(1);
75
}
76
77
// Create element
78
fElement =
new
TGeoElement(name.data(), symbol.data(), isotopes.size());
79
80
// Add isotopes
81
for (
unsigned
int
i = 0; i < isotopes.size(); i++) {
82
TGeoIsotope* tgeoIsotope =
IsotopeMap::Instance
()->
GetIsotope
(isotopes[i]);
83
fElement->AddIsotope(tgeoIsotope, relAbundances[i]);
84
}
85
86
// Register element in the map
87
ElementMap::Instance
()->
AddElement
(
this
, fElement);
88
}
89
90
//_____________________________________________________________________________
91
RootGM::Element::Element
(TGeoElement* geoElement)
92
:
VGM
::IElement(), fElement(geoElement)
93
{
96
97
// Register element in the map
98
ElementMap::Instance
()->
AddElement
(
this
, fElement);
99
}
100
101
//_____________________________________________________________________________
102
RootGM::Element::~Element
()
103
{
104
//
105
}
106
107
//
108
// private functions
109
//
110
111
//_____________________________________________________________________________
112
void
RootGM::Element::CheckIndex(
int
i)
const
113
{
114
if
(i < 0 || i >= NofIsotopes()) {
115
std::cerr <<
" RootGM::Element::CheckIndex: "
<< std::endl;
116
std::cerr <<
" Index of isotope outside limits."
<< std::endl;
117
std::cerr <<
"*** Error: Aborting execution ***"
<< std::endl;
118
exit(1);
119
}
120
}
121
122
//
123
// public functions
124
//
125
126
//_____________________________________________________________________________
127
std::string
RootGM::Element::Name
()
const
{
return
fElement->GetName(); }
128
129
//_____________________________________________________________________________
130
std::string
RootGM::Element::Symbol
()
const
{
return
fElement->GetTitle(); }
131
132
//_____________________________________________________________________________
133
double
RootGM::Element::Z
()
const
{
return
fElement->Z(); }
134
135
//_____________________________________________________________________________
136
double
RootGM::Element::N
()
const
{
return
fElement->Neff(); }
137
138
//_____________________________________________________________________________
139
double
RootGM::Element::A
()
const
140
{
141
return
fElement->A() *
RootGM::Units::AtomicWeight
();
142
}
143
144
//_____________________________________________________________________________
145
int
RootGM::Element::NofIsotopes
()
const
{
return
fElement->GetNisotopes(); }
146
147
//_____________________________________________________________________________
148
VGM::IIsotope
*
RootGM::Element::Isotope
(
int
i)
const
149
{
150
CheckIndex(i);
151
152
TGeoIsotope* tgeoIsotope = fElement->GetIsotope(i);
153
return
IsotopeMap::Instance
()->
GetIsotope
(tgeoIsotope);
154
}
155
156
//_____________________________________________________________________________
157
double
RootGM::Element::RelAbundance
(
int
i)
const
158
{
159
CheckIndex(i);
160
161
return
fElement->GetRelativeAbundance(i);
162
}
Units.h
ElementMap.h
Element.h
IsotopeMap.h
Isotope.h
RootGM::ElementMap::AddElement
void AddElement(VGM::IElement *, TGeoElement *)
Definition
ElementMap.cxx:63
RootGM::ElementMap::Instance
static ElementMap * Instance()
Definition
ElementMap.cxx:28
RootGM::Element::Isotope
virtual VGM::IIsotope * Isotope(int i) const
Return the i-th isotope constituing this element.
Definition
Element.cxx:148
RootGM::Element::NofIsotopes
virtual int NofIsotopes() const
Return the number of isotopes constituing this element.
Definition
Element.cxx:145
RootGM::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:157
RootGM::Element::Symbol
virtual std::string Symbol() const
Return the symbol of this element.
Definition
Element.cxx:130
RootGM::Element::Element
Element(const std::string &name, const std::string &symbol, double z, double a)
Definition
Element.cxx:32
RootGM::Element::N
virtual double N() const
Return the effective number of nucleons.
Definition
Element.cxx:136
RootGM::Element::A
virtual double A() const
Return the effective effective mass of a mole in g/mole.
Definition
Element.cxx:139
RootGM::Element::Name
virtual std::string Name() const
Return the name of this element.
Definition
Element.cxx:127
RootGM::Element::~Element
virtual ~Element()
Definition
Element.cxx:102
RootGM::Element::Z
virtual double Z() const
Return the effective atomic number.
Definition
Element.cxx:133
RootGM::IsotopeMap::GetIsotope
TGeoIsotope * GetIsotope(VGM::IIsotope *iIsotope) const
Definition
IsotopeMap.cxx:93
RootGM::IsotopeMap::Instance
static IsotopeMap * Instance()
Definition
IsotopeMap.cxx:28
RootGM::Units
Conversion from Root physical units to VGM units.
Definition
Units.h:28
RootGM::Units::AtomicWeight
static double AtomicWeight()
Return Root atomic weight unit in VGM units.
Definition
Units.h:87
VGM::IIsotope
The VGM interface to elements.
Definition
IIsotope.h:28
RootGM
VGM implementation for Root.
Definition
axis.h:28
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