Skip to content

Commit

Permalink
output: add tests with HDF5 output schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Aug 8, 2024
1 parent fd141a3 commit a8c0573
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ project(remage-tests)

add_subdirectory(basics)
add_subdirectory(confinement)
add_subdirectory(output)
19 changes: 19 additions & 0 deletions tests/output/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# collect auxiliary files
file(
GLOB _aux
RELATIVE ${PROJECT_SOURCE_DIR}
macros/*.mac macros/*.hdf5ls gdml/*.gdml gdml/*.xml check-hdf5.py run-test-hdf5.sh)

# copy them to the build area
foreach(_file ${_aux})
configure_file(${PROJECT_SOURCE_DIR}/${_file} ${PROJECT_BINARY_DIR}/${_file} COPYONLY)
endforeach()

set(_macros ntuple-per-det.mac ntuple-flat.mac)

foreach(_mac ${_macros})
add_test(NAME output/${_mac} COMMAND ./run-test-hdf5.sh $<TARGET_FILE:remage-cli> ${_mac})
endforeach()

list(TRANSFORM _macros_extra PREPEND "output/")
set_tests_properties(${_macros_extra} PROPERTIES LABELS extra)
7 changes: 7 additions & 0 deletions tests/output/check-hdf5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/env python3

import h5py
import sys

f = h5py.File(sys.argv[1])
f.visit(print)
45 changes: 45 additions & 0 deletions tests/output/gdml/geometry.gdml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" ?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<define/>
<materials/>
<solids>
<box name="world" x="2" y="2" z="2" lunit="m"/>
<box name="scint" x="0.5" y="1" z="1" lunit="m"/>
<box name="det" x="0.1" y="0.5" z="0.5" lunit="m"/>
</solids>
<structure>
<volume name="det">
<materialref ref="G4_Ge"/>
<solidref ref="det"/>
</volume>
<volume name="scint1">
<materialref ref="G4_lAr"/>
<solidref ref="scint"/>
<physvol name="det1">
<volumeref ref="det"/>
</physvol>
</volume>
<volume name="scint2">
<materialref ref="G4_lAr"/>
<solidref ref="scint"/>
<physvol name="det2">
<volumeref ref="det"/>
</physvol>
</volume>
<volume name="world">
<materialref ref="G4_Galactic"/>
<solidref ref="world"/>
<physvol name="scint1">
<volumeref ref="scint1"/>
<position name="scint1_pos" x="-255.000000000000000" y="0.000000000000000" z="0.000000000000000" unit="mm"/>
</physvol>
<physvol name="scint2">
<volumeref ref="scint2"/>
<position name="scint2_pos" x="255.000000000000000" y="0.000000000000000" z="0.000000000000000" unit="mm"/>
</physvol>
</volume>
</structure>
<setup name="Default" version="1.0">
<world ref="world"/>
</setup>
</gdml>
27 changes: 27 additions & 0 deletions tests/output/gdml/geometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/env python3

from __future__ import annotations

import pyg4ometry
from pyg4ometry import geant4 as g4

registry = g4.Registry()
world = g4.solid.Box("world", 2, 2, 2, registry, "m")
world_lv = g4.LogicalVolume(world, g4.MaterialPredefined("G4_Galactic"), "world", registry)
registry.setWorld(world_lv)

scint = g4.solid.Box("scint", 0.5, 1, 1, registry, "m")
scint1 = g4.LogicalVolume(scint, g4.MaterialPredefined("G4_lAr"), "scint1", registry)
scint2 = g4.LogicalVolume(scint, g4.MaterialPredefined("G4_lAr"), "scint2", registry)
g4.PhysicalVolume([0, 0, 0], [-255, 0, 0], scint1, "scint1", world_lv, registry)
g4.PhysicalVolume([0, 0, 0], [+255, 0, 0], scint2, "scint2", world_lv, registry)

det = g4.solid.Box("det", 0.1, 0.5, 0.5, registry, "m")
det = g4.LogicalVolume(det, g4.MaterialPredefined("G4_Ge"), "det", registry)
g4.PhysicalVolume([0, 0, 0], [0, 0, 0], det, "det1", scint1, registry)
g4.PhysicalVolume([0, 0, 0], [0, 0, 0], det, "det2", scint2, registry)

w = pyg4ometry.gdml.Writer()
w.addDetector(registry)

w.write("geometry.gdml")
5 changes: 5 additions & 0 deletions tests/output/macros/_init.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/RMG/Geometry/GDMLDisableOverlapCheck true

/run/initialize

/RMG/Manager/Logging/LogLevel detail
99 changes: 99 additions & 0 deletions tests/output/macros/ntuple-flat.hdf5ls
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
default_histograms
header
hit
hit/germanium
hit/germanium/columns
hit/germanium/det_uid
hit/germanium/det_uid/entries
hit/germanium/det_uid/pages
hit/germanium/edep_in_keV
hit/germanium/edep_in_keV/entries
hit/germanium/edep_in_keV/pages
hit/germanium/entries
hit/germanium/evtid
hit/germanium/evtid/entries
hit/germanium/evtid/pages
hit/germanium/forms
hit/germanium/names
hit/germanium/particle
hit/germanium/particle/entries
hit/germanium/particle/pages
hit/germanium/time_in_ns
hit/germanium/time_in_ns/entries
hit/germanium/time_in_ns/pages
hit/germanium/xloc_in_m
hit/germanium/xloc_in_m/entries
hit/germanium/xloc_in_m/pages
hit/germanium/yloc_in_m
hit/germanium/yloc_in_m/entries
hit/germanium/yloc_in_m/pages
hit/germanium/zloc_in_m
hit/germanium/zloc_in_m/entries
hit/germanium/zloc_in_m/pages
hit/scintillator
hit/scintillator/columns
hit/scintillator/det_uid
hit/scintillator/det_uid/entries
hit/scintillator/det_uid/pages
hit/scintillator/edep_in_keV
hit/scintillator/edep_in_keV/entries
hit/scintillator/edep_in_keV/pages
hit/scintillator/entries
hit/scintillator/evtid
hit/scintillator/evtid/entries
hit/scintillator/evtid/pages
hit/scintillator/forms
hit/scintillator/names
hit/scintillator/particle
hit/scintillator/particle/entries
hit/scintillator/particle/pages
hit/scintillator/time_in_ns
hit/scintillator/time_in_ns/entries
hit/scintillator/time_in_ns/pages
hit/scintillator/v_post_in_m\ns
hit/scintillator/v_post_in_m\ns/entries
hit/scintillator/v_post_in_m\ns/pages
hit/scintillator/v_pre_in_m\ns
hit/scintillator/v_pre_in_m\ns/entries
hit/scintillator/v_pre_in_m\ns/pages
hit/scintillator/xloc_post_in_m
hit/scintillator/xloc_post_in_m/entries
hit/scintillator/xloc_post_in_m/pages
hit/scintillator/xloc_pre_in_m
hit/scintillator/xloc_pre_in_m/entries
hit/scintillator/xloc_pre_in_m/pages
hit/scintillator/yloc_post_in_m
hit/scintillator/yloc_post_in_m/entries
hit/scintillator/yloc_post_in_m/pages
hit/scintillator/yloc_pre_in_m
hit/scintillator/yloc_pre_in_m/entries
hit/scintillator/yloc_pre_in_m/pages
hit/scintillator/zloc_post_in_m
hit/scintillator/zloc_post_in_m/entries
hit/scintillator/zloc_post_in_m/pages
hit/scintillator/zloc_pre_in_m
hit/scintillator/zloc_pre_in_m/entries
hit/scintillator/zloc_pre_in_m/pages
hit/vertices
hit/vertices/columns
hit/vertices/entries
hit/vertices/evtid
hit/vertices/evtid/entries
hit/vertices/evtid/pages
hit/vertices/forms
hit/vertices/n_part
hit/vertices/n_part/entries
hit/vertices/n_part/pages
hit/vertices/names
hit/vertices/time_in_ns
hit/vertices/time_in_ns/entries
hit/vertices/time_in_ns/pages
hit/vertices/xloc_in_m
hit/vertices/xloc_in_m/entries
hit/vertices/xloc_in_m/pages
hit/vertices/yloc_in_m
hit/vertices/yloc_in_m/entries
hit/vertices/yloc_in_m/pages
hit/vertices/zloc_in_m
hit/vertices/zloc_in_m/entries
hit/vertices/zloc_in_m/pages
18 changes: 18 additions & 0 deletions tests/output/macros/ntuple-flat.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/RMG/Output/NtuplePerDetector false

/RMG/Geometry/RegisterDetector Scintillator scint1 1
/RMG/Geometry/RegisterDetector Scintillator scint2 2
/RMG/Geometry/RegisterDetector Germanium det1 11
/RMG/Geometry/RegisterDetector Germanium det2 12

/control/execute macros/_init.mac

/RMG/Generator/Confine UnConfined

/RMG/Generator/Select GPS
/gps/position 0 0 0
/gps/ang/type iso
/gps/particle gamma
/gps/energy 200 keV

/run/beamOn 5000
160 changes: 160 additions & 0 deletions tests/output/macros/ntuple-per-det.hdf5ls
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
default_histograms
header
hit
hit/det001
hit/det001/columns
hit/det001/edep_in_keV
hit/det001/edep_in_keV/entries
hit/det001/edep_in_keV/pages
hit/det001/entries
hit/det001/evtid
hit/det001/evtid/entries
hit/det001/evtid/pages
hit/det001/forms
hit/det001/names
hit/det001/particle
hit/det001/particle/entries
hit/det001/particle/pages
hit/det001/time_in_ns
hit/det001/time_in_ns/entries
hit/det001/time_in_ns/pages
hit/det001/v_post_in_m\ns
hit/det001/v_post_in_m\ns/entries
hit/det001/v_post_in_m\ns/pages
hit/det001/v_pre_in_m\ns
hit/det001/v_pre_in_m\ns/entries
hit/det001/v_pre_in_m\ns/pages
hit/det001/xloc_post_in_m
hit/det001/xloc_post_in_m/entries
hit/det001/xloc_post_in_m/pages
hit/det001/xloc_pre_in_m
hit/det001/xloc_pre_in_m/entries
hit/det001/xloc_pre_in_m/pages
hit/det001/yloc_post_in_m
hit/det001/yloc_post_in_m/entries
hit/det001/yloc_post_in_m/pages
hit/det001/yloc_pre_in_m
hit/det001/yloc_pre_in_m/entries
hit/det001/yloc_pre_in_m/pages
hit/det001/zloc_post_in_m
hit/det001/zloc_post_in_m/entries
hit/det001/zloc_post_in_m/pages
hit/det001/zloc_pre_in_m
hit/det001/zloc_pre_in_m/entries
hit/det001/zloc_pre_in_m/pages
hit/det002
hit/det002/columns
hit/det002/edep_in_keV
hit/det002/edep_in_keV/entries
hit/det002/edep_in_keV/pages
hit/det002/entries
hit/det002/evtid
hit/det002/evtid/entries
hit/det002/evtid/pages
hit/det002/forms
hit/det002/names
hit/det002/particle
hit/det002/particle/entries
hit/det002/particle/pages
hit/det002/time_in_ns
hit/det002/time_in_ns/entries
hit/det002/time_in_ns/pages
hit/det002/v_post_in_m\ns
hit/det002/v_post_in_m\ns/entries
hit/det002/v_post_in_m\ns/pages
hit/det002/v_pre_in_m\ns
hit/det002/v_pre_in_m\ns/entries
hit/det002/v_pre_in_m\ns/pages
hit/det002/xloc_post_in_m
hit/det002/xloc_post_in_m/entries
hit/det002/xloc_post_in_m/pages
hit/det002/xloc_pre_in_m
hit/det002/xloc_pre_in_m/entries
hit/det002/xloc_pre_in_m/pages
hit/det002/yloc_post_in_m
hit/det002/yloc_post_in_m/entries
hit/det002/yloc_post_in_m/pages
hit/det002/yloc_pre_in_m
hit/det002/yloc_pre_in_m/entries
hit/det002/yloc_pre_in_m/pages
hit/det002/zloc_post_in_m
hit/det002/zloc_post_in_m/entries
hit/det002/zloc_post_in_m/pages
hit/det002/zloc_pre_in_m
hit/det002/zloc_pre_in_m/entries
hit/det002/zloc_pre_in_m/pages
hit/det011
hit/det011/columns
hit/det011/edep_in_keV
hit/det011/edep_in_keV/entries
hit/det011/edep_in_keV/pages
hit/det011/entries
hit/det011/evtid
hit/det011/evtid/entries
hit/det011/evtid/pages
hit/det011/forms
hit/det011/names
hit/det011/particle
hit/det011/particle/entries
hit/det011/particle/pages
hit/det011/time_in_ns
hit/det011/time_in_ns/entries
hit/det011/time_in_ns/pages
hit/det011/xloc_in_m
hit/det011/xloc_in_m/entries
hit/det011/xloc_in_m/pages
hit/det011/yloc_in_m
hit/det011/yloc_in_m/entries
hit/det011/yloc_in_m/pages
hit/det011/zloc_in_m
hit/det011/zloc_in_m/entries
hit/det011/zloc_in_m/pages
hit/det012
hit/det012/columns
hit/det012/edep_in_keV
hit/det012/edep_in_keV/entries
hit/det012/edep_in_keV/pages
hit/det012/entries
hit/det012/evtid
hit/det012/evtid/entries
hit/det012/evtid/pages
hit/det012/forms
hit/det012/names
hit/det012/particle
hit/det012/particle/entries
hit/det012/particle/pages
hit/det012/time_in_ns
hit/det012/time_in_ns/entries
hit/det012/time_in_ns/pages
hit/det012/xloc_in_m
hit/det012/xloc_in_m/entries
hit/det012/xloc_in_m/pages
hit/det012/yloc_in_m
hit/det012/yloc_in_m/entries
hit/det012/yloc_in_m/pages
hit/det012/zloc_in_m
hit/det012/zloc_in_m/entries
hit/det012/zloc_in_m/pages
hit/vertices
hit/vertices/columns
hit/vertices/entries
hit/vertices/evtid
hit/vertices/evtid/entries
hit/vertices/evtid/pages
hit/vertices/forms
hit/vertices/n_part
hit/vertices/n_part/entries
hit/vertices/n_part/pages
hit/vertices/names
hit/vertices/time_in_ns
hit/vertices/time_in_ns/entries
hit/vertices/time_in_ns/pages
hit/vertices/xloc_in_m
hit/vertices/xloc_in_m/entries
hit/vertices/xloc_in_m/pages
hit/vertices/yloc_in_m
hit/vertices/yloc_in_m/entries
hit/vertices/yloc_in_m/pages
hit/vertices/zloc_in_m
hit/vertices/zloc_in_m/entries
hit/vertices/zloc_in_m/pages
Loading

0 comments on commit a8c0573

Please sign in to comment.