Does Geant4 have an accumulator analogous to TProfile?

Geant4 Version: 10.07.p04, 11.4.1
Operating System: Any
Compiler/Version: Any
CMake Version: Any


TL;DR: Does G4 have a built-in utility class that does the kind of things TProfile or TH1 can do (accumulating points, returning the sum/mean/errors in each bin)?

We are working on a “corrections table” for an aspect of the CDMS simulation framework, which will be a 2D table (G4Physics2DVector) in bins of energy and Shannon entropy for our detector. We will populate this at initialization time (like G4’s own cross-section tables, material-cuts couples, etc.), by running through a bunch of calculations once.

The raw results of those calculations are a spread of points in each bin, which need to be distilled down to the mean value that goes into the G4Physics2DVector. In our development code, we’ve been using ROOT’s TProfile to make that easy and encapsulated. But I really don’t want to (and in some ways, can’t) do that in our actual simulation framework, for many reasons.

Does Geant4 have some internal utility class, maybe something used within EM physics, that does what TProfile does? This isn’t really a G4Analysis thing (unless we can instantiate and use an individual G4Analysis histogram outside of the whole G4AnalysisManager framework).

I think (but @ivana is the expert here) this is possible through the G4analysis system. This does have at least 1D/2D histograms, though the full histogram API (in the underlying g4tools external) might not be directly exposed, as you note.

It might be possible through direct use of g4tools types, since the headers here are exposed. However, not that g4tools is under heavy maintenance right now, so I can’t guarantee future functionality (documentation is also a part of this, g4tools is rather… opaque… right now).

Maybe I misunderstand your use case, but could the quantities that go into the G4Physics2DVector be pre-computed and persisted (e.g. like calibration quantities), or is the calculation fully runtime dependent on some quantities? I’m guessing the later.