diff --git a/config/drich.json b/config/drich.json new file mode 100644 index 000000000..2d2aff4ff --- /dev/null +++ b/config/drich.json @@ -0,0 +1,34 @@ +{ + "torch": { + "gentype": "TORCH", + "trackid": 0, + "matline": 0, + "numphoton": 10000, + + "pos": [776.5, 402.6, 2590.0], + "time": 0.0, + + "mom": [0.7621, 0.4400, -0.4750], + "weight": 0.0, + + "pol": [1.0, 0.0, 0.0], + "wavelength": 420.0, + + "zenith": [0.0, 1.0], + "azimuth": [0.0, 1.0], + + "radius": 10.0, + "distance": 0.0, + "mode": 255, + "type": "disc" + }, + + "event": { + "mode": "HitPhoton", + "maxslot": 1000000, + "max_bounce": 31, + "propagate_epsilon": 0.05, + "propagate_epsilon0": 0.05, + "propagate_epsilon0_mask": "TO,CK,SI,SC,RE" + } +} diff --git a/src/GPUCerenkov.h b/src/GPUCerenkov.h index 40c417939..d9cb1a46c 100644 --- a/src/GPUCerenkov.h +++ b/src/GPUCerenkov.h @@ -1,6 +1,7 @@ #include #include #include +#include #include "G4AutoLock.hh" #include "G4BooleanSolid.hh" @@ -263,6 +264,7 @@ struct DetectorConstruction : G4VUserDetectorConstruction { G4cout << "ConstructSDandField is called." << G4endl; G4SDManager *SDman = G4SDManager::GetSDMpointer(); + size_t sensitive_index = 0; const G4GDMLAuxMapType *auxmap = parser_.GetAuxMap(); for (auto const &[logVol, listType] : *auxmap) @@ -272,7 +274,7 @@ struct DetectorConstruction : G4VUserDetectorConstruction if (auxtype.type == "SensDet") { G4cout << "Attaching sensitive detector to logical volume: " << logVol->GetName() << G4endl; - G4String name = logVol->GetName() + "_PhotonDetector"; + G4String name = logVol->GetName() + "_" + std::to_string(sensitive_index++) + "_PhotonDetector"; PhotonSD *aPhotonSD = new PhotonSD(name); SDman->AddNewDetector(aPhotonSD); logVol->SetSensitiveDetector(aPhotonSD); diff --git a/src/GPURaytrace.h b/src/GPURaytrace.h index 14606bfe3..03308240f 100644 --- a/src/GPURaytrace.h +++ b/src/GPURaytrace.h @@ -1,6 +1,7 @@ #include #include #include +#include #include "G4AutoLock.hh" #include "G4BooleanSolid.hh" @@ -264,6 +265,7 @@ struct DetectorConstruction : G4VUserDetectorConstruction { G4cout << "ConstructSDandField is called." << G4endl; G4SDManager *SDman = G4SDManager::GetSDMpointer(); + size_t sensitive_index = 0; const G4GDMLAuxMapType *auxmap = parser_.GetAuxMap(); for (auto const &[logVol, listType] : *auxmap) @@ -273,7 +275,7 @@ struct DetectorConstruction : G4VUserDetectorConstruction if (auxtype.type == "SensDet") { G4cout << "Attaching sensitive detector to logical volume: " << logVol->GetName() << G4endl; - G4String name = logVol->GetName() + "_PhotonDetector"; + G4String name = logVol->GetName() + "_" + std::to_string(sensitive_index++) + "_PhotonDetector"; PhotonSD *aPhotonSD = new PhotonSD(name); SDman->AddNewDetector(aPhotonSD); logVol->SetSensitiveDetector(aPhotonSD); diff --git a/src/g4app.h b/src/g4app.h index faf30feb5..69dc3ee7a 100644 --- a/src/g4app.h +++ b/src/g4app.h @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -150,6 +151,7 @@ struct DetectorConstruction : G4VUserDetectorConstruction void ConstructSDandField() override { G4SDManager* SDman = G4SDManager::GetSDMpointer(); + size_t sensitive_index = 0; const G4GDMLAuxMapType* auxmap = parser_.GetAuxMap(); for (auto const& [logVol, listType] : *auxmap) @@ -159,7 +161,7 @@ struct DetectorConstruction : G4VUserDetectorConstruction if (auxtype.type == "SensDet") { G4cout << "DetectorConstruction::ConstructSDandField: Attach sensitive detector to logical volume: " << logVol->GetName() << G4endl; - G4String name = logVol->GetName() + "_PhotonDetector"; + G4String name = logVol->GetName() + "_" + std::to_string(sensitive_index++) + "_PhotonDetector"; PhotonSD* aPhotonSD = new PhotonSD(name); SDman->AddNewDetector(aPhotonSD); logVol->SetSensitiveDetector(aPhotonSD); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ab4a1205d..6ad1f41ef 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,6 +28,7 @@ add_simg4ox_integration_test(raindrop) add_simg4ox_integration_test(dune_mock_wls_detector_box) add_simg4ox_integration_test(8x8SiPM_w_CSI_optial_grease) add_simg4ox_integration_test(opticks_two_spheres) +add_simg4ox_integration_test(drich) set(SIMPHONY_SIMG4OX_MULTIEVENT_TEST_WORKDIR "${CMAKE_CURRENT_BINARY_DIR}/simg4ox_multievent") file(MAKE_DIRECTORY "${SIMPHONY_SIMG4OX_MULTIEVENT_TEST_WORKDIR}") diff --git a/tests/test_simg4ox.sh b/tests/test_simg4ox.sh index 32c1d5c84..648a51fed 100755 --- a/tests/test_simg4ox.sh +++ b/tests/test_simg4ox.sh @@ -21,6 +21,7 @@ usage() { echo " dune_mock_wls_detector_box" >&2 echo " 8x8SiPM_w_CSI_optial_grease" >&2 echo " opticks_two_spheres" >&2 + echo " drich" >&2 } if [[ $# -gt 1 ]]; then @@ -50,6 +51,7 @@ run_record_validation() { run_hit_validation() { local geometry=$1 local config_name=$2 + local macro_file=${3:-${MAC_FILE}} local run_log="${PWD}/simg4ox.log" rm -f "${PWD}/g_hits.npy" "${PWD}/s_hits.npy" "${run_log}" @@ -58,7 +60,7 @@ run_hit_validation() { "${SIMG4OX_BIN}" \ -g "${REPO_DIR}/tests/geom/${geometry}.gdml" \ -c "${config_name}" \ - -m "${MAC_FILE}" \ + -m "${macro_file}" \ -s "${SEED}" > "${run_log}" 2>&1 "${PYTHON}" "${COMPARE_AB}" hits "${PWD}/g_hits.npy" "${PWD}/s_hits.npy" \ @@ -82,6 +84,13 @@ case "${TEST_CASE}" in # regression where each PhotonSD overwrites g_hits.npy with its own collection. run_hit_validation opticks_two_spheres dev ;; + drich) + # Loading the full geometry exercises conversion of its partial-phi + # sphere and tube solids. The torch aims identical optical photons at + # a SiPM patch for a stable, nonzero CPU/GPU hit comparison. + # Invoke Geant4 SDs for the EFFICIENCY=1 SiPM skin surfaces. + run_hit_validation drich drich "${REPO_DIR}/tests/run_validate.mac" + ;; *) echo "Unknown simg4ox test case: ${TEST_CASE}" >&2 usage