Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RLoopManager.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 03/2017
2
3/*************************************************************************
4 * Copyright (C) 1995-2022, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RLOOPMANAGER
12#define ROOT_RLOOPMANAGER
13
14#include "ROOT/RDataSource.hxx"
20#include "ROOT/RDF/Utils.hxx"
21
22#include <functional>
23#include <limits>
24#include <map>
25#include <memory>
26#include <set>
27#include <string>
28#include <string_view>
29#include <unordered_map>
30#include <unordered_set>
31#include <vector>
32#include <any>
33
34// forward declarations
35class TTree;
36class TTreeReader;
37class TDirectory;
38
39namespace ROOT {
40namespace RDF {
41class RCutFlowReport;
42class RDataSource;
43} // ns RDF
44
45namespace Internal {
46class RSlotStack;
47namespace RDF {
48class GraphNode;
49class RActionBase;
50class RVariationBase;
51class RDefinesWithReaders;
52class RVariationsWithReaders;
53class RColumnRegister;
54
55namespace GraphDrawing {
57} // ns GraphDrawing
58
59using Callback_t = std::function<void(unsigned int)>;
60
61class RCallback {
64 std::vector<ULong64_t> fCounters;
65
66public:
67 RCallback(ULong64_t everyN, Callback_t &&f, unsigned int nSlots)
68 : fFun(std::move(f)), fEveryN(everyN), fCounters(nSlots, 0ull)
69 {
70 }
71
72 void operator()(unsigned int slot)
73 {
74 auto &c = fCounters[slot];
75 ++c;
76 if (c == fEveryN) {
77 c = 0ull;
78 fFun(slot);
79 }
80 }
81};
82
85 std::vector<int> fHasBeenCalled; // std::vector<bool> is thread-unsafe for our purposes (and generally evil)
86
87public:
88 ROneTimeCallback(Callback_t &&f, unsigned int nSlots) : fFun(std::move(f)), fHasBeenCalled(nSlots, 0) {}
89
90 void operator()(unsigned int slot)
91 {
92 if (fHasBeenCalled[slot] == 1)
93 return;
94 fFun(slot);
95 fHasBeenCalled[slot] = 1;
96 }
97};
98
99struct RDSRangeRAII;
100
101/// Lets RDataFrame release the Python GIL while a thread waits for an event loop to finish, in
102/// RLoopManager::Run() and RunGraphs(). Without it, the waiting thread keeps the GIL and the threads that run the
103/// event loop block forever when they have to call a Python function.
104/// The Python bindings call this with three functions of the Python C API: `isHeld` tells whether the calling
105/// thread holds the GIL, `release` releases it and `restore` takes it again (it gets what `release` returned).
106void SetEventLoopHooks(int (*isHeld)(), void *(*release)(), void (*restore)(void *));
107
108/// Calls `release` when created, if `isHeld` says so, and `restore` when destroyed.
109/// Does nothing if SetEventLoopHooks() was never called.
119
120} // namespace RDF
121} // namespace Internal
122} // namespace ROOT
123
124namespace ROOT {
125namespace Detail {
126namespace RDF {
128
129class RFilterBase;
130class RRangeBase;
131class RDefineBase;
133
134/// The head node of a RDF computation graph.
135/// This class is responsible of running the event loop.
136class RLoopManager : public RNodeBase {
137 using ColumnNames_t = std::vector<std::string>;
138 enum class ELoopType {
139 kInvalid,
140 kNoFiles,
144 };
145
146 friend struct RCallCleanUpTask;
148
149 /*
150 A wrapped reference to a TTree dataset that can be shared by many computation graphs. Ensures lifetime management.
151 It needs to be destroyed *after* the fDataSource data member, in case it is holding the only Python reference to the
152 input dataset and the data source needs to access it before it is destroyed.
153 */
154 std::any fTTreeLifeline{};
155
156 std::vector<RDFInternal::RActionBase *> fBookedActions; ///< Non-owning pointers to actions to be run
157 std::vector<RDFInternal::RActionBase *> fRunActions; ///< Non-owning pointers to actions already run
158 std::vector<RFilterBase *> fBookedFilters;
159 std::vector<RFilterBase *> fBookedNamedFilters; ///< Contains a subset of fBookedFilters, i.e. only the named filters
160 std::vector<RRangeBase *> fBookedRanges;
161 std::vector<RDefineBase *> fBookedDefines;
162 std::vector<RDFInternal::RVariationBase *> fBookedVariations;
163
165 Long64_t fEndEntry{std::numeric_limits<Long64_t>::max()};
166
167 /// Keys are `fname + "/" + treename` as RSampleInfo::fID; Values are pointers to the corresponding sample
168 std::unordered_map<std::string, ROOT::RDF::Experimental::RSample *> fSampleMap;
169 /// Samples need to survive throughout the whole event loop, hence stored as an attribute
170 std::vector<ROOT::RDF::Experimental::RSample> fSamples;
171
173 /// Range of entries created when no data source is specified.
174 std::pair<ULong64_t, ULong64_t> fEmptyEntryRange{};
175 unsigned int fNSlots{1};
177 /// The kind of event loop that is going to be run (e.g. on ROOT files, on no files)
179 std::unique_ptr<RDataSource> fDataSource{}; ///< Owning pointer to a data-source object. Null if no data-source
180 /// Registered callbacks to be executed every N events.
181 /// The registration happens via the RegisterCallback method.
182 std::vector<RDFInternal::RCallback> fCallbacksEveryNEvents;
183 /// Registered callbacks to invoke just once before running the loop.
184 /// The registration happens via the RegisterCallback method.
185 std::vector<RDFInternal::ROneTimeCallback> fCallbacksOnce;
186 /// Registered callbacks to call at the beginning of each "data block".
187 /// The key is the pointer of the corresponding node in the computation graph (a RDefinePerSample or a RAction).
188 std::unordered_map<void *, ROOT::RDF::SampleCallback_t> fSampleCallbacks;
190 std::vector<ROOT::RDF::RSampleInfo> fSampleInfos;
191 unsigned int fNRuns{0}; ///< Number of event loops run
192
193 /// Readers for TTree/RDataSource columns (one per slot), shared by all nodes in the computation graph.
194 std::vector<std::unordered_map<std::string, std::unique_ptr<RColumnReaderBase>>> fDatasetColumnReaders;
195
196 /// Pointer to a shared slot stack in case this instance runs concurrently with others:
197 std::weak_ptr<ROOT::Internal::RSlotStack> fSlotStack;
198
199 void RunEmptySourceMT();
200 void RunEmptySource();
201 void RunDataSourceMT();
202 void RunDataSource();
203 void RunAndCheckFilters(unsigned int slot, Long64_t entry);
204 void InitNodeSlots(TTreeReader *r, unsigned int slot);
205 void InitNodes();
206 void CleanUpNodes();
207 void CleanUpTask(TTreeReader *r, unsigned int slot);
208 void EvalChildrenCounts();
209 void SetupSampleCallbacks(TTreeReader *r, unsigned int slot);
210 void UpdateSampleInfo(unsigned int slot, const std::pair<ULong64_t, ULong64_t> &range);
211 void UpdateSampleInfo(unsigned int slot, TTreeReader &r);
212 std::shared_ptr<ROOT::Internal::RSlotStack> SlotStack() const;
213
214 // List of branches for which we want to suppress the printed error about
215 // missing branch when switching to a new tree. This is modified by readers,
216 // so must be declared before them in this class.
217 std::set<std::string> fSuppressErrorsForMissingBranches{};
219 std::set<std::pair<std::string_view, std::unique_ptr<ROOT::Internal::RDF::RDefinesWithReaders>>>
221 std::set<std::pair<std::string_view, std::unique_ptr<ROOT::Internal::RDF::RVariationsWithReaders>>>
223
224 // deferred function calls to Jitted functions
226 std::size_t fFunctionId{};
227 std::unique_ptr<ROOT::Internal::RDF::RColumnRegister> fColRegister;
228 std::vector<std::string> fColNames;
229 std::shared_ptr<void> fJittedNode;
230 // Extra arguments to be passed to the jitted function, in one value. Each function will need to unpack it
231 // accordingly.
232 std::shared_ptr<void> fExtraArgs;
233 DeferredJitCall(std::size_t id, std::unique_ptr<ROOT::Internal::RDF::RColumnRegister> cols,
234 const std::vector<std::string> &colNamesArg, std::shared_ptr<void> jittedNode,
235 std::shared_ptr<void> arg);
236
240 DeferredJitCall &operator=(DeferredJitCall &&) noexcept;
242 };
244 std::hash<std::string> fStringHasher{};
245
246public:
247 RLoopManager(const ColumnNames_t &defaultColumns = {});
248 RLoopManager(TTree *tree, const ColumnNames_t &defaultBranches);
249 RLoopManager(ULong64_t nEmptyEntries);
250 RLoopManager(std::unique_ptr<RDataSource> ds, const ColumnNames_t &defaultBranches);
252
253 // Rule of five
254
255 RLoopManager(const RLoopManager &) = delete;
259 ~RLoopManager() override;
260
261 void Jit();
262 void RunDeferredCalls();
263 RLoopManager *GetLoopManagerUnchecked() final { return this; }
264 void Run(bool jit = true);
265 const ColumnNames_t &GetDefaultColumnNames() const;
267 RDataSource *GetDataSource() const { return fDataSource.get(); }
268 void Register(RDFInternal::RActionBase *actionPtr);
269 void Deregister(RDFInternal::RActionBase *actionPtr);
270 void Register(RFilterBase *filterPtr);
271 void Deregister(RFilterBase *filterPtr);
272 void Register(RRangeBase *rangePtr);
273 void Deregister(RRangeBase *rangePtr);
274 void Register(RDefineBase *definePtr);
275 void Deregister(RDefineBase *definePtr);
278 bool CheckFilters(unsigned int, Long64_t) final;
279 unsigned int GetNSlots() const { return fNSlots; }
280 void Report(ROOT::RDF::RCutFlowReport &rep) const final;
281 /// End of recursive chain of calls, does nothing
283 void IncrChildrenCount() final { ++fNChildren; }
284 void StopProcessing() final { ++fNStopsReceived; }
285 void ToJitExec(const std::string &) const;
286 void RegisterJitHelperCall(const std::string &funcBody,
287 std::unique_ptr<ROOT::Internal::RDF::RColumnRegister> colRegister,
288 const std::vector<std::string> &colnames, std::shared_ptr<void> jittedNode,
289 std::shared_ptr<void> argument = nullptr);
290 void RegisterCallback(ULong64_t everyNEvents, std::function<void(unsigned int)> &&f);
291 unsigned int GetNRuns() const { return fNRuns; }
292 bool HasDataSourceColumnReaders(std::string_view col, const std::type_info &ti) const;
293 void AddDataSourceColumnReaders(std::string_view col, std::vector<std::unique_ptr<RColumnReaderBase>> &&readers,
294 const std::type_info &ti);
295 RColumnReaderBase *GetDatasetColumnReader(unsigned int slot, std::string_view col, const std::type_info &ti) const;
296 RColumnReaderBase *AddDataSourceColumnReader(unsigned int slot, std::string_view col, const std::type_info &ti,
297 TTreeReader *treeReader);
298
299 /// End of recursive chain of calls, does nothing
300 void AddFilterName(std::vector<std::string> &) final {}
301 /// For each booked filter, returns either the name or "Unnamed Filter"
302 std::vector<std::string> GetFiltersNames();
303
304 /// Return all graph edges known to RLoopManager
305 /// This includes Filters and Ranges but not Defines.
306 std::vector<RNodeBase *> GetGraphEdges() const;
307
308 /// Return all actions, either booked or already run
309 std::vector<RDFInternal::RActionBase *> GetAllActions() const;
310
311 std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>
312 GetGraph(std::unordered_map<void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap) final;
313
314 void AddSampleCallback(void *nodePtr, ROOT::RDF::SampleCallback_t &&callback);
315
316 void SetEmptyEntryRange(std::pair<ULong64_t, ULong64_t> &&newRange);
319
321 std::set<std::pair<std::string_view, std::unique_ptr<ROOT::Internal::RDF::RDefinesWithReaders>>> &
326 std::set<std::pair<std::string_view, std::unique_ptr<ROOT::Internal::RDF::RVariationsWithReaders>>> &
331
332 void SetTTreeLifeline(std::any lifeline);
333 /// Register a slot stack to be used by this RLoopManager. This allows for sharing RDataFrame helpers safely in the
334 /// context of RunGraphs(). Note that the loop manager only stores a weak_ptr, in between runs.
335 void SetSlotStack(const std::shared_ptr<ROOT::Internal::RSlotStack> &slotStack) { fSlotStack = slotStack; }
336
337 void SetDataSource(std::unique_ptr<ROOT::RDF::RDataSource> dataSource);
338
339 void InsertSuppressErrorsForMissingBranch(const std::string &branchName)
340 {
341 fSuppressErrorsForMissingBranches.insert(branchName);
342 }
343 void EraseSuppressErrorsForMissingBranch(const std::string &branchName)
344 {
345 fSuppressErrorsForMissingBranches.erase(branchName);
346 }
347 const std::set<std::string> &GetSuppressErrorsForMissingBranches() const
348 {
350 }
351
352 // TODO(vpadulan): it seems undesirable that we need different "thread tasks" depending on the data source. It would
353 // be nice to merge everything into one, potentially opening up the possibility to making the MT processing interface
354 // of the data source public.
355
356 /// The task run by every thread on the input entry range, for the generic RDataSource.
357 void DataSourceThreadTask(const std::pair<ULong64_t, ULong64_t> &entryRange, ROOT::Internal::RSlotStack &slotStack,
358 std::atomic<ULong64_t> &entryCount);
359 /// The task run by every thread on an entry range (known by the input TTreeReader), for the TTree data source.
360 void
361 TTreeThreadTask(TTreeReader &treeReader, ROOT::Internal::RSlotStack &slotStack, std::atomic<ULong64_t> &entryCount);
362 /// The task run by every thread on the input entry range, for the RNTuple data source.
363 void RNTupleThreadTask(const std::pair<ULong64_t, ULong64_t> &entryRange, unsigned int slot,
364 std::uint64_t columnReaderOffset);
365};
366
367/// \brief Create an RLoopManager that reads a TChain.
368/// \param[in] datasetName Name of the TChain
369/// \param[in] fileNameGlob File name (or glob) in which the TChain is stored.
370/// \param[in] defaultColumns List of default columns, see
371/// \param[in] checkFile file validator boolean
372/// \ref https://root.cern/doc/master/classROOT_1_1RDataFrame.html#default-branches "Default column lists"
373/// \return the RLoopManager instance.
374std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
375CreateLMFromTTree(std::string_view datasetName, std::string_view fileNameGlob,
376 const std::vector<std::string> &defaultColumns, bool checkFile = true);
377
378/// \brief Create an RLoopManager that reads a TChain.
379/// \param[in] datasetName Name of the TChain
380/// \param[in] fileNameGlobs List of file names (potentially globs).
381/// \param[in] defaultColumns List of default columns, see
382/// \param[in] checkFile file validator boolean
383/// \ref https://root.cern/doc/master/classROOT_1_1RDataFrame.html#default-branches "Default column lists"
384/// \return the RLoopManager instance.
385std::shared_ptr<ROOT::Detail::RDF::RLoopManager>
386CreateLMFromTTree(std::string_view datasetName, const std::vector<std::string> &fileNameGlobs,
387 const std::vector<std::string> &defaultColumns, bool checkFile = true);
388
389/// \brief Create an RLoopManager that reads an RNTuple.
390/// \param[in] datasetName Name of the RNTuple
391/// \param[in] fileNameGlob File name (or glob) in which the RNTuple is stored.
392/// \param[in] defaultColumns List of default columns, see
393/// \ref https://root.cern/doc/master/classROOT_1_1RDataFrame.html#default-branches "Default column lists"
394/// \return the RLoopManager instance.
395std::shared_ptr<ROOT::Detail::RDF::RLoopManager> CreateLMFromRNTuple(std::string_view datasetName,
396 std::string_view fileNameGlob,
397 const std::vector<std::string> &defaultColumns);
398
399/// \brief Create an RLoopManager that reads multiple RNTuples chained vertically.
400/// \param[in] datasetName Name of the RNTuple
401/// \param[in] fileNameGlobs List of file names (potentially globs).
402/// \param[in] defaultColumns List of default columns, see
403/// \ref https://root.cern/doc/master/classROOT_1_1RDataFrame.html#default-branches "Default column lists"
404/// \return the RLoopManager instance.
405std::shared_ptr<ROOT::Detail::RDF::RLoopManager> CreateLMFromRNTuple(std::string_view datasetName,
406 const std::vector<std::string> &fileNameGlobs,
407 const std::vector<std::string> &defaultColumns);
408
409/// \brief Create an RLoopManager opening a file and checking the data format of the dataset.
410/// \param[in] datasetName Name of the dataset in the file.
411/// \param[in] fileNameGlob File name (or glob) in which the dataset is stored.
412/// \param[in] defaultColumns List of default columns, see
413/// \ref https://root.cern/doc/master/classROOT_1_1RDataFrame.html#default-branches "Default column lists"
414/// \throws std::invalid_argument if the file could not be opened.
415/// \return an RLoopManager of the appropriate data source.
416std::shared_ptr<ROOT::Detail::RDF::RLoopManager> CreateLMFromFile(std::string_view datasetName,
417 std::string_view fileNameGlob,
418 const std::vector<std::string> &defaultColumns);
419
420/// \brief Create an RLoopManager that reads many files. The first is opened to infer the data source type.
421/// \param[in] datasetName Name of the dataset.
422/// \param[in] fileNameGlobs List of file names (potentially globs).
423/// \param[in] defaultColumns List of default columns, see
424/// \ref https://root.cern/doc/master/classROOT_1_1RDataFrame.html#default-branches "Default column lists"
425/// \throws std::invalid_argument if the file could not be opened.
426/// \return an RLoopManager of the appropriate data source.
427std::shared_ptr<ROOT::Detail::RDF::RLoopManager> CreateLMFromFile(std::string_view datasetName,
428 const std::vector<std::string> &fileNameGlobs,
429 const std::vector<std::string> &defaultColumns);
430
431} // namespace RDF
432} // namespace Detail
433} // namespace ROOT
434
435#endif
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:84
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:85
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
The head node of a RDF computation graph.
RColumnReaderBase * AddDataSourceColumnReader(unsigned int slot, std::string_view col, const std::type_info &ti, TTreeReader *treeReader)
void UpdateSampleInfo(unsigned int slot, const std::pair< ULong64_t, ULong64_t > &range)
unsigned int fNRuns
Number of event loops run.
bool CheckFilters(unsigned int, Long64_t) final
void RegisterJitHelperCall(const std::string &funcBody, std::unique_ptr< ROOT::Internal::RDF::RColumnRegister > colRegister, const std::vector< std::string > &colnames, std::shared_ptr< void > jittedNode, std::shared_ptr< void > argument=nullptr)
void EvalChildrenCounts()
Trigger counting of number of children nodes for each node of the functional graph.
void RNTupleThreadTask(const std::pair< ULong64_t, ULong64_t > &entryRange, unsigned int slot, std::uint64_t columnReaderOffset)
The task run by every thread on the input entry range, for the RNTuple data source.
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.
const std::set< std::string > & GetSuppressErrorsForMissingBranches() const
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.
RLoopManager & operator=(RLoopManager &&)=delete
std::hash< std::string > fStringHasher
std::unordered_map< std::string, ROOT::RDF::Experimental::RSample * > fSampleMap
Keys are fname + "/" + treename as RSampleInfo::fID; Values are pointers to the corresponding sample.
void AddDataSourceColumnReaders(std::string_view col, std::vector< std::unique_ptr< RColumnReaderBase > > &&readers, const std::type_info &ti)
std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< ROOT::Internal::RDF::GraphDrawing::GraphNode > > &visitedMap) final
RLoopManager & operator=(const RLoopManager &)=delete
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
std::set< std::string > fSuppressErrorsForMissingBranches
void ChangeSpec(ROOT::RDF::Experimental::RDatasetSpec &&spec)
Changes the internal TTree held by the RLoopManager.
std::weak_ptr< ROOT::Internal::RSlotStack > fSlotStack
Pointer to a shared slot stack in case this instance runs concurrently with others:
std::set< std::pair< std::string_view, std::unique_ptr< ROOT::Internal::RDF::RVariationsWithReaders > > > & GetUniqueVariationsWithReaders()
std::vector< RDefineBase * > fBookedDefines
void TTreeThreadTask(TTreeReader &treeReader, ROOT::Internal::RSlotStack &slotStack, std::atomic< ULong64_t > &entryCount)
The task run by every thread on an entry range (known by the input TTreeReader), for the TTree data s...
void InsertSuppressErrorsForMissingBranch(const std::string &branchName)
std::vector< RDFInternal::RActionBase * > fRunActions
Non-owning pointers to actions already run.
RLoopManager(const ColumnNames_t &defaultColumns={})
void AddFilterName(std::vector< std::string > &) final
End of recursive chain of calls, does nothing.
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.
void ChangeBeginAndEndEntries(Long64_t begin, Long64_t end)
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::set< std::pair< std::string_view, std::unique_ptr< ROOT::Internal::RDF::RVariationsWithReaders > > > fUniqueVariationsWithReaders
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.
RLoopManager(RLoopManager &&)=delete
void SetupSampleCallbacks(TTreeReader *r, unsigned int slot)
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.
void Register(RDFInternal::RActionBase *actionPtr)
std::vector< DeferredJitCall > fJitHelperCalls
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.
std::set< std::pair< std::string_view, std::unique_ptr< ROOT::Internal::RDF::RDefinesWithReaders > > > & GetUniqueDefinesWithReaders()
void EraseSuppressErrorsForMissingBranch(const std::string &branchName)
RDataSource * GetDataSource() const
void RunDataSourceMT()
Run event loop over data accessed through a DataSource, in parallel.
void PartialReport(ROOT::RDF::RCutFlowReport &) const final
End of recursive chain of calls, does nothing.
void SetSlotStack(const std::shared_ptr< ROOT::Internal::RSlotStack > &slotStack)
Register a slot stack to be used by this RLoopManager.
std::vector< std::string > GetFiltersNames()
For each booked filter, returns either the name or "Unnamed Filter".
RLoopManager(const RLoopManager &)=delete
RDFInternal::RNewSampleNotifier fNewSampleNotifier
std::pair< ULong64_t, ULong64_t > fEmptyEntryRange
Range of entries created when no data source is specified.
std::set< std::pair< std::string_view, std::unique_ptr< ROOT::Internal::RDF::RDefinesWithReaders > > > fUniqueDefinesWithReaders
ROOT::Internal::RDF::RStringCache fCachedColNames
ROOT::Internal::RDF::RStringCache & GetColumnNamesCache()
std::unique_ptr< RDataSource > fDataSource
Owning pointer to a data-source object.
void DataSourceThreadTask(const std::pair< ULong64_t, ULong64_t > &entryRange, ROOT::Internal::RSlotStack &slotStack, std::atomic< ULong64_t > &entryCount)
The task run by every thread on the input entry range, for the generic RDataSource.
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 SetDataSource(std::unique_ptr< ROOT::RDF::RDataSource > dataSource)
void RegisterCallback(ULong64_t everyNEvents, std::function< void(unsigned int)> &&f)
void SetTTreeLifeline(std::any lifeline)
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.
RColumnReaderBase * GetDatasetColumnReader(unsigned int slot, std::string_view col, const std::type_info &ti) const
std::shared_ptr< ROOT::Internal::RSlotStack > SlotStack() const
Create a slot stack with the desired number of slots or reuse a shared instance.
void Deregister(RDFInternal::RActionBase *actionPtr)
ELoopType fLoopType
The kind of event loop that is going to be run (e.g. on ROOT files, on no files)
void InitNodes()
Initialize all nodes of the functional graph before running the event loop.
bool HasDataSourceColumnReaders(std::string_view col, const std::type_info &ti) const
Return true if AddDataSourceColumnReaders was called for column name col.
RLoopManager * GetLoopManagerUnchecked() final
Base class for non-leaf nodes of the computational graph.
Definition RNodeBase.hxx:43
unsigned int fNStopsReceived
Number of times that a children node signaled to stop processing entries.
Definition RNodeBase.hxx:47
unsigned int fNChildren
Number of nodes of the functional graph hanging from this object.
Definition RNodeBase.hxx:46
Helper class that provides the operation graph nodes.
RCallback(ULong64_t everyN, Callback_t &&f, unsigned int nSlots)
std::vector< ULong64_t > fCounters
void operator()(unsigned int slot)
Calls release when created, if isHeld says so, and restore when destroyed.
REventLoopHooksRAII(const REventLoopHooksRAII &)=delete
REventLoopHooksRAII & operator=(const REventLoopHooksRAII &)=delete
ROneTimeCallback(Callback_t &&f, unsigned int nSlots)
A Thread-safe cache for strings.
Definition Utils.hxx:277
This type includes all parts of RVariation that do not depend on the callable signature.
A thread-safe list of N indexes (0 to size - 1).
The dataset specification for RDataFrame.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
Describe directory structure in memory.
Definition TDirectory.h:45
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition TTreeReader.h:46
A TTree represents a columnar dataset.
Definition TTree.h:95
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.
std::shared_ptr< ROOT::Detail::RDF::RLoopManager > CreateLMFromFile(std::string_view datasetName, std::string_view fileNameGlob, const std::vector< std::string > &defaultColumns)
Create an RLoopManager opening a file and checking the data format of the dataset.
std::shared_ptr< ROOT::Detail::RDF::RLoopManager > CreateLMFromRNTuple(std::string_view datasetName, std::string_view fileNameGlob, const std::vector< std::string > &defaultColumns)
Create an RLoopManager that reads an RNTuple.
void SetEventLoopHooks(int(*isHeld)(), void *(*release)(), void(*restore)(void *))
Lets RDataFrame release the Python GIL while a thread waits for an event loop to finish,...
std::function< void(unsigned int)> Callback_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....
A RAII object that calls RLoopManager::CleanUpTask at destruction.
std::unique_ptr< ROOT::Internal::RDF::RColumnRegister > fColRegister
DeferredJitCall(const DeferredJitCall &)=delete
DeferredJitCall(DeferredJitCall &&) noexcept
DeferredJitCall(std::size_t id, std::unique_ptr< ROOT::Internal::RDF::RColumnRegister > cols, const std::vector< std::string > &colNamesArg, std::shared_ptr< void > jittedNode, std::shared_ptr< void > arg)
DeferredJitCall & operator=(const DeferredJitCall &)=delete