Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyG4ProcessManager.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: pyG4ProcessManager.cc,v 1.4 2006-06-29 15:34:55 gunter Exp $
27 // $Name: not supported by cvs2svn $
28 // ====================================================================
29 // pyG4ProcessManager.cc
30 //
31 // 2005 Q
32 // ====================================================================
33 #include <boost/python.hpp>
34 #include "G4ProcessManager.hh"
35 
36 using namespace boost::python;
37 
38 // ====================================================================
39 // thin wrappers
40 // ====================================================================
41 namespace pyG4ProcessManager {
42 
43 // GetProcessList()
44 // raw vector pointer -> Python list conversion
45 list f_GetProcessList(const G4ProcessManager* procMgr)
46 {
47  list procList;
48  G4ProcessVector* procVec= procMgr-> GetProcessList();
49  G4int nproc= procVec-> size();
50  for(G4int i=0; i< nproc; i++) {
51  procList.append(&(*procVec)[i]);
52  }
53  return procList;
54 }
55 
56 // GetProcessVector()
57 list f_GetProcessVector(const G4ProcessManager* procMgr,
60 {
61  list procList;
62  G4ProcessVector* procVec= procMgr-> GetProcessVector(idx, typ);
63  G4int nproc= procVec-> size();
64  for(G4int i=0; i< nproc; i++) {
65  procList.append(&(*procVec)[i]);
66  }
67  return procList;
68 }
69 
70 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetProcessVector,
71  f_GetProcessVector, 2, 3);
72 
73 // GetAtRestProcessVector()
76 {
77  list procList;
78  G4ProcessVector* procVec= procMgr-> GetAtRestProcessVector(typ);
79  G4int nproc= procVec-> size();
80  for(G4int i=0; i< nproc; i++) {
81  procList.append(&(*procVec)[i]);
82  }
83  return procList;
84 }
85 
86 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetAtRestProcessVector,
88 
89 // GetAlongStepProcessVector()
92 {
93  list procList;
94  G4ProcessVector* procVec= procMgr-> GetAlongStepProcessVector(typ);
95  G4int nproc= procVec-> size();
96  for(G4int i=0; i< nproc; i++) {
97  procList.append(&(*procVec)[i]);
98  }
99  return procList;
100 }
101 
102 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetAlongStepProcessVector,
104 
105 // GetPostStepProcessVector()
108 {
109  list procList;
110  G4ProcessVector* procVec= procMgr-> GetPostStepProcessVector(typ);
111  G4int nproc= procVec-> size();
112  for(G4int i=0; i< nproc; i++) {
113  procList.append(&(*procVec)[i]);
114  }
115  return procList;
116 }
117 
118 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetPostStepProcessVector,
120 
121 
122 // GetProcessVectorIndex...
123 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetProcessVectorIndex,
124  GetProcessVectorIndex, 2, 3);
125 
127  GetAtRestIndex, 1, 2);
128 
129 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetAlongStepIndex,
130  GetAlongStepIndex, 1, 2);
131 
132 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetPostStepIndex,
133  GetPostStepIndex, 1, 2);
134 // AddProcess...
135 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddProcess, AddProcess, 1, 4);
137  AddRestProcess, 1, 2);
138 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddDiscreteProcess,
139  AddDiscreteProcess, 1, 2);
140 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddContinuousProcess,
141  AddContinuousProcess, 1, 2);
142 // SetProcessOrdering
143 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_SetProcessOrdering,
144  SetProcessOrdering, 2, 3);
145 
146 // RemoveProcess...
149 
152 
153 // Set/GetProcessActivation...
156 
159 
162 
165 
166 };
167 
168 using namespace pyG4ProcessManager;
169 
170 // ====================================================================
171 // module definition
172 // ====================================================================
174 {
175  class_<G4ProcessManager, G4ProcessManager*, boost::noncopyable>
176  ("G4ProcessManager", "process manager class", no_init)
177  // ---
178  .def("GetProcessList", f_GetProcessList)
179  .def("GetProcessListLength", &G4ProcessManager::GetProcessListLength)
180  .def("GetProcessIndex", &G4ProcessManager::GetProcessIndex)
181  .def("GetProcessVector", f_GetProcessVector,
182  g_GetProcessVector())
183  .def("GetAtRestProcessVector", f_GetAtRestProcessVector,
184  g_GetAtRestProcessVector())
185  .def("GetAlongStepProcessVector", f_GetAlongStepProcessVector,
186  g_GetAlongStepProcessVector())
187  .def("GetPostStepProcessVector", f_GetPostStepProcessVector,
188  g_GetPostStepProcessVector())
189  .def("GetProcessVectorIndex",
191  f_GetProcessVectorIndex())
192  .def("GetAtRestIndex", &G4ProcessManager::GetAtRestIndex,
193  f_GetAtRestIndex())
194  .def("GetAlongStepIndex", &G4ProcessManager::GetAlongStepIndex,
195  f_GetAlongStepIndex())
196  .def("GetPostStepIndex", &G4ProcessManager::GetPostStepIndex,
197  f_GetPostStepIndex())
198  // ----
199  .def("AddProcess", &G4ProcessManager::AddProcess,
200  f_AddProcess())
201  .def("AddRestProcess", &G4ProcessManager::AddRestProcess,
202  f_AddRestProcess())
203  .def("AddDiscreteProcess", &G4ProcessManager::AddDiscreteProcess,
204  f_AddDiscreteProcess())
205  .def("AddContinuousProcess", &G4ProcessManager::AddContinuousProcess,
206  f_AddContinuousProcess())
207  // ---
208  .def("GetProcessOrdering", &G4ProcessManager::GetProcessOrdering)
209  .def("SetProcessOrdering", &G4ProcessManager::SetProcessOrdering,
210  f_SetProcessOrdering())
211  .def("SetProcessOrderingToFirst",
213  .def("SetProcessOrderingToLast",
215  // ---
216  .def("RemoveProcess", f1_RemoveProcess,
217  return_value_policy<reference_existing_object>())
218  .def("RemoveProcess", f2_RemoveProcess,
219  return_value_policy<reference_existing_object>())
220  // ---
221  .def("SetProcessActivation", f1_SetProcessActivation,
222  return_value_policy<reference_existing_object>())
223  .def("SetProcessActivation", f2_SetProcessActivation,
224  return_value_policy<reference_existing_object>())
225  .def("GetProcessActivation", f1_GetProcessActivation)
226  .def("GetProcessActivation", f2_GetProcessActivation)
227  // ---
228  .def("GetParticleType", &G4ProcessManager::GetParticleType,
229  return_internal_reference<>())
230  .def("SetParticleType", &G4ProcessManager::SetParticleType)
231  .def("DumpInfo", &G4ProcessManager::DumpInfo)
232  .def("SetVerboseLevel", &G4ProcessManager::SetVerboseLevel)
233  .def("GetVerboseLevel", &G4ProcessManager::GetVerboseLevel)
234  ;
235 
236  // enums...
237  enum_<G4ProcessVectorTypeIndex>("G4ProcessVectorTypeIndex")
238  .value("typeGPIL", typeGPIL)
239  .value("typeGPIL", typeDoIt)
240  ;
241 
242  enum_<G4ProcessVectorDoItIndex>("G4ProcessVectorDoItIndex")
243  .value("idxAll", idxAll)
244  .value("idxAtRest", idxAtRest)
245  .value("idxAlongStep", idxAlongStep)
246  .value("idxPostStep", idxPostStep)
247  ;
248 
249  enum_<G4ProcessVectorOrdering>("G4ProcessVectorOrdering")
250  .value("ordInActive", ordInActive)
251  .value("ordDefault", ordDefault)
252  .value("ordLast", ordLast)
253  ;
254 }