RDFAnalysis
0.1.1
Physics analysis with ROOT::RDataFrame
|
Job scheduler. More...
#include <Scheduler.h>
Data Structures | |
struct | Region |
Helper struct to define a region. More... | |
Public Types | |
using | detail_t = Detail |
The node detail type. More... | |
using | node_t = Node< Detail > |
The node type. More... | |
![]() | |
enum | ActionType { FILTER, VARIABLE, FILL, INVALID } |
Enum to describe the different types of action. More... | |
Public Member Functions | |||
Scheduler (node_t *root) | |||
Create the scheduler from a node. More... | |||
node_t * | root () | ||
Get the root node. After schedule has been called this will contain the whole data structure. More... | |||
ScheduleNode & | schedule (const std::string &graphFile="") | ||
Schedule the analysis. More... | |||
std::map< std::string, Region > & | regions () | ||
Get the string->region mapping. More... | |||
const std::map< std::string, Region > & | regions () const | ||
Get the string->region mapping. More... | |||
void | registerVariableImpl (const std::string &name, std::function< void(node_t *)> action, const std::set< std::string > &variables={}, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new variable. More... | |||
template<typename F > | |||
enable_ifn_string_t< F, void > | registerVariable (const std::string &name, F f, const ColumnNames_t &columns={}, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new variable definition. More... | |||
void | registerVariable (const std::string &name, const std::string &expression, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new variable definition. More... | |||
void | registerVariable (const std::string &name, const std::string &expression, const ColumnNames_t &columns, const std::set< std::string > &filters, float cost=0) | ||
Register a new variable definition. More... | |||
template<std::size_t N> | |||
void | registerVariablesImpl (const std::array< std::string, N > &names, std::function< void(node_t *)> action, const std::set< std::string > &variables={}, const std::set< std::string > &filters={}, float cost=0) | ||
Register a single action that defines multiple new variables. More... | |||
template<std::size_t N, typename F > | |||
enable_ifn_string_t< F, void > | registerVariables (const std::array< std::string, N > &names, F f, const ColumnNames_t &columns, const std::set< std::string > &filters={}, float cost=0) | ||
Register a single action that defines multiple new variables. More... | |||
void | registerFilterImpl (const std::string &name, std::function< node_t *(node_t *)> action, const std::set< std::string > &variables={}, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new filter. More... | |||
template<typename F > | |||
std::enable_if_t< std::is_convertible< typename ROOT::TTraits::CallableTraits< F >::ret_type, std::tuple< bool, float > >::value, void > | registerFilter (F f, const ColumnNames_t &columns, const std::string &name, const std::string &cutflowName="", WeightStrategy strategy=WeightStrategy::Default, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new filter. More... | |||
template<typename F > | |||
std::enable_if_t< std::is_convertible< typename ROOT::TTraits::CallableTraits< F >::ret_type, bool >::value, void > | registerFilter (F f, const ColumnNames_t &columns, const std::string &name, const std::string &cutflowName="", const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new filter. More... | |||
void | registerFilter (const std::string &expression, const std::string &name, const std::string &cutflowName="", const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new filter. More... | |||
template<typename F , typename W > | |||
std::enable_if_t<!std::is_convertible< F, std::string >::value &&!std::is_convertible< W, std::string >::value, void > | registerFilter (F f, const ColumnNames_t &columns, const std::string &name, const std::string &cutflowName, W w, const ColumnNames_t &weightColumns={}, WeightStrategy strategy=WeightStrategy::Default, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new filter. More... | |||
template<typename W > | |||
enable_ifn_string_t< W, void > | registerFilter (const std::string &expression, const std::string &name, const std::string &cutflowName, W w, const ColumnNames_t &weightColumns={}, WeightStrategy strategy=WeightStrategy::Default, const std::set< std::string > &filters={}, float cost=0) | ||
Register a new filter. More... | |||
void | registerFillImpl (const std::string &name, std::function< SysResultPtr< TObject >(node_t *)> action, const std::set< std::string > &variables={}, const std::set< std::string > &filters={}) | ||
Register a new fill. More... | |||
template<typename T > | |||
void | registerFill (const T &model, const ColumnNames_t &columns, const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default, const std::set< std::string > &filters={}) | ||
register a new fill More... | |||
![]() | |||
RegionDef & | addRegion (const std::string &name, const std::vector< std::string > &filterList) | ||
Add a region to be scheduled. More... | |||
std::map< std::string, RegionDef > & | regionDefs () | ||
Access the current region definitions. More... | |||
const std::map< std::string, RegionDef > & | regionDefs () const | ||
(const) access the current region definitions More... | |||
void | filterSatisfies (const std::string &filter, const std::vector< std::string > &satisfied) | ||
Tell the scheduler that a filter also satisfies the condition of other filters. More... | |||
ScheduleNode & | getSchedule () | ||
Get the ROOT of the output filter schedule. Will be empty if schedule has not been called. More... | |||
const ScheduleNode & | getSchedule () const | ||
Get the ROOT of the output filter schedule. Will be empty if schedule has not been called. More... | |||
const std::vector< std::string > & | usedVariables () const | ||
Get the variables used by this schedule. Will be empty if schedule has not been called. More... | |||
const std::set< Action > & | getDependencies (const Action &action) const | ||
Get the dependency corresponding to an action.
| |||
float | getCost (const Action &action) const | ||
Get the cost of an action
| |||
bool | isActionSatisfiedBy (const Action &action, const std::set< Action > &candidates, bool considerSelf=true) const | ||
Check whether an action has already been satisfied by one of a list of candidates. More... | |||
bool | isActionSatisfiedBy (const Action &action, const std::set< Action > &candidates, Action &satisfiedBy, bool considerSelf=true) const | ||
Check whether an action has already been satisfied by one of a list of candidates. More... | |||
Protected Member Functions | |
void | addNode (const ScheduleNode &source, node_t *target, const std::string ¤tRegion="") |
Copy information across from the Schedule node to the actual node. More... | |
![]() | |
void | addAction (const Action &action, const std::set< Action > &dependencies) |
Add a new action to the record. More... | |
std::map< Action, Action > | buildReplacementMap (const std::set< Action > &filters) const |
Look through a list of filters for any that satisfy each other. More... | |
void | actionDefinesMultipleVariables (const std::string &name, const std::vector< std::string > &defined) |
Tell the scheduler that an action is defining multiple variables. More... | |
ScheduleNode & | schedule (const IBranchNamer &namer) |
Build the schedule. More... | |
ScheduleNode | rawSchedule () const |
Build the 'raw' schedule. More... | |
Protected Attributes | |
std::map< std::string, std::function< node_t *(node_t *)> > | m_filters |
The defined filters. More... | |
std::map< std::string, std::function< void(node_t *)> > | m_variables |
The defined variables. More... | |
std::map< std::string, std::function< SysResultPtr< TObject >node_t *)> > | m_fills |
The defined fills. More... | |
node_t * | m_root |
The root node. More... | |
ScheduleNamer | m_namer |
The namer. More... | |
std::map< std::string, Region > | m_regions |
After scheduling, pointers to the end nodes for all defined regions will be here. More... | |
Additional Inherited Members | |
![]() | |
static std::string | actionTypeToString (ActionType type) |
Convert an ActionType to a string. More... | |
static void | printSchedule (std::ostream &os, const ScheduleNode &root) |
Print a schedule to a graphviz file. More... | |
Job scheduler.
Detail | The type of node detail to be scheduled |
The scheduler is designed to take care of ordering your Define and Filter calls for you. Each such call has dependencies on both variables and filters which the scheduler takes into account when it is called.
using detail_t = Detail |
The node detail type.
Create the scheduler from a node.
root | The root node to attach everything else to. |
|
protected |
Copy information across from the Schedule node to the actual node.
|
inline |
Get the string->region mapping.
This map is filled by the schedule function so will not be valid before this has been called.
|
inline |
Get the string->region mapping.
This map is filled by the schedule function so will not be valid before this has been called.
void registerFill | ( | const T & | model, |
const ColumnNames_t & | columns, | ||
const std::string & | weight = "" , |
||
WeightStrategy | strategy = WeightStrategy::Default , |
||
const std::set< std::string > & | filters = {} |
||
) |
register a new fill
T | The type of object to be filled. |
model | The 'model' object to fill. |
columns | The columns to use for the object's Fill method. |
weight | The column containing the weight information |
strategy | The weight strategy to use |
filters | The filters that this depends on |
Note that right now this won't work if T doesn't inherit from TH1. TODO fix this!
void registerFillImpl | ( | const std::string & | name, |
std::function< SysResultPtr< TObject >(node_t *)> | action, | ||
const std::set< std::string > & | variables = {} , |
||
const std::set< std::string > & | filters = {} |
||
) |
Register a new fill.
name | The name of the new fill |
action | The Fill call ot use |
variables | THe variables that this depends on |
filters | The filters that this depends on |
Fills always get cost == 0, the ordering of fills is completely unimportant
std::enable_if_t<std::is_convertible<typename ROOT::TTraits::CallableTraits<F>::ret_type, std::tuple<bool, float> >::value, void> registerFilter | ( | F | f, |
const ColumnNames_t & | columns, | ||
const std::string & | name, | ||
const std::string & | cutflowName = "" , |
||
WeightStrategy | strategy = WeightStrategy::Default , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new filter.
F | The functor type |
f | The functor |
columns | The input variables to the functor |
name | The name of both the new filter and the node it creates |
cutflowName | How the new node appears in the cutflow |
strategy | Weighting strategy for this weight |
filters | The filters that this depends on |
cost | The estimated cost of this action |
In this overload the functor calculates the pass decision and the weight in one go, return std::make_tuple(pass, weight).
std::enable_if_t<std::is_convertible<typename ROOT::TTraits::CallableTraits<F>::ret_type, bool>::value, void> registerFilter | ( | F | f, |
const ColumnNames_t & | columns, | ||
const std::string & | name, | ||
const std::string & | cutflowName = "" , |
||
const std::string & | weight = "" , |
||
WeightStrategy | strategy = WeightStrategy::Default , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new filter.
F | The functor type |
f | The functor |
columns | The input variables to the functor |
name | The name of both the new filter and the node it creates |
cutflowName | How the new node appears in the cutflow |
weight | Expression to calculate the node weight |
strategy | Weighting strategy for this weight |
filters | The filters that this depends on |
cost | The estimated cost of this action |
void registerFilter | ( | const std::string & | expression, |
const std::string & | name, | ||
const std::string & | cutflowName = "" , |
||
const std::string & | weight = "" , |
||
WeightStrategy | strategy = WeightStrategy::Default , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new filter.
expression | The expression to describe the filter |
name | The name of both the new filter and the node it creates |
cutflowName | How the new node appears in the cutflow |
weight | Expression to calculate the node weight |
strategy | Weighting strategy for this weight |
filters | The filters that this depends on |
cost | The estimated cost of this action |
std::enable_if_t<!std::is_convertible<F, std::string>::value && !std::is_convertible<W, std::string>::value, void> registerFilter | ( | F | f, |
const ColumnNames_t & | columns, | ||
const std::string & | name, | ||
const std::string & | cutflowName, | ||
W | w, | ||
const ColumnNames_t & | weightColumns = {} , |
||
WeightStrategy | strategy = WeightStrategy::Default , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new filter.
F | The functor type |
W | The functor type used for the weight |
f | The functor |
columns | The input variables to the functor |
name | The name of both the new filter and the node it creates |
cutflowName | How the new node appears in the cutflow |
w | The functor used to calculate the weight |
weightColumns | The input variables to the weight functor |
strategy | Weighting strategy for this weight |
filters | The filters that this depends on |
cost | The estimated cost of this action |
enable_ifn_string_t<W, void> registerFilter | ( | const std::string & | expression, |
const std::string & | name, | ||
const std::string & | cutflowName, | ||
W | w, | ||
const ColumnNames_t & | weightColumns = {} , |
||
WeightStrategy | strategy = WeightStrategy::Default , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new filter.
W | The functor type used for the weight |
expression | The expression to describe the filter |
name | The name of both the new filter and the node it creates |
cutflowName | How the new node appears in the cutflow |
w | The functor used to calculate the weight |
weightColumns | The input variables to the weight functor |
strategy | Weighting strategy for this weight |
filters | The filters that this depends on |
cost | The estimated cost of this action |
void registerFilterImpl | ( | const std::string & | name, |
std::function< node_t *(node_t *)> | action, | ||
const std::set< std::string > & | variables = {} , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new filter.
name | The name of the new filter |
action | The Define call to use |
variables | The variables that this depends on |
filters | The filters that this depends on |
cost | The estimated cost of this action |
Note that the name of this filter can be different from the name of the Node object(s) it creates. This is to allow for dependencies involving anonymous nodes.
enable_ifn_string_t<F, void> registerVariable | ( | const std::string & | name, |
F | f, | ||
const ColumnNames_t & | columns = {} , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new variable definition.
F | The functor type |
name | The name of the column to define |
f | The functor |
columns | The input variables (if any) to the functor |
filters | Any filters that this depends on |
cost | A cost estimate for this action |
void registerVariable | ( | const std::string & | name, |
const std::string & | expression, | ||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new variable definition.
name | The name of the column to define |
expression | The string expression to interpret |
filters | Any filters that this depends on |
cost | A cost estimate for this action |
void registerVariable | ( | const std::string & | name, |
const std::string & | expression, | ||
const ColumnNames_t & | columns, | ||
const std::set< std::string > & | filters, | ||
float | cost = 0 |
||
) |
Register a new variable definition.
name | The name of the column to define |
expression | The string expression to interpret |
columns | The input variables (if any) to the functor |
filters | Any filters that this depends on |
cost | A cost estimate for this action |
void registerVariableImpl | ( | const std::string & | name, |
std::function< void(node_t *)> | action, | ||
const std::set< std::string > & | variables = {} , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a new variable.
name | The name of the new variable |
action | The Define call to use |
variables | The variables that this depends on |
filters | The filters that this depends on |
cost | The estimate cost of this action |
enable_ifn_string_t<F, void> registerVariables | ( | const std::array< std::string, N > & | names, |
F | f, | ||
const ColumnNames_t & | columns, | ||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a single action that defines multiple new variables.
F | The functor type |
N | The number of defined arguments |
names | The names of the defined variables |
f | The functor |
columns | The inputs to the functor |
filters | The filters that this depends on |
cost | The estimate cost of this action |
void registerVariablesImpl | ( | const std::array< std::string, N > & | names, |
std::function< void(node_t *)> | action, | ||
const std::set< std::string > & | variables = {} , |
||
const std::set< std::string > & | filters = {} , |
||
float | cost = 0 |
||
) |
Register a single action that defines multiple new variables.
N | The number of variables defined |
names | The names of the new variables |
action | The Define call to use |
variables | The variables that this depends on |
filters | The filters that this depends on |
cost | The estimate cost of this action |
|
inline |
Get the root node. After schedule has been called this will contain the whole data structure.
ScheduleNode& schedule | ( | const std::string & | graphFile = "" | ) |
Schedule the analysis.
graphFile | If set, write the schedule to this file. |
|
protected |
The defined fills.
|
protected |
The namer.
|
protected |
After scheduling, pointers to the end nodes for all defined regions will be here.
|
protected |
The root node.
|
protected |
The defined variables.