11#include "RConfigure.h"
43 return *
c->GetTypeInfo();
44 }
else if (
name ==
"char" ||
name ==
"Char_t")
46 else if (
name ==
"unsigned char" ||
name ==
"UChar_t")
47 return typeid(
unsigned char);
48 else if (
name ==
"int" ||
name ==
"Int_t")
50 else if (
name ==
"unsigned int" ||
name ==
"UInt_t")
51 return typeid(
unsigned int);
52 else if (
name ==
"short" ||
name ==
"Short_t")
54 else if (
name ==
"unsigned short" ||
name ==
"UShort_t")
55 return typeid(
unsigned short);
56 else if (
name ==
"long" ||
name ==
"Long_t")
58 else if (
name ==
"unsigned long" ||
name ==
"ULong_t")
59 return typeid(
unsigned long);
60 else if (
name ==
"double" ||
name ==
"Double_t")
61 return typeid(double);
62 else if (
name ==
"float" ||
name ==
"Float_t")
64 else if (
name ==
"long long" ||
name ==
"long long int" ||
name ==
"Long64_t")
66 else if (
name ==
"unsigned long long" ||
name ==
"unsigned long long int" ||
name ==
"ULong64_t")
68 else if (
name ==
"bool" ||
name ==
"Bool_t")
71 std::string msg(
"Cannot extract type_info of type ");
74 throw std::runtime_error(msg);
86 }
else if (
id ==
typeid(
char))
88 else if (
id ==
typeid(
unsigned char))
89 return "unsigned char";
90 else if (
id ==
typeid(
int))
92 else if (
id ==
typeid(
unsigned int))
93 return "unsigned int";
94 else if (
id ==
typeid(
short))
96 else if (
id ==
typeid(
unsigned short))
97 return "unsigned short";
98 else if (
id ==
typeid(
long))
100 else if (
id ==
typeid(
unsigned long))
101 return "unsigned long";
102 else if (
id ==
typeid(
double))
104 else if (
id ==
typeid(
float))
110 else if (
id ==
typeid(
bool))
118 return "ROOT::VecOps::RVec<" + valueType +
">";
125 throw std::runtime_error(
"Could not deduce type of leaf " + colName);
134 throw std::runtime_error(
"TTree leaf " + colName +
135 " has both a leaf count and a static length. This is not supported.");
150 auto leaf = t.GetLeaf(colName.c_str());
152 const auto dotPos = colName.find_last_of(
'.');
153 const auto hasDot = dotPos != std::string::npos;
155 const auto branchName = colName.substr(0, dotPos);
156 const auto leafName = colName.substr(dotPos + 1);
157 leaf = t.GetLeaf(
branchName.c_str(), leafName.c_str());
164 auto branch = t.GetBranch(colName.c_str());
166 static const TClassRef tbranchelement(
"TBranchElement");
167 if (branch->InheritsFrom(tbranchelement)) {
169 if (
auto currentClass = be->GetCurrentClass())
170 return currentClass->
GetName();
172 return be->GetClassName();
177 return std::string();
187 RDataSource *ds,
bool isCustomColumn,
bool vector2tvec,
unsigned int customColID)
194 if (colType.empty() &&
tree) {
197 std::vector<std::string> split;
200 auto &valueType = split[1];
205 if (colType.empty() && isCustomColumn) {
207 colType =
"__tdf" + std::to_string(namespaceID) +
"::" + colName + std::to_string(customColID) +
"_type";
211 throw std::runtime_error(
"Column \"" + colName +
212 "\" is not in a dataset and is not a custom column been defined.");
221 if (
b ==
"Char_t" ||
b ==
"char")
223 if (
b ==
"UChar_t" ||
b ==
"unsigned char")
225 if (
b ==
"Short_t" ||
b ==
"short" ||
b ==
"short int")
227 if (
b ==
"UShort_t" ||
b ==
"unsigned short" ||
b ==
"unsigned short int")
229 if (
b ==
"Int_t" ||
b ==
"int")
231 if (
b ==
"UInt_t" ||
b ==
"unsigned" ||
b ==
"unsigned int")
233 if (
b ==
"Float_t" ||
b ==
"float")
235 if (
b ==
"Double_t" ||
b ==
"double")
237 if (
b ==
"Long64_t" ||
b ==
"long" ||
b ==
"long int")
239 if (
b ==
"ULong64_t" ||
b ==
"unsigned long" ||
b ==
"unsigned long int")
241 if (
b ==
"Bool_t" ||
b ==
"bool")
248 unsigned int nSlots = 1;
261 auto newColNames = columnNames;
262 for (
auto &col : newColNames) {
263 const auto dotPos = col.find(
'.');
264 if (dotPos != std::string::npos && dotPos != col.size() - 1 && dotPos != 0u) {
266 std::replace(col.begin(), col.end(),
'.',
'_');
267 if (std::find(columnNames.begin(), columnNames.end(), col) != columnNames.end())
268 throw std::runtime_error(
"Column " + oldName +
" would be written as " + col +
269 " but this column already exists. Please use Alias to select a new name for " +
271 Info(
"Snapshot",
"Column %s will be saved as %s", oldName.c_str(), col.c_str());
static RooMathCoreReg dummy
unsigned long long ULong64_t
void Info(const char *location, const char *msgfmt,...)
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.
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 Int_t GetLenStatic() const
Return the fixed length of this leaf.
virtual const char * GetName() const
Returns name of object.
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)
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.
std::string ColumnName2ColumnTypeName(const std::string &colName, unsigned int namespaceID, TTree *tree, RDataSource *ds, bool isCustomColumn, bool vector2tvec, unsigned int customColID)
Return a string containing the type of the given branch.
Namespace for new ROOT classes and functions.
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
UInt_t GetImplicitMTPoolSize()
Returns the size of the pool used for implicit multi-threading.
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.