Geant4.10
 All Data Structures 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 76884 2013-11-18 12:54:03Z gcosmo $
27 // ====================================================================
28 // pyG4ProcessManager.cc
29 //
30 // 2005 Q
31 // ====================================================================
32 #include <boost/python.hpp>
33 #include "G4ProcessManager.hh"
34 
35 using namespace boost::python;
36 
37 // ====================================================================
38 // thin wrappers
39 // ====================================================================
40 namespace pyG4ProcessManager {
41 
42 // GetProcessList()
43 // raw vector pointer -> Python list conversion
44 list f_GetProcessList(const G4ProcessManager* procMgr)
45 {
46  list procList;
47  G4ProcessVector* procVec= procMgr-> GetProcessList();
48  G4int nproc= procVec-> size();
49  for(G4int i=0; i< nproc; i++) {
50  procList.append(&(*procVec)[i]);
51  }
52  return procList;
53 }
54 
55 // GetProcessVector()
59 {
60  list procList;
61  G4ProcessVector* procVec= procMgr-> GetProcessVector(idx, typ);
62  G4int nproc= procVec-> size();
63  for(G4int i=0; i< nproc; i++) {
64  procList.append(&(*procVec)[i]);
65  }
66  return procList;
67 }
68 
69 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetProcessVector,
70  f_GetProcessVector, 2, 3)
71 
72 // GetAtRestProcessVector()
73 list f_GetAtRestProcessVector(const G4ProcessManager* procMgr,
75 {
76  list procList;
77  G4ProcessVector* procVec= procMgr-> GetAtRestProcessVector(typ);
78  G4int nproc= procVec-> size();
79  for(G4int i=0; i< nproc; i++) {
80  procList.append(&(*procVec)[i]);
81  }
82  return procList;
83 }
84 
85 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetAtRestProcessVector,
86  f_GetAtRestProcessVector, 1, 2)
87 
88 // GetAlongStepProcessVector()
89 list f_GetAlongStepProcessVector(const G4ProcessManager* procMgr,
91 {
92  list procList;
93  G4ProcessVector* procVec= procMgr-> GetAlongStepProcessVector(typ);
94  G4int nproc= procVec-> size();
95  for(G4int i=0; i< nproc; i++) {
96  procList.append(&(*procVec)[i]);
97  }
98  return procList;
99 }
100 
101 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetAlongStepProcessVector,
102  f_GetAlongStepProcessVector, 1, 2)
103 
104 // GetPostStepProcessVector()
105 list f_GetPostStepProcessVector(const G4ProcessManager* procMgr,
106  G4ProcessVectorTypeIndex typ= typeGPIL )
107 {
108  list procList;
109  G4ProcessVector* procVec= procMgr-> GetPostStepProcessVector(typ);
110  G4int nproc= procVec-> size();
111  for(G4int i=0; i< nproc; i++) {
112  procList.append(&(*procVec)[i]);
113  }
114  return procList;
115 }
116 
117 BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetPostStepProcessVector,
118  f_GetPostStepProcessVector, 1, 2)
119 
120 // GetProcessVectorIndex...
121 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetProcessVectorIndex,
122  GetProcessVectorIndex, 2, 3)
123 
125  GetAtRestIndex, 1, 2)
126 
127 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetAlongStepIndex,
128  GetAlongStepIndex, 1, 2)
129 
130 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetPostStepIndex,
131  GetPostStepIndex, 1, 2)
132 // AddProcess...
133 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddProcess, AddProcess, 1, 4)
135  AddRestProcess, 1, 2)
136 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddDiscreteProcess,
137  AddDiscreteProcess, 1, 2)
138 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddContinuousProcess,
139  AddContinuousProcess, 1, 2)
140 // SetProcessOrdering
141 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_SetProcessOrdering,
142  SetProcessOrdering, 2, 3)
143 
144 // RemoveProcess...
145 G4VProcess*(G4ProcessManager::*f1_RemoveProcess)(G4VProcess*)
146  = &G4ProcessManager::RemoveProcess;
147 
149  = &G4ProcessManager::RemoveProcess;
150 
151 // Set/GetProcessActivation...
153  = &G4ProcessManager::SetProcessActivation;
154 
156  = &G4ProcessManager::SetProcessActivation;
157 
159  = &G4ProcessManager::GetProcessActivation;
160 
162  = &G4ProcessManager::GetProcessActivation;
163 
164 }
165 
166 using namespace pyG4ProcessManager;
167 
168 // ====================================================================
169 // module definition
170 // ====================================================================
172 {
173  class_<G4ProcessManager, G4ProcessManager*, boost::noncopyable>
174  ("G4ProcessManager", "process manager class", no_init)
175  // ---
176  .def("GetProcessList", f_GetProcessList)
177  .def("GetProcessListLength", &G4ProcessManager::GetProcessListLength)
178  .def("GetProcessIndex", &G4ProcessManager::GetProcessIndex)
179  .def("GetProcessVector", f_GetProcessVector,
180  g_GetProcessVector())
181  .def("GetAtRestProcessVector", f_GetAtRestProcessVector,
182  g_GetAtRestProcessVector())
183  .def("GetAlongStepProcessVector", f_GetAlongStepProcessVector,
184  g_GetAlongStepProcessVector())
185  .def("GetPostStepProcessVector", f_GetPostStepProcessVector,
186  g_GetPostStepProcessVector())
187  .def("GetProcessVectorIndex",
189  f_GetProcessVectorIndex())
190  .def("GetAtRestIndex", &G4ProcessManager::GetAtRestIndex,
191  f_GetAtRestIndex())
192  .def("GetAlongStepIndex", &G4ProcessManager::GetAlongStepIndex,
193  f_GetAlongStepIndex())
194  .def("GetPostStepIndex", &G4ProcessManager::GetPostStepIndex,
195  f_GetPostStepIndex())
196  // ----
197  .def("AddProcess", &G4ProcessManager::AddProcess,
198  f_AddProcess())
199  .def("AddRestProcess", &G4ProcessManager::AddRestProcess,
200  f_AddRestProcess())
201  .def("AddDiscreteProcess", &G4ProcessManager::AddDiscreteProcess,
202  f_AddDiscreteProcess())
203  .def("AddContinuousProcess", &G4ProcessManager::AddContinuousProcess,
204  f_AddContinuousProcess())
205  // ---
206  .def("GetProcessOrdering", &G4ProcessManager::GetProcessOrdering)
207  .def("SetProcessOrdering", &G4ProcessManager::SetProcessOrdering,
208  f_SetProcessOrdering())
209  .def("SetProcessOrderingToFirst",
211  .def("SetProcessOrderingToLast",
213  // ---
214  .def("RemoveProcess", f1_RemoveProcess,
215  return_value_policy<reference_existing_object>())
216  .def("RemoveProcess", f2_RemoveProcess,
217  return_value_policy<reference_existing_object>())
218  // ---
219  .def("SetProcessActivation", f1_SetProcessActivation,
220  return_value_policy<reference_existing_object>())
221  .def("SetProcessActivation", f2_SetProcessActivation,
222  return_value_policy<reference_existing_object>())
223  .def("GetProcessActivation", f1_GetProcessActivation)
224  .def("GetProcessActivation", f2_GetProcessActivation)
225  // ---
226  .def("GetParticleType", &G4ProcessManager::GetParticleType,
227  return_internal_reference<>())
228  .def("SetParticleType", &G4ProcessManager::SetParticleType)
229  .def("DumpInfo", &G4ProcessManager::DumpInfo)
230  .def("SetVerboseLevel", &G4ProcessManager::SetVerboseLevel)
231  .def("GetVerboseLevel", &G4ProcessManager::GetVerboseLevel)
232  ;
233 
234  // enums...
235  enum_<G4ProcessVectorTypeIndex>("G4ProcessVectorTypeIndex")
236  .value("typeGPIL", typeGPIL)
237  .value("typeGPIL", typeDoIt)
238  ;
239 
240  enum_<G4ProcessVectorDoItIndex>("G4ProcessVectorDoItIndex")
241  .value("idxAll", idxAll)
242  .value("idxAtRest", idxAtRest)
243  .value("idxAlongStep", idxAlongStep)
244  .value("idxPostStep", idxPostStep)
245  ;
246 
247  enum_<G4ProcessVectorOrdering>("G4ProcessVectorOrdering")
248  .value("ordInActive", ordInActive)
249  .value("ordDefault", ordDefault)
250  .value("ordLast", ordLast)
251  ;
252 }
G4int GetProcessVectorIndex(G4VProcess *aProcess, G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL) const
void export_G4ProcessManager()
G4int GetAlongStepIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4ProcessVectorTypeIndex typ
void SetProcessOrderingToFirst(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
BOOST_PYTHON_FUNCTION_OVERLOADS(f_func2, func2, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume, CreateTubeVolume, 4, 6) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4int GetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void SetVerboseLevel(G4int value)
G4int GetVerboseLevel() const
void SetParticleType(const G4ParticleDefinition *)
int G4int
Definition: G4Types.hh:78
G4int GetAtRestIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4VProcess *(G4ProcessManager::* f1_SetProcessActivation)(G4VProcess *, G4bool)
G4bool(G4ProcessManager::* f1_GetProcessActivation)(G4VProcess *) const
bool G4bool
Definition: G4Types.hh:79
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
list f_GetProcessVector(const G4ProcessManager *procMgr, G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL)
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
G4ParticleDefinition * GetParticleType() const
G4VProcess *(G4ProcessManager::* f2_RemoveProcess)(G4int)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4int GetPostStepIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
list f_GetProcessList(const G4ProcessManager *procMgr)
G4int GetProcessIndex(G4VProcess *) const
const XML_Char int const XML_Char * value
G4int AddRestProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4VProcess *(G4ProcessManager::* f2_SetProcessActivation)(G4int, G4bool)
G4ProcessVectorTypeIndex
G4int GetProcessListLength() const
G4ProcessVectorDoItIndex
G4bool(G4ProcessManager::* f2_GetProcessActivation)(G4int) const
G4int AddContinuousProcess(G4VProcess *aProcess, G4int ord=ordDefault)