Skip to content

Commit

Permalink
added a few CSG examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jintonic committed Aug 28, 2024
1 parent 1e32bbb commit a878431
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tutorials/detector/CSG/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This folder contains demos of all CSG solids that can be handled by Geant4 text geometry description. A shape, sphere for example, is defined in [sphere.tg](sphere.tg). To visualize it, please run

```sh
G4VIS_DEFAULT_DRIVER=HepRepFile gears sphere.mac
```

The environment variable `G4VIS_DEFAULT_DRIVER` can be used to select a visualization driver other than the default one.
6 changes: 6 additions & 0 deletions tutorials/detector/CSG/hype.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/geometry/source hype.tg

/control/execute vis.mac

/control/shell if [ -f G4Data0.heprep ]; then mv G4Data0.heprep hype.heprep; fi
/control/shell if [ -f g4_00.wrl ]; then mv g4_00.wrl hype.wrl; fi
9 changes: 9 additions & 0 deletions tutorials/detector/CSG/hype.tg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:volu hall BOX 50 50 50 G4_Galactic
:vis hall OFF

:rotm r000 0 0 0

// Inner radius , Outer radius , Inner stereo angle , outer stereo angle , Half length in Z
:volu hype HYPE 10 12 25 35 9 G4_AIR
:color hype 0.4 0.3 0.8
:place hype 1 hall r000 0 0 0
6 changes: 6 additions & 0 deletions tutorials/detector/CSG/sphere.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/geometry/source sphere.tg

/control/execute vis.mac

/control/shell if [ -f G4Data0.heprep ]; then mv G4Data0.heprep sphere.heprep; fi
/control/shell if [ -f g4_00.wrl ]; then mv g4_00.wrl sphere.wrl; fi
9 changes: 9 additions & 0 deletions tutorials/detector/CSG/sphere.tg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:volu hall BOX 50 50 50 G4_Galactic
:vis hall OFF

:rotm r000 0 0 0

// inner, outer radius, starting, delta phi, starting, delta theta of the segment
:volu sphere SPHERE 20 40 30 60 45 60 G4_AIR
:color sphere 0.9 0 0
:place sphere 1 hall r000 0 0 0
11 changes: 11 additions & 0 deletions tutorials/detector/CSG/vis.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/run/initialize

/geometry/test/run

/vis/open
/vis/drawVolume

/vis/scene/add/axes 0 0 0 50 mm auto false
/vis/viewer/set/background white
/vis/viewer/set/viewpointThetaPhi 60 120
/vis/viewer/flush

0 comments on commit a878431

Please sign in to comment.