19template <
typename T,
unsigned int NDIM>
20class THnHelper :
public ROOT::Detail::RDF::RActionImpl<THnHelper<T, NDIM>> {
25 using Result_t = THn_t;
28 std::vector<std::shared_ptr<THn_t>> fHistos;
34 std::array<double, NDIM>
xmax)
38 fHistos.emplace_back(std::make_shared<THn_t>(std::string(
name).c_str(), std::string(title).c_str(),
39 NDIM, nbins.data(), xmins.data(),
xmax.data()));
43 THnHelper(THnHelper &&) =
default;
44 THnHelper(
const THnHelper &) =
delete;
45 std::shared_ptr<THn_t> GetResultPtr()
const {
return fHistos[0]; }
49 template <
typename... ColumnTypes>
50 void Exec(
unsigned int slot, ColumnTypes... values)
53 std::array<
double,
sizeof...(ColumnTypes)> valuesArr{
static_cast<double>(values)...};
54 fHistos[slot]->Fill(valuesArr.data());
60 auto &res = fHistos[0];
62 res->Add(fHistos[slot].get());
66 std::string GetActionName(){
71void df018_customActions()
80 auto genF = [&genD]() {
return (
float)genD(); };
81 auto genI = [&genD]() {
return (
int)genD(); };
82 auto dd =
d.Define(
"x0", genD).Define(
"x1", genD).Define(
"x2", genF).Define(
"x3", genI);
86 using Helper_t = THnHelper<float, 4>;
88 Helper_t helper{
"myThN",
89 "A THn with 4 dimensions",
91 {-10., -10, -4., -6.},
95 auto myTHnT = dd.Book<
double,
double, float,
int>(std::move(helper), {
"x0",
"x1",
"x2",
"x3"});
R__EXTERN TRandom * gRandom
typedef void((*Func_t)())
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A pseudo container class which is a generator of indices.
Templated implementation of the abstract base THn.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
basic_string_view< char > string_view
CPYCPPYY_EXTERN bool Exec(const std::string &cmd)
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.
void Initialize(Bool_t useTMVAStyle=kTRUE)