Skip to content

Cherenkov bug #81

@zhaozhiwen

Description

@zhaozhiwen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions