Logo ROOT  
Reference Guide
RFilterBase.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 09/2018
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2018, 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_RFILTERBASE
12 #define ROOT_RFILTERBASE
13 
15 #include "ROOT/RDF/RNodeBase.hxx"
16 #include "RtypesCore.h"
17 #include "TError.h" // R_ASSERT
18 
19 #include <string>
20 #include <vector>
21 
22 class TTreeReader;
23 
24 namespace ROOT {
25 
26 namespace RDF {
27 class RCutFlowReport;
28 } // ns RDF
29 
30 namespace Detail {
31 namespace RDF {
33 
34 class RLoopManager;
35 
36 class RFilterBase : public RNodeBase {
37 protected:
38  std::vector<Long64_t> fLastCheckedEntry;
39  std::vector<int> fLastResult = {true}; // std::vector<bool> cannot be used in a MT context safely
40  std::vector<ULong64_t> fAccepted = {0};
41  std::vector<ULong64_t> fRejected = {0};
42  const std::string fName;
43  const unsigned int fNSlots; ///< Number of thread slots used by this node, inherited from parent node.
44 
46 
47 public:
48  RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots,
49  const RDFInternal::RBookedDefines &defines);
50  RFilterBase &operator=(const RFilterBase &) = delete;
51 
52  virtual ~RFilterBase();
53 
54  virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
55  bool HasName() const;
56  std::string GetName() const;
57  virtual void FillReport(ROOT::RDF::RCutFlowReport &) const;
58  virtual void TriggerChildrenCount() = 0;
59  virtual void ResetReportCount()
60  {
61  R__ASSERT(!fName.empty()); // this method is to only be called on named filters
62  // fAccepted and fRejected could be different than 0 if this is not the first event-loop run using this filter
63  std::fill(fAccepted.begin(), fAccepted.end(), 0);
64  std::fill(fRejected.begin(), fRejected.end(), 0);
65  }
66  /// Clean-up operations to be performed at the end of a task.
67  virtual void FinaliseSlot(unsigned int slot) = 0;
68  virtual void InitNode();
69  virtual void AddFilterName(std::vector<std::string> &filters) = 0;
70 };
71 
72 } // ns RDF
73 } // ns Detail
74 } // ns ROOT
75 
76 #endif // ROOT_RFILTERBASE
ROOT::Detail::RDF::RFilterBase
Definition: RFilterBase.hxx:36
filters
const char * filters[]
Definition: TGFileBrowser.cxx:61
ROOT::Detail::RDF::RFilterBase::~RFilterBase
virtual ~RFilterBase()
Definition: RFilterBase.cxx:23
ROOT::Detail::RDF::RFilterBase::FillReport
virtual void FillReport(ROOT::RDF::RCutFlowReport &) const
Definition: RFilterBase.cxx:35
fit1_py.fill
fill
Definition: fit1_py.py:6
ROOT::Detail::RDF::RFilterBase::fName
const std::string fName
Definition: RFilterBase.hxx:42
RBookedDefines.hxx
r
ROOT::R::TRInterface & r
Definition: Object.C:4
string_view
basic_string_view< char > string_view
Definition: libcpp_string_view.h:785
ROOT::Detail::RDF::RNodeBase
Base class for non-leaf nodes of the computational graph.
Definition: RNodeBase.hxx:41
ROOT::Internal::RDF::RBookedDefines
Encapsulates the columns defined by the user.
Definition: RBookedDefines.hxx:39
ROOT::Detail::RDF::RFilterBase::GetName
std::string GetName() const
Definition: RFilterBase.cxx:30
ROOT::Detail::RDF::RFilterBase::InitNode
virtual void InitNode()
Definition: RFilterBase.cxx:44
ROOT::Detail::RDF::RFilterBase::fNSlots
const unsigned int fNSlots
Number of thread slots used by this node, inherited from parent node.
Definition: RFilterBase.hxx:43
ROOT::Detail::RDF::RFilterBase::operator=
RFilterBase & operator=(const RFilterBase &)=delete
ROOT::Detail::RDF::RFilterBase::TriggerChildrenCount
virtual void TriggerChildrenCount()=0
ROOT::Detail::RDF::RFilterBase::HasName
bool HasName() const
Definition: RFilterBase.cxx:25
ROOT::Detail::RDF::RFilterBase::AddFilterName
virtual void AddFilterName(std::vector< std::string > &filters)=0
ROOT::Detail::RDF::RFilterBase::fRejected
std::vector< ULong64_t > fRejected
Definition: RFilterBase.hxx:41
TTreeReader
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition: TTreeReader.h:44
ROOT::Detail::RDF::RFilterBase::InitSlot
virtual void InitSlot(TTreeReader *r, unsigned int slot)=0
ROOT::Detail::RDF::RFilterBase::fLastCheckedEntry
std::vector< Long64_t > fLastCheckedEntry
Definition: RFilterBase.hxx:38
RNodeBase.hxx
RtypesCore.h
ROOT::Detail::RDF::RFilterBase::fDefines
RDFInternal::RBookedDefines fDefines
Definition: RFilterBase.hxx:45
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:120
ROOT::RDF::RCutFlowReport
Definition: RCutFlowReport.hxx:47
ROOT::Detail::RDF::RFilterBase::FinaliseSlot
virtual void FinaliseSlot(unsigned int slot)=0
Clean-up operations to be performed at the end of a task.
ROOT::Internal::RDF
Definition: RArrowDS.hxx:15
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Detail::RDF::RFilterBase::fAccepted
std::vector< ULong64_t > fAccepted
Definition: RFilterBase.hxx:40
ROOT::Detail::RDF::RFilterBase::RFilterBase
RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots, const RDFInternal::RBookedDefines &defines)
Definition: RFilterBase.cxx:17
ROOT::Detail::RDF::RFilterBase::fLastResult
std::vector< int > fLastResult
Definition: RFilterBase.hxx:39
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Detail::RDF::RLoopManager
The head node of a RDF computation graph.
Definition: RLoopManager.hxx:57
ROOT::Detail::RDF::RFilterBase::ResetReportCount
virtual void ResetReportCount()
Definition: RFilterBase.hxx:59
TError.h