11#include "RConfigure.h"  
   54      if (!
c->GetTypeInfo()) {
 
   55         std::string msg(
"Cannot extract type_info of type ");
 
   58         throw std::runtime_error(msg);
 
   60      return *
c->GetTypeInfo();
 
   61   } 
else if (
name == 
"char" || 
name == 
"Char_t")
 
   63   else if (
name == 
"unsigned char" || 
name == 
"UChar_t")
 
   64      return typeid(
unsigned char);
 
   65   else if (
name == 
"int" || 
name == 
"Int_t")
 
   67   else if (
name == 
"unsigned int" || 
name == 
"UInt_t")
 
   68      return typeid(
unsigned int);
 
   69   else if (
name == 
"short" || 
name == 
"Short_t")
 
   71   else if (
name == 
"unsigned short" || 
name == 
"UShort_t")
 
   72      return typeid(
unsigned short);
 
   73   else if (
name == 
"long" || 
name == 
"Long_t")
 
   75   else if (
name == 
"unsigned long" || 
name == 
"ULong_t")
 
   76      return typeid(
unsigned long);
 
   77   else if (
name == 
"double" || 
name == 
"Double_t")
 
   79   else if (
name == 
"float" || 
name == 
"Float_t")
 
   81   else if (
name == 
"long long" || 
name == 
"long long int" || 
name == 
"Long64_t")
 
   83   else if (
name == 
"unsigned long long" || 
name == 
"unsigned long long int" || 
name == 
"ULong64_t")
 
   85   else if (
name == 
"bool" || 
name == 
"Bool_t")
 
   88      std::string msg(
"Cannot extract type_info of type ");
 
   91      throw std::runtime_error(msg);
 
  103   } 
else if (
id == 
typeid(
char))
 
  105   else if (
id == 
typeid(
unsigned char))
 
  106      return "unsigned char";
 
  107   else if (
id == 
typeid(
int))
 
  109   else if (
id == 
typeid(
unsigned int))
 
  110      return "unsigned int";
 
  111   else if (
id == 
typeid(
short))
 
  113   else if (
id == 
typeid(
unsigned short))
 
  114      return "unsigned short";
 
  115   else if (
id == 
typeid(
long))
 
  117   else if (
id == 
typeid(
unsigned long))
 
  118      return "unsigned long";
 
  119   else if (
id == 
typeid(
double))
 
  121   else if (
id == 
typeid(
float))
 
  127   else if (
id == 
typeid(
bool))
 
  135   return "ROOT::VecOps::RVec<" + valueType + 
">";
 
  141   std::string colType = colTypeCStr == 
nullptr ? 
"" : colTypeCStr;
 
  143      throw std::runtime_error(
"Could not deduce type of leaf " + colName);
 
  152      throw std::runtime_error(
"TTree leaf " + colName +
 
  153                               " has both a leaf count and a static length. This is not supported.");
 
  168   auto *leaf = t.
GetLeaf(colName.c_str());
 
  173      const auto dotPos = colName.find_last_of(
'.');
 
  174      const auto hasDot = dotPos != std::string::npos;
 
  176         const auto branchName = colName.substr(0, dotPos);
 
  177         const auto leafName = colName.substr(dotPos + 1);
 
  178         leaf = t.
GetLeaf(branchName.c_str(), leafName.c_str());
 
  185   auto branch = t.
GetBranch(colName.c_str());
 
  189      static const TClassRef tbranchelement(
"TBranchElement");
 
  190      if (branch->InheritsFrom(tbranchelement)) {
 
  192         if (
auto currentClass = be->GetCurrentClass())
 
  193            return currentClass->
GetName();
 
  197            auto mother = be->GetMother();
 
  198            if (mother && mother->InheritsFrom(tbranchelement) && mother != be) {
 
  200               auto beMomClass = beMom->
GetClass();
 
  201               if (beMomClass && 0 == std::strcmp(
"TClonesArray", beMomClass->GetName()))
 
  202                  return be->GetTypeName();
 
  204            return be->GetClassName();
 
  206      } 
else if (branch->IsA() == 
TBranch::Class() && branch->GetListOfLeaves()->GetEntriesUnsafe() == 1) {
 
  209         leaf = 
static_cast<TLeaf *
>(branch->GetListOfLeaves()->UncheckedAt(0));
 
  215   return std::string();
 
  230   } 
else if (ds && ds->
HasColumn(colName)) {
 
  235         std::vector<std::string> split;
 
  238         auto &valueType = split[1];
 
  244      throw std::runtime_error(
"Column \"" + colName +
 
  245                               "\" is not in a dataset and is not a custom column been defined.");
 
  254   if (
b == 
"Char_t" || 
b == 
"char")
 
  256   if (
b == 
"UChar_t" || 
b == 
"unsigned char")
 
  258   if (
b == 
"Short_t" || 
b == 
"short" || 
b == 
"short int")
 
  260   if (
b == 
"UShort_t" || 
b == 
"unsigned short" || 
b == 
"unsigned short int")
 
  262   if (
b == 
"Int_t" || 
b == 
"int")
 
  264   if (
b == 
"UInt_t" || 
b == 
"unsigned" || 
b == 
"unsigned int")
 
  266   if (
b == 
"Float_t" || 
b == 
"float")
 
  268   if (
b == 
"Double_t" || 
b == 
"double")
 
  270   if (
b == 
"Long64_t" || 
b == 
"long long" || 
b == 
"long long int")
 
  272   if (
b == 
"ULong64_t" || 
b == 
"unsigned long long" || 
b == 
"unsigned long long int")
 
  274   if (
b == 
"Long_t" || 
b == 
"long" || 
b == 
"long int")
 
  276   if (
b == 
"ULong_t" || 
b == 
"unsigned long" || 
b == 
"unsigned long int")
 
  278   if (
b == 
"Bool_t" || 
b == 
"bool")
 
  285   unsigned int nSlots = 1;
 
  298   auto newColNames = columnNames;
 
  299   for (
auto &col : newColNames) {
 
  300      const auto dotPos = col.find(
'.');
 
  301      if (dotPos != std::string::npos && dotPos != col.size() - 1 && dotPos != 0u) {
 
  303         std::replace(col.begin(), col.end(), 
'.', 
'_');
 
  304         if (std::find(columnNames.begin(), columnNames.end(), col) != columnNames.end())
 
  305            throw std::runtime_error(
"Column " + oldName + 
" would be written as " + col +
 
  306                                     " but this column already exists. Please use Alias to select a new name for " +
 
  308         Info(
"Snapshot", 
"Column %s will be saved as %s", oldName.c_str(), col.c_str());
 
  321         "\nRDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of " 
  322         "the crash\n All RDF objects that have not run an event loop yet should be considered in an invalid state.\n";
 
  323      throw std::runtime_error(msg);
 
  333   auto callCalc = [&errorCode, &context](
const std::string &codeSlice) {
 
  336         std::string msg = 
"\nAn error occurred during just-in-time compilation";
 
  337         if (!context.empty())
 
  338            msg += 
" in " + context;
 
  340            ". The lines above might indicate the cause of the crash\nAll RDF objects that have not run their event " 
  341            "loop yet should be considered in an invalid state.\n";
 
  342         throw std::runtime_error(msg);
 
  348   std::size_t substr_start = 0;
 
  349   std::size_t substr_end = 0;
 
  350   while (substr_end != std::string::npos && substr_start != code.size() - 1) {
 
  351      for (std::size_t i = 0u; i < 1000u && substr_end != std::string::npos; ++i) {
 
  352         substr_end = code.find(
'\n', substr_end + 1);
 
  354      const std::string subs = code.substr(substr_start, substr_end - substr_start);
 
  355      substr_start = substr_end;
 
  365   const auto str = colName.data();
 
  366   const auto goodPrefix = colName.size() > 3 &&               
 
  367                           (
'r' == str[0] || 
't' == str[0]) && 
 
  368                           0 == strncmp(
"df", str + 1, 2);     
 
  369   return goodPrefix && 
'_' == colName.back();                 
 
  372unsigned int GetColumnWidth(
const std::vector<std::string>& names, 
const unsigned int minColumnSpace)
 
  374   auto columnWidth = 0u;
 
  375   for (
const auto& 
name : names) {
 
  380   columnWidth = (columnWidth / minColumnSpace + 1) * minColumnSpace;
 
  385                            const std::string &colName)
 
  389   const auto diffTypes = (0 != std::strcmp(colType.name(), requestedType.name()));
 
  390   auto inheritedType = [&]() {
 
  392      return colTClass && colTClass->InheritsFrom(
TClass::GetClass(requestedType));
 
  395   if (diffTypes && !inheritedType()) {
 
  398      std::string errMsg = 
"RDataFrame: type mismatch: column \"" + colName + 
"\" is being used as ";
 
  400         errMsg += requestedType.name();
 
  401         errMsg += 
" (extracted from type info)";
 
  405      errMsg += 
" but the Define or Vary node advertises it as ";
 
  406      if (colTypeName.empty()) {
 
  409         errMsg += 
" (extracted from type info)";
 
  411         errMsg += colTypeName;
 
  413      throw std::runtime_error(errMsg);
 
  419   return std::find(
vec.cbegin(), 
vec.cend(), str) != 
vec.cend();
 
#define R__LOG_DEBUG(DEBUGLEVEL,...)
 
unsigned long long ULong64_t
 
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
 
std::string GetTypeName() const
 
A log configuration for a channel, e.g.
 
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
 
virtual bool HasColumn(std::string_view colName) const =0
Checks if the dataset has a certain column.
 
virtual std::string GetTypeName(std::string_view colName) const =0
Type of a column as a string, e.g.
 
A Branch for the case of an object.
 
virtual TClass * GetClass() const
 
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.
 
const char * GetName() const override
Returns name of object.
 
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.
 
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
 
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.