15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 1 Python Interface for Geant4 Medical Applications K.Murakami (KEK) 15/Jul/05.

Slides:



Advertisements
Similar presentations
Koichi Murakami Geant4 Users Conference – LIP / Lisboa (9/Oct./2006) Application of Geant4 Python Interface Koichi Murakami KEK / CRC Let's start with.
Advertisements

Blueprint RTAGs1 Coherent Software Framework a Proposal LCG meeting CERN- 11 June Ren é Brun ftp://root.cern.ch/root/blueprint.ppt.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11 th, 2002 Getting Started.
Usage of the Python Programming Language in the CMS Experiment Rick Wilkinson (Caltech), Benedikt Hegner (CERN) On behalf of CMS Offline & Computing 1.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Victor Serbo, SLAC30 September 2004, Interlaken, Switzerland JASSimApp plugin for JAS3: Interactive Geant4 GUI Serbo, Victor (SLAC) - presenter Donszelmann,
Software Installation The full set of lecture notes of this Geant4 Course is available at
Doxygen: Source Code Documentation Generator John Tully.
Improvements in Interface, Intercoms and environments Koichi Murakami (KEK/CRC) Koichi Murakami Geant4 Collaboration Workshop (18/Sep/2007) 1.
SEAL V1 Status 12 February 2003 P. Mato / CERN Shared Environment for Applications at LHC.
JCE A Java-based Commissioning Environment tool Hiroyuki Sako, JAEA Hiroshi Ikeda, Visible Information Center Inc. SAD Workshop.
A introduction Luciano Pandola INFN-LNGS Partially based on a presentation by G.A.P. Cirrone (INFN-LNS) and M.G. Pia (INFN-Ge) Queen’s University, Belfast.
OpenAlea An OpenSource platform for plant modeling C. Pradal, S. Dufour-Kowalski, F. Boudon, C. Fournier, C. Godin.
Introduction to Hall-D Software February 27, 2009 David Lawrence - JLab.
Java Analysis Studio Status Update 12 May 2000 Altas Software Week Tony Johnson
JAS3 + AIDA LC Simulations Workshop SLAC 19 th May 2003.
G EANT highlights kernel modules Gabriele Cosmo, CERN PH-SFT for the Geant4 Collaboration Gabriele Cosmo, CERN PH-SFT for the Geant4 Collaboration.
Codeigniter is an open source web application. It occupies a very small amount of space in the memory and is most useful for developers who aim to develop.
Parallel Interactive Computing with PyTrilinos and IPython Bill Spotz, SNL (Brian Granger, Tech-X Corporation) November 8, 2007 Trilinos Users Group Meeting.
Interface parallel session report Hajime Yoshida.
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
Nick Draper 05/11/2008 Mantid Manipulation and Analysis Toolkit for ISIS data.
V. Serbo, SLAC ACAT03, 1-5 December 2003 Interactive GUI for Geant4 by Victor Serbo, SLAC.
MINER A Software The Goals Software being developed have to be portable maintainable over the expected lifetime of the experiment extensible accessible.
W. Pokorski - CERN Simulation Project1 Python binding for Geant4 toolkit using Reflex/PyROOT tool Witek Pokorski EuroPython 2006, CERN, Geneva
LCG-SPI: SW-Testing LCG AppArea internal review (20/10/03)
User Application Toolkit + User application toolkit Geant4 is a toolkit –i.e. you cannot “run” it out of the box –You must write.
User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)
SEAL: Common Core Libraries and Services for LHC Applications CHEP’03, March 24-28, 2003 La Jolla, California J. Generowicz/CERN, M. Marino/LBNL, P. Mato/CERN,
Alex Howard - Event Biasing Geant4 Users - Lisbon Event biasing and Variance Reduction - Geometrical Alex Howard, CERN Geant4 Users Workshop, Lisbon.
SEAL Core Libraries and Services CLHEP Workshop 28 January 2003 P. Mato / CERN Shared Environment for Applications at LHC.
SEAL Project Core Libraries and Services 18 December 2002 P. Mato / CERN Shared Environment for Applications at LHC.
M Gallas CERN EP-SFT LCG-SPI: SW-Testing1 LCG-SPI: SW-Testing QMTest test framework LCG AppArea meeting (16/07/03) LCG/SPI LCG Software.
GDB Meeting - 10 June 2003 ATLAS Offline Software David R. Quarrie Lawrence Berkeley National Laboratory
Koichi Murakami Geant4 Users Conference – LIP / Lisboa (9/Oct./2006) Practical Usage of Geant4Py Koichi Murakami KEK / CRC Let's start with " >>> import.
Maria Grazia Pia INFN Genova Salamanca, July 2002
Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector.
G.Govi CERN/IT-DB 1 September 26, 2003 POOL Integration, Testing and Release Procedure Integration  Packages structure  External dependencies  Configuration.
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
Parallel Session Interfaces This session is intended to be a working session with a couple of introductory presentations “Geant4 Web Application” by Hajime.
N ATIONAL E NERGY R ESEARCH S CIENTIFIC C OMPUTING C ENTER Charles Leggett Prototype GEANT4 Service for ATHENA framework ATLAS Software Workshop Dec 3.
Project Work Plan SEAL: Core Libraries and Services 7 January 2003 P. Mato / CERN Shared Environment for Applications at LHC.
Geant4 on Web for Education, … - recent updates - Koichi Murakami (KEK/CRC) Koichi MurakamiGeant4 FFJPL Meeting (02/Sep/2008)1.
Visual Programming Borland Delphi. Developing Applications Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications.
Maria Grazia Pia Retrieving information from kernel Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
MAUS Status A. Dobbs CM43 29 th October Contents MAUS Overview Infrastructure Geometry and CDB Detector Updates CKOV EMR KL TOF Tracker Global Tracking.
Geant4 for (Medical) Education “ Geant4 for (Medical) Education ” Toolkit and Courseware Geant4 Medical Workshop in Lyon 21 July 2006 Universite-Lyon I.
GRID & Parallel Processing Koichi Murakami11 th Geant4 Collaboration Workshop / LIP - Lisboa (10-14/Oct./2006) 1 GRID-related activity in Japan Go Iwai,
Workshop Geant4 Presentation September 14 th, 2007 FASTRAD V3.
SEAL: Common Core Libraries and Services for LHC Applications
Interaction with the Geant4 kernel
Pipeline Execution Environment
The full set of lecture notes of this Geant4 Course is available at
GUI Parallel Session Hajime Yoshida
Interaction with the Geant4 kernel
Basics of a user application
User Interface
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002
G.A.P.Cirrone, S.E.Mazzaglia - INFN/LNS, Italy
ns-3 Waf build system ns-3 Annual Meeting June 2017
Software Installation
User Application
The n-3He Simulation Using Geant4
User Application
The full set of lecture notes of this Geant4 Course is available at
The full set of lecture notes of this Geant4 Course is available at
The full set of lecture notes of this Geant4 Course is available at
Use of GEANT4 in CMS The OSCAR Project
Presentation transcript:

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 1 Python Interface for Geant4 Medical Applications K.Murakami (KEK) 15/Jul/05

4th Workshop on Geant4 Bio-medical Developments and Physics Validation 2 Introduction Missing functionalities of current Geant4 command-line interface more powerful scripting environment only simple flow control is available, but not enough. flow control, variables, arithmetic operation direct handling each object of G4XXX only limited manager-like classes can be exposed via G4UIcommand. Python is believed to be the most promising technological choice in terms of Python as a powerful scripting language Python can work as front-end of a light framework modularization of user classes with dynamic loading scheme  DetectorConstruction, PhysicsList, PrimaryGeneratorAction, UserAction-s  It helps avoid code duplication. Python as “Software Component Bus” C++ objects can be exposed to python. interconnectivity with many Python external modules,  analysis tools (ROOT/AIDA), web interface,...

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 3 Project Aim of Geant4Py Generic and straight forward approach of Pythonization of Geant4 not specific to particular applications minimal dependencies of external packages only depending on Boost-Python, which is a common, well-established and freely available library.

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 4 Use-Case of Medical Application System integration of developed components... geometry modeling (DICOM, DICOM-RT, beam line,...) physics list (EM, Hadron, Ion [BC, JQMD],...) MPI parallelization (MPICH2) Analysis packages (ROOT, HBOOK, AIDA,...) Visualization (Real Intage, DoctorView, AVS,...) Web applications (mod-python, CherryPy) (G)UI (Java, Python, Web App., Qt, Tk,...) Grid service (LCG, Clarens) Interconnectivity with these items can be realized via Python interface.

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 5 Software Structure Applications C++ application, Python scripts, Web applications,... Component Implementation geometry modeling physics list scoring,... Simulation Framework component models plug-in management scripting parallelization Other Frameworks analysis (ROOT) visualization,... Software Component Bus Python, API, original interface Applications Simulation Framework Foundation Libraries Optional Libraries XXX Framework Other Frameworks... Software Component Bus Foundation Libraries Geant4, JQMD,... MPICH,... LCG Python, Boost-Python CLHEP... Optional Libraries ROOT, CERNLIB,... JAVA, Qt, Tk... Components Implementation

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 6 Tools for Geant4/Python interface There are several activities; SWIG supports for multiple languages Implementation of G4/Python interface can be found in advanced examples (Tiara). LCG Python Geant4 interface using PyReflex tool Boost-Python a part of comprehensive Boost C++ library, but independent from other components focused to C++/python interface, so performance loss is not so much.

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 7 What is/isnot Exposed What is exposed: Classes for main Geant4 flow control G4RunManager, G4UImanager, G4UIterminal Some Utility classes G4String, G4ThreeVector, G4RotationMatrix,... Classes of base classes of user actions G4UserDetetorConstruction, G4UserPhysicsList, G4UserXXXAction (PrimaryGenerator, Run, Event, Stepping,...) can be inherited in Python side Classes having information to be analyzed G4Step, G4Track, G4StepPoint, G4ParticleDefinition,... Classes for construction user inputs G4ParticleGun, G4Box, G4PVPlacement,... What is not exposed: NOT all methods are exposed. only safe methods (getting internal information) are exposed. Out of Scope implementation of physics processes implementation of internal control flows It just ends in deterioration of performance.

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 8 Module Structure Python module name : “Geant4” including CLHEP components typedef-ed as G4XXX, like G4ThreeVector, G4RotationMatrix,... Units definition (“HEPUnit” as namespace) From users side, >>> import Geant4 >>> from Geant4 import * “Geant4” module consists of a collection of submodules same as Geant4 directory structure. run/event/particle/geometry/track/...

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 9 Name Policy in Python side Names of classes as well as methods are same as used in Geant4. >>> gRunManager= Geant4.G4RunManager() >>> gRunManager.BeamOn(10) This makes it easy to translate from C++ to Python, and vice versa. As an exception, pure singleton class, which has no public constructor, like G4UImanager, can not be exposed in Boost- Python. So, necessary members of such classes are exposed directly in Geant4 namespace. >>> Geant4.gApplyUIcommand(“/run/beamOn”) >>> Geant4.gGetCurrentValues(“/run/verbose”) >>> Geant4.gStartUISession()

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 10 Global Variables/Functions Some global variables/functions starting with "g“ are predefined. gRunManager gVisManager gApplyUIcommand() gGetCurrentValues() gStartUISession() gRunManager and gVisManager are taken care not so as to be doubly instantiated, so that users do not have to take any more care about the timing of object instantiation in python side. All of visualization drivers (OpenGL, VRML, DAWN,...) are automatically registered. So users are now free from implementation of VisManager. Note that care from C++ side is of course in need! if(G4RunManager::GetRunManager() ==0 ) G4RunManager* runManager= new G4RunManager();

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 11 List of Current Exposed Classes global G4String G4ThreeVector interface G4UImanager G4UIterminal run G4RunManager G4VUserDetectorConstruction G4VUserPhysicsList G4UserRunAction G4VUserPrimaryGeneratorAction G4Run event G4Event G4ParticleGun G4UserEventAction tracking G4UserSteppingAction track G4Step G4Track G4StepPoint G4StepStatus G4TrackStatus particles G4ParticleDefinition G4DynamicParticle G4PrimaryParticle G4PrimaryVertex geometry G4VTouchable G4TouchableHistotry G4VPhysicalVolume material G4Material visualization G4VisManager G4VGraphicSystem G4OpenGLStoredX...

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 12 Various Levels of Pythonization Various level of pythonized application can be realized. It is completely up to users! Two metrics Execution Speed just wrapping current existing applications Interactivity interactive analysis rapid prototyping educational use for G4 primer

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 13 Use-case of Pythonization Execution Speed Interactivity/ Pythonization large scale of mass production a collection of short productions with various running conditions applications having interconnections with other software components interactive analysis free from compilation - rapid prototyping - educational uses

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 14 An Example of Exposure of Users’ Application Uses’ existing applications are easily exposed to python following a simple prescription of Boost-Python manner. BOOST_PYTHON_MODULE(demo_wp){ class_ ("MyApplication", "my application").def("Configure", &MyApplication::Configure) ; class_ ("MyMaterials", "my material").def("Construct", &MyMaterials::Construct) ; class_ > ("MyDetectorConstruction", "my detector") ; class_ > ("MyPhysicsList", "my physics list") ; }

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 15 A Medical Application Example Several examples of using Python interface are/will be presented. An example of “water phantom dosimetry” This demo program shows that a Geant4 application well coworks with ROOT on Python front end. VisManager, PrimaryGeneratorAction, UserAction-s, histogramming with ROOT are implemented in Python. dose calculation in a water phantom Python overloading of user actions on-line histogramming with ROOT visualization

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 16 Example of A Python Script from Geant4 import * import demo_wp # module of a user G4 application import ROOT # class MyRunAction(G4UserRunAction): # Python inheritance "My Run Action“ def EndOfRunAction(self, run): # method override print "*** End of Run“ print "- Run sammary : (id= %d, #events= %d)" \ % (run.runID, run.numberOfEventToBeProcessed) # class MyPrimaryGeneratorAction(G4VUserPrimaryGeneratorAction): "My Primary Generator Action“ def __init__(self): G4VUserPrimaryGeneratorAction.__init__(self) self.particleGun= G4ParticleGun(1) def GeneratePrimaries(self, event): self.particleGun.GeneratePrimaryVertex(event)

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 17 # user detector construction (C++) myDC= demo_wp.MyDetectorConstruction() gRunManager.SetUserInitialization(myDC) # user physics list (C++) myPL= demo_wp.MyPhysicsList() gRunManager.SetUserInitialization(myPL) # user P.G.A (Python) myPGA= MyPrimaryGeneratorAction() gRunManager.SetUserAction(myPGA)... # setting particle gun pg= myPGA.particleGun pg.SetParticleByName("proton") pg.SetParticleEnergy(230.*HEPUnit.MeV) pg.SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.)) pg.SetParticlePosition(G4ThreeVector(0.,0.,-20.)*HEPUnit.cm) gRunManager.Initialize() gApplyUICommand("/control/execute vis.mac") gRunManager.BeamOn(100)

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 18

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 19 Further to go... Making rapid progress for implementation of missing elements Realize interconnection with various software components; example of using AIDA example of using GDML multi-thread and parallelization web application GUI support in specific application contexts GRID service...

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 20 Software Requirements All libraries should be compiled in shared libraries. Python BOOST-Python 1.32, latest Geant4 7.0 or later - should be built in "global" and "shared" libraries. - All header files should be collected into $(G4INSTALL)/include by "make includes" CLHEP or later - building shared objects is supported since version 1.9. Platforms SUSE Linux 9.3 is a development environment. It is the easiest way to go, because Boost C++ library is preinstalled. Scientific Linux 3 (SL3) is checked for well working. SL4 will be checked as well.

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 21 Summary Python Interface of Geant4 (Geant4Py) has been well designed and implementation is now rapidly on-going. Python as a powerful scripting language much better interactivity configuration rapid prototyping Python as “Software Component Bus” interconnectivity with various kind of software components. histogramming with ROOT system integration We have a plan to commit the package into the next December release. “environments/” directory is a suitable position GUI Python math... shell GRID GUI PyROOT Root Classes MPI Geant4Py Geat4 Classes

15/Jul/054th Workshop on Geant4 Bio-medical Developments and Physics Validation 22 Resources Project Home Page CVS view Wiki Technical notes for the developers geant4.kek.jp/projects/Geant4Py/pukiwiki/ geant4.kek.jp/projects/Geant4Py/pukiwiki/