Skip to content

Fix process observables and documentation of TRestGeant4AnalysisProcess - #156

Merged
AlvaroEzq merged 2 commits into
masterfrom
aezq_fixG4AnalysisProcessObservables
Oct 9, 2026
Merged

AlvaroEzq merged 2 commits into
masterfrom
aezq_fixG4AnalysisProcessObservables

Conversation

@AlvaroEzq

@AlvaroEzq AlvaroEzq commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

AlvaroEzq Large: 506 Powered by Pull Request Badge

Summary

The class documentation of TRestGeant4AnalysisProcess did not match the code, and several documented observables were never computed. This PR implements them and rewrites the documentation.

Observables

  • <volume><Process>Process (e.g. gasComptonProcess): previously parsed in InitProcess but never filled. They now hold the energy (keV) deposited in that volume by that process, using TRestGeant4Event::GetEnergyInVolumePerProcessMap(), which is consistent with <volume>VolumeEDep.
  • Process names: there is now an explicit REST ↔ Geant4 table (GetRestToGeant4ProcessNameMap()), and Geant4 names with a capital first letter are accepted (Compt, HadElastic, NCapture...). The hardcoded-length parser is replaced by matching the longest known process name before the Process suffix. An unknown name prints a warning listing the valid names. The legacy spellings Bremstralung, RadiactiveDecay and NInelastic are still accepted.
  • PerProcess* (perProcessSensitiveEnergy): a local fObservables vector was hiding the class member, so these never reached the tree. They are now registered and filled with the energy in the sensitive volume per process, normalized to the sensitive volume energy if perProcessSensitiveEnergyNorm is set.
  • containsProcess<Process>: works for any process. Phot and Compt are always filled, as before. Any other process is filled only if requested in the RML, so observable="all" does not add extra branches.

Bug fixes

  • TRestGeant4PhysicsInfo::GetProcessID() returns 0 for unknown names, and 0 is the ID of Init. As a result, containsProcess<X> returned 1 for processes absent from the simulation. The process is now checked to be registered before testing it.
  • InitProcess() is called twice by TRestThread, which duplicated the auxiliary vectors. They are now cleared first.

Known limitation (documented)

restG4 builds process IDs as type*1000+subtype, so eIoni, hIoni, ionIoni and muIoni share an ID and only one name is registered. containsProcess cannot distinguish between them. The energy-based observables are keyed by name and are not affected.

Documentation

The Doxygen header is rewritten. It now covers:

  • volume aliases (volume="...") and the active-volume requirement
  • a process name table
  • corrected TracksCounter/TracksEDep examples
  • the firstTrackInSensitive*, sensitiveVolume*, *PrimaryParticleName and zenith*Degrees observables
  • a full RML example

Testing

Tested on a 10-event 252Cf restG4 simulation:

  • Build: compiles with no new warnings (-Wall -Wextra).
  • containsProcess: containsProcessNCapture, NeutronInelastic and HadElastic match an independent hit-by-hit check.
  • Per-volume energy: shieldingHadElasticProcess (23–284 keV), shieldingComptonProcess and shieldingPhotProcess are non-zero.
  • PerProcess: the observables add up to at most sensitiveVolumeEnergy.
  • Error cases: an inactive volume and unknown process names print clear warnings without crashing.

Not tested: perProcessSensitiveEnergyNorm=true, and the particle-specific PerProcess categories, which were 0 in the sample.

🤖 Generated with Claude Code

Alvaro Ezquerro and others added 2 commits October 9, 2026 10:32
- Implement <volume><Process>Process observables (energy deposited in the
  volume by the process, in keV), which were parsed but never filled.
- Add an explicit REST <-> Geant4 process name table and replace the
  hardcoded-length parser with suffix matching against known names.
- Implement PerProcess* sensitive volume energy observables (the local
  fObservables vector was shadowing the member and they never reached the tree).
- Generalize containsProcess<Process> to any process requested in the RML.
  Guard against unregistered processes, whose default id (0) matches "Init".
- Clear auxiliary vectors in InitProcess, which is called twice.
- Rewrite the class documentation to match the implemented observables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlvaroEzq

Copy link
Copy Markdown
Contributor Author

I did a quick test by myself and seems to work fine.

@AlvaroEzq
AlvaroEzq merged commit de22247 into master Oct 9, 2026
64 checks passed
@AlvaroEzq
AlvaroEzq deleted the aezq_fixG4AnalysisProcessObservables branch October 9, 2026 09:44
@jgalan

jgalan commented Oct 10, 2026

Copy link
Copy Markdown
Member

Just wondering if one could pass the code of each C++ class to IA with strict instructions to do not modify code, and improve the Doxygen documentation of the class automatically, including REAME files at each directory once the agent understands the context of a given directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants