Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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,v 1.5 2007-11-07 09:12:53 kmura Exp $
27 // $Name: not supported by cvs2svn $
28 // ====================================================================
29 // pyG4ParticleTable.cc
30 //
31 // 2005 Q
32 // ====================================================================
33 #include <boost/python.hpp>
34 #include "G4Version.hh"
35 #include "G4ParticleTable.hh"
36 
37 using namespace boost::python;
38 
39 // ====================================================================
40 // thin wrappers
41 // ====================================================================
42 namespace pyG4ParticleTable {
43 
44 // contains...
47 
50 
51 // FindParticle...
54 
57 
60 
61 // FindAntiParticle...
64 
67 
70 
71 // FindIon
74 
77 
78 #if G4VERSION_NUMBER >= 910
81 #endif
82 
83 #if G4VERSION_NUMBER >= 910
84 // GetIon
87 
90 #endif
91 
92 // DumpTable
93 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DumpTable, DumpTable, 0, 1);
94 
95 
96 // --------------------------------------------------------------------
97 // GetParticleList (returning python list)
98 
99 list GetParticleList(G4ParticleTable* particleTable)
100 {
101  list particleList;
103  theParticleIterator= particleTable-> GetIterator();
104  theParticleIterator-> reset();
105  while( (*theParticleIterator)() ){
106  G4ParticleDefinition* particle= theParticleIterator-> value();
107  particleList.append(&particle);
108  }
109 
110  return particleList;
111 }
112 
113 };
114 
115 using namespace pyG4ParticleTable;
116 
117 // ====================================================================
118 // module definition
119 // ====================================================================
121 {
122  class_<G4ParticleTable, G4ParticleTable*, boost::noncopyable>
123  ("G4ParticleTable", "particle table", no_init)
124  // ---
125  .def("GetParticleTable", &G4ParticleTable::GetParticleTable,
126  return_value_policy<reference_existing_object>())
127  .staticmethod("GetParticleTable")
128  .def("contains", f1_contains)
129  .def("contains", f2_contains)
130  .def("entries", &G4ParticleTable::entries)
131  .def("size", &G4ParticleTable::size)
132  // ---
133  .def("GetParticle", &G4ParticleTable::GetParticle,
134  return_value_policy<reference_existing_object>())
135  .def("GetParticleName", &G4ParticleTable::GetParticleName,
136  return_value_policy<return_by_value>())
137  .def("FindParticle", f1_FindParticle,
138  return_value_policy<reference_existing_object>())
139  .def("FindParticle", f2_FindParticle,
140  return_value_policy<reference_existing_object>())
141  .def("FindParticle", f3_FindParticle,
142  return_value_policy<reference_existing_object>())
143  .def("FindAntiParticle", f1_FindAntiParticle,
144  return_value_policy<reference_existing_object>())
145  .def("FindAntiParticle", f2_FindAntiParticle,
146  return_value_policy<reference_existing_object>())
147  .def("FindAntiParticle", f3_FindAntiParticle,
148  return_value_policy<reference_existing_object>())
149  .def("FindIon", f1_FindIon,
150  return_value_policy<reference_existing_object>())
151  .def("FindIon", f2_FindIon,
152  return_value_policy<reference_existing_object>())
153 #if G4VERSION_NUMBER >= 910
154  .def("FindIon", f3_FindIon,
155  return_value_policy<reference_existing_object>())
156 #endif
157 #if G4VERSION_NUMBER >= 910
158  .def("GetIon", f1_GetIon,
159  return_value_policy<reference_existing_object>())
160  .def("GetIon", f2_GetIon,
161  return_value_policy<reference_existing_object>())
162 #else
163  .def("GetIon", &G4ParticleTable::GetIon,
164  return_value_policy<reference_existing_object>())
165 #endif
166  .def("DumpTable", &G4ParticleTable::DumpTable, f_DumpTable())
167  //.def("GetIonTable", &G4ParticleTable::GetIonTable,
168  //...)
169  //.def("GetShortLivedTable", &G4ParticleTable::GetShortLivedTable,
170  //...)
171  .def("SetVerboseLevel", &G4ParticleTable::SetVerboseLevel)
172  .def("GetVerboseLevel", &G4ParticleTable::GetVerboseLevel)
173  .def("SetReadiness", &G4ParticleTable::SetReadiness)
174  .def("GetReadiness", &G4ParticleTable::GetReadiness)
175  // ---
176  // additionals
177  .def("GetParticleList", GetParticleList)
178  ;
179 }