-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add distance to surface tests #224
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) |
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 | ||
} | ||
} | ||
} | ||
} |
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 | ||
} | ||
} | ||
} | ||
} |
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 | ||
} | ||
} | ||
} | ||
} |
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 | ||
} | ||
} | ||
} | ||
} |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
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", 500, 500, 500, 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) | ||
|
||
|
||
# lar | ||
lar_s = pg4.geant4.solid.Tubs( | ||
"LAr_s", 0, 200, 250, 0, 2 * np.pi, registry=reg, lunit="mm" | ||
) | ||
lar_l = pg4.geant4.LogicalVolume(lar_s, "G4_lAr", "LAr_l", registry=reg) | ||
lar_l.pygeom_color_rgba = (1, 0.1, 0, 0.2) | ||
pg4.geant4.PhysicalVolume([0, 0, 0], [0, 0, 0], lar_l, "LAr", wl, registry=reg) | ||
|
||
|
||
# hpge strings | ||
string_radius = 85 | ||
string_angles = [0, 90, 180, 270] | ||
detectors = ["V", "P", "B", "C"] | ||
|
||
|
||
n = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these lines are not needed in this case. They only create a macro to simulate in the LAr cylinders. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do kinda need both lines. The list of detectors is so i can just loop through all 4 types (although i can omit the detectors variable by just directly inserting the list into the enumerator). And i need the n to keep track of the unique detector IDs to also create the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I selected the wrong lines. I meant 70-77 where we create the LAr cylinder information ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, you are right. I dont know how i deleted the write statements below but not that^^ |
||
lines = [] | ||
for i, det in enumerate(detectors): | ||
angle = string_angles[i] | ||
n = add_hpge(lar_l, reg, angle, string_radius, -20, n, det) | ||
|
||
x = string_radius * np.sin(np.deg2rad(angle)) | ||
y = string_radius * np.cos(np.deg2rad(angle)) | ||
|
||
lines.append("/RMG/Generator/Confinement/Geometrical/AddSolid Cylinder ") | ||
lines.append(f"/RMG/Generator/Confinement/Geometrical/CenterPositionX {x} mm") | ||
lines.append(f"/RMG/Generator/Confinement/Geometrical/CenterPositionY {y} mm ") | ||
lines.append("/RMG/Generator/Confinement/Geometrical/CenterPositionZ 0 mm ") | ||
lines.append("/RMG/Generator/Confinement/Geometrical/Cylinder/OuterRadius 44 mm ") | ||
lines.append("/RMG/Generator/Confinement/Geometrical/Cylinder/Height 100 mm \n") | ||
|
||
lines_exclude = [line.replace("AddSolid", "AddExcludedSolid") for line in lines] | ||
|
||
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lar can be removed from this GDML, but then change the mother volume for HPGe to be the world not lar.