27#include <unordered_map>
38namespace GraphDrawing {
39std::shared_ptr<GraphNode>
44 const std::vector<std::string> &prevNodeDefines,
45 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap);
57template <
typename FilterF,
typename PrevNodeRaw>
60 using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
64 using PrevNode_t = std::conditional_t<std::is_same<PrevNodeRaw, RJittedFilter>::value,
RFilterBase, PrevNodeRaw>;
68 std::vector<std::array<RColumnReaderBase *, ColumnTypes_t::list_size>>
fValues;
75 const std::string &variationName =
"nominal")
76 :
RFilterBase(pd->GetLoopManagerUnchecked(),
name, pd->GetLoopManagerUnchecked()->GetNSlots(), colRegister,
77 columns, pd->GetVariations(), variationName),
78 fFilter(std::move(
f)), fValues(pd->GetLoopManagerUnchecked()->GetNSlots()), fPrevNodePtr(std::move(pd)),
79 fPrevNode(*fPrevNodePtr)
81 fLoopManager->Register(
this);
89 fLoopManager->Deregister(
this);
94 if (entry != fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()]) {
95 if (!fPrevNode.CheckFilters(slot, entry)) {
97 fLastResult[slot * RDFInternal::CacheLineStep<int>()] =
false;
101 passed ? ++fAccepted[slot * RDFInternal::CacheLineStep<ULong64_t>()]
102 : ++fRejected[slot * RDFInternal::CacheLineStep<ULong64_t>()];
103 fLastResult[slot * RDFInternal::CacheLineStep<int>()] = passed;
105 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = entry;
107 return fLastResult[slot * RDFInternal::CacheLineStep<int>()];
110 template <
typename... ColTypes, std::size_t... S>
113 return fFilter(fValues[slot][S]->
template Get<ColTypes>(entry)...);
123 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = -1;
131 fPrevNode.PartialReport(rep);
138 if (fNStopsReceived == fNChildren)
139 fPrevNode.StopProcessing();
146 if (fNChildren == 1 && fName.empty())
147 fPrevNode.IncrChildrenCount();
152 assert(!fName.empty());
153 fPrevNode.IncrChildrenCount();
158 fPrevNode.AddFilterName(
filters);
159 auto name = (HasName() ? fName :
"Unnamed Filter");
164 void FinalizeSlot(
unsigned int slot)
final { fValues[slot].fill(
nullptr); }
166 std::shared_ptr<RDFGraphDrawing::GraphNode>
167 GetGraph(std::unordered_map<
void *, std::shared_ptr<RDFGraphDrawing::GraphNode>> &visitedMap)
final
170 auto prevNode = fPrevNode.GetGraph(visitedMap);
171 const auto &prevColumns = prevNode->GetDefinedColumns();
178 if (!thisNode->IsNew()) {
182 auto upmostNode = AddDefinesToGraph(thisNode, fColRegister, prevColumns, visitedMap);
185 thisNode->AddDefinedColumns(fColRegister.GetNames());
187 upmostNode->SetPrevNode(prevNode);
196 assert(variationName !=
"nominal");
201 auto it = fVariedFilters.find(variationName);
202 if (it != fVariedFilters.end())
205 auto prevNode = fPrevNodePtr;
206 if (
static_cast<RNodeBase *
>(fPrevNodePtr.get()) !=
static_cast<RNodeBase *
>(fLoopManager) &&
208 prevNode = std::static_pointer_cast<PrevNode_t>(prevNode->GetVariedFilter(variationName));
212 auto variedFilter = std::unique_ptr<RFilterBase>(
213 new RFilter(fFilter, fColumnNames, std::move(prevNode), fColRegister, fName, variationName));
214 auto e = fVariedFilters.insert({variationName, std::move(variedFilter)});
215 return e.first->second;
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
void InitSlot(TTreeReader *r, unsigned int slot) final
bool CheckFilterHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >)
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
void Report(ROOT::RDF::RCutFlowReport &rep) const final
RFilter(FilterF f, const ROOT::RDF::ColumnNames_t &columns, std::shared_ptr< PrevNode_t > pd, const RDFInternal::RColumnRegister &colRegister, std::string_view name="", const std::string &variationName="nominal")
bool CheckFilters(unsigned int slot, Long64_t entry) final
RFilter & operator=(const RFilter &)=delete
void IncrChildrenCount() final
const std::shared_ptr< PrevNode_t > fPrevNodePtr
std::conditional_t< std::is_same< PrevNodeRaw, RJittedFilter >::value, RFilterBase, PrevNodeRaw > PrevNode_t
RFilter(const RFilter &)=delete
std::make_index_sequence< ColumnTypes_t::list_size > TypeInd_t
void StopProcessing() final
void AddFilterName(std::vector< std::string > &filters) final
std::shared_ptr< RNodeBase > GetVariedFilter(const std::string &variationName) final
Return a clone of this Filter that works with values in the variationName "universe".
std::shared_ptr< RDFGraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< RDFGraphDrawing::GraphNode > > &visitedMap) final
typename CallableTraits< FilterF >::arg_types ColumnTypes_t
void TriggerChildrenCount() final
std::vector< std::array< RColumnReaderBase *, ColumnTypes_t::list_size > > fValues
Column readers per slot and per input column.
void PartialReport(ROOT::RDF::RCutFlowReport &rep) const final
A wrapper around a concrete RFilter, which forwards all calls to it RJittedFilter is the type of the ...
Base class for non-leaf nodes of the computational graph.
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,...
std::shared_ptr< GraphNode > CreateFilterNode(const ROOT::Detail::RDF::RFilterBase *filterPtr, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
std::shared_ptr< GraphNode > AddDefinesToGraph(std::shared_ptr< GraphNode > node, const RDFInternal::RColumnRegister &colRegister, const std::vector< std::string > &prevNodeDefines, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
bool IsStrInVec(const std::string &str, const std::vector< std::string > &vec)
std::array< RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> GetColumnReaders(unsigned int slot, TTreeReader *r, TypeList< ColTypes... >, const RColumnReadersInfo &colInfo, const std::string &variationName="nominal")
Create a group of column readers, one per type in the parameter pack.
std::vector< std::string > ColumnNames_t
ROOT type_traits extensions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Extract types from the signature of a callable object. See CallableTraits.
This type aggregates some of the arguments passed to GetColumnReaders.
Lightweight storage for a collection of types.