RDFAnalysis  0.1.1
Physics analysis with ROOT::RDataFrame
Scheduler< Detail > Class Template Reference

Job scheduler. More...

#include <Scheduler.h>

Inheritance diagram for Scheduler< Detail >:
SchedulerBase

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...
 
- Public Types inherited from SchedulerBase
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_troot ()
 Get the root node. After schedule has been called this will contain the whole data structure. More...
 
ScheduleNodeschedule (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...
 
- Public Member Functions inherited from SchedulerBase
RegionDefaddRegion (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...
 
ScheduleNodegetSchedule ()
 Get the ROOT of the output filter schedule. Will be empty if schedule has not been called. More...
 
const ScheduleNodegetSchedule () 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.

Exceptions
std::out_of_rangeif the action is unknown.
More...
 
float getCost (const Action &action) const
 Get the cost of an action

Exceptions
std::out_of_rangeif the action is unknown.
More...
 
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 &currentRegion="")
 Copy information across from the Schedule node to the actual node. More...
 
- Protected Member Functions inherited from SchedulerBase
void addAction (const Action &action, const std::set< Action > &dependencies)
 Add a new action to the record. More...
 
std::map< Action, ActionbuildReplacementMap (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...
 
ScheduleNodeschedule (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_tm_root
 The root node. More...
 
ScheduleNamer m_namer
 The namer. More...
 
std::map< std::string, Regionm_regions
 After scheduling, pointers to the end nodes for all defined regions will be here. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SchedulerBase
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...
 

Detailed Description

template<typename Detail>
class RDFAnalysis::Scheduler< Detail >

Job scheduler.

Template Parameters
DetailThe 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.

Member Typedef Documentation

using detail_t = Detail

The node detail type.

using node_t = Node<Detail>

The node type.

Constructor & Destructor Documentation

Scheduler ( node_t root)
inline

Create the scheduler from a node.

Parameters
rootThe root node to attach everything else to.

Member Function Documentation

void addNode ( const ScheduleNode source,
node_t target,
const std::string &  currentRegion = "" 
)
protected

Copy information across from the Schedule node to the actual node.

std::map<std::string, Region>& regions ( )
inline

Get the string->region mapping.

This map is filled by the schedule function so will not be valid before this has been called.

const std::map<std::string, Region>& regions ( ) const
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

Template Parameters
TThe type of object to be filled.
Parameters
modelThe 'model' object to fill.
columnsThe columns to use for the object's Fill method.
weightThe column containing the weight information
strategyThe weight strategy to use
filtersThe 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.

Parameters
nameThe name of the new fill
actionThe Fill call ot use
variablesTHe variables that this depends on
filtersThe 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,
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.

Template Parameters
FThe functor type
Parameters
fThe functor
columnsThe input variables to the functor
nameThe name of both the new filter and the node it creates
cutflowNameHow the new node appears in the cutflow
strategyWeighting strategy for this weight
filtersThe filters that this depends on
costThe 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,
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.

Template Parameters
FThe functor type
Parameters
fThe functor
columnsThe input variables to the functor
nameThe name of both the new filter and the node it creates
cutflowNameHow the new node appears in the cutflow
weightExpression to calculate the node weight
strategyWeighting strategy for this weight
filtersThe filters that this depends on
costThe 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.

Parameters
expressionThe expression to describe the filter
nameThe name of both the new filter and the node it creates
cutflowNameHow the new node appears in the cutflow
weightExpression to calculate the node weight
strategyWeighting strategy for this weight
filtersThe filters that this depends on
costThe 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,
const ColumnNames_t columns,
const std::string &  name,
const std::string &  cutflowName,
w,
const ColumnNames_t weightColumns = {},
WeightStrategy  strategy = WeightStrategy::Default,
const std::set< std::string > &  filters = {},
float  cost = 0 
)

Register a new filter.

Template Parameters
FThe functor type
WThe functor type used for the weight
Parameters
fThe functor
columnsThe input variables to the functor
nameThe name of both the new filter and the node it creates
cutflowNameHow the new node appears in the cutflow
wThe functor used to calculate the weight
weightColumnsThe input variables to the weight functor
strategyWeighting strategy for this weight
filtersThe filters that this depends on
costThe 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,
const ColumnNames_t weightColumns = {},
WeightStrategy  strategy = WeightStrategy::Default,
const std::set< std::string > &  filters = {},
float  cost = 0 
)

Register a new filter.

Template Parameters
WThe functor type used for the weight
Parameters
expressionThe expression to describe the filter
nameThe name of both the new filter and the node it creates
cutflowNameHow the new node appears in the cutflow
wThe functor used to calculate the weight
weightColumnsThe input variables to the weight functor
strategyWeighting strategy for this weight
filtersThe filters that this depends on
costThe 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.

Parameters
nameThe name of the new filter
actionThe Define call to use
variablesThe variables that this depends on
filtersThe filters that this depends on
costThe 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,
const ColumnNames_t columns = {},
const std::set< std::string > &  filters = {},
float  cost = 0 
)

Register a new variable definition.

Template Parameters
FThe functor type
Parameters
nameThe name of the column to define
fThe functor
columnsThe input variables (if any) to the functor
filtersAny filters that this depends on
costA 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.

Parameters
nameThe name of the column to define
expressionThe string expression to interpret
filtersAny filters that this depends on
costA 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.

Parameters
nameThe name of the column to define
expressionThe string expression to interpret
columnsThe input variables (if any) to the functor
filtersAny filters that this depends on
costA 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.

Parameters
nameThe name of the new variable
actionThe Define call to use
variablesThe variables that this depends on
filtersThe filters that this depends on
costThe estimate cost of this action
enable_ifn_string_t<F, void> registerVariables ( const std::array< std::string, N > &  names,
f,
const ColumnNames_t columns,
const std::set< std::string > &  filters = {},
float  cost = 0 
)

Register a single action that defines multiple new variables.

Template Parameters
FThe functor type
NThe number of defined arguments
Parameters
namesThe names of the defined variables
fThe functor
columnsThe inputs to the functor
filtersThe filters that this depends on
costThe 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.

Template Parameters
NThe number of variables defined
Parameters
namesThe names of the new variables
actionThe Define call to use
variablesThe variables that this depends on
filtersThe filters that this depends on
costThe estimate cost of this action
node_t* root ( )
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.

Parameters
graphFileIf set, write the schedule to this file.

Field Documentation

std::map<std::string, std::function<SysResultPtr<TObject>node_t*)> > m_fills
protected

The defined fills.

std::map<std::string, std::function<node_t*(node_t*)> > m_filters
protected

The defined filters.

ScheduleNamer m_namer
protected

The namer.

std::map<std::string, Region> m_regions
protected

After scheduling, pointers to the end nodes for all defined regions will be here.

node_t* m_root
protected

The root node.

std::map<std::string, std::function<void(node_t*)> > m_variables
protected

The defined variables.


The documentation for this class was generated from the following file: