The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
Gaudi::Accumulators::HistogramMap< Key, Histo, Seq > Struct Template Reference

generic class implementing a thread safe map of histograms More...

Detailed Description

template<typename Key, typename Histo, typename Seq = std::make_integer_sequence<unsigned int, std::tuple_size_v<typename Histo::AxisTupleType>>>
struct Gaudi::Accumulators::HistogramMap< Key, Histo, Seq >

generic class implementing a thread safe map of histograms

The map looks like and std:map with only operator[] and constructor The constructor takes 2 arguments allowing to build names and titles automatically when inserting new histograms in the map. There are 2 possibilities :

  • if 2 string_views are given, they are used in a call to std::format(name/title, key);
  • if 2 callables are given, they are called on the key they should take an argument of type Key and return some type convertible to string_view The operator[] will then build on the fly the name and title of the new histograms from the key when creating new entries

Thread safety is ensured by serializing calls to operator[] through a mutex

Note that this should in principle be used only with StaticHistograms, there is no reason to use Histograms there, as the histograms are only created at run time anyway so in a sense they are already dynamic

Typical usage : // Map of 1D histograms with simple names and titles, key being an int // Names will be GaudiH1D-N and similarly for titles where N is the key associated Gaudi::Accumulators::HistogramMap<int, Gaudi::Accumulators::Histogram<1>> histo1d{ &algo, "GaudiH1D-{}", "A Gaudi 1D histogram - number {}", { 21, -10.5, 10.5, "X" } }; ++histo1d[3][-10.0]; // Map of 2D weighted histograms with simple names and titles, key being int // Names will be Name0, Name1, ... and similarly for titles Gaudi::Accumulators::HistogramMap<int, Gaudi::Accumulators::WeightedHistogram<2>> histo2dw{ &algo, "Name{}", "Title {}", { 21, -10.5, 10.5, "X" }, { 21, -10.5, 10.5, "Y" } }; histo2dw[1][{ -10.0, -10.0 }] += 0.25; // Map of histograms with custom name and titles, key is a pair<int, string> // Names will be GaudiH1D-<N>-, where the key was the pair (<n>, ) // Titles will be "Title <S> (<N>)" Gaudi::Accumulators::HistogramMap<std::pair<int, std::string>, Gaudi::Accumulators::Histogram<1>> histoCustom{ &algo, []( std::pair<int, std::string> const& p ) { return fmt::format( "GaudiH1D-{}-{}", p.first, p.second ); }, []( std::pair<int, std::string> const& p ) { return fmt::format( "Title {} ({})", p.first, p.second ); }, { 21, -10.5, 10.5, "X" } }; ++histoCustom[{3, "three"}][-10.0];

Definition at line 125 of file HistogramMap.h.


The documentation for this struct was generated from the following file: