Skip to content

Conversation

tmadlener
Copy link
Member

BEGINRELEASENOTES

  • Add documentation about histograms

ENDRELEASENOTES

This is meant to be a basic introduction on how to use monitoring histograms. We should potentially also have a section about the underlying accumulators and maybe a few small examples.

@jmcarcell
Copy link
Member

jmcarcell commented Sep 25, 2025

These histograms have a few caveats:

  • Since they are templated, building in debug mode to debug something and having histograms can make an algorithm run incredibly slow, especially with histograms with many bins (this happened to me with 2D histograms).
  • I think the standard deviation that you get in the table in the final ROOT histogram is not the same that you would get if it was a ROOT histogram what was being filled because I think it is computed from the values of the bins instead of the original distribution.
    The second one at least should be noted since, depending on the case, it can be not what is expected.

It might be necessary to monitor an algorithm, e.g. by keeping track of how many
times different branches in the algorithm logic are taken. Since Functional
algorithms run potentially multithreaded, the usual approach of simply using
mutable counters or histograms for this is not easily possible. Gaudi, provides
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mutable counters or histograms for this is not easily possible. Gaudi, provides
mutable counters or histograms for this is not easily possible. Gaudi provides

Comment on lines +26 to +27
some threadsafe tools to make monitoring Functional algorithms possible more
easily. These tools generally take care of updating counters and histograms in a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
some threadsafe tools to make monitoring Functional algorithms possible more
easily. These tools generally take care of updating counters and histograms in a
some threadsafe tools to make monitoring Functional algorithms more easily
possible. These tools generally take care of updating counters and histograms in a


In Gaudi all of these tools live in the `Gaudi::Accumulators` namespace and we
refer to the [documentation of
that](ttps://gaudi.web.cern.ch/doxygen/v40r0/da/dd5/namespace_gaudi_1_1_accumulators.html)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
that](ttps://gaudi.web.cern.ch/doxygen/v40r0/da/dd5/namespace_gaudi_1_1_accumulators.html)
that](https://gaudi.web.cern.ch/doxygen/v40r0/da/dd5/namespace_gaudi_1_1_accumulators.html)


Histograms also exist as generic versions and as ROOT backed versions. The main
difference is that the ROOT backed version will obviously produce ROOTs
`TH[1-3][I,D,F]`s (and are hence also limited to at most 3 dimensions), where as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`TH[1-3][I,D,F]`s (and are hence also limited to at most 3 dimensions), where as
`TH[1-3][I,D,F]`s (and are hence also limited to at most 3 dimensions), whereas

// We can also just define the dimensions and the title
mutable Gaudi::Accumulators::RootHistogram<2> m_hist2d{this, "Hist2D", "A 2D histogram"};

// NOTE: For configurable histograms you ahve to register this empty callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// NOTE: For configurable histograms you ahve to register this empty callback
// NOTE: For configurable histograms you have to register this empty callback

```python
from Configurables import Gaudi__Histograming__Sink__Root as RootHistoSink

histoSinkSvc = RootHistSink("RootHistoSink")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
histoSinkSvc = RootHistSink("RootHistoSink")
histoSinkSvc = RootHistoSink("RootHistoSink")

Change here or change above. In Gaudi it is only used once and with the o.


### Customizing a histogram

Configurable histograms need to be crated in `initialize` as follows in order to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Configurable histograms need to be crated in `initialize` as follows in order to
Configurable histograms need to be created in `initialize` as follows in order to


```cpp
auto operator()(/* However your signature looks like */) {
{ // create a scope to limit the liftime of the buffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ // create a scope to limit the liftime of the buffer
{ // create a scope to limit the lifetime of the buffer

Configurable histograms need to be crated in `initialize` as follows in order to
pick up the configuration from python:
```cpp
StatusCode MyAlgorithm::initizlize() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
StatusCode MyAlgorithm::initizlize() {
StatusCode MyAlgorithm::initialize() {

Comment on lines +103 to +105
Filling a histogram is done by using the `operator[]` of the histogram classes
and is the same, regardless of whether the histograms are configurable or
static, e.g.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Filling a histogram is done by using the `operator[]` of the histogram classes
and is the same, regardless of whether the histograms are configurable or
static, e.g.
Filling a histogram is done by using the `operator[]` of the histogram classes
and is the same whether the histograms are configurable or
static.

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.

2 participants