Geant4-11
Functions
pytestem0.cc File Reference
#include "DetectorConstruction.hh"
#include "RunAction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4ParticleTable.hh"
#include <boost/python.hpp>
#include <boost/python/list.hpp>
#include <vector>
#include <string>

Go to the source code of this file.

Functions

 BOOST_PYTHON_MODULE (testem0)
 
boost::python::list getMaterialTable ()
 
boost::python::list getParticleTable ()
 

Function Documentation

◆ BOOST_PYTHON_MODULE()

BOOST_PYTHON_MODULE ( testem0  )

Definition at line 87 of file pytestem0.cc.

87 {
88
89 def ("getMaterialTable", getMaterialTable);
90
91 def ("getParticleTable", getParticleTable);
92
94 bases<G4VUserDetectorConstruction> >
95 ("DetectorConstruction", "testEm0 detector")
96 .def("SetMaterial",&DetectorConstruction::SetMaterial)
97 ;
98
100 bases<G4VUserPrimaryGeneratorAction> >
101 ("PrimaryGeneratorAction", init<DetectorConstruction*>())
102 ;
103
104 class_<RunAction, RunAction*,
105 bases<G4UserRunAction> >
106 ("RunAction", init<DetectorConstruction*, PrimaryGeneratorAction*>())
107 ;
108
109 class_<PhysicsList, PhysicsList*,
110 bases<G4VUserPhysicsList> >
111 ("PhysicsList", "testEm0 physics list")
112 ;
113}
boost::python::list getParticleTable()
Definition: pytestem0.cc:50
boost::python::list getMaterialTable()
Definition: pytestem0.cc:66

References getMaterialTable(), getParticleTable(), and DetectorConstruction::SetMaterial().

◆ getMaterialTable()

boost::python::list getMaterialTable ( )

Definition at line 66 of file pytestem0.cc.

67 {
68 // Create a list on heap which will be return to python
69 boost::python::list *materialTableList = new boost::python::list();
70
71 // Get material list fron G4Material
73
74 std::vector<G4Material*>::iterator itVectorData;
75 for(itVectorData = materialList.begin(); itVectorData != materialList.end(); itVectorData++) {
76 materialTableList->append ( (std::string)(*(itVectorData))->GetName()) ;
77
78 }
79 return *materialTableList;
80}
std::vector< G4Material * > G4MaterialTable
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
materialList
Definition: demo.py:39

References G4Material::GetMaterialTable(), and demo::materialList.

Referenced by BOOST_PYTHON_MODULE().

◆ getParticleTable()

boost::python::list getParticleTable ( )

Definition at line 50 of file pytestem0.cc.

51{
52 // Create a list on heap which will be return to python
53 boost::python::list *particleList = new boost::python::list();
54
55 // Get particle list fron G4ParticleTable
57
58 // Fill python list from g4ParticleList
59 for ( int index = 0 ; index <= g4ParticleList->size() ; index++ ) {
60 particleList->append ( (std::string) g4ParticleList->GetParticleName(index) );
61 }
62
63 return *particleList;
64}
static MCGIDI_particle * particleList
static G4ParticleTable * GetParticleTable()
G4int size() const
const G4String & GetParticleName(G4int index) const

References G4ParticleTable::GetParticleName(), G4ParticleTable::GetParticleTable(), particleList, and G4ParticleTable::size().

Referenced by BOOST_PYTHON_MODULE().