27#include <unordered_map>
35using namespace ROOT::Detail::RDF;
39std::shared_ptr<GraphNode>
40CreateFilterNode(
const RFilterBase *filterPtr, std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap);
42std::shared_ptr<GraphNode>
AddDefinesToGraph(std::shared_ptr<GraphNode> node,
const RColumnRegister &colRegister,
43 const std::vector<std::string> &prevNodeDefines,
44 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap);
52using namespace ROOT::TypeTraits;
56template <
typename FilterF,
typename PrevNodeRaw>
59 using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
63 using PrevNode_t = std::conditional_t<std::is_same<PrevNodeRaw, RJittedFilter>::value,
RFilterBase, PrevNodeRaw>;
67 std::vector<std::array<RColumnReaderBase *, ColumnTypes_t::list_size>>
fValues;
74 const std::string &variationName =
"nominal")
99 if (!
fPrevNode.CheckFilters(slot, entry)) {
114 template <
typename ColType>
117 if (
auto *val =
fValues[slot][readerIdx]->
template TryGet<ColType>(entry))
120 throw std::out_of_range{
"RDataFrame: Filter could not retrieve value for column '" +
fColumnNames[readerIdx] +
121 "' for entry " + std::to_string(entry) +
122 ". You can use the DefaultValueFor operation to provide a default value, or "
123 "FilterAvailable/FilterMissing to discard/keep entries with missing values instead."};
126 template <
typename... ColTypes, std::size_t... S>
168 assert(!
fName.empty());
182 std::shared_ptr<RDFGraphDrawing::GraphNode>
183 GetGraph(std::unordered_map<
void *, std::shared_ptr<RDFGraphDrawing::GraphNode>> &visitedMap)
final
186 auto prevNode =
fPrevNode.GetGraph(visitedMap);
187 const auto &prevColumns = prevNode->GetDefinedColumns();
189 auto thisNode = RDFGraphDrawing::CreateFilterNode(
this, visitedMap);
194 if (!thisNode->IsNew()) {
198 auto upmostNode = AddDefinesToGraph(thisNode,
fColRegister, prevColumns, visitedMap);
201 thisNode->AddDefinedColumns(
fColRegister.GenerateColumnNames());
203 upmostNode->SetPrevNode(prevNode);
214 assert(variationName !=
"nominal");
226 prevNode = std::static_pointer_cast<PrevNode_t>(prevNode->GetVariedFilter(variationName));
230 auto variedFilter = std::unique_ptr<RFilterBase>(
232 auto e =
fVariedFilters.insert({variationName, std::move(variedFilter)});
233 return e.first->second;
Basic types used by ROOT and required by TInterpreter.
long long Long64_t
Portable signed long integer 8 bytes.
const ROOT::RDF::ColumnNames_t fColumnNames
ROOT::RVecB fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
std::vector< ULong64_t > fRejected
virtual void FillReport(ROOT::RDF::RCutFlowReport &) const
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")
std::string fVariation
This indicates for what variation this filter evaluates values.
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
void InitSlot(TTreeReader *r, unsigned int slot) final
auto GetValueChecked(unsigned int slot, std::size_t readerIdx, Long64_t entry) -> ColType &
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
RFilter & operator=(RFilter &&)=delete
const std::shared_ptr< PrevNode_t > fPrevNodePtr
RFilter(RFilter &&)=delete
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.
const std::vector< std::string > & GetVariations() const
virtual RLoopManager * GetLoopManagerUnchecked()
unsigned int fNStopsReceived
Number of times that a children node signaled to stop processing entries.
unsigned int fNChildren
Number of nodes of the functional graph hanging from this object.
RLoopManager * fLoopManager
std::vector< std::string > fVariations
List of systematic variations that affect this node.
A binder for user-defined columns, variations and aliases.
ROOT::Detail::CallableTraitsImpl< F > CallableTraits
Extract types from the signature of a callable object.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Special implementation of ROOT::RRangeCast for TCollection, including a check that the cast target ty...
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 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)
constexpr std::size_t CacheLineStep()
Stepping through CacheLineStep<T> values in a vector<T> brings you to a new cache line.
std::array< RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> GetColumnReaders(unsigned int slot, TTreeReader *treeReader, 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
This type aggregates some of the arguments passed to GetColumnReaders.
Lightweight storage for a collection of types.