The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N > Struct Template Reference

Common base for Traits dealing with Histogram conversions to Root Provides generic implementation for creating the histogram and filling meta data The filling (method fill) is not implemented. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Histograming/Sink/Utils.h>

Inheritance diagram for Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N >:

Static Public Member Functions

template<typename AxisArray, std::size_t... index>
static RootHisto create (std::string &name, std::string &title, AxisArray axis, std::index_sequence< index... >)
template<typename... Axis>
static RootHisto create (std::string &name, std::string &title, Axis &... axis)
static void fillMetaData (RootHisto &histo, nlohmann::json const &jsonAxis, unsigned int nentries)

Static Public Attributes

static constexpr unsigned int Dimension { N }

Detailed Description

template<typename RootHisto, unsigned int N>
struct Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N >

Common base for Traits dealing with Histogram conversions to Root Provides generic implementation for creating the histogram and filling meta data The filling (method fill) is not implemented.

Definition at line 256 of file Utils.h.

Member Function Documentation

◆ create() [1/2]

template<typename RootHisto, unsigned int N>
template<typename... Axis>
RootHisto Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N >::create ( std::string & name,
std::string & title,
Axis &... axis )
inlinestatic

Definition at line 268 of file Utils.h.

268 {
269 return create( name, title, std::make_tuple( axis... ), std::make_index_sequence<sizeof...( Axis )>() );
270 }
Common base for Traits dealing with Histogram conversions to Root Provides generic implementation for...
Definition Utils.h:256
static RootHisto create(std::string &name, std::string &title, AxisArray axis, std::index_sequence< index... >)
Definition Utils.h:260

◆ create() [2/2]

template<typename RootHisto, unsigned int N>
template<typename AxisArray, std::size_t... index>
RootHisto Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N >::create ( std::string & name,
std::string & title,
AxisArray axis,
std::index_sequence< index... >  )
inlinestatic

Definition at line 260 of file Utils.h.

260 {
262 std::tuple_cat( std::tuple{ name.c_str(), title.c_str() },
263 std::tuple{ std::get<index>( axis ).nBins, std::get<index>( axis ).minValue,
264 std::get<index>( axis ).maxValue }... ) );
265 }

◆ fillMetaData()

template<typename RootHisto, unsigned int N>
void Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N >::fillMetaData ( RootHisto & histo,
nlohmann::json const & jsonAxis,
unsigned int nentries )
inlinestatic

Definition at line 272 of file Utils.h.

272 {
273 auto try_set_bin_labels = [&histo, &jsonAxis]( auto idx ) {
274 TAxis* axis = nullptr;
275 switch ( idx ) {
276 case 0:
277 axis = histo.GetXaxis();
278 break;
279 case 1:
280 axis = histo.GetYaxis();
281 break;
282 case 2:
283 axis = histo.GetZaxis();
284 break;
285 default:
286 break;
287 }
288 if ( axis && jsonAxis[idx].contains( "labels" ) ) {
289 const auto labels = jsonAxis[idx].at( "labels" );
290 for ( unsigned int i = 0; i < labels.size(); i++ ) {
291 axis->SetBinLabel( i + 1, labels[i].template get<std::string>().c_str() );
292 }
293 }
294 if ( axis && jsonAxis[idx].contains( "xbins" ) ) {
295 const auto xbins = jsonAxis[idx].at( "xbins" );
296 axis->Set( xbins.size() - 1, xbins.template get<std::vector<double>>().data() );
297 }
298 };
299 for ( unsigned int i = 0; i < jsonAxis.size(); i++ ) try_set_bin_labels( i );
300 // Fix the number of entries, wrongly computed by ROOT from the numer of calls to fill
301 histo.SetEntries( nentries );
302 }

Member Data Documentation

◆ Dimension

template<typename RootHisto, unsigned int N>
unsigned int Gaudi::Histograming::Sink::details::TraitsBase< RootHisto, N >::Dimension { N }
staticconstexpr

Definition at line 257 of file Utils.h.

257{ N };

The documentation for this struct was generated from the following file:
  • GaudiKernel/include/Gaudi/Histograming/Sink/Utils.h