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 std::string fVariation; ///< This indicates for what variation this filter evaluates values.
50 std::unordered_map<std::string, std::shared_ptr<RFilterBase>> fVariedFilters;
51
52public:
53 RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots,
54 const RDFInternal::RColumnRegister &colRegister, const ColumnNames_t &columns,
55 const std::vector<std::string> &prevVariations, const std::string &variation = "nominal");
56 RFilterBase &operator=(const RFilterBase &) = delete;
57
58 virtual ~RFilterBase();
59
60 virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
61 bool HasName() const;
62 std::string GetName() const;
63 virtual void FillReport(ROOT::RDF::RCutFlowReport &) const;
64 virtual void TriggerChildrenCount() = 0;
65 virtual void ResetReportCount()
66 {
67 assert(!fName.empty()); // this method is to only be called on named filters
68 // fAccepted and fRejected could be different than 0 if this is not the first event-loop run using this filter
69 std::fill(fAccepted.begin(), fAccepted.end(), 0);
70 std::fill(fRejected.begin(), fRejected.end(), 0);
71 }
72 /// Clean-up operations to be performed at the end of a task.
73 virtual void FinalizeSlot(unsigned int slot) = 0;
74 virtual void InitNode();
75};
76
77} // ns RDF
78} // ns Detail
79} // ns ROOT
80
81#endif // ROOT_RFILTERBASE
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
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
virtual void FinalizeSlot(unsigned int slot)=0
Clean-up operations to be performed at the end of a task.
std::vector< ULong64_t > fRejected
Definition: RFilterBase.hxx:43
RFilterBase & operator=(const RFilterBase &)=delete
virtual void FillReport(ROOT::RDF::RCutFlowReport &) const
Definition: RFilterBase.cxx:50
RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots, const RDFInternal::RColumnRegister &colRegister, const ColumnNames_t &columns, const std::vector< std::string > &prevVariations, const std::string &variation="nominal")
Definition: RFilterBase.cxx:19
virtual void TriggerChildrenCount()=0
std::string fVariation
This indicates for what variation this filter evaluates values.
Definition: RFilterBase.hxx:49
std::string GetName() const
Definition: RFilterBase.cxx:45
std::vector< int > fLastResult
Definition: RFilterBase.hxx:41
std::unordered_map< std::string, std::shared_ptr< RFilterBase > > fVariedFilters
Definition: RFilterBase.hxx:50
RDFInternal::RColumnRegister fColRegister
Definition: RFilterBase.hxx:46
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:43
A binder for user-defined columns and aliases.
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
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
fill
Definition: fit1_py.py:6