GEMC Source Fix for Cherenkov Test
Date: 2026-05-06
Conclusion
The Cherenkov test failure is in GEMC source, not the CO2 geometry.
Two GEMC source changes are needed:
- Attach parsed optical material properties to the Geant4
G4Material.
- Actually honor the
recordZeroEdep switch in digitization, so zero-energy optical photon steps are recorded.
Why
GMaterial already parses photonEnergy, indexOfRefraction, and absorptionLength, but G4World::createG4Material only builds density/composition. It never creates a G4MaterialPropertiesTable, so Geant4 optical physics has no RINDEX table and cannot produce Cherenkov photons from GEMC materials.
After that is fixed, optical photons are produced but still skipped unless recordZeroEdep is wired into GDynamicDigitization. Optical photons have zero deposited energy in the flux panel, so the default skip rule drops them.
GEMC writes optical photons with pid == -22, not pid == 0.
Patch
Apply these changes in https://github.com/gemc/src.
In g4system/g4world.cc:
+#include "G4MaterialPropertiesTable.hh"
After the material composition is built in G4World::createG4Material and before return true;:
auto photonEnergy = gmaterial->getPhotonEnergy();
if (!photonEnergy.empty()) {
auto* materialPropertiesTable = new G4MaterialPropertiesTable();
bool hasOpticalProperties = false;
auto addProperty = [&](const char* propertyName, const std::vector<double>& values) {
if (values.empty()) { return; }
if (values.size() != photonEnergy.size()) {
log->error(ERR_GMATERIALOPTICALPROPERTYMISMATCH,
"material <", materialName, "> optical property <", propertyName, "> has ",
values.size(), " entries but photonEnergy has ", photonEnergy.size());
}
materialPropertiesTable->AddProperty(propertyName, photonEnergy, values);
hasOpticalProperties = true;
};
addProperty("RINDEX", gmaterial->getIndexOfRefraction());
addProperty("ABSLENGTH", gmaterial->getAbsorptionLength());
addProperty("RAYLEIGH", gmaterial->getRayleigh());
if (hasOpticalProperties) {
g4materialsMap[materialName]->SetMaterialPropertiesTable(materialPropertiesTable);
log->info(2, "Attached optical material properties table to material <", materialName, ">");
}
else {
delete materialPropertiesTable;
}
}
In gdynamicDigitization/gdynamicdigitization.h:
explicit GDynamicDigitization(const std::shared_ptr<GOptions>& g) : GBase(g, GDIGITIZATION_LOGGER) {
+ recordZeroEdep = g->getSwitch("recordZeroEdep");
}
Validation
Source checkout tested at src/gemc, commit abe982a, built inside the GEMC3 Apptainer environment.
Patched 1000-electron center-axis run:
- Input:
tests/cherenkov/cherenkov.yaml
- Beam:
1000 electrons, 1 GeV, center axis
- GEMC binary:
src/gemc/build/gemc
- Output:
tests/cherenkov/results_src_checkout_1000/cherenkov_co2_t0.root
- Analysis:
tests/cherenkov/results_src_checkout_1000/analysis
Result:
events_with_flux_entries: 1000
total_flux_hits: 82275
optical_photon_pid: -22
total_optical_photon_hits: 82250
Impact: GEMC ASCII/SQLite materials with optical fields become usable by Geant4 optical physics, and zero-energy optical photon flux hits can be persisted when recordZeroEdep is enabled.
GEMC Source Fix for Cherenkov Test
Date: 2026-05-06
Conclusion
The Cherenkov test failure is in GEMC source, not the CO2 geometry.
Two GEMC source changes are needed:
G4Material.recordZeroEdepswitch in digitization, so zero-energy optical photon steps are recorded.Why
GMaterialalready parsesphotonEnergy,indexOfRefraction, andabsorptionLength, butG4World::createG4Materialonly builds density/composition. It never creates aG4MaterialPropertiesTable, so Geant4 optical physics has noRINDEXtable and cannot produce Cherenkov photons from GEMC materials.After that is fixed, optical photons are produced but still skipped unless
recordZeroEdepis wired intoGDynamicDigitization. Optical photons have zero deposited energy in the flux panel, so the default skip rule drops them.GEMC writes optical photons with
pid == -22, notpid == 0.Patch
Apply these changes in
https://github.com/gemc/src.In
g4system/g4world.cc:+#include "G4MaterialPropertiesTable.hh"After the material composition is built in
G4World::createG4Materialand beforereturn true;:In
gdynamicDigitization/gdynamicdigitization.h:explicit GDynamicDigitization(const std::shared_ptr<GOptions>& g) : GBase(g, GDIGITIZATION_LOGGER) { + recordZeroEdep = g->getSwitch("recordZeroEdep"); }Validation
Source checkout tested at
src/gemc, commitabe982a, built inside the GEMC3 Apptainer environment.Patched 1000-electron center-axis run:
tests/cherenkov/cherenkov.yaml1000electrons,1 GeV, center axissrc/gemc/build/gemctests/cherenkov/results_src_checkout_1000/cherenkov_co2_t0.roottests/cherenkov/results_src_checkout_1000/analysisResult:
events_with_flux_entries:1000total_flux_hits:82275optical_photon_pid:-22total_optical_photon_hits:82250Impact: GEMC ASCII/SQLite materials with optical fields become usable by Geant4 optical physics, and zero-energy optical photon flux hits can be persisted when
recordZeroEdepis enabled.