Logo ROOT   6.18/05
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
16#include "RtypesCore.h"
17#include "TError.h" // R_ASSERT
18
19#include <string>
20#include <vector>
21
22class TTreeReader;
23
24namespace ROOT {
25
26namespace RDF {
27class RCutFlowReport;
28} // ns RDF
29
30namespace Detail {
31namespace RDF {
33
34class RLoopManager;
35
36class RFilterBase : public RNodeBase {
37protected:
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
47public:
48 RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots,
49 const RDFInternal::RBookedCustomColumns &customColumns);
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 virtual void ClearValueReaders(unsigned int slot) = 0;
67 virtual void ClearTask(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::R::TRInterface & r
Definition: Object.C:4
#define R__ASSERT(e)
Definition: TError.h:96
const char * filters[]
char name[80]
Definition: TGX11.cxx:109
virtual void ClearValueReaders(unsigned int slot)=0
virtual void InitSlot(TTreeReader *r, unsigned int slot)=0
const unsigned int fNSlots
Number of thread slots used by this node, inherited from parent node.
Definition: RFilterBase.hxx:43
RDFInternal::RBookedCustomColumns fCustomColumns
Definition: RFilterBase.hxx:45
std::vector< ULong64_t > fRejected
Definition: RFilterBase.hxx:41
RFilterBase & operator=(const RFilterBase &)=delete
virtual void FillReport(ROOT::RDF::RCutFlowReport &) const
Definition: RFilterBase.cxx:35
virtual void AddFilterName(std::vector< std::string > &filters)=0
virtual void TriggerChildrenCount()=0
virtual void ClearTask(unsigned int slot)=0
std::string GetName() const
Definition: RFilterBase.cxx:30
std::vector< int > fLastResult
Definition: RFilterBase.hxx:39
RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots, const RDFInternal::RBookedCustomColumns &customColumns)
Definition: RFilterBase.cxx:17
std::vector< ULong64_t > fAccepted
Definition: RFilterBase.hxx:40
std::vector< Long64_t > fLastCheckedEntry
Definition: RFilterBase.hxx:38
The head node of a RDF computation graph.
Base class for non-leaf nodes of the computational graph.
Definition: RNodeBase.hxx:41
Encapsulates the columns defined by the user.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition: TTreeReader.h:44
basic_string_view< char > string_view
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
fill
Definition: fit1_py.py:6