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
16#include "ROOT/RDF/Utils.hxx" // ColumnNames_t
17#include "ROOT/RVec.hxx"
18#include "RtypesCore.h"
19
20#include <cassert>
21#include <string>
22#include <vector>
23
24class TTreeReader;
25
26namespace ROOT {
27
28namespace RDF {
29class RCutFlowReport;
30} // ns RDF
31
32namespace Detail {
33namespace RDF {
35
36class RLoopManager;
37
38class RFilterBase : public RNodeBase {
39protected:
40 std::vector<Long64_t> fLastCheckedEntry;
41 std::vector<int> fLastResult = {true}; // std::vector<bool> cannot be used in a MT context safely
42 std::vector<ULong64_t> fAccepted = {0};
43 std::vector<ULong64_t> fRejected = {0};
44 const std::string fName;
47 /// The nth flag signals whether the nth input column is a custom column or not.
49
50public:
51 RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots,
52 const RDFInternal::RBookedDefines &defines, const ColumnNames_t &columns);
53 RFilterBase &operator=(const RFilterBase &) = delete;
54
55 virtual ~RFilterBase();
56
57 virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
58 bool HasName() const;
59 std::string GetName() const;
60 virtual void FillReport(ROOT::RDF::RCutFlowReport &) const;
61 virtual void TriggerChildrenCount() = 0;
62 virtual void ResetReportCount()
63 {
64 assert(!fName.empty()); // this method is to only be called on named filters
65 // fAccepted and fRejected could be different than 0 if this is not the first event-loop run using this filter
66 std::fill(fAccepted.begin(), fAccepted.end(), 0);
67 std::fill(fRejected.begin(), fRejected.end(), 0);
68 }
69 /// Clean-up operations to be performed at the end of a task.
70 virtual void FinaliseSlot(unsigned int slot) = 0;
71 virtual void InitNode();
72 virtual void AddFilterName(std::vector<std::string> &filters) = 0;
73};
74
75} // ns RDF
76} // ns Detail
77} // ns ROOT
78
79#endif // ROOT_RFILTERBASE
ROOT::R::TRInterface & r
Definition: Object.C:4
const char * filters[]
char name[80]
Definition: TGX11.cxx:110
const ROOT::RDF::ColumnNames_t fColumnNames
Definition: RFilterBase.hxx:45
ROOT::RVecB fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
Definition: RFilterBase.hxx:48
virtual void InitSlot(TTreeReader *r, unsigned int slot)=0
RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots, const RDFInternal::RBookedDefines &defines, const ColumnNames_t &columns)
Definition: RFilterBase.cxx:18
RDFInternal::RBookedDefines fDefines
Definition: RFilterBase.hxx:46
std::vector< ULong64_t > fRejected
Definition: RFilterBase.hxx:43
RFilterBase & operator=(const RFilterBase &)=delete
virtual void FinaliseSlot(unsigned int slot)=0
Clean-up operations to be performed at the end of a task.
virtual void FillReport(ROOT::RDF::RCutFlowReport &) const
Definition: RFilterBase.cxx:44
virtual void AddFilterName(std::vector< std::string > &filters)=0
virtual void TriggerChildrenCount()=0
std::string GetName() const
Definition: RFilterBase.cxx:39
std::vector< int > fLastResult
Definition: RFilterBase.hxx:41
std::vector< ULong64_t > fAccepted
Definition: RFilterBase.hxx:42
std::vector< Long64_t > fLastCheckedEntry
Definition: RFilterBase.hxx:40
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
std::vector< std::string > ColumnNames_t
Definition: Utils.hxx:35
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
fill
Definition: fit1_py.py:6