11#include "RConfigure.h"
44using TypeInfoRef = std::reference_wrapper<const std::type_info>;
45struct TypeInfoRefHash {
49struct TypeInfoRefEqualComp {
66 {
"char",
typeid(char)},
67 {
"Char_t",
typeid(char)},
68 {
"unsigned char",
typeid(
unsigned char)},
69 {
"UChar_t",
typeid(
unsigned char)},
71 {
"Int_t",
typeid(
int)},
72 {
"unsigned",
typeid(
unsigned int)},
73 {
"unsigned int",
typeid(
unsigned int)},
74 {
"UInt_t",
typeid(
unsigned int)},
75 {
"short",
typeid(short)},
76 {
"short int",
typeid(short)},
77 {
"Short_t",
typeid(short)},
78 {
"unsigned short",
typeid(
unsigned short)},
79 {
"unsigned short int",
typeid(
unsigned short)},
80 {
"UShort_t",
typeid(
unsigned short)},
81 {
"long",
typeid(long)},
82 {
"long int",
typeid(long)},
83 {
"Long_t",
typeid(long)},
84 {
"unsigned long",
typeid(
unsigned long)},
85 {
"unsigned long int",
typeid(
unsigned long)},
86 {
"ULong_t",
typeid(
unsigned long)},
87 {
"double",
typeid(
double)},
88 {
"Double_t",
typeid(
double)},
89 {
"float",
typeid(float)},
90 {
"Float_t",
typeid(float)},
91 {
"long long",
typeid(
long long)},
92 {
"long long int",
typeid(
long long)},
93 {
"Long64_t",
typeid(
long long)},
94 {
"unsigned long long",
typeid(
unsigned long long)},
95 {
"unsigned long long int",
typeid(
unsigned long long)},
96 {
"ULong64_t",
typeid(
unsigned long long)},
97 {
"bool",
typeid(
bool)},
98 {
"Bool_t",
typeid(
bool)}};
101 return it->second.get();
104 if (!
c->GetTypeInfo()) {
105 throw std::runtime_error(
"Cannot extract type_info of type " +
name +
".");
107 return *
c->GetTypeInfo();
110 throw std::runtime_error(
"Cannot extract type_info of type " +
name +
".");
121 const static std::unordered_map<TypeInfoRef, std::string, TypeInfoRefHash, TypeInfoRefEqualComp>
typeID2TypeNameMap{
122 {
typeid(char),
"char"}, {
typeid(
unsigned char),
"unsigned char"},
123 {
typeid(
int),
"int"}, {
typeid(
unsigned int),
"unsigned int"},
124 {
typeid(short),
"short"}, {
typeid(
unsigned short),
"unsigned short"},
125 {
typeid(long),
"long"}, {
typeid(
unsigned long),
"unsigned long"},
126 {
typeid(
double),
"double"}, {
typeid(float),
"float"},
128 {
typeid(
bool),
"bool"}};
142 return "ROOT::VecOps::RVec<" +
valueType +
">";
150 throw std::runtime_error(
"Could not deduce type of leaf " +
colName);
151 if (
leaf->GetLeafCount() !=
nullptr &&
leaf->GetLenStatic() == 1) {
154 }
else if (
leaf->GetLeafCount() ==
nullptr &&
leaf->GetLenStatic() > 1) {
157 }
else if (
leaf->GetLeafCount() !=
nullptr &&
leaf->GetLenStatic() > 1) {
159 throw std::runtime_error(
"TTree leaf " +
colName +
160 " has both a leaf count and a static length. This is not supported.");
209 return be->GetTypeName();
211 return be->GetClassName();
216 leaf =
static_cast<TLeaf *
>(
branch->GetListOfLeaves()->UncheckedAt(0));
222 return std::string();
242 std::vector<std::string> split;
251 throw std::runtime_error(
"Column \"" +
colName +
252 "\" is not in a dataset and is not a custom column been defined.");
263 {
"unsigned char",
'b'},
268 {
"unsigned int",
'i'},
273 {
"unsigned short",
's'},
274 {
"unsigned short int",
's'},
279 {
"unsigned long",
'g'},
280 {
"unsigned long int",
'g'},
287 {
"long long int",
'L'},
289 {
"unsigned long long",
'l'},
290 {
"unsigned long long int",
'l'},
318 const auto dotPos = col.find(
'.');
321 std::replace(col.begin(), col.end(),
'.',
'_');
323 throw std::runtime_error(
"Column " +
oldName +
" would be written as " + col +
324 " but this column already exists. Please use Alias to select a new name for " +
326 Info(
"Snapshot",
"Column %s will be saved as %s",
oldName.c_str(), col.c_str());
339 "\nRDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of "
340 "the crash\n All RDF objects that have not run an event loop yet should be considered in an invalid state.\n";
341 throw std::runtime_error(
msg);
354 std::string
msg =
"\nAn error occurred during just-in-time compilation";
355 if (!context.empty())
356 msg +=
" in " + context;
358 ". The lines above might indicate the cause of the crash\nAll RDF objects that have not run their event "
359 "loop yet should be considered in an invalid state.\n";
360 throw std::runtime_error(
msg);
369 for (std::size_t i = 0
u; i < 1000u &&
substr_end != std::string::npos; ++i) {
383 const auto str =
colName.data();
385 (
'r' == str[0] ||
't' == str[0]) &&
386 0 ==
strncmp(
"df", str + 1, 2);
393 for (
const auto&
name : names) {
420 std::string
errMsg =
"RDataFrame: type mismatch: column \"" +
colName +
"\" is being used as ";
423 errMsg +=
" (extracted from type info)";
427 errMsg +=
" but the Define or Vary node advertises it as ";
431 errMsg +=
" (extracted from type info)";
435 throw std::runtime_error(
errMsg);
441 return std::find(
vec.cbegin(),
vec.cend(), str) !=
vec.cend();
447 std::shared_lock
l{fMutex};
448 if (
auto it = fStrings.find(
string); it != fStrings.end())
454 std::unique_lock
l{fMutex};
455 if (
auto it = fStrings.find(
string); it != fStrings.end())
458 return fStrings.insert(
string).first;
#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.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
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
A log configuration for a channel, e.g.
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.
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 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::Experimental::RLogChannel & RDFLogChannel()
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)
std::string ColumnName2ColumnTypeName(const std::string &colName, TTree *, RDataSource *, RDefineBase *, bool vector2rvec=true)
Return a string containing the type of the given branch.
std::string GetLeafTypeName(TLeaf *leaf, const std::string &colName)
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.
Long64_t 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 InterpreterDeclare(const std::string &code)
Declare code in the interpreter via the TInterpreter::Declare method, throw in case of errors.
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.