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

Class to represent a single step in the analysis process. More...

#include <Node.h>

Inheritance diagram for Node< Detail >:
NodeBase

Public Types

using detail_t = Detail
 The type of the Detail on this node. More...
 

Public Member Functions

template<typename F >
enable_ifn_string_t< F, Node * > Define (const std::string &name, F f, const ColumnNames_t &columns={})
 Define a new variable on this node. More...
 
NodeDefine (const std::string &name, const std::string &expression)
 Define a new variable on this node. More...
 
NodeDefine (const std::string &name, const std::string &expression, const ColumnNames_t &columns)
 Define a new variable on this node. More...
 
template<std::size_t N, typename F , typename Ret_t = typename ROOT::TTraits::CallableTraits<F>::ret_type>
std::enable_if_t< N==std::tuple_size< Ret_t >::value, Node > * Define (const std::array< std::string, N > &names, F f, const ColumnNames_t &columns)
 Define several new variables on this node in a single statement. More...
 
template<typename F >
std::enable_if_t< std::is_convertible< typename ROOT::TTraits::CallableTraits< F >::ret_type, std::tuple< bool, float > >::value, Node * > Filter (F f, const ColumnNames_t &columns={}, const std::string &name="", const std::string &cutflowName="", WeightStrategy strategy=WeightStrategy::Default)
 Create a filter on this node. More...
 
template<typename F >
std::enable_if_t< std::is_convertible< typename ROOT::TTraits::CallableTraits< F >::ret_type, bool >::value, Node * > Filter (F f, const ColumnNames_t &columns={}, const std::string &name="", const std::string &cutflowName="", const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default)
 Create a filter on this node. More...
 
NodeFilter (const std::string &expression, const std::string &name="", const std::string &cutflowName="", const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default)
 Create a filter on this node. More...
 
template<typename F , typename W >
std::enable_if_t<!std::is_convertible< F, std::string >::value &&!std::is_convertible< W, std::string >::value, Node * > Filter (F f, const ColumnNames_t &columns, const std::string &name, const std::string &cutflowName, W w, const ColumnNames_t &weightColumns={}, WeightStrategy strategy=WeightStrategy::Default)
 Create a filter on this node. More...
 
template<typename W >
enable_ifn_string_t< W, Node * > Filter (const std::string &expression, const std::string &name, const std::string &cutflowName, W w, const ColumnNames_t &weightColumns={}, WeightStrategy strategy=WeightStrategy::Default)
 Create a filter on this node. More...
 
auto children ()
 Allow access to iterate over the child nodes. More...
 
auto children () const
 Allow (const) access to iterate over the child nodes. More...
 
Detail & detail ()
 Get the node details. More...
 
const Detail & detail () const
 (Const) get the node details More...
 
Nodeparent ()
 Get the parent of this node. More...
 
const Nodeparent () const
 (const) get the parent of this node More...
 
bool isRoot () const
 Is the node the root? More...
 
void run (ULong64_t printEvery)
 Trigger the run. More...
 
void run (ULong64_t printEvery, ULong64_t total)
 Trigger the run. More...
 
template<typename Monitor >
void run (Monitor monitor)
 Trigger the run. More...
 
- Public Member Functions inherited from NodeBase
template<typename F >
enable_ifn_string_t< F, NodeBase * > Define (const std::string &name, F f, const ColumnNames_t &columns={})
 Define a new variable on this node. More...
 
NodeBaseDefine (const std::string &name, const std::string &expression)
 Define a new variable on this node. More...
 
NodeBaseDefine (const std::string &name, const std::string &expression, const ColumnNames_t &columns)
 Define a new variable on this node. More...
 
template<std::size_t N, typename F , typename Ret_t = typename ROOT::TTraits::CallableTraits<F>::ret_type>
std::enable_if_t< N==std::tuple_size< Ret_t >::value, NodeBase * > Define (const std::array< std::string, N > &names, F f, const ColumnNames_t &columns)
 Define several new variables on this node in a single statement. More...
 
const std::string & getWeight () const
 Get the name of the weight branch. More...
 
template<typename T >
SysResultPtr< T > Fill (const T &model, const ColumnNames_t &columns, const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default)
 Fill an object on each event. More...
 
template<typename AccFun , typename MergeFun , typename ArgTypes = typename ROOT::TTraits::CallableTraits<AccFun>::arg_types, typename U = ROOT::TTraits::TakeFirstParameter_t<ArgTypes>>
SysResultPtr< U > Aggregate (AccFun aggregator, MergeFun merger, const std::string &columnName, const U &aggIdentity)
 Execute a user-defined accumulation function. More...
 
template<typename AccFun , typename MergeFun , typename ArgTypes = typename ROOT::TTraits::CallableTraits<AccFun>::arg_types, typename U = ROOT::TTraits::TakeFirstParameter_t<ArgTypes>>
SysResultPtr< U > Aggregate (AccFun aggregator, MergeFun merger, const std::string &columnName)
 Execute a user-defined accumulation function. More...
 
SysResultPtr< ULong64_t > Count ()
 Count the number of entries processed by this node. More...
 
template<typename... TrArgs, typename T , typename... Args>
std::map< std::string, T > Act (std::function< T(RNode &, TrArgs...)> f, const ColumnNames_t &columns, Args &&...args)
 Transmit a systematically varied action to the underlying ROOT::RNodes. More...
 
template<typename F , typename... Args, typename T = typename ROOT::TTraits::CallableTraits<F>::ret_type>
std::enable_if_t<!is_std_function< F >::value, std::map< std::string, T > > Act (F &&f, const ColumnNames_t &columns, Args &&...args)
 Transmit a systematically varied action to the underlying ROOT::RNodes. More...
 
template<typename T , typename... TrArgs, typename... Args>
std::map< std::string, T > Act (T(RNode::*f)(TrArgs...), const ColumnNames_t &columns, Args &&...args)
 Transmit a systematically varied action to the underlying ROOT::RNodes. More...
 
template<typename... TrArgs, typename T , typename... Args, typename U = typename T::Value_t>
SysResultPtr< U > ActResult (std::function< T(RNode &, TrArgs...)> f, const ColumnNames_t &columns, Args &&...args)
 Specialised version of Node::Act for functions returning a ROOT::RDF::RResultPtr. More...
 
template<typename F , typename... Args, typename T = typename ROOT::TTraits::CallableTraits<F>::ret_type, typename U = typename T::Value_t>
std::enable_if_t<!is_std_function< F >::value, SysResultPtr< U > > ActResult (F &&f, const ColumnNames_t &columns, Args &&...args)
 Specialised version of Node::Act for functions returning a ROOT::RDF::RResultPtr. More...
 
template<typename T , typename... TrArgs, typename... Args, typename U = typename T::Value_t>
SysResultPtr< U > ActResult (T(RNode::*f)(TrArgs...), const ColumnNames_t &columns, Args &&...args)
 Specialised version of Node::Act for functions returning a ROOT::RDF::RResultPtr. More...
 
const std::string & name () const
 Get the name. More...
 
const std::string & cutflowName () const
 Get the name in a cutflow. More...
 
bool isAnonymous () const
 Is this anonymous? More...
 
bool isMC () const
 Was 'MC' mode activated? More...
 
const std::map< std::string, RNode > & rnodes () const
 Get the RNode objects. More...
 
std::map< std::string, RNode > & rnodes ()
 Get the RNode objects. More...
 
const IBranchNamernamer () const
 The namer. More...
 
auto objects ()
 Iterate over the objects defined on this. More...
 
auto objects () const
 (Const) iterate over all the objects defined on this More...
 

Static Public Member Functions

static std::unique_ptr< NodecreateROOT (const RNode &rnode, std::unique_ptr< IBranchNamer > &&namer, bool isMC, const std::string &name="ROOT", const std::string &cutflowName="Number of events", const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default)
 Create the root node of the tree. More...
 

Additional Inherited Members

- Protected Member Functions inherited from NodeBase
template<std::size_t I, std::size_t N, typename... Elements>
std::enable_if_t< I!=0, void > unwindDefine (const std::array< std::string, N > &names, const std::string &fullName, const std::tuple< Elements... > *)
 Base case for unwinding multiple define calls. More...
 
template<std::size_t I, std::size_t N, typename... Elements>
std::enable_if_t< I==0, void > unwindDefine (const std::array< std::string, N > &names, const std::string &fullName, const std::tuple< Elements... > *)
 Unwind multiple define calls. More...
 
template<typename F >
enable_ifn_string_t< F, std::map< std::string, RNode > > makeChildRNodes (F f, const ColumnNames_t &columns={}, const std::string &cutflowName="")
 Create child RNodes to be used for a filter from this node. More...
 
std::map< std::string, RNodemakeChildRNodes (const std::string &expression, const std::string &cutflowName="")
 Create child RNodes to be used for a filter from this node. More...
 
std::map< std::string, RNodemakeChildRNodes (const std::string &expression, const ColumnNames_t &columns, const std::string &cutflowName="")
 Create child RNodes to be used for a filter from this node. More...
 
 NodeBase (const RNode &rnode, std::unique_ptr< IBranchNamer > &&namer, bool isMC, const std::string &name="ROOT", const std::string &cutflowName="Number of events", const std::string &weight="", WeightStrategy strategy=WeightStrategy::Default)
 Create the root node of the tree. More...
 
template<typename W >
 NodeBase (const RNode &rnode, std::unique_ptr< IBranchNamer > &&namer, bool isMC, const std::string &name, const std::string &cutflowName, W w, const ColumnNames_t &columns, WeightStrategy strategy=WeightStrategy::Default)
 Create the root node of the tree. More...
 
 NodeBase (NodeBase &parent, std::map< std::string, RNode > &&rnodes, const std::string &name, const std::string &cutflowName, const std::string &weight, WeightStrategy strategy=WeightStrategy::Default)
 Create a child node. More...
 
template<typename W >
 NodeBase (NodeBase &parent, std::map< std::string, RNode > &&rnodes, const std::string &name, const std::string &cutflowName, W w, const ColumnNames_t &columns, WeightStrategy strategy=WeightStrategy::Default)
 Create a child node. More...
 
template<typename F >
enable_ifn_string_t< F, std::string > setWeight (F f, const ColumnNames_t &columns, NodeBase *parent, WeightStrategy strategy)
 Set the weight on this node. More...
 
std::string setWeight (const std::string &expression, NodeBase *parent, WeightStrategy strategy)
 Set the weight on this node. More...
 
std::string nameWeight ()
 Internal function to name the weight branch. More...
 
- Protected Attributes inherited from NodeBase
std::map< std::string, RNodem_rnodes
 The RNode objects, keyed by systematic. More...
 
std::unique_ptr< IBranchNamerm_namer
 The branch namer. More...
 
NamerInitialiser m_namerInit
 Helper struct to force early initialisation of the namer. More...
 
bool m_isMC
 Whether or not 'MC' mode was activated. More...
 
std::string m_name
 The Node's name. More...
 
std::string m_cutflowName
 The name in the cutflow. More...
 
RNodem_rootRNode = nullptr
 Keep a pointer to the ROOT RNode of the whole chain. More...
 
std::string m_weight
 The weight on this node. More...
 
std::vector< SysResultPtr< TObject > > m_objects
 Any TObject pointers declared on this. More...
 

Detailed Description

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

Class to represent a single step in the analysis process.

Template Parameters
DetailClass to contain any extra information attached to the node.

For the purposes of this package an analysis is modeled as a tree structure, each selection forming a new node in the tree. Multiple selections can be defined from a single node, forming a branch in the tree at that point. Each node can have attached TObjects (created using the Fill function and accessed using the NodeBase::objects function) as well as additional objects that can be accessed using the details function.

The tree structure can be navigated through using the parent and children functions.

Member Typedef Documentation

using detail_t = Detail

The type of the Detail on this node.

Member Function Documentation

auto children ( )
inline

Allow access to iterate over the child nodes.

auto children ( ) const
inline

Allow (const) access to iterate over the child nodes.

static std::unique_ptr<Node> createROOT ( const RNode< Detail > &  rnode,
std::unique_ptr< IBranchNamer > &&  namer,
bool  isMC,
const std::string &  name = "ROOT",
const std::string &  cutflowName = "Number of events",
const std::string &  weight = "",
WeightStrategy  strategy = WeightStrategy::Default 
)
inlinestatic

Create the root node of the tree.

Parameters
rnodeThe RDataFrame that forms the base of the tree
namerThe branch namer
isMCWhether or not MC mode (weighting) should be used
nameThe name of the root node
cutflowNameHow the root node appears in the cutflow
weightExpression to calculate a weight.
strategyThe weight strategy
enable_ifn_string_t<F, Node*> Define ( const std::string &  name,
f,
const ColumnNames_t columns = {} 
)
inline

Define a new variable on this node.

Template Parameters
FThe functor type
Parameters
nameThe name of the column to define
fThe functor
columnsThe input variables (if any) to the functor
Returns
A non-owning pointer to this object.

The new column's data type will be the return type of the functor

Node* Define ( const std::string &  name,
const std::string &  expression 
)
inline

Define a new variable on this node.

Parameters
nameThe name of the column to define
expressionThe string expression to interpret
Returns
A non-owning pointer to this object.

The new column's data type will be the return type of the JITted function

Node* Define ( const std::string &  name,
const std::string &  expression,
const ColumnNames_t columns 
)
inline

Define a new variable on this node.

Parameters
nameThe name of the column to define
expressionThe string expression to interpret
columnsThe input variables to the expression
Returns
A non-owning pointer to this object.

The new column's data type will be the return type of the JITted function. The expression should have the column names replaced by placeholders like {idx} (where idx is the index of the branch in the columns vector).

std::enable_if_t<N==std::tuple_size<Ret_t>::value, Node>* Define ( const std::array< std::string, N > &  names,
f,
const ColumnNames_t columns 
)
inline

Define several new variables on this node in a single statement.

Template Parameters
NThe number of defined arguments
FThe functor type
Ret_tThe return type of the functor - must be a tuple
Parameters
namesThe names of the defined variables
fThe functor
columnsThe inputs to the functor
Returns
a non-owning pointer to this object.

Use this function where you need to return multiple variables from a single function. Note that the affecting systematics will be the same for all of the returned objects so make sure that this is appropriate. The functor should return a std::tuple with N different types and the names parameter should have exactly the same number of entries (else the code will not compile).

Detail& detail ( )
inline

Get the node details.

const Detail& detail ( ) const
inline

(Const) get the node details

std::enable_if_t<std::is_convertible<typename ROOT::TTraits::CallableTraits<F>::ret_type, std::tuple<bool, float> >::value, Node*> Filter ( f,
const ColumnNames_t columns = {},
const std::string &  name = "",
const std::string &  cutflowName = "",
WeightStrategy  strategy = WeightStrategy::Default 
)

Create a filter on this node.

Template Parameters
FThe functor type
Parameters
fThe functor
columnsThe input variables to the functor
nameThe name of the new node
cutflowNameHow the new node appears in the cutflow
strategyWeighting strategy for this weight

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, Node*> Filter ( f,
const ColumnNames_t columns = {},
const std::string &  name = "",
const std::string &  cutflowName = "",
const std::string &  weight = "",
WeightStrategy  strategy = WeightStrategy::Default 
)

Create a filter on this node.

Template Parameters
FThe functor type
Parameters
fThe functor
columnsThe input variables to the functor
nameThe name of the new node
cutflowNameHow the new node appears in the cutflow
weightExpression to calculate the node weight
strategyWeighting strategy for this weight

TODO - right now this introduces unnecessary systematic variations - there is no way to distinguish between systematics affecting the selection and systematics affecting the weight...

Node* Filter ( const std::string &  expression,
const std::string &  name = "",
const std::string &  cutflowName = "",
const std::string &  weight = "",
WeightStrategy  strategy = WeightStrategy::Default 
)

Create a filter on this node.

Parameters
expressionThe expression to describe the filter
nameThe name of the new node
cutflowNameHow the new node appears in the cutflow
weightExpression to calculate the node weight
strategyWeighting strategy for this weight
std::enable_if_t<!std::is_convertible<F, std::string>::value && !std::is_convertible<W, std::string>::value, Node*> Filter ( f,
const ColumnNames_t columns,
const std::string &  name,
const std::string &  cutflowName,
w,
const ColumnNames_t weightColumns = {},
WeightStrategy  strategy = WeightStrategy::Default 
)

Create a filter on this node.

Template Parameters
FThe functor type
WThe functor type used for the weight
Parameters
fThe functor
columnsThe input variables to the functor
nameThe name of the new node
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
enable_ifn_string_t<W, Node*> Filter ( const std::string &  expression,
const std::string &  name,
const std::string &  cutflowName,
w,
const ColumnNames_t weightColumns = {},
WeightStrategy  strategy = WeightStrategy::Default 
)

Create a filter on this node.

Template Parameters
WThe functor type used for the weight
Parameters
expressionThe expression to describe the filter
nameThe name of the new node
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
bool isRoot ( ) const
inlinevirtual

Is the node the root?

Implements NodeBase.

Node* parent ( )
inline

Get the parent of this node.

const Node* parent ( ) const
inline

(const) get the parent of this node

void run ( ULong64_t  printEvery)

Trigger the run.

Parameters
printEveryHow often to print to the screen
void run ( ULong64_t  printEvery,
ULong64_t  total 
)

Trigger the run.

Parameters
printEveryHow often to print to the screen
totalThe total number of events

This is different to the function above in that it prints as a fraction of the total.

void run ( Monitor  monitor)

Trigger the run.

Template Parameters
MonitorThe monitor type
Parameters
monitorThe monitor

Trigger the run, calling the operator()(unsigned int) of the monitor. The argument to this call is the slot number. If you are not running in a multi-threaded environment this will always be 0. You are responsible for the thread safety of this function!


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