15 #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();
185 RDataSource *ds,
bool isCustomColumn,
bool vector2tvec)
192 if (colType.empty() &&
tree) {
195 std::vector<std::string> split;
198 auto &valueType = split[1];
203 if (colType.empty() && isCustomColumn) {
205 colType =
"__tdf" + std::to_string(namespaceID) +
"::" + colName +
"_type";
209 throw std::runtime_error(
"Column \"" + colName +
210 "\" is not in a dataset and is not a custom column been defined.");
219 if (b ==
"Char_t" || b ==
"char")
221 if (b ==
"UChar_t" || b ==
"unsigned char")
223 if (b ==
"Short_t" || b ==
"short" || b ==
"short int")
225 if (b ==
"UShort_t" || b ==
"unsigned short" || b ==
"unsigned short int")
227 if (b ==
"Int_t" || b ==
"int")
229 if (b ==
"UInt_t" || b ==
"unsigned" || b ==
"unsigned int")
231 if (b ==
"Float_t" || b ==
"float")
233 if (b ==
"Double_t" || b ==
"double")
235 if (b ==
"Long64_t" || b ==
"long" || b ==
"long int")
237 if (b ==
"ULong64_t" || b ==
"unsigned long" || b ==
"unsigned long int")
239 if (b ==
"Bool_t" || b ==
"bool")
246 unsigned int nSlots = 1;
259 auto newColNames = columnNames;
260 for (
auto &col : newColNames) {
261 const auto dotPos = col.find(
'.');
262 if (dotPos != std::string::npos && dotPos != col.size() - 1 && dotPos != 0u) {
264 std::replace(col.begin(), col.end(),
'.',
'_');
265 if (std::find(columnNames.begin(), columnNames.end(), col) != columnNames.end())
266 throw std::runtime_error(
"Column " + oldName +
" would be written as " + col +
267 " but this column already exists. Please use Alias to select a new name for " +
269 Info(
"Snapshot",
"Column %s will be saved as %s", oldName.c_str(), col.c_str());
virtual const char * GetName() const
Returns name of object.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
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...
virtual bool HasColumn(std::string_view) const =0
Checks if the dataset has a certain column.
Namespace for new ROOT classes and functions.
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.
virtual const char * GetTypeName() const
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 GetLeafTypeName(TLeaf *leaf, const std::string &colName)
virtual std::string GetTypeName(std::string_view) const =0
Type of a column as a string, e.g.
void Info(const char *location, const char *msgfmt,...)
std::vector< std::string > ReplaceDotWithUnderscore(const std::vector< std::string > &columnNames)
Replace occurrences of '.
char TypeName2ROOTTypeName(const std::string &b)
Convert type name (e.g.
std::string ComposeRVecTypeName(const std::string &valueType)
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.
A Branch for the case of an object.
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.
unsigned long long ULong64_t
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
static RooMathCoreReg dummy
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.
TClassRef is used to implement a permanent reference to a TClass object.
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
std::string GetBranchOrLeafTypeName(TTree &t, const std::string &colName)
Return the typename of object colName stored in t, if any.
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
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.