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: pyG4RunManager.cc,v 1.5 2010/06/21 12:28:29 kmura Exp $ |
---|
27 | // $Name: geant4-09-04-beta-01 $ |
---|
28 | // ==================================================================== |
---|
29 | // pyG4RunManager.cc |
---|
30 | // |
---|
31 | // 2005 Q |
---|
32 | // ==================================================================== |
---|
33 | #include <boost/python.hpp> |
---|
34 | #include "G4Version.hh" |
---|
35 | #include "G4RunManager.hh" |
---|
36 | #include "G4VUserDetectorConstruction.hh" |
---|
37 | #include "G4VUserPhysicsList.hh" |
---|
38 | #include "G4UserRunAction.hh" |
---|
39 | #include "G4VUserPrimaryGeneratorAction.hh" |
---|
40 | #include "G4UserEventAction.hh" |
---|
41 | #include "G4UserStackingAction.hh" |
---|
42 | #include "G4UserTrackingAction.hh" |
---|
43 | #include "G4UserSteppingAction.hh" |
---|
44 | #include "G4Region.hh" |
---|
45 | #include "G4Run.hh" |
---|
46 | #include "G4Event.hh" |
---|
47 | |
---|
48 | using namespace boost::python; |
---|
49 | |
---|
50 | // ==================================================================== |
---|
51 | // thin wrappers |
---|
52 | // ==================================================================== |
---|
53 | namespace pyG4RunManager { |
---|
54 | |
---|
55 | // SetUserInitialization() |
---|
56 | void (G4RunManager::*f1_SetUserInitialization)(G4VUserDetectorConstruction*) |
---|
57 | = &G4RunManager::SetUserInitialization; |
---|
58 | void (G4RunManager::*f2_SetUserInitialization)(G4VUserPhysicsList*) |
---|
59 | = &G4RunManager::SetUserInitialization; |
---|
60 | |
---|
61 | // SetUserAction() |
---|
62 | void (G4RunManager::*f1_SetUserAction)(G4UserRunAction*) |
---|
63 | = &G4RunManager::SetUserAction; |
---|
64 | void (G4RunManager::*f2_SetUserAction)(G4VUserPrimaryGeneratorAction*) |
---|
65 | = &G4RunManager::SetUserAction; |
---|
66 | void (G4RunManager::*f3_SetUserAction)(G4UserEventAction*) |
---|
67 | = &G4RunManager::SetUserAction; |
---|
68 | void (G4RunManager::*f4_SetUserAction)(G4UserStackingAction*) |
---|
69 | = &G4RunManager::SetUserAction; |
---|
70 | void (G4RunManager::*f5_SetUserAction)(G4UserTrackingAction*) |
---|
71 | = &G4RunManager::SetUserAction; |
---|
72 | void (G4RunManager::*f6_SetUserAction)(G4UserSteppingAction*) |
---|
73 | = &G4RunManager::SetUserAction; |
---|
74 | |
---|
75 | // DumpRegion |
---|
76 | #if G4VERSION_NUMBER >= 940 |
---|
77 | void (G4RunManager::*f1_DumpRegion)(const G4String&) const |
---|
78 | = &G4RunManager::DumpRegion; |
---|
79 | #else |
---|
80 | void (G4RunManager::*f1_DumpRegion)(G4String) const |
---|
81 | = &G4RunManager::DumpRegion; |
---|
82 | #endif |
---|
83 | void (G4RunManager::*f2_DumpRegion)(G4Region*) const |
---|
84 | = &G4RunManager::DumpRegion; |
---|
85 | |
---|
86 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DumpRegion, DumpRegion, 0, 1); |
---|
87 | |
---|
88 | // BeamOn() |
---|
89 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_BeamOn, BeamOn, 1, 3); |
---|
90 | |
---|
91 | // AbortRun() |
---|
92 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AbortRun, AbortRun, 0, 1); |
---|
93 | |
---|
94 | // DefineWorldVolume() |
---|
95 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DefineWorldVolume, |
---|
96 | DefineWorldVolume, 1, 2); |
---|
97 | |
---|
98 | }; |
---|
99 | |
---|
100 | using namespace pyG4RunManager; |
---|
101 | |
---|
102 | // ==================================================================== |
---|
103 | // module definition |
---|
104 | // ==================================================================== |
---|
105 | void export_G4RunManager() |
---|
106 | { |
---|
107 | class_<G4RunManager>("G4RunManager", "run manager class") |
---|
108 | // --- |
---|
109 | .def("GetRunManager", &G4RunManager::GetRunManager, |
---|
110 | "Get an instance of G4RunManager", |
---|
111 | return_value_policy<reference_existing_object>()) |
---|
112 | .staticmethod("GetRunManager") |
---|
113 | // --- |
---|
114 | .def("SetVerboseLevel", &G4RunManager::SetVerboseLevel) |
---|
115 | .def("GetVerboseLevel", &G4RunManager::GetVerboseLevel) |
---|
116 | // --- |
---|
117 | .def("Initialize", &G4RunManager::Initialize) |
---|
118 | .def("BeamOn", &G4RunManager::BeamOn, |
---|
119 | f_BeamOn((arg("n_event"), arg("macroFile")=0, |
---|
120 | arg("n_select")=-1), |
---|
121 | "Starts event loop.")) |
---|
122 | // --- |
---|
123 | .def("SetUserInitialization", f1_SetUserInitialization) |
---|
124 | .def("SetUserInitialization", f2_SetUserInitialization) |
---|
125 | .def("SetUserAction", f1_SetUserAction) |
---|
126 | .def("SetUserAction", f2_SetUserAction) |
---|
127 | .def("SetUserAction", f3_SetUserAction) |
---|
128 | .def("SetUserAction", f4_SetUserAction) |
---|
129 | .def("SetUserAction", f5_SetUserAction) |
---|
130 | .def("SetUserAction", f6_SetUserAction) |
---|
131 | // --- |
---|
132 | .def("GetUserDetectorConstruction", |
---|
133 | &G4RunManager::GetUserDetectorConstruction, |
---|
134 | return_internal_reference<>()) |
---|
135 | .def("GetUserPhysicsList", |
---|
136 | &G4RunManager::GetUserPhysicsList, |
---|
137 | return_internal_reference<>()) |
---|
138 | .def("GetUserPrimaryGeneratorAction", |
---|
139 | &G4RunManager::GetUserPrimaryGeneratorAction, |
---|
140 | return_internal_reference<>()) |
---|
141 | .def("GetUserRunAction", &G4RunManager::GetUserRunAction, |
---|
142 | return_internal_reference<>()) |
---|
143 | .def("GetUserEventAction", &G4RunManager::GetUserEventAction, |
---|
144 | return_internal_reference<>()) |
---|
145 | .def("GetUserStackingAction", &G4RunManager::GetUserStackingAction, |
---|
146 | return_internal_reference<>()) |
---|
147 | .def("GetUserTrackingAction", &G4RunManager::GetUserTrackingAction, |
---|
148 | return_internal_reference<>()) |
---|
149 | .def("GetUserSteppingAction", &G4RunManager::GetUserSteppingAction, |
---|
150 | return_internal_reference<>()) |
---|
151 | // --- |
---|
152 | .def("AbortRun", &G4RunManager::AbortRun, |
---|
153 | f_AbortRun((arg("soft_abort")=false), |
---|
154 | "Abort run (event loop).")) |
---|
155 | .def("AbortEvent", &G4RunManager::AbortEvent) |
---|
156 | .def("DefineWorldVolume", &G4RunManager::DefineWorldVolume, |
---|
157 | f_DefineWorldVolume()) |
---|
158 | .def("DumpRegion", f1_DumpRegion) |
---|
159 | .def("DumpRegion", f2_DumpRegion, f_DumpRegion()) |
---|
160 | .def("rndmSaveThisRun", &G4RunManager::rndmSaveThisRun) |
---|
161 | .def("rndmSaveThisEvent", &G4RunManager::rndmSaveThisEvent) |
---|
162 | .def("RestoreRandomNumberStatus", |
---|
163 | &G4RunManager::RestoreRandomNumberStatus) |
---|
164 | .def("SetRandomNumberStore", &G4RunManager::SetRandomNumberStore) |
---|
165 | .def("GetRandomNumberStore", &G4RunManager::GetRandomNumberStore) |
---|
166 | .def("SetRandomNumberStoreDir", &G4RunManager::SetRandomNumberStoreDir) |
---|
167 | .def("GeometryHasBeenModified", &G4RunManager::GeometryHasBeenModified) |
---|
168 | .def("PhysicsHasBeenModified", &G4RunManager::PhysicsHasBeenModified) |
---|
169 | .def("GetGeometryToBeOptimized",&G4RunManager::GetGeometryToBeOptimized) |
---|
170 | .def("GetCurrentRun", &G4RunManager::GetCurrentRun, |
---|
171 | return_value_policy<reference_existing_object>()) |
---|
172 | .def("GetCurrentEvent", &G4RunManager::GetCurrentEvent, |
---|
173 | return_value_policy<reference_existing_object>()) |
---|
174 | .def("SetRunIDCounter", &G4RunManager::SetRunIDCounter) |
---|
175 | |
---|
176 | #if G4VERSION_NUMBER >= 940 |
---|
177 | .def("GetVersionString", &G4RunManager::GetVersionString, |
---|
178 | return_value_policy<reference_existing_object>()) |
---|
179 | .def("GetRandomNumberStoreDir", &G4RunManager::GetRandomNumberStoreDir, |
---|
180 | return_internal_reference<>()) |
---|
181 | #else |
---|
182 | .def("GetVersionString", &G4RunManager::GetVersionString) |
---|
183 | .def("GetRandomNumberStoreDir", &G4RunManager::GetRandomNumberStoreDir) |
---|
184 | #endif |
---|
185 | ; |
---|
186 | |
---|
187 | // reduced functionality... |
---|
188 | // void SetPrimaryTransformer(G4PrimaryTransformer* pt) |
---|
189 | // void SetNumberOfAdditionalWaitingStacks(G4int iAdd) |
---|
190 | // void CutOffHasBeenModified() |
---|
191 | // void SetGeometryToBeOptimized(G4bool vl) |
---|
192 | // const G4Event* GetPreviousEvent(G4int i) const |
---|
193 | // void SetNumberOfEventsToBeStored(G4int val) |
---|
194 | // void SetDCtable(G4DCtable* DCtbl) |
---|
195 | |
---|
196 | } |
---|