RDFAnalysis  0.1.1
Physics analysis with ROOT::RDataFrame
SchedulerBase Class Reference

Base class for the scheduler. More...

#include <SchedulerBase.h>

Inheritance diagram for SchedulerBase:
Scheduler< Detail >

Data Structures

struct  Action
 Helper struct to represent all the information that the scheduler needs to know about an action in order to form the ordering. More...
 
struct  RegionDef
 Helper struct to define a region. More...
 
struct  ScheduleNode
 Helper struct used to build and express the schedule. More...
 

Public Types

enum  ActionType { FILTER, VARIABLE, FILL, INVALID }
 Enum to describe the different types of action. More...
 

Public Member Functions

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...
 

Static Public Member Functions

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...
 

Protected Member Functions

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...
 

Detailed Description

Base class for the scheduler.

This is the class that does most of the heavy-lifting, being responsible for figuring out the order of the actions used.

Member Enumeration Documentation

enum ActionType

Enum to describe the different types of action.

Enumerator
FILTER 

A filter imposes a selection on the events it sees and can also create a branch in the tree structure.

VARIABLE 

A variable defines a new variable.

FILL 

A fill is required to return a SysResultPtr to a TObject.

INVALID 

Not a valid action, used to construct a placeholder action.

Member Function Documentation

void actionDefinesMultipleVariables ( const std::string &  name,
const std::vector< std::string > &  defined 
)
protected

Tell the scheduler that an action is defining multiple variables.

Parameters
nameThe name of the action
definedThe list of variables.
std::string actionTypeToString ( ActionType  type)
static

Convert an ActionType to a string.

void addAction ( const Action action,
const std::set< Action > &  dependencies 
)
protected

Add a new action to the record.

Parameters
actionThe action to add
dependenciesIts dependencies
Exceptions
std::runtime_errorIf that type/name combination exists
SchedulerBase::RegionDef & addRegion ( const std::string &  name,
const std::vector< std::string > &  filterList 
)

Add a region to be scheduled.

Parameters
nameThe name of the region to be added
filterListThe ordered list of filters to be added.
Exceptions
std::runtime_errorAn invalid region name is given. Invalid region names are the empty string '', 'ROOT' or any pre-existing region or filter name.
std::map< SchedulerBase::Action, SchedulerBase::Action > buildReplacementMap ( const std::set< Action > &  filters) const
protected

Look through a list of filters for any that satisfy each other.

Imagine an action that ends up with the dependencies (writing filters only) {pT > 100, n_B > 1, n_B > 2}. Clearly running both of the n_B selections is wasteful, and if scale factors are applied as part of those selections it might well be actively harmful. Given this set of inputs the return value of this function would be {n_B > 1 : n_B > 2}

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.

Parameters
filterThe filter
satisfiedOther filters that this filter satisfies.

For example, x == 4 clearly satisfies the filter x > 2 so any action that depends on this selection does not need to sequence 'x > 2' if 'x == 4' has already been scheduled.

float getCost ( const Action action) const

Get the cost of an action

Exceptions
std::out_of_rangeif the action is unknown.

const std::set< SchedulerBase::Action > & getDependencies ( const Action action) const

Get the dependency corresponding to an action.

Exceptions
std::out_of_rangeif the action is unknown.

ScheduleNode& getSchedule ( )
inline

Get the ROOT of the output filter schedule. Will be empty if schedule has not been called.

const ScheduleNode& getSchedule ( ) const
inline

Get the ROOT of the output filter schedule. Will be empty if schedule has not been called.

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.

Parameters
actionThe action to check for
candidatesCandidates that could have satisfied it.
considerSelfWhether or not to count action satsified if it occurs in candidates
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.

Parameters
actionThe action to check for
candidatesCandidates that could have satisfied it.
[out]satisfiedByIf the action has already been satisfied, fill this reference with the candidate that satisfied it
considerSelfWhether or not to count action satsified if it occurs in candidates
void printSchedule ( std::ostream &  os,
const ScheduleNode root 
)
static

Print a schedule to a graphviz file.

Parameters
osThe output stream
rootthe root node of the schedule
SchedulerBase::ScheduleNode rawSchedule ( ) const
protected

Build the 'raw' schedule.

Returns
The root node of the raw schedule

The raw schedule is derived only from the requested regions.

std::map<std::string, RegionDef>& regionDefs ( )
inline

Access the current region definitions.

const std::map<std::string, RegionDef>& regionDefs ( ) const
inline

(const) access the current region definitions

SchedulerBase::ScheduleNode & schedule ( const IBranchNamer namer)
protected

Build the schedule.

Parameters
namerIBranchNamer that provides the list of predefined variables.
Returns
A reference to the root node of the full schedule
const std::vector<std::string>& usedVariables ( ) const
inline

Get the variables used by this schedule. Will be empty if schedule has not been called.


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