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.
Our student did find the G4Analysis “CreateP1()” function to create a profile plot, but all that seems embedded withing the “analysis management” framework. Thank you for the pointer to “g4tools”! We will look there and see if we can leverage things in a free-standing way.
In a perfect world, that’s what we’d do, and store data files in our repository to be read in at runtime. There are two potential issues with that – we have a bunch of different detector types, and each one needs its own correction table. Second, there are detector response parameters which can be changed at run time, either by setting values, or by choosing particular fabricated detectors (by serial number). The corrections tables depend on those response parameters, so we would still need the ability to recompute them at run time.
If g4tools turns out to be a good solution, I’ll make sure to flag that as the Solution. Thank you very much, Ben!
You can find texamples of he code showing how to use g4tools object without g4analysis management in geant4/tests/ctests_source/externals/g4tools/utest
Thank you very much, Ben! I was able to create the profile points using g4tools p1d directly. This was just as easy/encapsulated as using TProfile. This is exactly what we needed. Thank you!