Skip to content

Commit 95dc778

Browse files
committed
test: add full-physics scintillation test for trd
Adds test_trd_scint.gdml (same scintillating-Quartz setup as test_trap_scint.gdml but with a G4Trd solid instead of G4Trap) and splits the scintillation sub-test into: scintillation_trap -- 5 GeV e- in trap_scint gdml (472693 G4 hits) scintillation_trd -- 5 GeV e- in trd_scint gdml (892626 G4 hits) Both folded under the dispatcher case "scintillation" so existing invocations keep working. Empirical result on trd full-physics: count: 892626 vs 893156 = 0.06% diff x,y: chi2/ndf 0.96, 0.58 dx,dy,dz: chi2/ndf 0.89, 0.98, 0.68 All pos/dir chi2/ndf well under 1.1.
1 parent ab8dcac commit 95dc778

3 files changed

Lines changed: 142 additions & 22 deletions

File tree

tests/g4trap_validation.README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,26 @@ branch.
1010
|---|---|---|
1111
| `trap` (iso) | 50k γ isotropic from an off-axis point inside the trap | alpha-sheared slanted walls, heavy TIR + multi-bounce |
1212
| `trd` (iso) | same source in the trd | converging-wedge slanted walls |
13-
| `scintillation` | 10× 5 GeV e⁻ through a synthetic-scintillator trap | Cherenkov + Scintillation + dispersive RINDEX + ABSLENGTH=100m + multi-bounce |
13+
| `scintillation_trap` | 5× 5 GeV e⁻ through a synthetic-scintillator **trap** | Cherenkov + Scintillation + ABSLENGTH=100m + multi-bounce |
14+
| `scintillation_trd` | 5× 5 GeV e⁻ through a synthetic-scintillator **trd** | same, on the trd |
1415

1516
The two iso tests cover each new solid (Trap and Trd) under heavy
16-
boundary stress. The scintillation test folds every optical physics
17-
process together in one realistic scenario.
17+
boundary stress. The two scintillation tests fold every optical physics
18+
process together (Cerenkov + Scintillation + dispersive RINDEX + finite
19+
absorption + multi-bounce) and run on both solids.
1820

1921
## How to run
2022

2123
Requires the branch built in `/opt/eic-opticks/build` and installed to
2224
`/opt/eic-opticks/{bin,lib,share,include}`.
2325

2426
```bash
25-
./tests/g4trap_validation.sh # all three tests
26-
./tests/g4trap_validation.sh trap # iso, trap only
27-
./tests/g4trap_validation.sh trd # iso, trd only
28-
./tests/g4trap_validation.sh scintillation # full-physics test
27+
./tests/g4trap_validation.sh # all four tests
28+
./tests/g4trap_validation.sh trap # iso, trap only
29+
./tests/g4trap_validation.sh trd # iso, trd only
30+
./tests/g4trap_validation.sh scintillation # full-physics on both
31+
./tests/g4trap_validation.sh scintillation_trap # full-physics, trap only
32+
./tests/g4trap_validation.sh scintillation_trd # full-physics, trd only
2933
```
3034

3135
Outputs land in `/tmp/g4trap_validation/<case>/``run.log`,
@@ -41,11 +45,18 @@ On the current branch (commit `0d90a9b80` + simphony PR #309 mtline fix
4145
+ `tests/geom/test_trap_scint.gdml` dual-naming fix):
4246

4347
```
44-
trap iso: G4=11129 Opticks≈11116 rel=0.12% all chi2/ndf<1
45-
trd iso: G4=7696 Opticks≈7691 rel=0.07% all chi2/ndf<0.25
46-
scintillation: G4=472693 Opticks≈472017 rel=0.14% all chi2/ndf<5 (t<5.3)
48+
trap iso: G4=11129 Opticks≈11116 rel=0.12% all pos/dir chi2/ndf<1
49+
trd iso: G4=7696 Opticks≈7691 rel=0.07% all pos/dir chi2/ndf<0.25
50+
scintillation_trap: G4=472693 Opticks≈472017 rel=0.14% all pos/dir chi2/ndf<1.5
51+
scintillation_trd: G4=892626 Opticks≈893156 rel=0.06% all pos/dir chi2/ndf<1.1
4752
```
4853

54+
The position/direction χ²/ndf are the geometry-quality figures of merit.
55+
Time χ²/ndf is dominated by a known ~80 ps group-velocity offset between
56+
G4's and Opticks's dispersion handling (see `FINDINGS.md §5`); at full-
57+
physics statistics (≥ 0.5M hits) this becomes large but it is not a
58+
geometry issue.
59+
4960
## Required prerequisite — simphony PR #309 patch
5061

5162
Before running the scintillation test, ensure that `sysrap/SEvt.cc`

tests/g4trap_validation.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,29 +153,41 @@ test_trd_iso () {
153153
}
154154

155155
# (2) Full-physics test: 5 GeV electrons in synthetic-scintillator Quartz
156-
# trap with dispersive Sellmeier index + finite ABSLENGTH=100m. Folds
157-
# Cherenkov + Scintillation + dispersion + absorption + slanted walls
158-
# + multi-bounce together. Single-thread G4 for deterministic file
159-
# output; ~3 min wall time.
160-
test_scintillation () {
156+
# solid with finite ABSLENGTH=100m. Folds Cerenkov + Scintillation +
157+
# absorption + slanted walls + multi-bounce. Run on BOTH trap and trd
158+
# so each solid sees the full physics chain. Single-thread G4 for
159+
# deterministic file output; ~3 min wall time per solid.
160+
test_scintillation_trap () {
161161
echo
162-
echo "----- Test: Scintillation+Cherenkov from 5 x 5 GeV electrons -----"
163-
local outd="${OUT_DIR}/scintillation"
162+
echo "----- Test: Scintillation+Cherenkov on trap, 5 x 5 GeV electrons -----"
163+
local outd="${OUT_DIR}/scintillation_trap"
164164
mkdir -p "${outd}"; cd "${outd}"; rm -f *_hits_output.txt
165165
"${EIC_OPTICKS_BIN}/GPURaytrace" -g "${GEOM_DIR}/test_trap_scint.gdml" -m "${G4_MACRO_5EVT}" -s 42 > run.log 2>&1
166-
python3 "${COMPARE_PY}" "${outd}/g4_hits_output.txt" "${outd}/opticks_hits_output.txt" "scintillation" 10 50
166+
python3 "${COMPARE_PY}" "${outd}/g4_hits_output.txt" "${outd}/opticks_hits_output.txt" "scintillation trap" 10 50
167+
}
168+
169+
test_scintillation_trd () {
170+
echo
171+
echo "----- Test: Scintillation+Cherenkov on trd, 5 x 5 GeV electrons -----"
172+
local outd="${OUT_DIR}/scintillation_trd"
173+
mkdir -p "${outd}"; cd "${outd}"; rm -f *_hits_output.txt
174+
"${EIC_OPTICKS_BIN}/GPURaytrace" -g "${GEOM_DIR}/test_trd_scint.gdml" -m "${G4_MACRO_5EVT}" -s 42 > run.log 2>&1
175+
python3 "${COMPARE_PY}" "${outd}/g4_hits_output.txt" "${outd}/opticks_hits_output.txt" "scintillation trd" 10 50
167176
}
168177

169178
# ------------------------------------------------------------------
170179
# dispatch
171180
# ------------------------------------------------------------------
172181
case "${1:-all}" in
173-
trap|iso_trap) test_trap_iso ;;
174-
trd|iso_trd) test_trd_iso ;;
175-
scintillation|sc) test_scintillation ;;
182+
trap|iso_trap) test_trap_iso ;;
183+
trd|iso_trd) test_trd_iso ;;
184+
scintillation|sc) test_scintillation_trap; test_scintillation_trd ;;
185+
scintillation_trap|sc_trap) test_scintillation_trap ;;
186+
scintillation_trd|sc_trd) test_scintillation_trd ;;
176187
all|*)
177188
test_trap_iso
178189
test_trd_iso
179-
test_scintillation
190+
test_scintillation_trap
191+
test_scintillation_trd
180192
;;
181193
esac

tests/geom/test_trd_scint.gdml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
4+
5+
<define>
6+
<matrix coldim="2" name="RINDEX_Vacuum" values="1.55e-06 1.0 6.2e-06 1.0 1.033e-05 1.0 1.55e-05 1.0"/>
7+
<matrix coldim="2" name="RINDEX_Quartz" values="1.55e-06 1.46 6.2e-06 1.46 1.033e-05 1.46 1.55e-05 1.46"/>
8+
<matrix coldim="2" name="ABSLENGTH_Quartz" values="1.55e-06 100000 6.2e-06 100000 1.033e-05 100000 1.55e-05 100000"/>
9+
10+
<matrix coldim="2" name="SCINT_SPECTRUM"
11+
values="2.480e-06 0.05 2.755e-06 0.50 2.952e-06 1.00 3.100e-06 0.80 3.542e-06 0.20"/>
12+
<matrix coldim="1" name="SCINT_YIELD" values="10.0"/>
13+
<matrix coldim="1" name="RESOLUTION_SCALE" values="1.0"/>
14+
<matrix coldim="1" name="FAST_TIME_CONST" values="2.0"/>
15+
<matrix coldim="1" name="YIELD_RATIO" values="1.0"/>
16+
<matrix coldim="2" name="REEMISSION_PROB" values="1.55e-06 0.0 1.55e-05 0.0"/>
17+
18+
<matrix coldim="2" name="REFLECTIVITY_Det" values="1.55e-06 0 6.2e-06 0 1.033e-05 0 1.55e-05 0"/>
19+
<matrix coldim="2" name="EFFICIENCY_Det" values="1.55e-06 1 6.2e-06 1 1.033e-05 1 1.55e-05 1"/>
20+
</define>
21+
22+
<materials>
23+
<isotope N="28" Z="14" name="Si28"><atom unit="g/mole" value="27.977"/></isotope>
24+
<element name="Silicon"><fraction n="1.0" ref="Si28"/></element>
25+
<isotope N="16" Z="8" name="O16"><atom unit="g/mole" value="15.995"/></isotope>
26+
<element name="Oxygen"><fraction n="1.0" ref="O16"/></element>
27+
<material Z="1" name="Vacuum" state="gas">
28+
<D unit="g/cm3" value="1e-25"/>
29+
<atom unit="g/mole" value="1.00794"/>
30+
<property name="RINDEX" ref="RINDEX_Vacuum"/>
31+
</material>
32+
<material name="Quartz" state="solid">
33+
<D unit="g/cm3" value="2.2"/>
34+
<fraction n="0.4674" ref="Silicon"/>
35+
<fraction n="0.5326" ref="Oxygen"/>
36+
<property name="RINDEX" ref="RINDEX_Quartz"/>
37+
<property name="ABSLENGTH" ref="ABSLENGTH_Quartz"/>
38+
<!-- Synthetic scintillation properties (Quartz isn't really a scintillator).
39+
Both new (G4 11.x) and old (G4 10.x / Opticks U4Scint) names are required. -->
40+
<property name="SCINTILLATIONYIELD" ref="SCINT_YIELD"/>
41+
<property name="RESOLUTIONSCALE" ref="RESOLUTION_SCALE"/>
42+
<property name="SCINTILLATIONCOMPONENT1" ref="SCINT_SPECTRUM"/>
43+
<property name="SCINTILLATIONTIMECONSTANT1" ref="FAST_TIME_CONST"/>
44+
<property name="SCINTILLATIONYIELD1" ref="YIELD_RATIO"/>
45+
<property name="FASTCOMPONENT" ref="SCINT_SPECTRUM"/>
46+
<property name="SLOWCOMPONENT" ref="SCINT_SPECTRUM"/>
47+
<property name="FASTTIMECONSTANT" ref="FAST_TIME_CONST"/>
48+
<property name="SLOWTIMECONSTANT" ref="FAST_TIME_CONST"/>
49+
<property name="YIELDRATIO" ref="YIELD_RATIO"/>
50+
<property name="REEMISSIONPROB" ref="REEMISSION_PROB"/>
51+
</material>
52+
</materials>
53+
54+
<solids>
55+
<box name="WorldSolid" x="2000" y="2000" z="2000" lunit="mm"/>
56+
<trd name="TrdSolid"
57+
x1="200" x2="60"
58+
y1="300" y2="80"
59+
z="400"
60+
lunit="mm"/>
61+
<box name="DetSolid" x="500" y="500" z="1" lunit="mm"/>
62+
<opticalsurface name="DetOpSurface" model="0" finish="0" type="1" value="1">
63+
<property name="REFLECTIVITY" ref="REFLECTIVITY_Det"/>
64+
<property name="EFFICIENCY" ref="EFFICIENCY_Det"/>
65+
</opticalsurface>
66+
</solids>
67+
68+
<structure>
69+
<volume name="DetVolume">
70+
<materialref ref="Quartz"/>
71+
<solidref ref="DetSolid"/>
72+
<auxiliary auxtype="SensDet" auxvalue="PMT"/>
73+
</volume>
74+
<volume name="TrdVolume">
75+
<materialref ref="Quartz"/>
76+
<solidref ref="TrdSolid"/>
77+
</volume>
78+
<volume name="World">
79+
<materialref ref="Vacuum"/>
80+
<solidref ref="WorldSolid"/>
81+
<physvol name="TrdPV">
82+
<volumeref ref="TrdVolume"/>
83+
</physvol>
84+
<physvol name="DetPV">
85+
<volumeref ref="DetVolume"/>
86+
<position name="DetPV_pos" unit="mm" x="0" y="0" z="250"/>
87+
</physvol>
88+
</volume>
89+
<skinsurface name="DetSkinSurface" surfaceproperty="DetOpSurface">
90+
<volumeref ref="DetVolume"/>
91+
</skinsurface>
92+
</structure>
93+
94+
<setup name="Default" version="1.0">
95+
<world ref="World"/>
96+
</setup>
97+
</gdml>

0 commit comments

Comments
 (0)