LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 
35 using namespace boost::python;
36 
37 // ====================================================================
38 // thin wrappers
39 // ====================================================================
40 namespace pyG4Element {
41 
42 // raw pointer -> Python list conversion
43 list f_GetRelativeAbundanceVector(const G4Element* element)
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 ...
55 void Print(G4Element& ele)
56 {
57  std::cout << ele; // problem with G4cout. (delayed message)
58 }
59 
60 }
61 
62 using 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 }
void export_G4Element()
Definition: pyG4Element.cc:67
void Print(G4Element &ele)
Definition: pyG4Element.cc:55
list f_GetRelativeAbundanceVector(const G4Element *element)
Definition: pyG4Element.cc:43