28 #include <type_traits> 35 namespace Experimental {
63 namespace Experimental {
64 template <
int D,
typename P,
template <
int,
typename,
template <
typename>
class>
class...
S>
71 using ColumnNames_t = std::vector<std::string>;
74 class TCustomColumnBase;
91 class TIgnoreErrorLevelRAII {
96 TIgnoreErrorLevelRAII(
int errorIgnoreLevel);
97 ~TIgnoreErrorLevelRAII();
106 template <
int N,
int...
S>
107 struct GenStaticSeq : GenStaticSeq<N - 1, N - 1, S...> {
111 struct GenStaticSeq<0, S...> {
112 using type = StaticSeq<S...>;
116 using GenStaticSeq_t =
typename GenStaticSeq<S...>
::type;
119 template <
typename R,
typename F,
typename... Args>
122 return [f](
unsigned int, Args...
a) ->
R {
return f(
a...); };
125 template <
typename BranchType,
typename... Rest>
126 struct TNeedJitting {
127 static constexpr
bool value = TNeedJitting<Rest...>::value;
130 template <
typename... Rest>
131 struct TNeedJitting<TInferType, Rest...> {
132 static constexpr
bool value =
true;
135 template <
typename T>
136 struct TNeedJitting<T> {
137 static constexpr
bool value =
false;
141 struct TNeedJitting<TInferType> {
142 static constexpr
bool value =
true;
145 using TVBPtr_t = std::shared_ptr<TTreeReaderValueBase>;
146 using TVBVec_t = std::vector<TVBPtr_t>;
163 template <
typename T>
164 struct TReaderValueOrArray {
168 template <
typename T>
169 struct TReaderValueOrArray<TArrayBranch<T>> {
173 template <
typename T>
174 using ReaderValueOrArray_t =
typename TReaderValueOrArray<T>::Proxy_t;
180 template <
typename TDFValueTuple,
int... S>
181 void InitTDFValues(
unsigned int slot, TDFValueTuple &valueTuple,
TTreeReader *
r,
const ColumnNames_t &bn,
182 const ColumnNames_t &tmpbn,
183 const std::map<std::string, std::shared_ptr<TCustomColumnBase>> &customCols, StaticSeq<S...>)
188 std::array<bool,
sizeof...(S)> isTmpColumn;
189 for (
auto i = 0u; i < isTmpColumn.size(); ++i)
190 isTmpColumn[i] = std::find(tmpbn.begin(), tmpbn.end(), bn.at(i)) != tmpbn.end();
195 std::initializer_list<int> expander{(isTmpColumn[
S]
196 ? std::get<S>(valueTuple).SetTmpColumn(slot, customCols.at(bn.at(S)).
get())
197 : std::get<S>(valueTuple).MakeProxy(r, bn.at(S)),
204 template <
typename Filter>
205 void CheckFilter(Filter &)
207 using FilterRet_t =
typename TDF::CallableTraits<Filter>::ret_type;
208 static_assert(std::is_same<FilterRet_t, bool>::value,
"filter functions must return a bool");
214 const ColumnNames_t &dataSourceColumns);
220 template <
typename F,
typename T>
223 using ret_type =
typename CallableTraits<F>::ret_type;
224 static_assert(std::is_same<ret_type, T>::value,
"reduce function must have return type equal to argument type");
230 template <
typename F,
typename T>
231 void CheckReduce(F &, T)
233 static_assert(
sizeof(F) == 0,
"reduce function must take exactly two arguments of the same type");
238 void CheckSnapshot(
unsigned int nTemplateParams,
unsigned int nColumnNames);
241 const ColumnNames_t
SelectColumns(
unsigned int nArgs,
const ColumnNames_t &bl,
const ColumnNames_t &defBl);
244 ColumnNames_t
FindUnknownColumns(
const ColumnNames_t &requiredCols, TTree *
tree,
const ColumnNames_t &definedCols,
245 const ColumnNames_t &dataSourceColumns);
248 namespace ActionTypes {
263 template <
typename T>
264 struct IsV7Hist :
public std::false_type {
265 static_assert(std::is_base_of<TH1, T>::value,
"not implemented for this type");
268 template <
int D,
typename P,
template <
int,
typename,
template <
typename>
class>
class... S>
272 template <typename T, bool ISV7HISTO = IsV7Hist<T>::value>
274 static void SetCanExtendAllAxes(T &
h) { h.SetCanExtend(::
TH1::kAllAxes); }
275 static bool HasAxisLimits(T &h)
277 auto xaxis = h.GetXaxis();
278 return !(xaxis->GetXmin() == 0. && xaxis->GetXmax() == 0.);
282 template <
typename T>
283 struct HistoUtils<T, true> {
284 static void SetCanExtendAllAxes(T &) {}
285 static bool HasAxisLimits(T &) {
return true; }
289 template <
bool MustRemove,
typename TypeList>
290 struct RemoveFirstParameterIf {
294 template <
typename TypeList>
295 struct RemoveFirstParameterIf<true, TypeList> {
296 using type = RemoveFirstParameter_t<TypeList>;
299 template <
bool MustRemove,
typename TypeList>
300 struct RemoveFirstTwoParametersIf {
301 using type = TypeList;
304 template <
typename TypeList>
305 struct RemoveFirstTwoParametersIf<true, TypeList> {
315 template <
bool... bs>
316 using IsTrueForAllImpl_t =
typename std::is_same<TBoolPack<bs...,
true>, TBoolPack<
true, bs...>>;
318 template <
bool... Conditions>
320 static constexpr
bool value = IsTrueForAllImpl_t<Conditions...>::value;
326 struct IsVector_t : std::false_type {
329 template <
typename T>
330 struct IsVector_t<std::vector<T>> : std::true_type {
334 struct IsList_t : std::false_type {
337 template <
typename T>
338 struct IsList_t<std::list<T>> : std::true_type {
342 struct IsDeque_t : std::false_type {
345 template <
typename T>
346 struct IsDeque_t<std::deque<T>> : std::true_type {
350 struct IsTArrayBranch_t : std::false_type {
353 template <
typename T>
361 using value_type =
typename T::value_type;
364 template <
typename T>
365 struct ValueType<T, false> {
366 using value_type =
T;
369 template <
typename T>
371 using value_type =
T;
std::string TypeID2TypeName(const std::type_info &id)
Returns the name of a type starting from its type_info An empty string is returned in case of failure...
A collection of options to steer the creation of the dataset on file.
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
char TypeName2ROOTTypeName(const std::string &b)
Convert type name (e.g.
R__EXTERN Int_t gErrorIgnoreLevel
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
basic_string_view< char > string_view
Namespace for new ROOT classes and functions.
ColumnNames_t FindUnknownColumns(const ColumnNames_t &requiredCols, TTree *tree, const ColumnNames_t &definedCols, const ColumnNames_t &dataSourceColumns)
void CheckCustomColumn(std::string_view definedCol, TTree *treePtr, const ColumnNames_t &customCols, const ColumnNames_t &dataSourceColumns)
Short_t Min(Short_t a, Short_t b)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
ECAlgo fCompressionAlgorithm
bool IsInternalColumn(std::string_view colName)
Extracts data from a TTree.
TSnapshotOptions()=default
ECompressionAlgorithm
The global settings depend on a global variable named R__ZipMode which can be modified by a global fu...
When using TDataFrame to read data from a ROOT file, users can specify that the type of a branch is T...
const ColumnNames_t SelectColumns(unsigned int nRequiredNames, const ColumnNames_t &names, const ColumnNames_t &defaultNames)
Choose between local column names or default column names, throw in case of errors.
RooArgSet S(const RooAbsArg &v1)
::ROOT::ECompressionAlgorithm ECAlgo
TDataSource defines an API that TDataFrame can use to read arbitrary data formats.
Double_t Mean(Long64_t n, const T *a, const Double_t *w=0)
const char * ToConstCharPtr(const char *s)
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Lightweight storage for a collection of types.
Extracts array data from a TTree.
ROOT type_traits extensions.
static constexpr double s
typedef void((*Func_t)())
void CheckSnapshot(unsigned int nTemplateParams, unsigned int nColumnNames)
std::string ColumnName2ColumnTypeName(const std::string &colName, TTree *tree, TCustomColumnBase *tmpBranch, TDataSource *ds)
Return a string containing the type of the given branch.
Short_t Max(Short_t a, Short_t b)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
A TTree object has a header with a name and a title.
ColumnNames_t GetBranchNames(TTree &t)
Get all the branches names, including the ones of the friend trees.
TSnapshotOptions(std::string_view mode, ECAlgo comprAlgo, int comprLevel, int autoFlush, int splitLevel)