ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyG4ParticleTable.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyG4ParticleTable.cc
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 // ====================================================================
27 // pyG4ParticleTable.cc
28 //
29 // 2005 Q
30 // ====================================================================
31 #include <boost/python.hpp>
32 #include "G4Version.hh"
33 #include "G4ParticleTable.hh"
34 
35 using namespace boost::python;
36 
37 // ====================================================================
38 // thin wrappers
39 // ====================================================================
40 namespace pyG4ParticleTable {
41 
42 // contains...
45 
48 
49 // FindParticle...
52 
55 
58 
59 // FindAntiParticle...
62 
65 
68 
69 // DumpTable
70 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DumpTable, DumpTable, 0, 1)
71 
72 
73 // --------------------------------------------------------------------
74 // GetParticleList (returning python list)
75 
76 list GetParticleList(G4ParticleTable* particleTable)
77 {
78  list particleList;
80  theParticleIterator= particleTable-> GetIterator();
81  theParticleIterator-> reset();
82  while( (*theParticleIterator)() ){
83  G4ParticleDefinition* particle= theParticleIterator-> value();
84  particleList.append(&particle);
85  }
86 
87  return particleList;
88 }
89 
90 }
91 
92 using namespace pyG4ParticleTable;
93 
94 // ====================================================================
95 // module definition
96 // ====================================================================
98 {
99  class_<G4ParticleTable, G4ParticleTable*, boost::noncopyable>
100  ("G4ParticleTable", "particle table", no_init)
101  // ---
102  .def("GetParticleTable", &G4ParticleTable::GetParticleTable,
103  return_value_policy<reference_existing_object>())
104  .staticmethod("GetParticleTable")
105  .def("contains", f1_contains)
106  .def("contains", f2_contains)
107  .def("entries", &G4ParticleTable::entries)
108  .def("size", &G4ParticleTable::size)
109  // ---
110  .def("GetParticle", &G4ParticleTable::GetParticle,
111  return_value_policy<reference_existing_object>())
112  .def("GetParticleName", &G4ParticleTable::GetParticleName,
113  return_value_policy<return_by_value>())
114  .def("FindParticle", f1_FindParticle,
115  return_value_policy<reference_existing_object>())
116  .def("FindParticle", f2_FindParticle,
117  return_value_policy<reference_existing_object>())
118  .def("FindParticle", f3_FindParticle,
119  return_value_policy<reference_existing_object>())
120  .def("FindAntiParticle", f1_FindAntiParticle,
121  return_value_policy<reference_existing_object>())
122  .def("FindAntiParticle", f2_FindAntiParticle,
123  return_value_policy<reference_existing_object>())
124  .def("FindAntiParticle", f3_FindAntiParticle,
125  return_value_policy<reference_existing_object>())
126  .def("DumpTable", &G4ParticleTable::DumpTable, f_DumpTable())
127  //.def("GetIonTable", &G4ParticleTable::GetIonTable,
128  //...)
129  //.def("GetShortLivedTable", &G4ParticleTable::GetShortLivedTable,
130  //...)
131  .def("SetVerboseLevel", &G4ParticleTable::SetVerboseLevel)
132  .def("GetVerboseLevel", &G4ParticleTable::GetVerboseLevel)
133  .def("SetReadiness", &G4ParticleTable::SetReadiness)
134  .def("GetReadiness", &G4ParticleTable::GetReadiness)
135  // ---
136  // additionals
137  .def("GetParticleList", GetParticleList)
138  ;
139 }