11#include "RConfigure.h"
46using TypeInfoRef = std::reference_wrapper<const std::type_info>;
47struct TypeInfoRefHash {
51struct TypeInfoRefEqualComp {
68 {
"char",
typeid(char)},
69 {
"Char_t",
typeid(char)},
70 {
"unsigned char",
typeid(
unsigned char)},
71 {
"UChar_t",
typeid(
unsigned char)},
73 {
"Int_t",
typeid(
int)},
74 {
"unsigned",
typeid(
unsigned int)},
75 {
"unsigned int",
typeid(
unsigned int)},
76 {
"UInt_t",
typeid(
unsigned int)},
77 {
"short",
typeid(short)},
78 {
"short int",
typeid(short)},
79 {
"Short_t",
typeid(short)},
80 {
"unsigned short",
typeid(
unsigned short)},
81 {
"unsigned short int",
typeid(
unsigned short)},
82 {
"UShort_t",
typeid(
unsigned short)},
83 {
"long",
typeid(long)},
84 {
"long int",
typeid(long)},
85 {
"Long_t",
typeid(long)},
86 {
"unsigned long",
typeid(
unsigned long)},
87 {
"unsigned long int",
typeid(
unsigned long)},
88 {
"ULong_t",
typeid(
unsigned long)},
89 {
"double",
typeid(
double)},
90 {
"Double_t",
typeid(
double)},
91 {
"float",
typeid(float)},
92 {
"Float_t",
typeid(float)},
93 {
"long long",
typeid(
long long)},
94 {
"long long int",
typeid(
long long)},
95 {
"Long64_t",
typeid(
long long)},
96 {
"unsigned long long",
typeid(
unsigned long long)},
97 {
"unsigned long long int",
typeid(
unsigned long long)},
98 {
"ULong64_t",
typeid(
unsigned long long)},
99 {
"bool",
typeid(
bool)},
100 {
"Bool_t",
typeid(
bool)}};
103 return it->second.get();
106 if (!
c->GetTypeInfo()) {
107 throw std::runtime_error(
"Cannot extract type_info of type " +
name +
".");
109 return *
c->GetTypeInfo();
112 throw std::runtime_error(
"Cannot extract type_info of type " +
name +
".");
123 const static std::unordered_map<TypeInfoRef, std::string, TypeInfoRefHash, TypeInfoRefEqualComp>
typeID2TypeNameMap{
124 {
typeid(char),
"char"}, {
typeid(
unsigned char),
"unsigned char"},
125 {
typeid(
int),
"int"}, {
typeid(
unsigned int),
"unsigned int"},
126 {
typeid(short),
"short"}, {
typeid(
unsigned short),
"unsigned short"},
127 {
typeid(long),
"long"}, {
typeid(
unsigned long),
"unsigned long"},
128 {
typeid(
double),
"double"}, {
typeid(float),
"float"},
130 {
typeid(
bool),
"bool"}};
144 return "ROOT::VecOps::RVec<" +
valueType +
">";
152 throw std::runtime_error(
"Could not deduce type of leaf " +
colName);
153 if (
leaf->GetLeafCount() !=
nullptr &&
leaf->GetLenStatic() == 1) {
156 }
else if (
leaf->GetLeafCount() ==
nullptr &&
leaf->GetLenStatic() > 1) {
159 }
else if (
leaf->GetLeafCount() !=
nullptr &&
leaf->GetLenStatic() > 1) {
161 throw std::runtime_error(
"TTree leaf " +
colName +
162 " has both a leaf count and a static length. This is not supported.");
211 return be->GetTypeName();
213 return be->GetClassName();
218 leaf =
static_cast<TLeaf *
>(
branch->GetListOfLeaves()->UncheckedAt(0));
224 return std::string();
244 std::vector<std::string> split;
253 throw std::runtime_error(
"Column \"" +
colName +
254 "\" is not in a dataset and is not a custom column been defined.");
265 {
"unsigned char",
'b'},
270 {
"unsigned int",
'i'},
275 {
"unsigned short",
's'},
276 {
"unsigned short int",
's'},
281 {
"unsigned long",
'g'},
282 {
"unsigned long int",
'g'},
289 {
"long long int",
'L'},
291 {
"unsigned long long",
'l'},
292 {
"unsigned long long int",
'l'},
320 const auto dotPos = col.find(
'.');
323 std::replace(col.begin(), col.end(),
'.',
'_');
325 throw std::runtime_error(
"Column " +
oldName +
" would be written as " + col +
326 " but this column already exists. Please use Alias to select a new name for " +
328 Info(
"Snapshot",
"Column %s will be saved as %s",
oldName.c_str(), col.c_str());
341 "\nRDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of "
342 "the crash\n All RDF objects that have not run an event loop yet should be considered in an invalid state.\n";
343 throw std::runtime_error(
msg);
359 std::string
msg =
"\nAn error occurred during just-in-time compilation";
360 if (!context.empty())
361 msg +=
" in " + context;
363 ". The lines above might indicate the cause of the crash\nAll RDF objects that have not run their event "
364 "loop yet should be considered in an invalid state.\n";
365 throw std::runtime_error(
msg);
374 for (std::size_t i = 0
u; i < 1000u &&
substr_end != std::string::npos; ++i) {
386 const auto str =
colName.data();
388 (
'r' == str[0] ||
't' == str[0]) &&
389 0 ==
strncmp(
"df", str + 1, 2);
396 for (
const auto&
name : names) {
423 std::string
errMsg =
"RDataFrame: type mismatch: column \"" +
colName +
"\" is being used as ";
426 errMsg +=
" (extracted from type info)";
430 errMsg +=
" but the Define or Vary node advertises it as ";
434 errMsg +=
" (extracted from type info)";
438 throw std::runtime_error(
errMsg);
444 return std::find(
vec.cbegin(),
vec.cend(), str) !=
vec.cend();
450 std::shared_lock
l{fMutex};
451 if (
auto it = fStrings.find(
string); it != fStrings.end())
457 std::unique_lock
l{fMutex};
458 if (
auto it = fStrings.find(
string); it != fStrings.end())
461 return fStrings.insert(
string).first;
491 return ds.DescribeDataset();
496 const std::unordered_map<std::string, ROOT::RDF::Experimental::RSample *> &
sampleMap)
511std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>
#define R__LOG_DEBUG(DEBUGLEVEL,...)
unsigned long long ULong64_t
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
TRObject operator()(const T1 &t1) const
std::string GetTypeName() const
The head node of a RDF computation graph.
auto Insert(const std::string &string) -> decltype(fStrings)::const_iterator
Inserts the input string in the cache and returns an iterator to the cached string.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
virtual const std::vector< std::string > & GetColumnNamesNoDuplicates() const
virtual std::string GetTypeNameWithOpts(std::string_view colName, bool) const
virtual const std::vector< std::string > & GetTopLevelFieldNames() const
This type represents a sample identifier, to be used in conjunction with RDataFrame features such as ...
A log configuration for a channel, e.g.
const_iterator begin() const
const_iterator end() const
A Branch for the case of an object.
TClassRef is used to implement a permanent reference to a TClass object.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
A TTree represents a columnar dataset.
virtual TBranch * FindBranch(const char *name)
Return the branch that correspond to the path 'branchname', which can include the name of the tree or...
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual TLeaf * GetLeaf(const char *branchname, const char *leafname)
Return pointer to the 1st Leaf named name in any Branch of this Tree or any branch in the list of fri...
virtual TLeaf * FindLeaf(const char *name)
Find leaf..
ROOT::RLogChannel & RDFLogChannel()
void RunFinalChecks(const ROOT::RDF::RDataSource &ds, bool nodesLeftNotRun)
std::vector< std::string > ReplaceDotWithUnderscore(const std::vector< std::string > &columnNames)
Replace occurrences of '.
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
std::string ComposeRVecTypeName(const std::string &valueType)
void CallInitializeWithOpts(ROOT::RDF::RDataSource &ds, const std::set< std::string > &suppressErrorsForMissingColumns)
std::string GetLeafTypeName(TLeaf *leaf, const std::string &colName)
const std::vector< std::string > & GetTopLevelFieldNames(const ROOT::RDF::RDataSource &ds)
char TypeName2ROOTTypeName(const std::string &b)
Convert type name (e.g.
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...
bool IsStrInVec(const std::string &str, const std::vector< std::string > &vec)
unsigned int GetColumnWidth(const std::vector< std::string > &names, const unsigned int minColumnSpace=8u)
Get optimal column width for printing a table given the names and the desired minimal space between c...
std::string GetBranchOrLeafTypeName(TTree &t, const std::string &colName)
Return the typename of object colName stored in t, if any.
std::string DescribeDataset(ROOT::RDF::RDataSource &ds)
ROOT::RDF::RSampleInfo CreateSampleInfo(const ROOT::RDF::RDataSource &ds, const std::unordered_map< std::string, ROOT::RDF::Experimental::RSample * > &sampleMap)
std::unique_ptr< ROOT::Detail::RDF::RColumnReaderBase > CreateColumnReader(ROOT::RDF::RDataSource &ds, unsigned int slot, std::string_view col, const std::type_info &tid, TTreeReader *treeReader)
std::string ColumnName2ColumnTypeName(const std::string &colName, TTree *, RDataSource *, RDefineBase *, bool vector2RVec=true)
Return a string containing the type of the given branch.
void InterpreterCalc(const std::string &code, const std::string &context="")
Jit code in the interpreter with TInterpreter::Calc, throw in case of errors.
void CheckReaderTypeMatches(const std::type_info &colType, const std::type_info &requestedType, const std::string &colName)
bool IsInternalColumn(std::string_view colName)
Whether custom column with name colName is an "internal" column such as rdfentry_ or rdfslot_.
void ProcessMT(ROOT::RDF::RDataSource &ds, ROOT::Detail::RDF::RLoopManager &lm)
std::string GetTypeNameWithOpts(const ROOT::RDF::RDataSource &ds, std::string_view colName, bool vector2RVec)
void InterpreterDeclare(const std::string &code)
Declare code in the interpreter via the TInterpreter::Declare method, throw in case of errors.
const std::vector< std::string > & GetColumnNamesNoDuplicates(const ROOT::RDF::RDataSource &ds)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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.
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.