Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RJittedFilter.cxx
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
15
16#include <cassert>
17
18using namespace ROOT::Detail::RDF;
19
20RJittedFilter::RJittedFilter(RLoopManager *lm, std::string_view name, const std::vector<std::string> &variations)
21 : RFilterBase(lm, name, lm->GetNSlots(), RDFInternal::RColumnRegister(lm), /*columnNames*/ {}, variations)
22{
23 // Jitted nodes of the computation graph (e.g. RJittedAction, RJittedDefine) usually don't need to register
24 // themselves with the RLoopManager: the _concrete_ nodes will be registered with the RLoopManager right before
25 // the event loop, at jitting time, and that is good enough.
26 // RJittedFilter is an exception: RLoopManager needs to know about what filters have been booked even before
27 // the event loop in order to return a correct list from RLoopManager::GetFiltersNames().
28 // So RJittedFilters register themselves with RLoopManager at construction time and deregister themselves
29 // in SetFilter, i.e. when they are sure that the concrete filter has been instantiated in jitted code and it has
30 // been registered with RLoopManager, making the RJittedFilter registration redundant.
31 fLoopManager->Register(this);
32}
33
35{
36 // This should be a no-op in most sane cases: the RJittedFilter should already have been deregistered in SetFilter.
37 // However, in the edge case in which the branch of the computation graph that included this RJittedFilter went out
38 // of scope before any event loop ran (e.g. because of bad code logic or a user that changed their mind during
39 // interactive usage), we need to make sure RJittedFilters get properly deregistered.
41}
42
43void RJittedFilter::SetFilter(std::unique_ptr<RFilterBase> f)
44{
45 // the concrete filter has been registered with RLoopManager on creation, so let's deregister ourselves
47 fConcreteFilter = std::move(f);
48}
49
50void RJittedFilter::InitSlot(TTreeReader *r, unsigned int slot)
51{
52 assert(fConcreteFilter != nullptr);
53 fConcreteFilter->InitSlot(r, slot);
54}
55
56bool RJittedFilter::CheckFilters(unsigned int slot, Long64_t entry)
57{
58 assert(fConcreteFilter != nullptr);
59 return fConcreteFilter->CheckFilters(slot, entry);
60}
61
63{
64 assert(fConcreteFilter != nullptr);
65 fConcreteFilter->Report(cr);
66}
67
69{
70 assert(fConcreteFilter != nullptr);
71 fConcreteFilter->PartialReport(cr);
72}
73
75{
76 assert(fConcreteFilter != nullptr);
77 fConcreteFilter->FillReport(cr);
78}
79
81{
82 assert(fConcreteFilter != nullptr);
83 fConcreteFilter->IncrChildrenCount();
84}
85
87{
88 assert(fConcreteFilter != nullptr);
89 fConcreteFilter->StopProcessing();
90}
91
93{
94 assert(fConcreteFilter != nullptr);
95 fConcreteFilter->ResetChildrenCount();
96}
97
99{
100 assert(fConcreteFilter != nullptr);
101 fConcreteFilter->TriggerChildrenCount();
102}
103
105{
106 assert(fConcreteFilter != nullptr);
107 fConcreteFilter->ResetReportCount();
108}
109
110void RJittedFilter::FinalizeSlot(unsigned int slot)
111{
112 assert(fConcreteFilter != nullptr);
113 fConcreteFilter->FinalizeSlot(slot);
114}
115
117{
118 assert(fConcreteFilter != nullptr);
119 fConcreteFilter->InitNode();
120}
121
122void RJittedFilter::AddFilterName(std::vector<std::string> &filters)
123{
124 if (fConcreteFilter == nullptr) {
125 // No event loop performed yet, but the JITTING must be performed.
127 }
128 fConcreteFilter->AddFilterName(filters);
129}
130
131std::shared_ptr<RDFGraphDrawing::GraphNode>
132RJittedFilter::GetGraph(std::unordered_map<void *, std::shared_ptr<RDFGraphDrawing::GraphNode>> &visitedMap)
133{
134 if (fConcreteFilter != nullptr) {
135 // Here the filter exists, so it can be served
136 return fConcreteFilter->GetGraph(visitedMap);
137 }
138 throw std::runtime_error("The Jitting should have been invoked before this method.");
139}
140
141std::shared_ptr<RNodeBase> RJittedFilter::GetVariedFilter(const std::string &variationName)
142{
143 assert(fConcreteFilter != nullptr);
144 return fConcreteFilter->GetVariedFilter(variationName);
145}
#define f(i)
Definition RSha256.hxx:104
long long Long64_t
Definition RtypesCore.h:69
const char * filters[]
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
void FillReport(ROOT::RDF::RCutFlowReport &) const final
void AddFilterName(std::vector< std::string > &filters) final
void Report(ROOT::RDF::RCutFlowReport &) const final
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
void InitSlot(TTreeReader *r, unsigned int slot) final
std::shared_ptr< RDFGraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< RDFGraphDrawing::GraphNode > > &visitedMap) final
RJittedFilter(RLoopManager *lm, std::string_view name, const std::vector< std::string > &variations)
std::unique_ptr< RFilterBase > fConcreteFilter
void PartialReport(ROOT::RDF::RCutFlowReport &) const final
bool CheckFilters(unsigned int slot, Long64_t entry) final
std::shared_ptr< RNodeBase > GetVariedFilter(const std::string &variationName) final
Return a clone of this node that acts as a Filter working with values in the variationName "universe"...
void SetFilter(std::unique_ptr< RFilterBase > f)
The head node of a RDF computation graph.
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
void Deregister(RDFInternal::RActionBase *actionPtr)
virtual RLoopManager * GetLoopManagerUnchecked()
Definition RNodeBase.hxx:72
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition TTreeReader.h:46