![]() |
The Gaudi Framework
master (181af51f)
|
generic class implementing a thread safe map of histograms More...
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 :
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.