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 "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 ~RFilterBase() override;
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
ROOT::RVecB fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
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
RFilterBase & operator=(const RFilterBase &)=delete
virtual void FillReport(ROOT::RDF::RCutFlowReport &) const
virtual void TriggerChildrenCount()=0
std::string fVariation
This indicates for what variation this filter evaluates values.
std::string GetName() const
std::vector< int > fLastResult
std::unordered_map< std::string, std::shared_ptr< RFilterBase > > fVariedFilters
RDFInternal::RColumnRegister fColRegister
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:43
A binder for user-defined columns, variations and aliases.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition TTreeReader.h:44
std::vector< std::string > ColumnNames_t
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.