53#include <unordered_map>
67std::string &GetCodeToJit()
69 static std::string code;
73bool ContainsLeaf(
const std::set<TLeaf *> &leaves,
TLeaf *leaf)
75 return (leaves.find(leaf) != leaves.end());
81void InsertBranchName(std::set<std::string> &bNamesReg,
ColumnNames_t &bNames,
const std::string &branchName,
82 const std::string &friendName,
bool allowDuplicates)
84 if (!friendName.empty()) {
86 const auto friendBName = friendName +
"." + branchName;
87 if (bNamesReg.insert(friendBName).second)
88 bNames.push_back(friendBName);
91 if (allowDuplicates || friendName.empty()) {
92 if (bNamesReg.insert(branchName).second)
93 bNames.push_back(branchName);
99void InsertBranchName(std::set<std::string> &bNamesReg,
ColumnNames_t &bNames,
const std::string &branchName,
100 const std::string &friendName, std::set<TLeaf *> &foundLeaves,
TLeaf *leaf,
101 bool allowDuplicates)
103 const bool canAdd = allowDuplicates ? true : !ContainsLeaf(foundLeaves, leaf);
108 InsertBranchName(bNamesReg, bNames, branchName, friendName, allowDuplicates);
110 foundLeaves.insert(leaf);
114 std::string prefix, std::string &friendName,
bool allowDuplicates)
116 for (
auto sb : *
b->GetListOfBranches()) {
118 auto subBranchName = std::string(subBranch->
GetName());
119 auto fullName = prefix + subBranchName;
121 std::string newPrefix;
123 newPrefix = fullName +
".";
125 ExploreBranch(t, bNamesReg, bNames, subBranch, newPrefix, friendName, allowDuplicates);
127 auto branchDirectlyFromTree = t.
GetBranch(fullName.c_str());
128 if (!branchDirectlyFromTree)
129 branchDirectlyFromTree = t.
FindBranch(fullName.c_str());
130 if (branchDirectlyFromTree)
131 InsertBranchName(bNamesReg, bNames, std::string(branchDirectlyFromTree->GetFullName()), friendName,
134 if (bNamesReg.find(subBranchName) == bNamesReg.end() && t.
GetBranch(subBranchName.c_str()))
135 InsertBranchName(bNamesReg, bNames, subBranchName, friendName, allowDuplicates);
139void GetBranchNamesImpl(
TTree &t, std::set<std::string> &bNamesReg,
ColumnNames_t &bNames,
140 std::set<TTree *> &analysedTrees, std::string &friendName,
bool allowDuplicates)
142 std::set<TLeaf *> foundLeaves;
143 if (!analysedTrees.insert(&t).second) {
152 std::string err(
"GetBranchNames: error in opening the tree ");
154 throw std::runtime_error(err);
157 for (
auto b : *branches) {
159 const auto branchName = std::string(branch->
GetName());
163 if (listOfLeaves->GetEntriesUnsafe() == 1) {
164 auto leaf =
static_cast<TLeaf *
>(listOfLeaves->UncheckedAt(0));
165 InsertBranchName(bNamesReg, bNames, branchName, friendName, foundLeaves, leaf, allowDuplicates);
168 for (
auto leaf : *listOfLeaves) {
169 auto castLeaf =
static_cast<TLeaf *
>(leaf);
170 const auto leafName = std::string(leaf->
GetName());
171 const auto fullName = branchName +
"." + leafName;
172 InsertBranchName(bNamesReg, bNames, fullName, friendName, foundLeaves, castLeaf, allowDuplicates);
176 ExploreBranch(t, bNamesReg, bNames, branch, branchName +
".", friendName, allowDuplicates);
177 InsertBranchName(bNamesReg, bNames, branchName, friendName, allowDuplicates);
182 bool dotIsImplied =
false;
185 throw std::runtime_error(
"GetBranchNames: unsupported branch type");
187 if (be->GetType() == 3 || be->GetType() == 4)
190 if (dotIsImplied || branchName.back() ==
'.')
191 ExploreBranch(t, bNamesReg, bNames, branch,
"", friendName, allowDuplicates);
193 ExploreBranch(t, bNamesReg, bNames, branch, branchName +
".", friendName, allowDuplicates);
195 InsertBranchName(bNamesReg, bNames, branchName, friendName, allowDuplicates);
208 for (
auto friendTreeObj : *friendTrees) {
213 if (alias !=
nullptr)
214 frName = std::string(alias);
216 frName = std::string(friendTree->GetName());
218 GetBranchNamesImpl(*friendTree, bNamesReg, bNames, analysedTrees, frName, allowDuplicates);
222void ThrowIfNSlotsChanged(
unsigned int nSlots)
225 if (currentSlots != nSlots) {
226 std::string msg =
"RLoopManager::Run: when the RDataFrame was constructed the number of slots required was " +
227 std::to_string(nSlots) +
", but when starting the event loop it was " +
228 std::to_string(currentSlots) +
".";
229 if (currentSlots > nSlots)
230 msg +=
" Maybe EnableImplicitMT() was called after the RDataFrame was constructed?";
232 msg +=
" Maybe DisableImplicitMT() was called after the RDataFrame was constructed?";
233 throw std::runtime_error(msg);
245struct MaxTreeSizeRAII {
248 MaxTreeSizeRAII() : fOldMaxTreeSize(
TTree::GetMaxTreeSize())
256struct DatasetLogInfo {
257 std::string fDataSet;
263std::string LogRangeProcessing(
const DatasetLogInfo &info)
265 std::stringstream msg;
266 msg <<
"Processing " << info.fDataSet <<
": entry range [" << info.fRangeStart <<
"," << info.fRangeEnd - 1
267 <<
"], using slot " << info.fSlot <<
" in thread " << std::this_thread::get_id() <<
'.';
271DatasetLogInfo TreeDatasetLogInfo(
const TTreeReader &
r,
unsigned int slot)
273 const auto tree =
r.GetTree();
274 const auto chain =
dynamic_cast<TChain *
>(
tree);
278 std::vector<std::string> treeNames;
279 std::vector<std::string> fileNames;
281 treeNames.emplace_back(
f->GetName());
282 fileNames.emplace_back(
f->GetTitle());
285 for (
const auto &t : treeNames) {
289 what +=
" in files {";
290 for (
const auto &
f : fileNames) {
295 assert(tree !=
nullptr);
296 const auto treeName =
tree->GetName();
297 what = std::string(
"tree \"") + treeName +
"\"";
298 const auto file =
tree->GetCurrentFile();
300 what += std::string(
" in file \"") + file->GetName() +
"\"";
302 const auto entryRange =
r.GetEntriesRange();
303 const ULong64_t end = entryRange.second == -1ll ?
tree->GetEntries() : entryRange.second;
304 return {std::move(
what),
static_cast<ULong64_t>(entryRange.first), end, slot};
307auto MakeDatasetColReadersKey(
const std::string &colName,
const std::type_info &ti)
313 return colName +
':' + ti.name();
342 std::set<std::string> bNamesSet;
344 std::set<TTree *> analysedTrees;
345 std::string emptyFrName =
"";
346 GetBranchNamesImpl(t, bNamesSet, bNames, analysedTrees, emptyFrName, allowDuplicates);
351 : fTree(std::shared_ptr<
TTree>(tree, [](
TTree *) {})), fDefaultColumns(defaultBranches),
354 fNewSampleNotifier(fNSlots), fSampleInfos(fNSlots), fDatasetColumnReaders(fNSlots)
359 : fTree(std::move(tree)),
360 fDefaultColumns(defaultBranches),
363 fNewSampleNotifier(fNSlots),
364 fSampleInfos(fNSlots),
365 fDatasetColumnReaders(fNSlots)
370 : fEmptyEntryRange(0, nEmptyEntries),
373 fNewSampleNotifier(fNSlots),
374 fSampleInfos(fNSlots),
375 fDatasetColumnReaders(fNSlots)
382 fDataSource(std::move(ds)), fNewSampleNotifier(fNSlots), fSampleInfos(fNSlots), fDatasetColumnReaders(fNSlots)
390 fNewSampleNotifier(fNSlots),
391 fSampleInfos(fNSlots),
392 fDatasetColumnReaders(fNSlots)
423 const auto &trees = sample.GetTreeNames();
424 const auto &files = sample.GetFileNameGlobs();
425 for (std::size_t i = 0ul; i < files.size(); ++i) {
428 const auto fullpath = files[i] +
"?#" + trees[i];
429 chain->Add(fullpath.c_str());
433 const auto sampleId = files[i] +
'/' + trees[i];
440 const auto &friendInfo = spec.GetFriendInfo();
442 for (std::size_t i = 0ul; i <
fFriends.size(); i++) {
443 const auto &thisFriendAlias = friendInfo.fFriendNames[i].second;
444 fTree->AddFriend(
fFriends[i].get(), thisFriendAlias.c_str());
456 const auto nEntriesPerSlot = nEmptyEntries / (
fNSlots * 2);
457 auto remainder = nEmptyEntries % (
fNSlots * 2);
458 std::vector<std::pair<ULong64_t, ULong64_t>> entryRanges;
466 entryRanges.emplace_back(begin, end);
471 auto genFunction = [
this, &slotStack](
const std::pair<ULong64_t, ULong64_t> &range) {
473 auto slot = slotRAII.
fSlot;
479 for (
auto currEntry = range.first; currEntry < range.second; ++currEntry) {
484 std::cerr <<
"RDataFrame::Run: event loop was interrupted\n";
490 pool.
Foreach(genFunction, entryRanges);
509 std::cerr <<
"RDataFrame::Run: event loop was interrupted\n";
524 : std::make_unique<ROOT::TTreeProcessorMT>(*
fTree, entryList,
fNSlots);
526 std::atomic<ULong64_t> entryCount(0ull);
528 tp->Process([
this, &slotStack, &entryCount](
TTreeReader &
r) ->
void {
530 auto slot = slotRAII.
fSlot;
534 const auto entryRange =
r.GetEntriesRange();
535 const auto nEntries = entryRange.second - entryRange.first;
536 auto count = entryCount.fetch_add(nEntries);
546 std::cerr <<
"RDataFrame::Run: event loop was interrupted\n";
553 throw std::runtime_error(
"An error was encountered while processing the data. TTreeReader status code is: " +
554 std::to_string(
r.GetEntryStatus()));
571 throw std::logic_error(
"Something went wrong in initializing the TTreeReader.");
587 std::cerr <<
"RDataFrame::Run: event loop was interrupted\n";
592 throw std::runtime_error(
"An error was encountered while processing the data. TTreeReader status code is: " +
593 std::to_string(
r.GetEntryStatus()));
608 for (
const auto &range : ranges) {
609 const auto start = range.first;
610 const auto end = range.second;
619 std::cerr <<
"RDataFrame::Run: event loop was interrupted\n";
637 auto runOnRange = [
this, &slotStack](
const std::pair<ULong64_t, ULong64_t> &range) {
639 const auto slot = slotRAII.
fSlot;
643 const auto start = range.first;
644 const auto end = range.second;
647 for (
auto entry = start; entry < end; ++entry) {
653 std::cerr <<
"RDataFrame::Run: event loop was interrupted\n";
661 while (!ranges.empty()) {
662 pool.
Foreach(runOnRange, ranges);
681 actionPtr->Run(slot, entry);
683 namedFilterPtr->CheckFilters(slot, entry);
695 ptr->InitSlot(
r, slot);
697 ptr->InitSlot(
r, slot);
699 ptr->InitSlot(
r, slot);
701 ptr->InitSlot(
r, slot);
723 "Empty source, range: {" + std::to_string(range.first) +
", " + std::to_string(range.second) +
"}", range);
728 auto *tree =
r.GetTree()->GetTree();
731 auto *file = tree->GetCurrentFile();
732 const std::string fname = file !=
nullptr ? file->GetName() :
"#inmemorytree#";
734 std::pair<Long64_t, Long64_t> range =
r.GetEntriesRange();
736 if (range.second == -1) {
737 range.second = tree->GetEntries();
739 const std::string &
id = fname +
'/' + treename;
774 ptr->ResetChildrenCount();
776 ptr->ResetChildrenCount();
788 ptr->FinalizeSlot(slot);
790 ptr->FinalizeSlot(slot);
792 ptr->FinalizeSlot(slot);
809 const std::string code = std::move(GetCodeToJit());
821 :
" in less than 1ms.");
833 actionPtr->TriggerChildrenCount();
835 namedFilterPtr->TriggerChildrenCount();
844 MaxTreeSizeRAII ctxtmts;
858 class NodesCleanerRAII {
862 NodesCleanerRAII(
RLoopManager &thisRLM) : fRLM(thisRLM) {}
866 NodesCleanerRAII runKeeper(*
this);
967 fPtr->FillReport(rep);
972 fTree = std::move(tree);
982 GetCodeToJit().append(code);
987 if (everyNEvents == 0ull)
995 std::vector<std::string>
filters;
997 auto name = (filter->HasName() ? filter->GetName() :
"Unnamed Filter");
1020 std::unordered_map<
void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap)
1023 auto duplicateRLoopManagerIt = visitedMap.find((
void *)
this);
1024 if (duplicateRLoopManagerIt != visitedMap.end())
1025 return duplicateRLoopManagerIt->second;
1037 auto thisNode = std::make_shared<ROOT::Internal::RDF::GraphDrawing::GraphNode>(
1039 visitedMap[(
void *)
this] = thisNode;
1057 const auto key = MakeDatasetColReadersKey(col, ti);
1065 std::vector<std::unique_ptr<RColumnReaderBase>> &&readers,
1066 const std::type_info &ti)
1068 const auto key = MakeDatasetColReadersKey(col, ti);
1070 assert(readers.size() ==
fNSlots);
1072 for (
auto slot = 0u; slot <
fNSlots; ++slot) {
1081 std::unique_ptr<RColumnReaderBase> &&reader,
1082 const std::type_info &ti)
1085 const auto key = MakeDatasetColReadersKey(col, ti);
1087 assert(readers.find(key) == readers.end() || readers[key] ==
nullptr);
1088 auto *rptr = reader.get();
1089 readers[key] = std::move(reader);
1096 const auto key = MakeDatasetColReadersKey(col, ti);
1099 return it->second.get();
1122 bool fileIsGlob = [&fileNameGlob]() {
1123 const std::vector<std::string_view> wildcards = {
"[",
"]",
"*",
"?"};
1124 return std::any_of(wildcards.begin(), wildcards.end(),
1125 [&fileNameGlob](
const auto &wc) { return fileNameGlob.find(wc) != std::string_view::npos; });
1133 std::unique_ptr<TFile> inFile{
TFile::Open(fileToOpen.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION")};
1134 if (!inFile || inFile->IsZombie())
1135 throw std::invalid_argument(
"RDataFrame: could not open file \"" + fileToOpen +
"\".");
1140std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
1150 std::string datasetNameInt{datasetName};
1151 std::string fileNameGlobInt{fileNameGlob};
1153 chain->Add(fileNameGlobInt.c_str());
1154 auto lm = std::make_shared<ROOT::Detail::RDF::RLoopManager>(std::move(chain), defaultColumns);
1158std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
1160 const std::vector<std::string> &defaultColumns,
bool checkFile)
1168 std::string treeNameInt(datasetName);
1170 for (
auto &
f : fileNameGlobs)
1171 chain->Add(
f.c_str());
1172 auto lm = std::make_shared<ROOT::Detail::RDF::RLoopManager>(std::move(chain), defaultColumns);
1177std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
1178ROOT::Detail::RDF::CreateLMFromRNTuple(std::string_view datasetName, std::string_view fileNameGlob,
1181 auto dataSource = std::make_unique<ROOT::Experimental::RNTupleDS>(datasetName, fileNameGlob);
1182 auto lm = std::make_shared<ROOT::Detail::RDF::RLoopManager>(std::move(dataSource), defaultColumns);
1186std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
1187ROOT::Detail::RDF::CreateLMFromRNTuple(std::string_view datasetName,
const std::vector<std::string> &fileNameGlobs,
1190 auto dataSource = std::make_unique<ROOT::Experimental::RNTupleDS>(datasetName, fileNameGlobs);
1191 auto lm = std::make_shared<ROOT::Detail::RDF::RLoopManager>(std::move(dataSource), defaultColumns);
1195std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
1196ROOT::Detail::RDF::CreateLMFromFile(std::string_view datasetName, std::string_view fileNameGlob,
1202 if (inFile->Get<
TTree>(datasetName.data())) {
1205 return CreateLMFromRNTuple(datasetName, fileNameGlob, defaultColumns);
1208 throw std::invalid_argument(
"RDataFrame: unsupported data format for dataset \"" + std::string(datasetName) +
1209 "\" in file \"" + inFile->GetName() +
"\".");
1212std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
1213ROOT::Detail::RDF::CreateLMFromFile(std::string_view datasetName,
const std::vector<std::string> &fileNameGlobs,
1219 if (inFile->Get<
TTree>(datasetName.data())) {
1222 return CreateLMFromRNTuple(datasetName, fileNameGlobs, defaultColumns);
1225 throw std::invalid_argument(
"RDataFrame: unsupported data format for dataset \"" + std::string(datasetName) +
1226 "\" in file \"" + inFile->GetName() +
"\".");
#define R__LOG_DEBUG(DEBUGLEVEL,...)
std::unique_ptr< TFile > OpenFileWithSanityChecks(std::string_view fileNameGlob)
Helper function to open a file (or the first file from a glob).
unsigned long long ULong64_t
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 r
R__EXTERN TVirtualMutex * gROOTMutex
#define R__LOCKGUARD(mutex)
The head node of a RDF computation graph.
void UpdateSampleInfo(unsigned int slot, const std::pair< ULong64_t, ULong64_t > &range)
RLoopManager(TTree *tree, const ColumnNames_t &defaultBranches)
unsigned int fNRuns
Number of event loops run.
bool CheckFilters(unsigned int, Long64_t) final
void EvalChildrenCounts()
Trigger counting of number of children nodes for each node of the functional graph.
void CleanUpNodes()
Perform clean-up operations. To be called at the end of each event loop.
void RunEmptySource()
Run event loop with no source files, in sequence.
void SetEmptyEntryRange(std::pair< ULong64_t, ULong64_t > &&newRange)
void Report(ROOT::RDF::RCutFlowReport &rep) const final
Call FillReport on all booked filters.
void AddSampleCallback(void *nodePtr, ROOT::RDF::SampleCallback_t &&callback)
std::vector< RFilterBase * > fBookedNamedFilters
Contains a subset of fBookedFilters, i.e. only the named filters.
void RunEmptySourceMT()
Run event loop with no source files, in parallel.
ULong64_t GetNEmptyEntries() const
std::unordered_map< std::string, ROOT::RDF::Experimental::RSample * > fSampleMap
Keys are fname + "/" + treename as RSampleInfo::fID; Values are pointers to the corresponding sample.
std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > > &visitedMap) final
const ColumnNames_t & GetBranchNames()
Return all valid TTree::Branch names (caching results for subsequent calls).
void ToJitExec(const std::string &) const
std::vector< RDFInternal::RActionBase * > GetAllActions() const
Return all actions, either booked or already run.
std::vector< ROOT::RDF::RSampleInfo > fSampleInfos
bool fMustRunNamedFilters
void ChangeSpec(ROOT::RDF::Experimental::RDatasetSpec &&spec)
Changes the internal TTree held by the RLoopManager.
void SetTree(std::shared_ptr< TTree > tree)
std::shared_ptr< TTree > fTree
Shared pointer to the input TTree.
std::vector< RDefineBase * > fBookedDefines
void RunTreeReader()
Run event loop over one or multiple ROOT files, in sequence.
ROOT::Internal::TreeUtils::RNoCleanupNotifier fNoCleanupNotifier
std::vector< RDFInternal::RActionBase * > fRunActions
Non-owning pointers to actions already run.
RColumnReaderBase * GetDatasetColumnReader(unsigned int slot, const std::string &col, const std::type_info &ti) const
std::vector< RRangeBase * > fBookedRanges
std::vector< ROOT::RDF::Experimental::RSample > fSamples
Samples need to survive throughout the whole event loop, hence stored as an attribute.
std::vector< std::string > ColumnNames_t
void RunAndCheckFilters(unsigned int slot, Long64_t entry)
Execute actions and make sure named filters are called for each event.
std::vector< RFilterBase * > fBookedFilters
void Run(bool jit=true)
Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source.
std::unordered_map< void *, ROOT::RDF::SampleCallback_t > fSampleCallbacks
Registered callbacks to call at the beginning of each "data block".
std::vector< RDFInternal::RActionBase * > fBookedActions
Non-owning pointers to actions to be run.
RColumnReaderBase * AddTreeColumnReader(unsigned int slot, const std::string &col, std::unique_ptr< RColumnReaderBase > &&reader, const std::type_info &ti)
Register a new RTreeColumnReader with this RLoopManager.
const ELoopType fLoopType
The kind of event loop that is going to be run (e.g. on ROOT files, on no files)
void AddDataSourceColumnReaders(const std::string &col, std::vector< std::unique_ptr< RColumnReaderBase > > &&readers, const std::type_info &ti)
void SetupSampleCallbacks(TTreeReader *r, unsigned int slot)
ColumnNames_t fValidBranchNames
Cache of the tree/chain branch names. Never access directy, always use GetBranchNames().
void CleanUpTask(TTreeReader *r, unsigned int slot)
Perform clean-up operations. To be called at the end of each task execution.
std::vector< RDFInternal::RCallback > fCallbacksEveryNEvents
Registered callbacks to be executed every N events.
std::vector< std::unordered_map< std::string, std::unique_ptr< RColumnReaderBase > > > fDatasetColumnReaders
Readers for TTree/RDataSource columns (one per slot), shared by all nodes in the computation graph.
const unsigned int fNSlots
void Register(RDFInternal::RActionBase *actionPtr)
const ColumnNames_t & GetDefaultColumnNames() const
Return the list of default columns – empty if none was provided when constructing the RDataFrame.
std::vector< RDFInternal::RVariationBase * > fBookedVariations
std::vector< RNodeBase * > GetGraphEdges() const
Return all graph edges known to RLoopManager This includes Filters and Ranges but not Defines.
unsigned int GetNSlots() const
void RunDataSourceMT()
Run event loop over data accessed through a DataSource, in parallel.
std::vector< std::string > GetFiltersNames()
For each booked filter, returns either the name or "Unnamed Filter".
const std::unique_ptr< RDataSource > fDataSource
Owning pointer to a data-source object.
RDFInternal::RNewSampleNotifier fNewSampleNotifier
std::pair< ULong64_t, ULong64_t > fEmptyEntryRange
Range of entries created when no data source is specified.
const ColumnNames_t fDefaultColumns
void InitNodeSlots(TTreeReader *r, unsigned int slot)
Build TTreeReaderValues for all nodes This method loops over all filters, actions and other booked ob...
std::vector< RDFInternal::ROneTimeCallback > fCallbacksOnce
Registered callbacks to invoke just once before running the loop.
void RegisterCallback(ULong64_t everyNEvents, std::function< void(unsigned int)> &&f)
void RunDataSource()
Run event loop over data accessed through a DataSource, in sequence.
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
void RunTreeProcessorMT()
Run event loop over one or multiple ROOT files, in parallel.
void Deregister(RDFInternal::RActionBase *actionPtr)
void InitNodes()
Initialize all nodes of the functional graph before running the event loop.
std::vector< std::unique_ptr< TChain > > fFriends
Friends of the fTree. Only used if we constructed fTree ourselves.
bool HasDataSourceColumnReaders(const std::string &col, const std::type_info &ti) const
Return true if AddDataSourceColumnReaders was called for column name col.
unsigned int fNStopsReceived
Number of times that a children node signaled to stop processing entries.
unsigned int fNChildren
Number of nodes of the functional graph hanging from this object.
Representation of an RNTuple data set in a ROOT file.
virtual ROOT::RDF::SampleCallback_t GetSampleCallback()=0
void SetFlag(unsigned int slot)
bool CheckFlag(unsigned int slot) const
void UnsetFlag(unsigned int slot)
TNotifyLink< RNewSampleFlag > & GetChainNotifyLink(unsigned int slot)
This type includes all parts of RVariation that do not depend on the callable signature.
A thread-safe stack of N indexes (0 to size - 1).
void RegisterChain(TChain &c)
The dataset specification for RDataFrame.
This type represents a sample identifier, to be used in conjunction with RDataFrame features such as ...
This class provides a simple interface to execute the same task multiple times in parallel threads,...
void Foreach(F func, unsigned nTimes, unsigned nChunks=0)
Execute a function without arguments several times in parallel, dividing the execution in nChunks.
A Branch for the case of an object.
A TTree is a list of TBranches.
TClass * IsA() const override
TObjArray * GetListOfLeaves()
A chain is a collection of files containing TTree objects.
TObjArray * GetListOfFiles() const
TDirectory::TContext keeps track and restore the current directory.
A List of entry numbers in a TTree or TChain.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TFriendElement TF describes a TTree object TF in a file.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
@ kEntryBeyondEnd
last entry loop has reached its end
@ kEntryValid
data read okay
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.
static void SetMaxTreeSize(Long64_t maxsize=100000000000LL)
Set the maximum size in bytes of a Tree file (static function).
virtual TObjArray * GetListOfBranches()
virtual TTree * GetTree() const
virtual TList * GetListOfFriends() const
virtual const char * GetFriendAlias(TTree *) const
If the 'tree' is a friend, this method returns its alias name.
std::shared_ptr< ROOT::Detail::RDF::RLoopManager > CreateLMFromTTree(std::string_view datasetName, std::string_view fileNameGlob, const std::vector< std::string > &defaultColumns, bool checkFile=true)
Create an RLoopManager that reads a TChain.
ROOT::Experimental::RLogChannel & RDFLogChannel()
std::vector< std::string > GetBranchNames(TTree &t, bool allowDuplicates=true)
Get all the branches names, including the ones of the friend trees.
void Erase(const T &that, std::vector< T > &v)
Erase that element from vector v
Long64_t InterpreterCalc(const std::string &code, const std::string &context="")
Jit code in the interpreter with TInterpreter::Calc, throw in case of errors.
std::vector< std::string > GetTreeFullPaths(const TTree &tree)
std::unique_ptr< TChain > MakeChainForMT(const std::string &name="", const std::string &title="")
Create a TChain object with options that avoid common causes of thread contention.
std::vector< std::unique_ptr< TChain > > MakeFriends(const ROOT::TreeUtils::RFriendInfo &finfo)
Create friends from the main TTree.
std::vector< std::string > ExpandGlob(const std::string &glob)
Expands input glob into a collection of full paths to files.
std::vector< std::string > ColumnNames_t
std::function< void(unsigned int, const ROOT::RDF::RSampleInfo &)> SampleCallback_t
The type of a data-block callback, registered with an RDataFrame computation graph via e....
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.
A RAII object that calls RLoopManager::CleanUpTask at destruction.
RCallCleanUpTask(RLoopManager &lm, unsigned int arg=0u, TTreeReader *reader=nullptr)
RLoopManager & fLoopManager
A RAII object to pop and push slot numbers from a RSlotStack object.