Logo ROOT   6.14/05
Reference Guide
RDFUtils.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 12/2016
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2016, 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_RDFUTILS
12 #define ROOT_RDFUTILS
13 
14 #include "ROOT/RDataSource.hxx" // ColumnName2ColumnTypeName
15 #include "ROOT/TypeTraits.hxx"
16 #include "ROOT/RVec.hxx"
18 #include "TH1.h"
19 #include "TTreeReaderArray.h"
20 #include "TTreeReaderValue.h"
21 
22 #include <array>
23 #include <deque>
24 #include <functional>
25 #include <memory>
26 #include <string>
27 #include <type_traits> // std::decay
28 #include <vector>
29 
30 class TTree;
31 class TTreeReader;
32 
33 /// \cond HIDDEN_SYMBOLS
34 
35 namespace ROOT {
36 
37 namespace Detail {
38 namespace RDF {
39 using ColumnNames_t = std::vector<std::string>;
40 
41 // fwd decl for ColumnName2ColumnTypeName
42 class RCustomColumnBase;
43 
44 // type used for tag dispatching
45 struct TInferType {
46 };
47 
48 } // end ns Detail
49 } // end ns RDF
50 
51 namespace Internal {
52 namespace RDF {
53 using namespace ROOT::TypeTraits;
54 using namespace ROOT::Detail::RDF;
55 using namespace ROOT::RDF;
56 
57 /// Detect whether a type is an instantiation of vector<T,A>
58 template <typename>
59 struct IsVector_t : public std::false_type {};
60 
61 template <typename T, typename A>
62 struct IsVector_t<std::vector<T, A>> : public std::true_type {};
63 
64 const std::type_info &TypeName2TypeID(const std::string &name);
65 
66 std::string TypeID2TypeName(const std::type_info &id);
67 
68 std::string ColumnName2ColumnTypeName(const std::string &colName, unsigned int namespaceID, TTree *, RDataSource *,
69  bool isCustomColumn, bool extraConversions = true);
70 
71 char TypeName2ROOTTypeName(const std::string &b);
72 
73 unsigned int GetNSlots();
74 
75 /// `type` is TypeList if MustRemove is false, otherwise it is a TypeList with the first type removed
76 template <bool MustRemove, typename TypeList>
77 struct RemoveFirstParameterIf {
78  using type = TypeList;
79 };
80 
81 template <typename TypeList>
82 struct RemoveFirstParameterIf<true, TypeList> {
83  using type = RemoveFirstParameter_t<TypeList>;
84 };
85 
86 template <bool MustRemove, typename TypeList>
87 struct RemoveFirstTwoParametersIf {
88  using type = TypeList;
89 };
90 
91 template <typename TypeList>
92 struct RemoveFirstTwoParametersIf<true, TypeList> {
93  using typeTmp = typename RemoveFirstParameterIf<true, TypeList>::type;
95 };
96 
97 /// Detect whether a type is an instantiation of RVec<T>
98 template <typename>
99 struct IsRVec_t : public std::false_type {};
100 
101 template <typename T>
102 struct IsRVec_t<ROOT::VecOps::RVec<T>> : public std::true_type {};
103 
104 // Check the value_type type of a type with a SFINAE to allow compilation in presence
105 // fundamental types
107 struct ValueType {
108  using value_type = typename T::value_type;
109 };
110 
111 template <typename T>
112 struct ValueType<T, false> {
113  using value_type = T;
114 };
115 
116 template <typename T>
117 struct ValueType<ROOT::VecOps::RVec<T>, false> {
118  using value_type = T;
119 };
120 
121 std::vector<std::string> ReplaceDotWithUnderscore(const std::vector<std::string> &columnNames);
122 
123 } // end NS RDF
124 } // end NS Internal
125 } // end NS ROOT
126 
127 /// \endcond
128 
129 #endif // RDFUTILS
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
Definition: TTreeReader.h:43
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
double T(double x)
Definition: ChebyshevPol.h:34
unsigned int GetNSlots()
Definition: RDFUtils.cxx:244
STL namespace.
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...
Definition: RDFUtils.cxx:82
std::vector< std::string > ReplaceDotWithUnderscore(const std::vector< std::string > &columnNames)
Replace occurrences of &#39;.
Definition: RDFUtils.cxx:257
char TypeName2ROOTTypeName(const std::string &b)
Convert type name (e.g.
Definition: RDFUtils.cxx:217
Lightweight storage for a collection of types.
Definition: TypeTraits.hxx:27
std::string ColumnName2ColumnTypeName(const std::string &colName, unsigned int namespaceID, TTree *tree, RDataSource *ds, bool isCustomColumn, bool vector2tvec)
Return a string containing the type of the given branch.
Definition: RDFUtils.cxx:184
int type
Definition: TGX11.cxx:120
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
Definition: RDFUtils.cxx:40
ROOT type_traits extensions.
Definition: TypeTraits.hxx:23
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
Definition: TRolke.cxx:630
A TTree object has a header with a name and a title.
Definition: TTree.h:70
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
Definition: RDataSource.hxx:91
char name[80]
Definition: TGX11.cxx:109