Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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::list getParticleTable ()
 
boost::python::list getMaterialTable ()
 
 BOOST_PYTHON_MODULE (TestEm0)
 

Function Documentation

BOOST_PYTHON_MODULE ( TestEm0  )

Definition at line 88 of file pyTestEm0.cc.

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

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

Definition at line 67 of file pyTestEm0.cc.

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

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 51 of file pyTestEm0.cc.

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

Referenced by BOOST_PYTHON_MODULE().

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