The Gaudi Framework  v38r0 (2143aa4c)
Gaudi::Histograming::Sink Namespace Reference

Namespaces

 details
 

Classes

class  Base
 
struct  Root
 
struct  Traits
 templated Traits dealing with Root Histogram filling for standard histograms More...
 
struct  Traits< false, RootHisto, N >
 Specialization of Traits dealing with non profile Root Histograms. More...
 
struct  Traits< true, RootHisto, N >
 Specialization of Traits dealing with profile Root Histograms. More...
 

Functions

template<typename Traits >
std::tuple< typename Traits::Histo, std::stringjsonToRootHistogram (std::string &dir, std::string &name, nlohmann::json const &j)
 generic function to convert json to a ROOT Histogram More...
 
template<typename Histo >
nlohmann::json rootHistogramTojson (Histo const &)
 generic function to convert a ROOT Histogram to json More...
 
template<typename Traits >
void saveRootHisto (TFile &file, std::string dir, std::string name, nlohmann::json const &j)
 generic method to save histograms to files, based on Traits More...
 
template<unsigned int N, bool isProfile, typename ROOTHisto >
void saveRootHisto (TFile &file, std::string dir, std::string name, nlohmann::json const &j)
 generic method to save regular histograms to files More...
 

Function Documentation

◆ jsonToRootHistogram()

template<typename Traits >
std::tuple< typename Traits::Histo, std::string > Gaudi::Histograming::Sink::jsonToRootHistogram ( std::string dir,
std::string name,
nlohmann::json const &  j 
)

generic function to convert json to a ROOT Histogram

returns the Root histogram and the dir where to save it in the Root file This may be different from input dir in case name has slashes

Definition at line 378 of file Utils.h.

379  {
380  return details::jsonToRootHistogramInternal<Traits>( dir, name, j, std::make_index_sequence<Traits::Dimension>() );
381  }

◆ rootHistogramTojson()

template<typename Histo >
nlohmann::json Gaudi::Histograming::Sink::rootHistogramTojson ( Histo const &  )

generic function to convert a ROOT Histogram to json

essentially used for backward compatibility of old HistogramService with MonitoringHub

◆ saveRootHisto() [1/2]

template<typename Traits >
void Gaudi::Histograming::Sink::saveRootHisto ( TFile &  file,
std::string  dir,
std::string  name,
nlohmann::json const &  j 
)

generic method to save histograms to files, based on Traits

Definition at line 384 of file Utils.h.

384  {
385  // get the Root histogram
386  auto [histo, newDir] = jsonToRootHistogram<Traits>( dir, name, j );
387  // Change to the proper directory in the ROOT file
388  auto previousDir = details::changeDir( file, newDir );
389  // write to file
390  histo.Write();
391  // switch back to the previous directory
392  previousDir->cd();
393  }

◆ saveRootHisto() [2/2]

template<unsigned int N, bool isProfile, typename ROOTHisto >
void Gaudi::Histograming::Sink::saveRootHisto ( TFile &  file,
std::string  dir,
std::string  name,
nlohmann::json const &  j 
)

generic method to save regular histograms to files

Can be used in most cases as the handler function to register into Sink::Base contains all the boiler plate code and redirects specific code to the adapted Traits template

Definition at line 396 of file Utils.h.

396  {
397  saveRootHisto<Traits<isProfile, ROOTHisto, N>>( file, std::move( dir ), std::move( name ), j );
398  }
std::move
T move(T... args)
bug_34121.name
name
Definition: bug_34121.py:20
Gaudi::Histograming::Sink::details::changeDir
TDirectory * changeDir(TFile &file, std::string dir)
changes to the ROOT directory given in the current ROOT file and returns the current directory before...
Definition: Utils.h:254
ProduceConsume.j
j
Definition: ProduceConsume.py:101