Logo ROOT   6.16/01
Reference Guide
NodesUtils.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 02/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RDFNODES_UTILS
12#define ROOT_RDFNODES_UTILS
13
16#include "ROOT/RVec.hxx"
17#include "ROOT/RDF/Utils.hxx" // ColumnNames_t
18
19/// \cond
20template <typename T>
22
23template <typename T>
25/// \endcond
26
27namespace ROOT {
28namespace Internal {
29namespace RDF {
30using namespace ROOT::VecOps;
31using namespace ROOT::Detail::RDF;
32using namespace ROOT::RDF;
33
34/// Choose between TTreeReader{Array,Value} depending on whether the branch type
35/// T is a `RVec<T>` or any other type (respectively).
36template <typename T>
39};
40
41template <typename T>
44};
45
46template <typename T>
48
49/// Initialize a tuple of RColumnValues.
50/// For real TTree branches a TTreeReader{Array,Value} is built and passed to the
51/// RColumnValue. For temporary columns a pointer to the corresponding variable
52/// is passed instead.
53template <typename RDFValueTuple, std::size_t... S>
54void InitRDFValues(unsigned int slot, RDFValueTuple &valueTuple, TTreeReader *r, const ColumnNames_t &bn,
56{
57 // isTmpBranch has length bn.size(). Elements are true if the corresponding
58 // branch is a temporary branch created with Define, false if they are
59 // actual branches present in the TTree.
60 // TODO: evaluate this once, pass it down
61 std::array<bool, sizeof...(S)> isTmpColumn;
62 for (auto i = 0u; i < isTmpColumn.size(); ++i)
63 isTmpColumn[i] = customCols.HasName(bn.at(i));
64
65 // hack to expand a parameter pack without c++17 fold expressions.
66 // The statement defines a variable with type std::initializer_list<int>, containing all zeroes, and SetTmpColumn or
67 // SetProxy are conditionally executed as the braced init list is expanded. The final ... expands S.
68 //- TODO
69 int expander[] = {(isTmpColumn[S]
70 ? std::get<S>(valueTuple).SetTmpColumn(slot, customCols.GetColumns().at(bn.at(S)).get())
71 : std::get<S>(valueTuple).MakeProxy(r, bn.at(S)),
72 0)...,
73 0};
74 (void)expander; // avoid "unused variable" warnings for expander on gcc4.9
75 (void)slot; // avoid _bogus_ "unused variable" warnings for slot on gcc 4.9
76 (void)r; // avoid "unused variable" warnings for r on gcc5.2
77}
78
79} // namespace RDF
80} // namespace Internal
81} // namespace ROOT
82
83#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
typedef void((*Func_t)())
Encapsulates the columns defined by the user.
bool HasName(std::string name) const
Check if the provided name is tracked in the names list.
RCustomColumnBasePtrMap_t GetColumns() const
Returns the list of the pointers to the defined columns.
A "std::vector"-like collection of values implementing handy operation to analyse them.
Definition: RVec.hxx:221
An interface for reading collections stored in ROOT columnar datasets.
An interface for reading values stored in ROOT columnar datasets.
A simple, robust and fast interface to read values from ROOT colmnar datasets such as TTree,...
Definition: TTreeReader.h:44
void InitRDFValues(unsigned int slot, RDFValueTuple &valueTuple, TTreeReader *r, const ColumnNames_t &bn, const RBookedCustomColumns &customCols, std::index_sequence< S... >)
Initialize a tuple of RColumnValues.
Definition: NodesUtils.hxx:54
typename TReaderValueOrArray< T >::Proxy_t ReaderValueOrArray_t
Definition: NodesUtils.hxx:47
double T(double x)
Definition: ChebyshevPol.h:34
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
ROOT::Detail::RDF::ColumnNames_t ColumnNames_t
Definition: RDataFrame.cxx:790
RooArgSet S(const RooAbsArg &v1)
Choose between TTreeReader{Array,Value} depending on whether the branch type T is a RVec<T> or any ot...
Definition: NodesUtils.hxx:37