From 64399dbf3c5b3a3828346bb51010b6548ba76b58 Mon Sep 17 00:00:00 2001 From: Jan Kieseler Date: Thu, 22 Aug 2024 14:41:24 +0200 Subject: [PATCH] fixes --- bind/G4Calo.py | 2 +- bind/example.ipynb | 24 +++++++++++------------- bind/example.py | 4 +--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/bind/G4Calo.py b/bind/G4Calo.py index 47a591c..07cf48e 100644 --- a/bind/G4Calo.py +++ b/bind/G4Calo.py @@ -317,7 +317,7 @@ def _run_mini_batch( print(f"Running mini batch {counter} with {nEvents} events") import time - time.sleep(counter/1000) + time.sleep(counter/20) print(f'done sleeping {counter}') #this is now encapsuled diff --git a/bind/example.ipynb b/bind/example.ipynb index 3b0c452..83f2b46 100644 --- a/bind/example.ipynb +++ b/bind/example.ipynb @@ -6,19 +6,16 @@ "metadata": {}, "outputs": [], "source": [ - "from G4Calo import GeometryDescriptor, G4System\n", + "from G4Calo import GeometryDescriptor, run_batch, display_event\n", "\n", - "cw = GeometryDescriptor() #the width of the calorimeter is 50 cm times 50 cm (also steerable, but I'd leave it)\n", + "gd = GeometryDescriptor() #the width of the calorimeter is 50 cm times 50 cm (also steerable, but I'd leave it)\n", "\n", - "cw.addLayer(3,\"G4_Si\",True, 7)\n", - "cw.addLayer(4,\"G4_Pb\",False) \n", - "cw.addLayer(3,\"G4_Si\",True, 7)\n", - "cw.addLayer(4,\"G4_Pb\",False)\n", - "cw.addLayer(3,\"G4_Si\",True, 7)\n", - "cw.addLayer(4,\"G4_Pb\",False)\n", - "\n", - "G4s = G4System\n", - "G4s.init(cw)" + "gd.addLayer(3,\"G4_Si\",True, 7)\n", + "gd.addLayer(4,\"G4_Pb\",False) \n", + "gd.addLayer(3,\"G4_Si\",True, 7)\n", + "gd.addLayer(4,\"G4_Pb\",False)\n", + "gd.addLayer(3,\"G4_Si\",True, 7)\n", + "gd.addLayer(4,\"G4_Pb\",False)" ] }, { @@ -27,7 +24,8 @@ "metadata": {}, "outputs": [], "source": [ - "df = G4s.run_batch(10, 'gamma', 1)" + "df = run_batch(gd, 1000, 'gamma', 1)\n", + "df" ] }, { @@ -36,7 +34,7 @@ "metadata": {}, "outputs": [], "source": [ - "G4s.displayEvent()" + "display_event(gd,\"gamma\", 2)" ] }, { diff --git a/bind/example.py b/bind/example.py index f25fa76..766d551 100644 --- a/bind/example.py +++ b/bind/example.py @@ -3,8 +3,7 @@ from G4Calo import GeometryDescriptor, run_batch, display_event import sys if __name__ == '__main__': - #multiprocessing.set_start_method('spawn') - + gd = GeometryDescriptor() for _ in range(25): @@ -19,5 +18,4 @@ if __name__ == '__main__': gd.addLayer(1.,"G4_POLYSTYRENE",True,1) df = run_batch(gd,10, 'gamma', 1) - display_event(gd,"gamma", 2) \ No newline at end of file