Skip to content

New (counter based) histograms

Sebastien Ponce requested to merge sponce_histocounters into master

Depends on !1112 (merged).

This adds new types of Counters, namely (Profile)?(Weighted)?Histogram with the following features :

  • can be any number of dimensions. The dimension is its first template parameter
  • at construction, you give a triplet of values per dimension : nbins, minValue, maxValue.
  • operator+= takes either an array of values (one per dimension) or a tuple<array of values, weight> for weighted histograms. The size of the array of value has to match the dimension, or dimension + 1 for profile histograms.
  • the prefered syntax is to avoid operator+= and use operator[] to get a buffer on the bin you're updating. Syntax becomes : ++counter[{x,y}] or wcounter[{x,y]] += w
  • the internal counter type is templated, allowing to choose floats or even int while default is double
  • the counters can be atomic or not and supports buffering. Note that the atomicity is classical eventual consistency. So each bin is atomically updated but bins are not garranted to be coherent when reading all of them back

Typical usage :

  Histogram<2, atomicity::full, double>
    counter{owner, "CounterName", {nBins1, minVal1, maxVal1}, {nBins2, minVal2, maxVal2}};
  ++counter[{val1, val2}];

Of course shortcuts are possible :

  Histogram<1> myHisto{...}; // will be atomic by default, storing doubles
  Histogram<1, atomicity::none> myFastHisto; // non atomic, storing doubles

This also adds a new Sink (see !1112 (merged) for details on the new monitoring) that saves histograms to ROOT files. This is only a toy Sink with hardcoded file name, but demonstrates how one can convert these new histograms to ROOT.

Edited by Marco Clemencic

Merge request reports