Skip to content

Commit

Permalink
Merge pull request #224 from EricMEsch/DistanceTests
Browse files Browse the repository at this point in the history
  • Loading branch information
gipert authored Jan 15, 2025
2 parents b42777a + 10f7f51 commit b2766c7
Show file tree
Hide file tree
Showing 10 changed files with 403 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 @@ -9,6 +9,7 @@ get_target_property(PYTHONPATH python-virtualenv PYTHONPATH)

add_subdirectory(basics)
add_subdirectory(confinement)
add_subdirectory(distances)
add_subdirectory(germanium)
add_subdirectory(internals)
add_subdirectory(output)
Expand Down
28 changes: 28 additions & 0 deletions tests/distances/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# collect auxiliary files
file(
GLOB _aux
RELATIVE ${PROJECT_SOURCE_DIR}
macros/*.mac macros/*.json gdml/*.gdml gdml/*.xml *.py)

# copy them to the build area

foreach(_file ${_aux})
configure_file(${PROJECT_SOURCE_DIR}/${_file} ${PROJECT_BINARY_DIR}/${_file} COPYONLY)
endforeach()

# generate the GDML file
add_test(NAME distances-ge/gen-gdml COMMAND ${PYTHONPATH} make_ge_gdml.py)
set_tests_properties(distances-ge/gen-gdml PROPERTIES LABELS extra FIXTURES_SETUP
distance-gdml-fixture)

# test on HPGe containment
add_test(NAME distances-ge/gen-output COMMAND ${REMAGE_PYEXE} -g gdml/ge-array.gdml -w -o
test-distance.lh5 -- macros/test-ge-distance.mac)
set_tests_properties(
distances-ge/gen-output PROPERTIES LABELS extra FIXTURES_SETUP distance-output-fixture
FIXTURES_REQUIRED distance-gdml-fixture)

add_test(NAME distances-ge/distance COMMAND ${PYTHONPATH} ./test_ge_distance.py)

set_tests_properties(distances-ge/distance PROPERTIES LABELS extra FIXTURES_REQUIRED
distance-output-fixture)
Empty file.
36 changes: 36 additions & 0 deletions tests/distances/macros/B99000A.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "B99000A",
"type": "bege",
"production": {
"manufacturer": "Test",
"enrichment": {
"val": 0.75,
"unc": 0.05
}
},
"geometry": {
"height_in_mm": 40.0,
"radius_in_mm": 35.0,
"groove": {
"depth_in_mm": 2.0,
"radius_in_mm": {
"outer": 12.0,
"inner": 10.0
}
},
"pp_contact": {
"radius_in_mm": 7.5,
"depth_in_mm": 0
},
"taper": {
"top": {
"angle_in_deg": 0.0,
"height_in_mm": 0.0
},
"bottom": {
"angle_in_deg": 0.0,
"height_in_mm": 0.0
}
}
}
}
44 changes: 44 additions & 0 deletions tests/distances/macros/C99000A.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "C99000A",
"type": "coax",
"production": {
"manufacturer": "Test",
"enrichment": {
"val": 0.75,
"unc": 0.05
}
},
"geometry": {
"height_in_mm": 80,
"radius_in_mm": 40,
"borehole": {
"radius_in_mm": 7,
"depth_in_mm": 70
},
"groove": {
"depth_in_mm": 2,
"radius_in_mm": {
"outer": 20,
"inner": 17
}
},
"pp_contact": {
"radius_in_mm": 17,
"depth_in_mm": 0
},
"taper": {
"top": {
"angle_in_deg": 45,
"height_in_mm": 5
},
"bottom": {
"angle_in_deg": 45,
"height_in_mm": 2
},
"borehole": {
"angle_in_deg": 0,
"height_in_mm": 0
}
}
}
}
29 changes: 29 additions & 0 deletions tests/distances/macros/P99000A.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "P99000A",
"type": "ppc",
"production": {
"manufacturer": "Test",
"enrichment": {
"val": 0.75,
"unc": 0.05
}
},
"geometry": {
"height_in_mm": 45.0,
"radius_in_mm": 35.0,
"pp_contact": {
"radius_in_mm": 2,
"depth_in_mm": 2
},
"taper": {
"top": {
"angle_in_deg": 0,
"height_in_mm": 0
},
"bottom": {
"angle_in_deg": 30,
"height_in_mm": 10
}
}
}
}
44 changes: 44 additions & 0 deletions tests/distances/macros/V99000A.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "V99000A",
"type": "icpc",
"production": {
"manufacturer": "Test",
"enrichment": {
"val": 0.75,
"unc": 0.05
}
},
"geometry": {
"height_in_mm": 70,
"radius_in_mm": 35,
"borehole": {
"radius_in_mm": 5,
"depth_in_mm": 55
},
"groove": {
"depth_in_mm": 1,
"radius_in_mm": {
"outer": 10,
"inner": 9
}
},
"pp_contact": {
"radius_in_mm": 3,
"depth_in_mm": 2
},
"taper": {
"top": {
"angle_in_deg": 10,
"height_in_mm": 10
},
"bottom": {
"angle_in_deg": 0,
"height_in_mm": 0
},
"borehole": {
"angle_in_deg": 0,
"height_in_mm": 0
}
}
}
}
17 changes: 17 additions & 0 deletions tests/distances/macros/test-ge-distance.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/control/execute macros/detectors-fake.mac
/RMG/Output/NtuplePerDetector false

/run/initialize

/RMG/Generator/Confine Volume
/RMG/Generator/Confinement/Physical/AddVolume B.*
/RMG/Generator/Confinement/Physical/AddVolume C.*
/RMG/Generator/Confinement/Physical/AddVolume P.*
/RMG/Generator/Confinement/Physical/AddVolume V.*


/RMG/Generator/Select GPS
/gps/particle e-
/gps/energy 1 eV

/run/beamOn 100000
62 changes: 62 additions & 0 deletions tests/distances/make_ge_gdml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from __future__ import annotations

import json
from pathlib import Path

import numpy as np
import pyg4ometry as pg4
import pygeomtools as pytools
from legendhpges import make_hpge

# read the configs
out_gdml = "gdml/ge-array.gdml"
det_macro = "macros/detectors-fake.mac"
config_dict = {}
for det_type in ["B", "P", "V", "C"]:
with Path.open(Path(f"macros/{det_type}99000A.json")) as file:
config_dict[det_type] = json.load(file)


def add_hpge(lar, reg, angle, radius, z, idx, dtype):
x = radius * np.sin(np.deg2rad(angle))
y = radius * np.cos(np.deg2rad(angle))
logical_detector = make_hpge(config_dict[dtype], name=f"{dtype}{idx}", registry=reg)
logical_detector.pygeom_color_rgba = (0, 1, 1, 0.2)
physical_detector = pg4.geant4.PhysicalVolume(
[0, 0, 0], [x, y, z], logical_detector, f"{dtype}{idx}", lar, reg
)

physical_detector.pygeom_active_dector = pytools.RemageDetectorInfo(
"germanium",
idx,
config_dict[dtype],
)
return idx + 1


# construct geometry
reg = pg4.geant4.Registry()
ws = pg4.geant4.solid.Box("ws", 300, 300, 300, reg, lunit="mm")
wl = pg4.geant4.LogicalVolume(ws, "G4_Galactic", "wl", reg)
wl.pygeom_color_rgba = (0.1, 1, 0.1, 0.5)

reg.setWorld(wl)


# hpge strings
string_radius = 85
string_angles = [0, 90, 180, 270]

n = 0
for i, det in enumerate(["V", "P", "B", "C"]):
angle = string_angles[i]
n = add_hpge(wl, reg, angle, string_radius, -20, n, det)

pytools.detectors.write_detector_auxvals(reg)
pytools.geometry.check_registry_sanity(reg, reg)


w = pg4.gdml.Writer()
w.addDetector(reg)
w.write(out_gdml)
pytools.detectors.generate_detector_macro(reg, det_macro)
Loading

0 comments on commit b2766c7

Please sign in to comment.