Geant4  10.00.p03
pyG4ParticleTable.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 // $Id: pyG4ParticleTable.cc 76884 2013-11-18 12:54:03Z gcosmo $
27 // ====================================================================
28 // pyG4ParticleTable.cc
29 //
30 // 2005 Q
31 // ====================================================================
32 #include <boost/python.hpp>
33 #include "G4Version.hh"
34 #include "G4ParticleTable.hh"
35 
36 using namespace boost::python;
37 
38 // ====================================================================
39 // thin wrappers
40 // ====================================================================
41 namespace pyG4ParticleTable {
42 
43 // contains...
46 
49 
50 // FindParticle...
53 
56 
59 
60 // FindAntiParticle...
63 
66 
69 
70 // FindIon
73 
76 
77 #if G4VERSION_NUMBER >= 910
80 #endif
81 
82 #if G4VERSION_NUMBER >= 910
83 // GetIon
86 
89 #endif
90 
91 // DumpTable
92 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DumpTable, DumpTable, 0, 1)
93 
94 
95 // --------------------------------------------------------------------
96 // GetParticleList (returning python list)
97 
98 list GetParticleList(G4ParticleTable* particleTable)
99 {
100  list particleList;
102  theParticleIterator= particleTable-> GetIterator();
103  theParticleIterator-> reset();
104  while( (*theParticleIterator)() ){
105  G4ParticleDefinition* particle= theParticleIterator-> value();
106  particleList.append(&particle);
107  }
108 
109  return particleList;
110 }
111 
112 }
113 
114 using namespace pyG4ParticleTable;
115 
116 // ====================================================================
117 // module definition
118 // ====================================================================
120 {
121  class_<G4ParticleTable, G4ParticleTable*, boost::noncopyable>
122  ("G4ParticleTable", "particle table", no_init)
123  // ---
124  .def("GetParticleTable", &G4ParticleTable::GetParticleTable,
125  return_value_policy<reference_existing_object>())
126  .staticmethod("GetParticleTable")
127  .def("contains", f1_contains)
128  .def("contains", f2_contains)
129  .def("entries", &G4ParticleTable::entries)
130  .def("size", &G4ParticleTable::size)
131  // ---
132  .def("GetParticle", &G4ParticleTable::GetParticle,
133  return_value_policy<reference_existing_object>())
134  .def("GetParticleName", &G4ParticleTable::GetParticleName,
135  return_value_policy<return_by_value>())
136  .def("FindParticle", f1_FindParticle,
137  return_value_policy<reference_existing_object>())
138  .def("FindParticle", f2_FindParticle,
139  return_value_policy<reference_existing_object>())
140  .def("FindParticle", f3_FindParticle,
141  return_value_policy<reference_existing_object>())
142  .def("FindAntiParticle", f1_FindAntiParticle,
143  return_value_policy<reference_existing_object>())
144  .def("FindAntiParticle", f2_FindAntiParticle,
145  return_value_policy<reference_existing_object>())
146  .def("FindAntiParticle", f3_FindAntiParticle,
147  return_value_policy<reference_existing_object>())
148  .def("FindIon", f1_FindIon,
149  return_value_policy<reference_existing_object>())
150  .def("FindIon", f2_FindIon,
151  return_value_policy<reference_existing_object>())
152 #if G4VERSION_NUMBER >= 910
153  .def("FindIon", f3_FindIon,
154  return_value_policy<reference_existing_object>())
155 #endif
156 #if G4VERSION_NUMBER >= 910
157  .def("GetIon", f1_GetIon,
158  return_value_policy<reference_existing_object>())
159  .def("GetIon", f2_GetIon,
160  return_value_policy<reference_existing_object>())
161 #else
162  .def("GetIon", &G4ParticleTable::GetIon,
163  return_value_policy<reference_existing_object>())
164 #endif
165  .def("DumpTable", &G4ParticleTable::DumpTable, f_DumpTable())
166  //.def("GetIonTable", &G4ParticleTable::GetIonTable,
167  //...)
168  //.def("GetShortLivedTable", &G4ParticleTable::GetShortLivedTable,
169  //...)
170  .def("SetVerboseLevel", &G4ParticleTable::SetVerboseLevel)
171  .def("GetVerboseLevel", &G4ParticleTable::GetVerboseLevel)
172  .def("SetReadiness", &G4ParticleTable::SetReadiness)
173  .def("GetReadiness", &G4ParticleTable::GetReadiness)
174  // ---
175  // additionals
176  .def("GetParticleList", GetParticleList)
177  ;
178 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4ParticleDefinition * FindAntiParticle(G4int PDGEncoding)
G4ParticleDefinition *(G4ParticleTable::* f2_FindAntiParticle)(const G4String &)
void DumpTable(const G4String &particle_name="ALL")
G4ParticleDefinition * GetIon(G4int atomicNumber, G4int atomicMass, G4double excitationEnergy)
const G4String & GetParticleName(G4int index) const
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume, CreateTubeVolume, 4, 6) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume
G4ParticleDefinition *(G4ParticleTable::* f1_FindParticle)(G4int)
void SetVerboseLevel(G4int value)
void SetReadiness(G4bool val=true)
G4bool GetReadiness() const
int G4int
Definition: G4Types.hh:78
G4bool(G4ParticleTable::* f2_contains)(const G4String &) const
G4ParticleDefinition * GetParticle(G4int index) const
static G4ThreadLocal tpia_particle * particleList
bool G4bool
Definition: G4Types.hh:79
G4ParticleDefinition * FindIon(G4int atomicNumber, G4int atomicMass, G4double excitationEnergy)
list GetParticleList(G4ParticleTable *particleTable)
G4bool contains(const G4ParticleDefinition *particle) const
static G4ParticleTable * GetParticleTable()
G4bool(G4ParticleTable::* f1_contains)(const G4ParticleDefinition *) const
G4ParticleDefinition *(G4ParticleTable::* f3_FindAntiParticle)(const G4ParticleDefinition *)
G4ParticleDefinition *(G4ParticleTable::* f1_FindIon)(G4int, G4int, G4double)
G4ParticleDefinition *(G4ParticleTable::* f2_FindParticle)(const G4String &)
G4ParticleDefinition *(G4ParticleTable::* f2_FindIon)(G4int, G4int, G4int, G4int)
double G4double
Definition: G4Types.hh:76
G4int size() const
G4int GetVerboseLevel() const
G4int entries() const
G4ParticleDefinition *(G4ParticleTable::* f3_FindParticle)(const G4ParticleDefinition *)
#define theParticleIterator
G4ParticleDefinition *(G4ParticleTable::* f1_FindAntiParticle)(G4int)
void export_G4ParticleTable()