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