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