VGM Version 5.3
Loading...
Searching...
No Matches
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
20#include "RootGM/common/Units.h"
24
25#include "TGeoElement.h"
26#include "TGeoManager.h"
27
28#include <cstdlib>
29#include <math.h>
30
31//_____________________________________________________________________________
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//_____________________________________________________________________________
50RootGM::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//_____________________________________________________________________________
91RootGM::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//_____________________________________________________________________________
103{
104 //
105}
106
107//
108// private functions
109//
110
111//_____________________________________________________________________________
112void 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//_____________________________________________________________________________
127std::string RootGM::Element::Name() const { return fElement->GetName(); }
128
129//_____________________________________________________________________________
130std::string RootGM::Element::Symbol() const { return fElement->GetTitle(); }
131
132//_____________________________________________________________________________
133double RootGM::Element::Z() const { return fElement->Z(); }
134
135//_____________________________________________________________________________
136double RootGM::Element::N() const { return fElement->Neff(); }
137
138//_____________________________________________________________________________
139double RootGM::Element::A() const
140{
141 return fElement->A() * RootGM::Units::AtomicWeight();
142}
143
144//_____________________________________________________________________________
145int RootGM::Element::NofIsotopes() const { return fElement->GetNisotopes(); }
146
147//_____________________________________________________________________________
149{
150 CheckIndex(i);
151
152 TGeoIsotope* tgeoIsotope = fElement->GetIsotope(i);
153 return IsotopeMap::Instance()->GetIsotope(tgeoIsotope);
154}
155
156//_____________________________________________________________________________
158{
159 CheckIndex(i);
160
161 return fElement->GetRelativeAbundance(i);
162}
void AddElement(VGM::IElement *, TGeoElement *)
static ElementMap * Instance()
virtual VGM::IIsotope * Isotope(int i) const
Return the i-th isotope constituing this element.
Definition Element.cxx:148
virtual int NofIsotopes() const
Return the number of isotopes constituing this element.
Definition Element.cxx:145
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
virtual std::string Symbol() const
Return the symbol of this element.
Definition Element.cxx:130
Element(const std::string &name, const std::string &symbol, double z, double a)
Definition Element.cxx:32
virtual double N() const
Return the effective number of nucleons.
Definition Element.cxx:136
virtual double A() const
Return the effective effective mass of a mole in g/mole.
Definition Element.cxx:139
virtual std::string Name() const
Return the name of this element.
Definition Element.cxx:127
virtual ~Element()
Definition Element.cxx:102
virtual double Z() const
Return the effective atomic number.
Definition Element.cxx:133
TGeoIsotope * GetIsotope(VGM::IIsotope *iIsotope) const
static IsotopeMap * Instance()
Conversion from Root physical units to VGM units.
Definition Units.h:28
static double AtomicWeight()
Return Root atomic weight unit in VGM units.
Definition Units.h:87
The VGM interface to elements.
Definition IIsotope.h:28
VGM implementation for Root.
Definition axis.h:28
VGM interfaces.
Definition VMedium.h:28
std::vector< double > RelAbundanceVector
Definition IElement.h:31
std::vector< IIsotope * > IsotopeVector
Definition IElement.h:30