17std::vector<void *> RRootDS::GetColumnReadersImpl(
std::string_view name,
const std::type_info &
id)
19 const auto colTypeName = GetTypeName(
name);
21 if (
id != colTypeId) {
22 std::string err =
"The type of column \"";
26 err +=
" but a different one has been selected.";
27 throw std::runtime_error(err);
31 std::distance(fListOfBranches.begin(), std::find(fListOfBranches.begin(), fListOfBranches.end(),
name));
32 std::vector<void *> ret(fNSlots);
34 ret[slot] = (
void *)&fBranchAddresses[index][slot];
40 : fTreeName(treeName), fFileNameGlob(fileNameGlob), fModelChain(std::string(treeName).c_str())
42 fModelChain.Add(fFileNameGlob.c_str());
44 const TObjArray &lob = *fModelChain.GetListOfBranches();
48 std::transform(iter.Begin(), iter.End(), fListOfBranches.begin(), [](
TObject *o) { return o->GetName(); });
53 for (
auto addr : fAddressesToFree) {
60 if (!HasColumn(colName)) {
61 std::string
e =
"The dataset does not have column ";
63 throw std::runtime_error(
e);
74const std::vector<std::string> &RRootDS::GetColumnNames()
const
76 return fListOfBranches;
81 if (!fListOfBranches.empty())
83 return fListOfBranches.end() != std::find(fListOfBranches.begin(), fListOfBranches.end(), colName);
86void RRootDS::InitSlot(
unsigned int slot,
ULong64_t firstEntry)
88 auto chain =
new TChain(fTreeName.c_str());
90 chain->Add(fFileNameGlob.c_str());
91 chain->GetEntry(firstEntry);
93 for (
auto i :
ROOT::TSeqU(fListOfBranches.size())) {
94 auto colName = fListOfBranches[i].c_str();
95 auto &addr = fBranchAddresses[i][slot];
96 auto typeName = GetTypeName(colName);
99 chain->SetBranchAddress(colName, &addr,
nullptr, typeClass,
EDataType(0),
true);
103 fAddressesToFree.emplace_back((
double *)addr);
105 chain->SetBranchAddress(colName, addr);
108 fChains[slot].reset(chain);
111void RRootDS::FinaliseSlot(
unsigned int slot)
113 fChains[slot].reset(
nullptr);
116std::vector<std::pair<ULong64_t, ULong64_t>> RRootDS::GetEntryRanges()
118 auto entryRanges(std::move(fEntryRanges));
122bool RRootDS::SetEntry(
unsigned int slot,
ULong64_t entry)
124 fChains[slot]->GetEntry(entry);
128void RRootDS::SetNSlots(
unsigned int nSlots)
130 R__ASSERT(0U == fNSlots &&
"Setting the number of slots even if the number of slots is different from zero.");
134 const auto nColumns = fListOfBranches.size();
136 fBranchAddresses.resize(nColumns, std::vector<void *>(fNSlots,
nullptr));
138 fChains.resize(fNSlots);
141void RRootDS::Initialise()
143 const auto nentries = fModelChain.GetEntries();
144 const auto chunkSize =
nentries / fNSlots;
145 const auto reminder = 1U == fNSlots ? 0 :
nentries % fNSlots;
151 fEntryRanges.emplace_back(start, end);
154 fEntryRanges.back().second += reminder;
157std::string RRootDS::GetLabel()
unsigned long long ULong64_t
typedef void((*Func_t)())
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A pseudo container class which is a generator of indices.
A chain is a collection of files containing TTree objects.
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.
Int_t GetEntries() const
Return the number of objects in array (i.e.
Mother of all ROOT objects.
basic_string_view< char > string_view
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
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.
class R__DEPRECATED(6, 24, "RRootDS will be removed from the public namespace. Please use standard RDataFrame constructors " "and interfaces instead") RRootDS final RDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...