Geant4-11
pyG4Element.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// ====================================================================
27// pyG4Element.cc
28//
29// 2005 Q
30// ====================================================================
31#include <boost/python.hpp>
32#include "G4Version.hh"
33#include "G4Element.hh"
34
35using namespace boost::python;
36
37// ====================================================================
38// thin wrappers
39// ====================================================================
40namespace pyG4Element {
41
42// raw pointer -> Python list conversion
44{
45 list aList;
46 const G4double* aVec= element-> GetRelativeAbundanceVector();
47 G4int niso= element-> GetNumberOfIsotopes();
48 for(G4int i=0; i<niso; i++) {
49 aList.append(aVec[i]);
50 }
51 return aList;
52}
53
54// copy constructor is private, so ...
56{
57 std::cout << ele; // problem with G4cout. (delayed message)
58}
59
60}
61
62using namespace pyG4Element;
63
64// ====================================================================
65// module definition
66// ====================================================================
68{
69 class_<G4Element, G4Element*, boost::noncopyable>
70 ("G4Element", "element class", no_init)
71 // constructors
72 .def(init<const G4String&, const G4String&, G4double, G4double>())
73 .def(init<const G4String&, const G4String&, G4int>())
74 // ---
75 .def("AddIsotope", &G4Element::AddIsotope)
76 .def("GetName", &G4Element::GetName,
77 return_value_policy<reference_existing_object>())
78 .def("GetSymbol", &G4Element::GetSymbol,
79 return_value_policy<reference_existing_object>())
80 .def("SetName", &G4Element::SetName)
81 .def("GetZ", &G4Element::GetZ)
82 .def("GetN", &G4Element::GetN)
83 .def("GetA", &G4Element::GetA)
84 .def("GetNbOfAtomicShells", &G4Element::GetNbOfAtomicShells)
85 .def("GetAtomicShell", &G4Element::GetAtomicShell)
86 .def("GetNumberOfIsotopes", &G4Element::GetNumberOfIsotopes)
87 .def("GetIsotopeVector", &G4Element::GetIsotopeVector,
88 return_internal_reference<>())
89 .def("GetRelativeAbundanceVector", f_GetRelativeAbundanceVector)
90 .def("GetIsotope", &G4Element::GetIsotope,
91 return_value_policy<reference_existing_object>())
92 .def("GetElementTable", &G4Element::GetElementTable,
93 return_value_policy<reference_existing_object>())
94 .staticmethod("GetElementTable")
95 .def("GetNumberOfElements", &G4Element::GetNumberOfElements)
96 .staticmethod("GetNumberOfElements")
97 .def("GetIndex", &G4Element::GetIndex)
98 .def("GetElement", &G4Element::GetElement,
99 return_value_policy<reference_existing_object>())
100 .staticmethod("GetElement")
101 .def("GetfCoulomb", &G4Element::GetfCoulomb)
102 .def("GetfRadTsai", &G4Element::GetfRadTsai)
103 .def("GetIonisation", &G4Element::GetIonisation,
104 return_internal_reference<>())
105 // ---
106 .def("Print", Print)
107 ;
108}
static const G4double ele
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:397
const G4String & GetSymbol() const
Definition: G4Element.hh:128
G4double GetZ() const
Definition: G4Element.hh:131
G4int GetNbOfAtomicShells() const
Definition: G4Element.hh:147
static size_t GetNumberOfElements()
Definition: G4Element.cc:404
void SetName(const G4String &name)
Definition: G4Element.hh:215
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:151
const G4Isotope * GetIsotope(G4int iso) const
Definition: G4Element.hh:170
G4double GetA() const
Definition: G4Element.hh:139
size_t GetIndex() const
Definition: G4Element.hh:182
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:159
const G4String & GetName() const
Definition: G4Element.hh:127
G4double GetfCoulomb() const
Definition: G4Element.hh:191
G4IonisParamElm * GetIonisation() const
Definition: G4Element.hh:199
G4double GetfRadTsai() const
Definition: G4Element.hh:195
G4double GetN() const
Definition: G4Element.hh:135
G4double GetAtomicShell(G4int index) const
Definition: G4Element.cc:366
static G4Element * GetElement(G4String name, G4bool warning=true)
Definition: G4Element.cc:411
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:163
list f_GetRelativeAbundanceVector(const G4Element *element)
Definition: pyG4Element.cc:43
void Print(G4Element &ele)
Definition: pyG4Element.cc:55
void export_G4Element()
Definition: pyG4Element.cc:67