12#include <ROOT/Hist/ConvertToTH1.hxx>
13#include <ROOT/RFile.hxx>
14#include <ROOT/RHist.hxx>
21#include <spdlog/spdlog.h>
30 : filename_{std::move(filename)}, file_{ROOT::Experimental::RFile::Recreate(filename_)} {}
32 void put(
char const* name,
char const* title, ROOT::Experimental::RHist<double>
const& h) {
34 std::scoped_lock lock{mutex_};
35 auto th1 = ROOT::Experimental::Hist::ConvertToTH1D(h);
36 th1->SetNameTitle(name, title);
37 file_->Put(name, *th1);
38 }
catch (std::exception
const& e) {
41 spdlog::error(
"HistoFileService: failed to write histogram '{}' to '{}': {}", name,
49 std::string filename_;
50 std::unique_ptr<ROOT::Experimental::RFile> file_;
56inline std::shared_ptr<ROOT::Experimental::RHist<double>>
make_hist(std::uint64_t nbins,
double low,
58 return std::make_shared<ROOT::Experimental::RHist<double>>(nbins, std::make_pair(low, high));
void put(char const *name, char const *title, ROOT::Experimental::RHist< double > const &h)
Definition HistoFileService.hpp:32
HistoFileService(std::string filename)
Definition HistoFileService.hpp:29
Definition fit_seed.cpp:16
std::shared_ptr< ROOT::Experimental::RHist< double > > make_hist(std::uint64_t nbins, double low, double high)
Definition HistoFileService.hpp:56