18 template <
typename T,
unsigned int NDIM>
19 class THnHelper :
public ROOT::Detail::RDF::RActionImpl<THnHelper<T, NDIM>> {
24 using Result_t = THn_t;
27 std::vector<std::shared_ptr<THn_t>> fHistos;
33 std::array<double, NDIM>
xmax)
37 fHistos.emplace_back(std::make_shared<THn_t>(std::string(name).c_str(), std::string(title).c_str(),
38 NDIM, nbins.data(), xmins.data(), xmax.data()));
42 THnHelper(THnHelper &&) =
default;
43 THnHelper(
const THnHelper &) =
delete;
44 std::shared_ptr<THn_t> GetResultPtr()
const {
return fHistos[0]; }
48 template <
typename... ColumnTypes>
49 void Exec(
unsigned int slot, ColumnTypes... values)
52 std::array<double,
sizeof...(ColumnTypes)> valuesArr{
static_cast<double>(values)...};
53 fHistos[slot]->Fill(valuesArr.data());
59 auto &res = fHistos[0];
61 res->Add(fHistos[slot].
get());
66 void df018_customActions()
75 auto genF = [&genD]() {
return (
float)genD(); };
76 auto genI = [&genD]() {
return (
int)genD(); };
77 auto dd =
d.Define(
"x0", genD).Define(
"x1", genD).Define(
"x2", genF).Define(
"x3", genI);
81 using Helper_t = THnHelper<float, 4>;
83 Helper_t helper{
"myThN",
84 "A THn with 4 dimensions",
86 {-10., -10, -4., -6.},
90 auto myTHnT = dd.Book<double, double, float,
int>(std::move(helper), {
"x0",
"x1",
"x2",
"x3"});
UInt_t GetImplicitMTPoolSize()
Returns the size of the pool used for implicit multi-threading.
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
Templated implementation of the abstract base THn.
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
void Initialize(Bool_t useTMVAStyle=kTRUE)
R__EXTERN TRandom * gRandom
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees, CSV's and other data formats.
A pseudo container class which is a generator of indices.
basic_string_view< char > string_view
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
typedef void((*Func_t)())
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.