Logo ROOT   6.10/02
Reference Guide
TDFNodes.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 03/2017
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2016, 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_TDFNODES
12 #define ROOT_TDFNODES
13 
14 #include "ROOT/TDFUtils.hxx"
15 #include "ROOT/RArrayView.hxx"
16 #include "ROOT/TSpinMutex.hxx"
17 #include "TTreeReaderArray.h"
18 #include "TTreeReaderValue.h"
19 
20 #include <map>
21 #include <numeric> // std::iota for TSlotStack
22 #include <string>
23 #include <tuple>
24 #include <cassert>
25 
26 namespace ROOT {
27 
28 namespace Internal {
29 namespace TDF {
30 class TActionBase;
31 }
32 }
33 
34 namespace Detail {
35 namespace TDF {
37 
38 // forward declarations for TLoopManager
39 using ActionBasePtr_t = std::shared_ptr<TDFInternal::TActionBase>;
40 using ActionBaseVec_t = std::vector<ActionBasePtr_t>;
41 class TCustomColumnBase;
42 using TmpBranchBasePtr_t = std::shared_ptr<TCustomColumnBase>;
43 class TFilterBase;
44 using FilterBasePtr_t = std::shared_ptr<TFilterBase>;
45 using FilterBaseVec_t = std::vector<FilterBasePtr_t>;
46 class TRangeBase;
47 using RangeBasePtr_t = std::shared_ptr<TRangeBase>;
48 using RangeBaseVec_t = std::vector<RangeBasePtr_t>;
49 
50 class TLoopManager : public std::enable_shared_from_this<TLoopManager> {
51 
55  std::map<std::string, TmpBranchBasePtr_t> fBookedBranches;
57  std::vector<std::shared_ptr<bool>> fResProxyReadiness;
58  ::TDirectory *fDirPtr{nullptr};
59  std::shared_ptr<TTree> fTree{nullptr};
60  const ColumnNames_t fDefaultBranches;
61  const Long64_t fNEmptyEntries{0};
62  const unsigned int fNSlots{0};
63  bool fHasRunAtLeastOnce{false};
64  unsigned int fNChildren{0}; ///< Number of nodes of the functional graph hanging from this object
65  unsigned int fNStopsReceived{0}; ///< Number of times that a children node signaled to stop processing entries.
66 
67  void RunAndCheckFilters(unsigned int slot, Long64_t entry);
68  void InitNodes();
69 
70 public:
71  TLoopManager(TTree *tree, const ColumnNames_t &defaultBranches);
72  TLoopManager(Long64_t nEmptyEntries);
73  TLoopManager(const TLoopManager &) = delete;
75  void Run();
76  void InitAllNodes(TTreeReader *r, unsigned int slot);
77  TLoopManager *GetImplPtr();
78  std::shared_ptr<TLoopManager> GetSharedPtr() { return shared_from_this(); }
79  const ColumnNames_t &GetDefaultBranches() const;
80  const ColumnNames_t GetTmpBranches() const { return {}; };
81  TTree *GetTree() const;
82  TCustomColumnBase *GetBookedBranch(const std::string &name) const;
83  const std::map<std::string, TmpBranchBasePtr_t> &GetBookedBranches() const { return fBookedBranches; }
84  ::TDirectory *GetDirectory() const;
85  Long64_t GetNEmptyEntries() const { return fNEmptyEntries; }
86  void Book(const ActionBasePtr_t &actionPtr);
87  void Book(const FilterBasePtr_t &filterPtr);
88  void Book(const TmpBranchBasePtr_t &branchPtr);
89  void Book(const std::shared_ptr<bool> &branchPtr);
90  void Book(const RangeBasePtr_t &rangePtr);
91  bool CheckFilters(int, unsigned int);
92  unsigned int GetNSlots() const { return fNSlots; }
93  bool HasRunAtLeastOnce() const { return fHasRunAtLeastOnce; }
94  void Report() const;
95  /// End of recursive chain of calls, does nothing
96  void PartialReport() const {}
97  void SetTree(std::shared_ptr<TTree> tree) { fTree = tree; }
98  void IncrChildrenCount() { ++fNChildren; }
99  void StopProcessing() { ++fNStopsReceived; }
100 };
101 } // end ns TDF
102 } // end ns Detail
103 
104 namespace Internal {
105 namespace TDF {
106 using namespace ROOT::Detail::TDF;
107 
108 /**
109 \class ROOT::Internal::TDF::TColumnValue
110 \ingroup dataframe
111 \brief Helper class that updates and returns TTree branches as well as TDataFrame temporary columns
112 \tparam T The type of the column
113 
114 TDataFrame nodes must access two different types of values during the event loop:
115 values of real branches, for which TTreeReader{Values,Arrays} act as proxies, or
116 temporary columns whose values are generated on the fly. While the type of the
117 value is known at compile time (or just-in-time), it is only at runtime that nodes
118 can check whether a certain value is generated on the fly or not.
119 
120 TColumnValuePtr abstracts this difference by providing the same interface for
121 both cases and handling the reading or generation of new values transparently.
122 Only one of the two data members fReaderProxy or fValuePtr will be non-null
123 for a given TColumnValue, depending on whether the value comes from a real
124 TTree branch or from a temporary column respectively.
125 
126 TDataFrame nodes can store tuples of TColumnValues and retrieve an updated
127 value for the column via the `Get` method.
128 **/
129 template <typename T>
131  // following line is equivalent to pseudo-code: ProxyParam_t == array_view<U> ? U : T
132  // ReaderValueOrArray_t is a TTreeReaderValue<T> unless T is array_view<U>
133  using ProxyParam_t = typename std::conditional<std::is_same<ReaderValueOrArray_t<T>, TTreeReaderValue<T>>::value, T,
134  ExtractType_t<T>>::type;
135  std::unique_ptr<TTreeReaderValue<T>> fReaderValue{nullptr}; //< Owning ptr to a TTreeReaderValue. Used for
136  /// non-temporary columns and T != std::array_view<U>
137  std::unique_ptr<TTreeReaderArray<ProxyParam_t>> fReaderArray{nullptr}; //< Owning ptr to a TTreeReaderArray. Used for
138  /// non-temporary columsn and
139  /// T == std::array_view<U>.
140  T *fValuePtr{nullptr}; //< Non-owning ptr to the value of a temporary column.
141  TCustomColumnBase *fTmpColumn{nullptr}; //< Non-owning ptr to the node responsible for the temporary column.
142  unsigned int fSlot{0}; //< The slot this value belongs to. Only used for temporary columns, not for real branches.
143 
144 public:
145  TColumnValue() = default;
146 
147  void SetTmpColumn(unsigned int slot, TCustomColumnBase *tmpColumn);
148 
149  void MakeProxy(TTreeReader *r, const std::string &bn)
150  {
151  Reset();
152  bool useReaderValue = std::is_same<ProxyParam_t, T>::value;
153  if (useReaderValue)
154  fReaderValue.reset(new TTreeReaderValue<T>(*r, bn.c_str()));
155  else
156  fReaderArray.reset(new TTreeReaderArray<ProxyParam_t>(*r, bn.c_str()));
157  }
158 
159  template <typename U = T,
160  typename std::enable_if<std::is_same<typename TColumnValue<U>::ProxyParam_t, U>::value, int>::type = 0>
161  T &Get(Long64_t entry);
162 
163  template <typename U = T, typename std::enable_if<!std::is_same<ProxyParam_t, U>::value, int>::type = 0>
164  std::array_view<ProxyParam_t> Get(Long64_t)
165  {
166  auto &readerArray = *fReaderArray;
167  if (readerArray.GetSize() > 1 && 1 != (&readerArray[1] - &readerArray[0])) {
168  std::string exceptionText = "Branch ";
169  exceptionText += fReaderArray->GetBranchName();
170  exceptionText += " hangs from a non-split branch. For this reason, it cannot be accessed via an array_view."
171  " Please read the top level branch instead.";
172  throw std::runtime_error(exceptionText.c_str());
173  }
174 
175  return std::array_view<ProxyParam_t>(fReaderArray->begin(), fReaderArray->end());
176  }
177 
178  void Reset()
179  {
180  fReaderValue = nullptr;
181  fReaderArray = nullptr;
182  fValuePtr = nullptr;
183  fTmpColumn = nullptr;
184  fSlot = 0;
185  }
186 };
187 
188 template <typename T>
190 };
191 
192 template <typename... BranchTypes>
193 struct TTDFValueTuple<TTypeList<BranchTypes...>> {
194  using type = std::tuple<TColumnValue<BranchTypes>...>;
195 };
196 
197 template <typename BranchType>
199 
200 class TActionBase {
201 protected:
202  TLoopManager *fImplPtr; ///< A raw pointer to the TLoopManager at the root of this functional
203  /// graph. It is only guaranteed to contain a valid address during an
204  /// event loop.
205  const ColumnNames_t fTmpBranches;
206  const unsigned int fNSlots; ///< Number of thread slots used by this node.
207 
208 public:
209  TActionBase(TLoopManager *implPtr, const ColumnNames_t &tmpBranches, unsigned int nSlots);
210  virtual ~TActionBase() {}
211  virtual void Run(unsigned int slot, Long64_t entry) = 0;
212  virtual void Init(TTreeReader *r, unsigned int slot) = 0;
213  unsigned int GetNSlots() const { return fNSlots; }
214 };
215 
216 template <typename Helper, typename PrevDataFrame, typename BranchTypes_t = typename Helper::BranchTypes_t>
217 class TAction final : public TActionBase {
218  using TypeInd_t = typename TGenStaticSeq<BranchTypes_t::fgSize>::Type_t;
219 
220  Helper fHelper;
221  const ColumnNames_t fBranches;
222  PrevDataFrame &fPrevData;
223  std::vector<TDFValueTuple_t<BranchTypes_t>> fValues;
224 
225 public:
226  TAction(Helper &&h, const ColumnNames_t &bl, PrevDataFrame &pd)
227  : TActionBase(pd.GetImplPtr(), pd.GetTmpBranches(), pd.GetNSlots()), fHelper(std::move(h)), fBranches(bl),
228  fPrevData(pd), fValues(fNSlots)
229  {
230  }
231 
232  TAction(const TAction &) = delete;
233 
234  void Init(TTreeReader *r, unsigned int slot) final
235  {
236  InitTDFValues(slot, fValues[slot], r, fBranches, fTmpBranches, fImplPtr->GetBookedBranches(), TypeInd_t());
237  fHelper.Init(r, slot);
238  }
239 
240  void Run(unsigned int slot, Long64_t entry) final
241  {
242  // check if entry passes all filters
243  if (fPrevData.CheckFilters(slot, entry)) Exec(slot, entry, TypeInd_t());
244  }
245 
246  template <int... S>
247  void Exec(unsigned int slot, Long64_t entry, TStaticSeq<S...>)
248  {
249  (void)entry; // avoid bogus 'unused parameter' warning in gcc4.9
250  fHelper.Exec(slot, std::get<S>(fValues[slot]).Get(entry)...);
251  }
252 
253  ~TAction() { fHelper.Finalize(); }
254 };
255 
256 } // end NS TDF
257 } // end NS Internal
258 
259 namespace Detail {
260 namespace TDF {
261 
263 protected:
264  TLoopManager *fImplPtr; ///< A raw pointer to the TLoopManager at the root of this functional graph. It is only
265  /// guaranteed to contain a valid address during an event loop.
266  ColumnNames_t fTmpBranches;
267  const std::string fName;
268  unsigned int fNChildren{0}; ///< Number of nodes of the functional graph hanging from this object
269  unsigned int fNStopsReceived{0}; ///< Number of times that a children node signaled to stop processing entries.
270  const unsigned int fNSlots; ///< Number of thread slots used by this node, inherited from parent node.
271 
272 public:
273  TCustomColumnBase(TLoopManager *df, const ColumnNames_t &tmpBranches, std::string_view name, unsigned int nSlots);
274  virtual ~TCustomColumnBase() {}
275  virtual void Init(TTreeReader *r, unsigned int slot) = 0;
276  virtual void *GetValuePtr(unsigned int slot) = 0;
277  virtual const std::type_info &GetTypeId() const = 0;
278  virtual bool CheckFilters(unsigned int slot, Long64_t entry) = 0;
279  TLoopManager *GetImplPtr() const;
280  virtual void Report() const = 0;
281  virtual void PartialReport() const = 0;
282  std::string GetName() const;
283  ColumnNames_t GetTmpBranches() const;
284  virtual void Update(unsigned int slot, Long64_t entry) = 0;
285  void IncrChildrenCount() { ++fNChildren; }
286  virtual void StopProcessing() = 0;
287  unsigned int GetNSlots() const { return fNSlots; }
288 };
289 
290 template <typename F, typename PrevData>
291 class TCustomColumn final : public TCustomColumnBase {
292  using BranchTypes_t = typename TDFInternal::TFunctionTraits<F>::Args_t;
293  using TypeInd_t = typename TDFInternal::TGenStaticSeq<BranchTypes_t::fgSize>::Type_t;
294  using Ret_t = typename TDFInternal::TFunctionTraits<F>::Ret_t;
295 
297  const ColumnNames_t fBranches;
298  std::vector<std::unique_ptr<Ret_t>> fLastResultPtr;
299  PrevData &fPrevData;
300  std::vector<Long64_t> fLastCheckedEntry = {-1};
301 
302  std::vector<TDFInternal::TDFValueTuple_t<BranchTypes_t>> fValues;
303 
304 public:
305  TCustomColumn(std::string_view name, F &&expression, const ColumnNames_t &bl, PrevData &pd)
306  : TCustomColumnBase(pd.GetImplPtr(), pd.GetTmpBranches(), name, pd.GetNSlots()),
307  fExpression(std::move(expression)), fBranches(bl), fLastResultPtr(fNSlots), fPrevData(pd),
308  fLastCheckedEntry(fNSlots, -1), fValues(fNSlots)
309  {
310  std::generate(fLastResultPtr.begin(), fLastResultPtr.end(),
311  []() { return std::unique_ptr<Ret_t>(new Ret_t()); });
312  fTmpBranches.emplace_back(name);
313  }
314 
315  TCustomColumn(const TCustomColumn &) = delete;
316 
317  void Init(TTreeReader *r, unsigned int slot) final
318  {
319  TDFInternal::InitTDFValues(slot, fValues[slot], r, fBranches, fTmpBranches, fImplPtr->GetBookedBranches(),
320  TypeInd_t());
321  }
322 
323  void *GetValuePtr(unsigned int slot) final { return static_cast<void *>(fLastResultPtr[slot].get()); }
324 
325  void Update(unsigned int slot, Long64_t entry) final
326  {
327  if (entry != fLastCheckedEntry[slot]) {
328  // evaluate this filter, cache the result
329  UpdateHelper(slot, entry, TypeInd_t(), BranchTypes_t());
330  fLastCheckedEntry[slot] = entry;
331  }
332  }
333 
334  const std::type_info &GetTypeId() const { return typeid(Ret_t); }
335 
336  bool CheckFilters(unsigned int slot, Long64_t entry) final
337  {
338  // dummy call: it just forwards to the previous object in the chain
339  return fPrevData.CheckFilters(slot, entry);
340  }
341 
342  template <int... S, typename... BranchTypes>
343  void UpdateHelper(unsigned int slot, Long64_t entry, TDFInternal::TStaticSeq<S...>,
344  TDFInternal::TTypeList<BranchTypes...>)
345  {
346  *fLastResultPtr[slot] = fExpression(std::get<S>(fValues[slot]).Get(entry)...);
347  }
348 
349  // recursive chain of `Report`s
350  // TCustomColumn simply forwards the call to the previous node
351  void Report() const final { fPrevData.PartialReport(); }
352 
353  void PartialReport() const final { fPrevData.PartialReport(); }
354 
356  {
357  ++fNStopsReceived;
358  if (fNStopsReceived == fNChildren) fPrevData.StopProcessing();
359  }
360 };
361 
362 class TFilterBase {
363 protected:
364  TLoopManager *fImplPtr; ///< A raw pointer to the TLoopManager at the root of this functional graph. It is only
365  /// guaranteed to contain a valid address during an event loop.
366  const ColumnNames_t fTmpBranches;
367  std::vector<Long64_t> fLastCheckedEntry = {-1};
368  std::vector<int> fLastResult = {true}; // std::vector<bool> cannot be used in a MT context safely
369  std::vector<ULong64_t> fAccepted = {0};
370  std::vector<ULong64_t> fRejected = {0};
371  const std::string fName;
372  unsigned int fNChildren{0}; ///< Number of nodes of the functional graph hanging from this object
373  unsigned int fNStopsReceived{0}; ///< Number of times that a children node signaled to stop processing entries.
374  const unsigned int fNSlots; ///< Number of thread slots used by this node, inherited from parent node.
375 
376 public:
377  TFilterBase(TLoopManager *df, const ColumnNames_t &tmpBranches, std::string_view name, unsigned int nSlots);
378  virtual ~TFilterBase() {}
379  virtual void Init(TTreeReader *r, unsigned int slot) = 0;
380  virtual bool CheckFilters(unsigned int slot, Long64_t entry) = 0;
381  virtual void Report() const = 0;
382  virtual void PartialReport() const = 0;
383  TLoopManager *GetImplPtr() const;
384  ColumnNames_t GetTmpBranches() const;
385  bool HasName() const;
386  void PrintReport() const;
387  void IncrChildrenCount() { ++fNChildren; }
388  virtual void StopProcessing() = 0;
389  unsigned int GetNSlots() const { return fNSlots; }
390  virtual void ResetReportCount() = 0;
391 };
392 
393 template <typename FilterF, typename PrevDataFrame>
394 class TFilter final : public TFilterBase {
395  using BranchTypes_t = typename TDFInternal::TFunctionTraits<FilterF>::Args_t;
396  using TypeInd_t = typename TDFInternal::TGenStaticSeq<BranchTypes_t::fgSize>::Type_t;
397 
398  FilterF fFilter;
399  const ColumnNames_t fBranches;
400  PrevDataFrame &fPrevData;
401  std::vector<TDFInternal::TDFValueTuple_t<BranchTypes_t>> fValues;
402 
403 public:
404  TFilter(FilterF &&f, const ColumnNames_t &bl, PrevDataFrame &pd, std::string_view name = "")
405  : TFilterBase(pd.GetImplPtr(), pd.GetTmpBranches(), name, pd.GetNSlots()), fFilter(std::move(f)), fBranches(bl),
406  fPrevData(pd), fValues(fNSlots)
407  {
408  }
409 
410  TFilter(const TFilter &) = delete;
411 
412  bool CheckFilters(unsigned int slot, Long64_t entry) final
413  {
414  if (entry != fLastCheckedEntry[slot]) {
415  if (!fPrevData.CheckFilters(slot, entry)) {
416  // a filter upstream returned false, cache the result
417  fLastResult[slot] = false;
418  } else {
419  // evaluate this filter, cache the result
420  auto passed = CheckFilterHelper(slot, entry, TypeInd_t());
421  passed ? ++fAccepted[slot] : ++fRejected[slot];
422  fLastResult[slot] = passed;
423  }
424  fLastCheckedEntry[slot] = entry;
425  }
426  return fLastResult[slot];
427  }
428 
429  template <int... S>
430  bool CheckFilterHelper(unsigned int slot, Long64_t entry, TDFInternal::TStaticSeq<S...>)
431  {
432  return fFilter(std::get<S>(fValues[slot]).Get(entry)...);
433  }
434 
435  void Init(TTreeReader *r, unsigned int slot) final
436  {
437  TDFInternal::InitTDFValues(slot, fValues[slot], r, fBranches, fTmpBranches, fImplPtr->GetBookedBranches(),
438  TypeInd_t());
439  }
440 
441  // recursive chain of `Report`s
442  void Report() const final { PartialReport(); }
443 
444  void PartialReport() const final
445  {
446  fPrevData.PartialReport();
447  PrintReport();
448  }
449 
451  {
452  ++fNStopsReceived;
453  if (fNStopsReceived == fNChildren) fPrevData.StopProcessing();
454  }
455 
457  {
458  assert(!fName.empty()); // this method is to only be called on named filters
459  // fAccepted and fRejected could be different than 0 if this is not the first event-loop run using this filter
460  std::fill(fAccepted.begin(), fAccepted.end(), 0);
461  std::fill(fRejected.begin(), fRejected.end(), 0);
462  }
463 };
464 
465 class TRangeBase {
466 protected:
467  TLoopManager *fImplPtr; ///< A raw pointer to the TLoopManager at the root of this functional graph. It is only
468  /// guaranteed to contain a valid address during an event loop.
469  ColumnNames_t fTmpBranches;
470  unsigned int fStart;
471  unsigned int fStop;
472  unsigned int fStride;
473  Long64_t fLastCheckedEntry{-1};
474  bool fLastResult{true};
475  ULong64_t fNProcessedEntries{0};
476  unsigned int fNChildren{0}; ///< Number of nodes of the functional graph hanging from this object
477  unsigned int fNStopsReceived{0}; ///< Number of times that a children node signaled to stop processing entries.
478  bool fHasStopped{false}; ///< True if the end of the range has been reached
479  const unsigned int fNSlots; ///< Number of thread slots used by this node, inherited from parent node.
480 
481 public:
482  TRangeBase(TLoopManager *implPtr, const ColumnNames_t &tmpBranches, unsigned int start, unsigned int stop,
483  unsigned int stride, unsigned int nSlots);
484  virtual ~TRangeBase() {}
485  TLoopManager *GetImplPtr() const;
486  ColumnNames_t GetTmpBranches() const;
487  virtual bool CheckFilters(unsigned int slot, Long64_t entry) = 0;
488  virtual void Report() const = 0;
489  virtual void PartialReport() const = 0;
490  void IncrChildrenCount() { ++fNChildren; }
491  virtual void StopProcessing() = 0;
492  unsigned int GetNSlots() const { return fNSlots; }
493 };
494 
495 template <typename PrevData>
496 class TRange final : public TRangeBase {
497  PrevData &fPrevData;
498 
499 public:
500  TRange(unsigned int start, unsigned int stop, unsigned int stride, PrevData &pd)
501  : TRangeBase(pd.GetImplPtr(), pd.GetTmpBranches(), start, stop, stride, pd.GetNSlots()), fPrevData(pd)
502  {
503  }
504 
505  TRange(const TRange &) = delete;
506 
507  /// Ranges act as filters when it comes to selecting entries that downstream nodes should process
508  bool CheckFilters(unsigned int slot, Long64_t entry) final
509  {
510  if (fHasStopped) {
511  return false;
512  } else if (entry != fLastCheckedEntry) {
513  if (!fPrevData.CheckFilters(slot, entry)) {
514  // a filter upstream returned false, cache the result
515  fLastResult = false;
516  } else {
517  // apply range filter logic, cache the result
518  ++fNProcessedEntries;
519  if (fNProcessedEntries <= fStart || (fStop > 0 && fNProcessedEntries > fStop) ||
520  (fStride != 1 && fNProcessedEntries % fStride != 0))
521  fLastResult = false;
522  else
523  fLastResult = true;
524  if (fNProcessedEntries == fStop) {
525  fHasStopped = true;
526  fPrevData.StopProcessing();
527  }
528  }
529  fLastCheckedEntry = entry;
530  }
531  return fLastResult;
532  }
533 
534  // recursive chain of `Report`s
535  // TRange simply forwards these calls to the previous node
536  void Report() const final { fPrevData.PartialReport(); }
537 
538  void PartialReport() const final { fPrevData.PartialReport(); }
539 
541  {
542  ++fNStopsReceived;
543  if (fNStopsReceived == fNChildren && !fHasStopped) fPrevData.StopProcessing();
544  }
545 };
546 
547 } // namespace TDF
548 } // namespace Detail
549 } // namespace ROOT
550 
551 // method implementations
552 template <typename T>
555 {
556  Reset();
557  fTmpColumn = tmpColumn;
558  if (tmpColumn->GetTypeId() != typeid(T))
559  throw std::runtime_error(std::string("TColumnValue: type specified is ") + typeid(T).name() +
560  " but temporary column has type " + tmpColumn->GetTypeId().name());
561  fValuePtr = static_cast<T *>(tmpColumn->GetValuePtr(slot));
562  fSlot = slot;
563 }
564 
565 // This method is executed inside the event-loop, many times per entry
566 // If need be, the if statement can be avoided using thunks
567 // (have both branches inside functions and have a pointer to
568 // the branch to be executed)
569 template <typename T>
570 template <typename U,
571  typename std::enable_if<std::is_same<typename ROOT::Internal::TDF::TColumnValue<U>::ProxyParam_t, U>::value,
572  int>::type>
574 {
575  if (fReaderValue) {
576  return *(fReaderValue->Get());
577  } else {
578  fTmpColumn->Update(fSlot, entry);
579  return *fValuePtr;
580  }
581 }
582 
583 #endif // ROOT_TDFNODES
typename TTDFValueTuple< BranchType >::type TDFValueTuple_t
Definition: TDFNodes.hxx:198
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
FilterBaseVec_t fBookedFilters
Definition: TDFNodes.hxx:53
bool CheckFilters(unsigned int slot, Long64_t entry) final
Definition: TDFNodes.hxx:412
long long Long64_t
Definition: RtypesCore.h:69
const std::type_info & GetTypeId() const
Definition: TDFNodes.hxx:334
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
Definition: TTreeReader.h:42
void Init(TTreeReader *r, unsigned int slot) final
Definition: TDFNodes.hxx:435
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
PrevDataFrame & fPrevData
Definition: TDFNodes.hxx:400
std::array_view< ProxyParam_t > Get(Long64_t)
Definition: TDFNodes.hxx:164
std::vector< TDFValueTuple_t< BranchTypes_t > > fValues
Definition: TDFNodes.hxx:223
typename std::conditional< std::is_same< ReaderValueOrArray_t< T >, TTreeReaderValue< T >>::value, T, ExtractType_t< T >>::type ProxyParam_t
Definition: TDFNodes.hxx:134
double T(double x)
Definition: ChebyshevPol.h:34
unsigned int GetNSlots() const
Definition: TDFNodes.hxx:389
void PartialReport() const final
Definition: TDFNodes.hxx:444
TH1 * h
Definition: legend2.C:5
std::vector< std::unique_ptr< Ret_t > > fLastResultPtr
Definition: TDFNodes.hxx:298
fill
Definition: fit1_py.py:6
void Update(unsigned int slot, Long64_t entry) final
Definition: TDFNodes.hxx:325
void PartialReport() const
End of recursive chain of calls, does nothing.
Definition: TDFNodes.hxx:96
const ColumnNames_t GetTmpBranches() const
Definition: TDFNodes.hxx:80
std::vector< TDFInternal::TDFValueTuple_t< BranchTypes_t > > fValues
Definition: TDFNodes.hxx:401
std::map< std::string, TmpBranchBasePtr_t > fBookedBranches
Definition: TDFNodes.hxx:55
void generate(R &r, TH1D *h)
Definition: piRandom.C:28
void Init(TTreeReader *r, unsigned int slot) final
Definition: TDFNodes.hxx:234
STL namespace.
const ColumnNames_t fBranches
Definition: TDFNodes.hxx:399
TAction(Helper &&h, const ColumnNames_t &bl, PrevDataFrame &pd)
Definition: TDFNodes.hxx:226
const ColumnNames_t fTmpBranches
Definition: TDFNodes.hxx:205
void Report() const final
Definition: TDFNodes.hxx:442
void MakeProxy(TTreeReader *r, const std::string &bn)
Definition: TDFNodes.hxx:149
const std::map< std::string, TmpBranchBasePtr_t > & GetBookedBranches() const
Definition: TDFNodes.hxx:83
std::shared_ptr< TFilterBase > FilterBasePtr_t
Definition: TDFNodes.hxx:44
typename TDFInternal::TFunctionTraits< FilterF >::Args_t BranchTypes_t
Definition: TDFNodes.hxx:395
Helper class that updates and returns TTree branches as well as TDataFrame temporary columns...
Definition: TDFNodes.hxx:130
typename TDFInternal::TFunctionTraits< F >::Ret_t Ret_t
Definition: TDFNodes.hxx:294
bool CheckFilters(unsigned int slot, Long64_t entry) final
Definition: TDFNodes.hxx:336
typename TDFInternal::TGenStaticSeq< BranchTypes_t::fgSize >::Type_t TypeInd_t
Definition: TDFNodes.hxx:293
std::shared_ptr< TLoopManager > GetSharedPtr()
Definition: TDFNodes.hxx:78
void SetTmpColumn(unsigned int slot, TCustomColumnBase *tmpColumn)
Definition: TDFNodes.hxx:553
const ColumnNames_t fTmpBranches
Definition: TDFNodes.hxx:366
typename TGenStaticSeq< BranchTypes_t::fgSize >::Type_t TypeInd_t
Definition: TDFNodes.hxx:218
Extracts data from a TTree.
const ColumnNames_t fBranches
Definition: TDFNodes.hxx:297
ActionBaseVec_t fBookedActions
Definition: TDFNodes.hxx:52
PrevDataFrame & fPrevData
Definition: TDFNodes.hxx:222
std::vector< FilterBasePtr_t > FilterBaseVec_t
Definition: TDFNodes.hxx:45
TCustomColumn(std::string_view name, F &&expression, const ColumnNames_t &bl, PrevData &pd)
Definition: TDFNodes.hxx:305
void PartialReport() const final
Definition: TDFNodes.hxx:538
unsigned int GetNSlots() const
Definition: TDFNodes.hxx:492
RooArgSet S(const RooAbsArg &v1)
TRange(unsigned int start, unsigned int stop, unsigned int stride, PrevData &pd)
Definition: TDFNodes.hxx:500
#define F(x, y, z)
bool CheckFilterHelper(unsigned int slot, Long64_t entry, TDFInternal::TStaticSeq< S... >)
Definition: TDFNodes.hxx:430
const unsigned int fNSlots
Number of thread slots used by this node, inherited from parent node.
Definition: TDFNodes.hxx:270
unsigned int GetNSlots() const
Definition: TDFNodes.hxx:213
TRandom2 r(17)
std::vector< RangeBasePtr_t > RangeBaseVec_t
Definition: TDFNodes.hxx:48
std::vector< ActionBasePtr_t > ActionBaseVec_t
Definition: TDFNodes.hxx:40
std::shared_ptr< TCustomColumnBase > TmpBranchBasePtr_t
Definition: TDFNodes.hxx:42
TLoopManager * fImplPtr
A raw pointer to the TLoopManager at the root of this functional graph.
Definition: TDFNodes.hxx:364
void Exec(unsigned int slot, Long64_t entry, TStaticSeq< S... >)
Definition: TDFNodes.hxx:247
void SetTree(std::shared_ptr< TTree > tree)
Definition: TDFNodes.hxx:97
std::vector< TDFInternal::TDFValueTuple_t< BranchTypes_t > > fValues
Definition: TDFNodes.hxx:302
std::tuple< TColumnValue< BranchTypes >... > type
Definition: TDFNodes.hxx:194
unsigned int GetNSlots() const
Definition: TDFNodes.hxx:92
unsigned int GetNSlots() const
Definition: TDFNodes.hxx:287
typename TDFInternal::TFunctionTraits< F >::Args_t BranchTypes_t
Definition: TDFNodes.hxx:292
void Reset(Detail::TBranchProxy *x)
FilterBaseVec_t fBookedNamedFilters
Definition: TDFNodes.hxx:54
TFilter(FilterF &&f, const ColumnNames_t &bl, PrevDataFrame &pd, std::string_view name="")
Definition: TDFNodes.hxx:404
double f(double x)
virtual const std::type_info & GetTypeId() const =0
const unsigned int fNSlots
Number of thread slots used by this node, inherited from parent node.
Definition: TDFNodes.hxx:479
Describe directory structure in memory.
Definition: TDirectory.h:34
int type
Definition: TGX11.cxx:120
unsigned long long ULong64_t
Definition: RtypesCore.h:70
const unsigned int fNSlots
Number of thread slots used by this node.
Definition: TDFNodes.hxx:206
void Run(unsigned int slot, Long64_t entry) final
Definition: TDFNodes.hxx:240
TLoopManager * fImplPtr
A raw pointer to the TLoopManager at the root of this functional graph.
Definition: TDFNodes.hxx:467
const ColumnNames_t fDefaultBranches
Definition: TDFNodes.hxx:60
void * GetValuePtr(unsigned int slot) final
Definition: TDFNodes.hxx:323
std::shared_ptr< TDFInternal::TActionBase > ActionBasePtr_t
Definition: TDFNodes.hxx:39
TLoopManager * fImplPtr
A raw pointer to the TLoopManager at the root of this functional graph.
Definition: TDFNodes.hxx:264
typedef void((*Func_t)())
Long64_t GetNEmptyEntries() const
Definition: TDFNodes.hxx:85
typename TDFInternal::TGenStaticSeq< BranchTypes_t::fgSize >::Type_t TypeInd_t
Definition: TDFNodes.hxx:396
void Report() const final
Definition: TDFNodes.hxx:536
unsigned int GetNSlots()
Definition: TDFUtils.cxx:125
const ColumnNames_t fBranches
Definition: TDFNodes.hxx:221
void PartialReport() const final
Definition: TDFNodes.hxx:353
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:78
std::vector< std::shared_ptr< bool > > fResProxyReadiness
Definition: TDFNodes.hxx:57
void Init(TTreeReader *r, unsigned int slot) final
Definition: TDFNodes.hxx:317
const unsigned int fNSlots
Number of thread slots used by this node, inherited from parent node.
Definition: TDFNodes.hxx:374
void UpdateHelper(unsigned int slot, Long64_t entry, TDFInternal::TStaticSeq< S... >, TDFInternal::TTypeList< BranchTypes... >)
Definition: TDFNodes.hxx:343
TLoopManager * fImplPtr
A raw pointer to the TLoopManager at the root of this functional graph.
Definition: TDFNodes.hxx:202
char name[80]
Definition: TGX11.cxx:109
virtual void * GetValuePtr(unsigned int slot)=0
std::shared_ptr< TRangeBase > RangeBasePtr_t
Definition: TDFNodes.hxx:47
bool CheckFilters(unsigned int slot, Long64_t entry) final
Ranges act as filters when it comes to selecting entries that downstream nodes should process...
Definition: TDFNodes.hxx:508