Design of a new statistics service based on Accumulators
We have Gaudi::Accumulators::Counters
that can be used very efficiently in re-entrant algorithms. However, it would be nice if we also provide some support for cloned algorithms, similar to what the THistSvc does with "shared" histograms.
Conceptually this would require a service where one registers a Counter under a given name. If there is already a counter under the same name (with the parent prefixed), a reference to the existing counter is returned. This would ensure that all algorithm clones use the same Counter instance. [Alternatively, one could hand out new Counters for all clones and do the merge at the end. But since we don't expect performance issues here I don't think that's needed].
From the user-side we may want:
// .h
CounterHandle<AveragingCounter<int>> m_avg{this, "MyCounter"};
// .cpp
(*m_avg) += 2;
(*m_avg) += 3;
info() << m_avg->mean() << endmsg;
Some comments/questions:
- Do we agree that such a service is useful at all?
- Is the above at all possible since we don't have a common base class for Counters and need to support different types?
- Instead of adding an extra handle, should we implement the registration feature directly in the Counter?
- Are we worried about the performance implications of the additional wrapper and the de-referencing?
- It should still be possible to use bare Counters as now if one doesn't want the registration/sharing feature
- Having such a service would also solve the issue of a thread-safe timing service (cf. !787 (merged))