LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 87 of file pytestem0.cc.

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

87  {
88 
89  def ("getMaterialTable", getMaterialTable);
90 
91  def ("getParticleTable", getParticleTable);
92 
93  class_<DetectorConstruction, DetectorConstruction*,
94  bases<G4VUserDetectorConstruction> >
95  ("DetectorConstruction", "testEm0 detector")
96  .def("SetMaterial",&DetectorConstruction::SetMaterial)
97  ;
98 
99  class_<PrimaryGeneratorAction, PrimaryGeneratorAction*,
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
TConfigurablePhysicsList< ModularPhysicsList > PhysicsList
Definition: PhysicsList.h:83
boost::python::list getMaterialTable ( )

Definition at line 66 of file pytestem0.cc.

Referenced by BOOST_PYTHON_MODULE().

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
72  G4MaterialTable materialList = *G4Material::GetMaterialTable();
73 
75  for(itVectorData = materialList.begin(); itVectorData != materialList.end(); itVectorData++) {
76  materialTableList->append ( (std::string)(*(itVectorData))->GetName()) ;
77 
78  }
79  return *materialTableList;
80 }
intermediate_table::iterator iterator
boost::python::list getParticleTable ( )

Definition at line 50 of file pytestem0.cc.

Referenced by BOOST_PYTHON_MODULE().

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
56  G4ParticleTable *g4ParticleList = G4ParticleTable::GetParticleTable();
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 }