From 3c4b7afccb464525a1eb7ad9dc8c44d647c854e0 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Sat, 21 Sep 2024 14:26:01 +0100 Subject: [PATCH 1/6] readme: capability, examples and YouTube video --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dee24156..9b5df87f5 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,31 @@ Carlo (Geant4 and Fluka) geometries. [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10449301.svg)](https://doi.org/10.5281/zenodo.10449301) [![Read the Docs](https://img.shields.io/readthedocs/pyg4ometry?logo=readthedocs)](https://pyg4ometry.readthedocs.io) +## Introduction + +Pyg4ometry is a very capable python package to do many tasks related +to Geant4/Fluka/MCNP geometry + +- Python scripting to create and assemble geometries +- Loading, editing and writing GDML +- Load and tessellate CAD geometry and export to GDML +- Load ROOT geometry and convert to GDML +- Powerful VTK viewer of geometries +- Converting from GDML to FLUKA and MCNP +- Exporting mesh geometries from GDML to VTP, OBJ, VRML etc +- Python bindings to CGAL allowing complex mesh manipulation (e.g. hole filling, remeshing) + +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/OPvQFZsFvhs/0.jpg)](https://www.youtube.com/watch?v=OPvQFZsFvhs) + +Many people and groups have used it for various tasks + +- Geometries for BDSIM Geant4 simulation of accelerators +- [Legend experiment](https://indico.cern.ch/event/1252095/contributions/5592424/attachments/2730430/4746429/202310-PyHEP.pdf) +- [FASER2 detector](https://cds.cern.ch/record/2893550) +- CERN North area +- [Moller](https://www.lucbarrett.info/Poster.pdf) +- Proton therapy beam lines + ## How to Install Pre-built pyg4ometry wheels can be installed [from PyPI](https://pypi.org/project/pyg4ometry) @@ -27,7 +52,8 @@ pip install pyg4ometry If you cannot find wheels for your operating system / architecture, please [open an issue](https://github.com/g4edge/pyg4ometry/issues). Building from source requires some non-Python software dependencies. -More documentation can be found in the developer's guide. +More documentation can be found in the +[installation guide](https://pyg4ometry.readthedocs.io/en/stable/manual/installation.html) in the manual. ## Referencing and Citation From 8fdf2dc8acca7a03534f3dda0552756bad0c6ca8 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Mon, 23 Sep 2024 10:34:22 +0200 Subject: [PATCH 2/6] Add code showcase to README --- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9b5df87f5..a1f159d5b 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ Carlo (Geant4 and Fluka) geometries. [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10449301.svg)](https://doi.org/10.5281/zenodo.10449301) [![Read the Docs](https://img.shields.io/readthedocs/pyg4ometry?logo=readthedocs)](https://pyg4ometry.readthedocs.io) -## Introduction +## Quick start -Pyg4ometry is a very capable python package to do many tasks related -to Geant4/Fluka/MCNP geometry +_pyg4ometry_ is a very capable package to do many tasks related +to Geant4/Fluka/MCNP geometry: - Python scripting to create and assemble geometries - Loading, editing and writing GDML @@ -26,23 +26,51 @@ to Geant4/Fluka/MCNP geometry - Load ROOT geometry and convert to GDML - Powerful VTK viewer of geometries - Converting from GDML to FLUKA and MCNP -- Exporting mesh geometries from GDML to VTP, OBJ, VRML etc +- Exporting mesh geometries from GDML to VTP, OBJ, VRML etc. - Python bindings to CGAL allowing complex mesh manipulation (e.g. hole filling, remeshing) -[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/OPvQFZsFvhs/0.jpg)](https://www.youtube.com/watch?v=OPvQFZsFvhs) +All with few lines of Python code! -Many people and groups have used it for various tasks +```py +import pyg4ometry as pg4 +from g4edgetestdata import G4EdgeTestData -- Geometries for BDSIM Geant4 simulation of accelerators -- [Legend experiment](https://indico.cern.ch/event/1252095/contributions/5592424/attachments/2730430/4746429/202310-PyHEP.pdf) -- [FASER2 detector](https://cds.cern.ch/record/2893550) -- CERN North area -- [Moller](https://www.lucbarrett.info/Poster.pdf) -- Proton therapy beam lines +g4data = G4EdgeTestData() +# define a geometry registry +reg = pg4.geant4.Registry() + +# build the world volume +# NOTE: syntax in the geant4 subpackage matches the Geant4 API! +world_s = pg4.geant4.solid.Box("WorldAir", 10, 10, 10, reg, lunit="cm") +world_l = pg4.geant4.LogicalVolume(world_s, "G4_AIR", "WorldAir", reg) +reg.setWorld(world_l) + +# import an STL file +reader = pg4.stl.Reader(g4data["stl/utah_teapot.stl"], reg) +teapot_s = reader.getSolid() + +# place the teapot in the world +teapot_l = pg4.geant4.LogicalVolume(teapot_s, "G4_Cu", "UtahTeapot", reg) +pg4.geant4.PhysicalVolume([0, 0, 0], [0, 0, 0], teapot_l, "UtahTeapot", world_l, reg) + +# export to GDML file "geometry.gdml" +writer = pg4.gdml.Writer() +writer.addDetector(reg) +writer.write("./geometry.gdml") + +# start an interactive VTK viewer instance +viewer = pg4.visualisation.VtkViewer() +viewer.addLogicalVolume(reg.getWorldVolume()) +viewer.view() +``` + +Check out our video tutorial for more: + +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/OPvQFZsFvhs/0.jpg)](https://www.youtube.com/watch?v=OPvQFZsFvhs) ## How to Install -Pre-built pyg4ometry wheels can be installed [from PyPI](https://pypi.org/project/pyg4ometry) +Pre-built _pyg4ometry_ wheels can be installed [from PyPI](https://pypi.org/project/pyg4ometry) using pip: ``` @@ -55,11 +83,20 @@ Building from source requires some non-Python software dependencies. More documentation can be found in the [installation guide](https://pyg4ometry.readthedocs.io/en/stable/manual/installation.html) in the manual. +## Many people and groups are using _pyg4ometry_ + +- Geometries for BDSIM Geant4 simulation of accelerators +- [LEGEND experiment](https://indico.cern.ch/event/1252095/contributions/5592424/attachments/2730430/4746429/202310-PyHEP.pdf) +- [FASER2 detector](https://cds.cern.ch/record/2893550) +- CERN North area +- [Moller](https://www.lucbarrett.info/Poster.pdf) +- Proton therapy beam lines + ## Referencing and Citation -To support the development and maintenance of pyg4ometry, please cite it! +To support the development and maintenance of _pyg4ometry_, please cite it! Any publications including simulations made using this software must cite -the pyg4ometry paper: +the _pyg4ometry_ paper: > S.D. Walker, A. Abramov, L.J. Nevay, W. Shields, S.T. Boogert, > “pyg4ometry: A Python library for the creation of Monte Carlo radiation transport physical geometries”, From 290130c4dc01aa708b6a9b33f3c4297af47cfd49 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 23 Sep 2024 10:06:20 +0100 Subject: [PATCH 3/6] Fix example code --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a1f159d5b..56882b249 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ teapot_s = reader.getSolid() # place the teapot in the world teapot_l = pg4.geant4.LogicalVolume(teapot_s, "G4_Cu", "UtahTeapot", reg) pg4.geant4.PhysicalVolume([0, 0, 0], [0, 0, 0], teapot_l, "UtahTeapot", world_l, reg) +reg.setWorldVolume(teapot_l) # export to GDML file "geometry.gdml" writer = pg4.gdml.Writer() From 38945c23c740962f7605689619dc3acb79cb1382 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 23 Sep 2024 10:14:06 +0100 Subject: [PATCH 4/6] Proper fix for failure --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 56882b249..77d23f876 100644 --- a/README.md +++ b/README.md @@ -46,13 +46,12 @@ world_l = pg4.geant4.LogicalVolume(world_s, "G4_AIR", "WorldAir", reg) reg.setWorld(world_l) # import an STL file -reader = pg4.stl.Reader(g4data["stl/utah_teapot.stl"], reg) +reader = pg4.stl.Reader(g4data["stl/utah_teapot.stl"], registry=reg) teapot_s = reader.getSolid() # place the teapot in the world teapot_l = pg4.geant4.LogicalVolume(teapot_s, "G4_Cu", "UtahTeapot", reg) pg4.geant4.PhysicalVolume([0, 0, 0], [0, 0, 0], teapot_l, "UtahTeapot", world_l, reg) -reg.setWorldVolume(teapot_l) # export to GDML file "geometry.gdml" writer = pg4.gdml.Writer() From 8fb34538a08f7a6d20868ee085c9e25f7fd08b76 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Mon, 23 Sep 2024 11:15:35 +0200 Subject: [PATCH 5/6] Remove mention to Geant4 API --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 77d23f876..2727fa52e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ g4data = G4EdgeTestData() reg = pg4.geant4.Registry() # build the world volume -# NOTE: syntax in the geant4 subpackage matches the Geant4 API! world_s = pg4.geant4.solid.Box("WorldAir", 10, 10, 10, reg, lunit="cm") world_l = pg4.geant4.LogicalVolume(world_s, "G4_AIR", "WorldAir", reg) reg.setWorld(world_l) From b9a1d9b4a03b8f9359627f8c019ddee8d7b38cfc Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Mon, 23 Sep 2024 11:16:07 +0200 Subject: [PATCH 6/6] Use Orb in README example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2727fa52e..5195a4eb4 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ g4data = G4EdgeTestData() reg = pg4.geant4.Registry() # build the world volume -world_s = pg4.geant4.solid.Box("WorldAir", 10, 10, 10, reg, lunit="cm") +world_s = pg4.geant4.solid.Orb("WorldAir", 1.5, reg, lunit="cm") world_l = pg4.geant4.LogicalVolume(world_s, "G4_AIR", "WorldAir", reg) reg.setWorld(world_l)