Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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::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::R::TRInterface & r
Definition Object.C:4
#define R__ASSERT(e)
Definition TError.h:120
const char * filters[]
char name[80]
Definition TGX11.cxx:110
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.
RDFInternal::RBookedDefines fDefines
std::vector< ULong64_t > fRejected
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
virtual void AddFilterName(std::vector< std::string > &filters)=0
virtual void TriggerChildrenCount()=0
std::string GetName() const
std::vector< int > fLastResult
std::vector< ULong64_t > fAccepted
std::vector< Long64_t > fLastCheckedEntry
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
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...