11#include "RConfigure.h"
45 return *
c->GetTypeInfo();
46 }
else if (
name ==
"char" ||
name ==
"Char_t")
48 else if (
name ==
"unsigned char" ||
name ==
"UChar_t")
49 return typeid(
unsigned char);
50 else if (
name ==
"int" ||
name ==
"Int_t")
52 else if (
name ==
"unsigned int" ||
name ==
"UInt_t")
53 return typeid(
unsigned int);
54 else if (
name ==
"short" ||
name ==
"Short_t")
56 else if (
name ==
"unsigned short" ||
name ==
"UShort_t")
57 return typeid(
unsigned short);
58 else if (
name ==
"long" ||
name ==
"Long_t")
60 else if (
name ==
"unsigned long" ||
name ==
"ULong_t")
61 return typeid(
unsigned long);
62 else if (
name ==
"double" ||
name ==
"Double_t")
64 else if (
name ==
"float" ||
name ==
"Float_t")
66 else if (
name ==
"long long" ||
name ==
"long long int" ||
name ==
"Long64_t")
68 else if (
name ==
"unsigned long long" ||
name ==
"unsigned long long int" ||
name ==
"ULong64_t")
70 else if (
name ==
"bool" ||
name ==
"Bool_t")
73 std::string msg(
"Cannot extract type_info of type ");
76 throw std::runtime_error(msg);
88 }
else if (
id ==
typeid(
char))
90 else if (
id ==
typeid(
unsigned char))
91 return "unsigned char";
92 else if (
id ==
typeid(
int))
94 else if (
id ==
typeid(
unsigned int))
95 return "unsigned int";
96 else if (
id ==
typeid(
short))
98 else if (
id ==
typeid(
unsigned short))
99 return "unsigned short";
100 else if (
id ==
typeid(
long))
102 else if (
id ==
typeid(
unsigned long))
103 return "unsigned long";
104 else if (
id ==
typeid(
double))
106 else if (
id ==
typeid(
float))
112 else if (
id ==
typeid(
bool))
120 return "ROOT::VecOps::RVec<" + valueType +
">";
127 throw std::runtime_error(
"Could not deduce type of leaf " + colName);
136 throw std::runtime_error(
"TTree leaf " + colName +
137 " has both a leaf count and a static length. This is not supported.");
152 auto leaf = t.
GetLeaf(colName.c_str());
154 const auto dotPos = colName.find_last_of(
'.');
155 const auto hasDot = dotPos != std::string::npos;
157 const auto branchName = colName.substr(0, dotPos);
158 const auto leafName = colName.substr(dotPos + 1);
159 leaf = t.
GetLeaf(branchName.c_str(), leafName.c_str());
166 auto branch = t.
GetBranch(colName.c_str());
169 if (leaves->GetEntries() == 1 && branch->GetListOfBranches()->GetEntries() == 0 &&
179 auto branch = t.
GetBranch(colName.c_str());
181 static const TClassRef tbranchelement(
"TBranchElement");
182 if (branch->InheritsFrom(tbranchelement)) {
184 if (
auto currentClass = be->GetCurrentClass())
185 return currentClass->
GetName();
189 auto mother = be->GetMother();
190 if (mother && mother->InheritsFrom(tbranchelement) && mother != be) {
192 auto beMomClass = beMom->
GetClass();
193 if (beMomClass && 0 == std::strcmp(
"TClonesArray", beMomClass->GetName()))
194 return be->GetTypeName();
196 return be->GetClassName();
202 return std::string();
219 if (colType.empty() &&
tree) {
222 std::vector<std::string> split;
225 auto &valueType = split[1];
230 if (colType.empty() && customColumn) {
235 throw std::runtime_error(
"Column \"" + colName +
236 "\" is not in a dataset and is not a custom column been defined.");
245 if (
b ==
"Char_t" ||
b ==
"char")
247 if (
b ==
"UChar_t" ||
b ==
"unsigned char")
249 if (
b ==
"Short_t" ||
b ==
"short" ||
b ==
"short int")
251 if (
b ==
"UShort_t" ||
b ==
"unsigned short" ||
b ==
"unsigned short int")
253 if (
b ==
"Int_t" ||
b ==
"int")
255 if (
b ==
"UInt_t" ||
b ==
"unsigned" ||
b ==
"unsigned int")
257 if (
b ==
"Float_t" ||
b ==
"float")
259 if (
b ==
"Double_t" ||
b ==
"double")
261 if (
b ==
"Long64_t" ||
b ==
"long" ||
b ==
"long int")
263 if (
b ==
"ULong64_t" ||
b ==
"unsigned long" ||
b ==
"unsigned long int")
265 if (
b ==
"Bool_t" ||
b ==
"bool")
272 unsigned int nSlots = 1;
285 auto newColNames = columnNames;
286 for (
auto &col : newColNames) {
287 const auto dotPos = col.find(
'.');
288 if (dotPos != std::string::npos && dotPos != col.size() - 1 && dotPos != 0u) {
290 std::replace(col.begin(), col.end(),
'.',
'_');
291 if (std::find(columnNames.begin(), columnNames.end(), col) != columnNames.end())
292 throw std::runtime_error(
"Column " + oldName +
" would be written as " + col +
293 " but this column already exists. Please use Alias to select a new name for " +
295 Info(
"Snapshot",
"Column %s will be saved as %s", oldName.c_str(), col.c_str());
306 "\nRDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of "
307 "the crash\n All RDF objects that have not run an event loop yet should be considered in an invalid state.\n";
308 throw std::runtime_error(msg);
315 auto res =
gInterpreter->Calc(code.c_str(), &errorCode);
316 if (errorCode != TInterpreter::EErrorCode::kNoError) {
317 std::string msg =
"\nAn error occurred during just-in-time compilation";
318 if (!context.empty())
319 msg +=
" in " + context;
320 msg +=
". The lines above might indicate the cause of the crash\nAll RDF objects that have not run their event "
321 "loop yet should be considered in an invalid state.\n";
322 throw std::runtime_error(msg);
static RooMathCoreReg dummy
unsigned long long ULong64_t
void Info(const char *location, const char *msgfmt,...)
std::string GetTypeName() const
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
virtual bool HasColumn(std::string_view) const =0
Checks if the dataset has a certain column.
virtual std::string GetTypeName(std::string_view) const =0
Type of a column as a string, e.g.
A Branch for the case of an object.
virtual TClass * GetClass() const
TObjArray * GetListOfLeaves()
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.
virtual const char * GetTypeName() const
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
virtual TString GetFullName() const
Return the full name (including the parent's branch names) of the leaf.
virtual Int_t GetLenStatic() const
Return the fixed length of this leaf.
virtual const char * GetName() const
Returns name of object.
A TTree represents a columnar dataset.
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...
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 GetLeafTypeName(TLeaf *leaf, const std::string &colName)
std::string ColumnName2ColumnTypeName(const std::string &colName, TTree *tree, RDataSource *ds, RCustomColumnBase *customColumn, bool vector2rvec)
Return a string containing the type of the given branch.
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...
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)
void InterpreterDeclare(const std::string &code)
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.