RDFAnalysis
0.1.1
Physics analysis with ROOT::RDataFrame
|
Base class for the Node classes. More...
#include <NodeBase.h>
Data Structures | |
struct | NamerInitialiser |
Helper struct that forces the initialisation of the branch namer. More... | |
Public Member Functions | |
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... | |
NodeBase * | Define (const std::string &name, const std::string &expression) |
Define a new variable on this node. More... | |
NodeBase * | Define (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 IBranchNamer & | namer () 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... | |
virtual bool | isRoot () const =0 |
Is the node the root? More... | |
Protected Member Functions | |
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, RNode > | makeChildRNodes (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, RNode > | makeChildRNodes (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 | |
std::map< std::string, RNode > | m_rnodes |
The RNode objects, keyed by systematic. More... | |
std::unique_ptr< IBranchNamer > | m_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... | |
RNode * | m_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... | |
Base class for the Node classes.
This class contains everything that does not depend on the Detail parameter of the Node class. Many functions merely forward their calls onto the underlying ROOT::RNode objects, performing the necessary steps to allow for weights and systematics so you should consult the RDataFrame documentation for explanations of those functions.
|
protected |
Create the root node of the tree.
rnode | The RDataFrame that forms the base of the tree |
namer | The branch namer |
isMC | If true, set the 'MC' mode, otherwise the 'data' mode |
name | The name of the root node |
cutflowName | How the root node appears in the cutflow |
weight | Expression to calculate a weight. |
strategy | Weighting strategy for this weight |
|
protected |
Create the root node of the tree.
W | The functor used to calculate the weight |
rnode | The RDataFrame that forms the base of the tree |
namer | The branch namer |
isMC | If true, set the 'MC' mode, otherwise the 'data' mode |
name | The name of the root node |
cutflowName | How the root node appears in the cutflow |
w | Functor used to calculate the weight |
columns | The input columns for the weight |
strategy | Weighting strategy for this weight |
|
protected |
Create a child node.
parent | The parent of this node |
rnodes | This node's RNodes |
name | The name of this node |
cutflowName | How this node appears in cutflows |
weight | Expression to calculate the node weight |
strategy | Weighting strategy for this weight |
|
protected |
Create a child node.
W | The functor used to calculate the weight |
parent | The parent of this node |
rnodes | This node's RNodes |
name | The name of this node |
cutflowName | How this node appears in cutflows |
w | Functor used to calculate the weight |
columns | The input columns for the weight |
strategy | Weighting strategy for this weight |
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.
TrArgs | The types of the action's arguments |
T | The return type of the action |
Args | The types of the arguments before translation |
f | The action |
columns | The columns affected by the action |
args | The arguments to the action |
Most functions on the Node classes get routed through this or one of its overloads. It carries out the following operations:
The first parameter of f should be a ROOT::RNode&, this will be provided by this function and should not be included in args, as it will provide each systematically varied ROOT::RNode in turn.
|
inline |
Transmit a systematically varied action to the underlying ROOT::RNodes.
F | The function type |
Args | The argument types |
f | The action |
columns | The columns affected by the action |
args | The arguments to the action |
Overload for non-member functions, will forward the call to Node::Act<TrArgs, T, Args>.
std::map<std::string, T> Act | ( | T(RNode::*)(TrArgs...) | f, |
const ColumnNames_t & | columns, | ||
Args &&... | args | ||
) |
Transmit a systematically varied action to the underlying ROOT::RNodes.
TrArgs | The types of the action's arguments |
T | The return type of the action |
Args | The types of the arguments before translation |
f | The action |
columns | The columns affected by the action |
args | The arguments to the action |
Most functions on the Node classes get routed through this or one of its overloads. It carries out the following operations:
This overload is selected when f is a member function of ROOT::RNode. In this case is usually necessary to specify T and TrArgs in the call.
|
inline |
Specialised version of Node::Act for functions returning a ROOT::RDF::RResultPtr.
TrArgs | The types of the action's arguments |
T | The return type of the action, should be a ROOT::RDF::RResultPtr |
Args | The types of the arguments before translation |
U | The type wrapped by T |
f | The action |
columns | The columns affected by the action |
args | The arguments to the action |
This function wraps Act for cases where it returns an RResultPtr and wraps that return value in a SysResultPtr.
|
inline |
Specialised version of Node::Act for functions returning a ROOT::RDF::RResultPtr.
F | The type of the action |
T | The return type of the action, should be a ROOT::RDF::RResultPtr |
Args | The types of the arguments before translation |
U | The type wrapped by T |
f | The action |
columns | The columns affected by the action |
args | The arguments to the action |
This function wraps Act for cases where it returns an RResultPtr and wraps that return value in a SysResultPtr.
|
inline |
Specialised version of Node::Act for functions returning a ROOT::RDF::RResultPtr.
TrArgs | The types of the action's arguments |
T | The return type of the action, should be a ROOT::RDF::RResultPtr |
Args | The types of the arguments before translation |
U | The type wrapped by T |
f | The action |
columns | The columns affected by the action |
args | The arguments to the action |
This function wraps Act for cases where it returns an RResultPtr and wraps that return value in a SysResultPtr. This overload is selected when the action is a member function of ROOT::RNode.
|
inline |
Execute a user-defined accumulation function.
AccFun | The type of the accumulation function |
MergeFun | The type of the merging function |
U | The return type of the accumulation function |
aggregator | The accumulation function |
merger | The merging function |
columnName | The column for the funtion to act on |
aggIdentity | The identity |
|
inline |
Execute a user-defined accumulation function.
AccFun | The type of the accumulation function |
MergeFun | The type of the merging function |
U | The return type of the accumulation function |
aggregator | The accumulation function |
merger | The merging function |
columnName | The column for the funtion to act on |
|
inline |
Count the number of entries processed by this node.
|
inline |
Get the name in a cutflow.
enable_ifn_string_t<F, NodeBase*> Define | ( | const std::string & | name, |
F | f, | ||
const ColumnNames_t & | columns = {} |
||
) |
Define a new variable on this node.
F | The functor type |
name | The name of the column to define |
f | The functor |
columns | The input variables (if any) to the functor |
The new column's data type will be the return type of the functor
NodeBase * Define | ( | const std::string & | name, |
const std::string & | expression | ||
) |
Define a new variable on this node.
name | The name of the column to define |
expression | The string expression to interpret |
The new column's data type will be the return type of the JITted function
NodeBase * Define | ( | const std::string & | name, |
const std::string & | expression, | ||
const ColumnNames_t & | columns | ||
) |
Define a new variable on this node.
name | The name of the column to define |
expression | The string expression to interpret |
columns | The input variables to the expression |
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, 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.
F | The functor type |
Ret_t | The return type of the functor - must be a tuple |
N | The number of defined arguments |
names | The names of the defined variables |
f | The functor |
columns | The inputs to the functor |
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).
SysResultPtr<T> Fill | ( | const T & | model, |
const ColumnNames_t & | columns, | ||
const std::string & | weight = "" , |
||
WeightStrategy | strategy = WeightStrategy::Default |
||
) |
Fill an object on each event.
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 |
Note that right now this won't work if T doesn't inherit from TH1. TODO fix this! The method also assumes that the weight is always provided as the last input column for the RDF Fill Action. This is always true for types inheriting from TH1 but other objects (particularly user-defined ones) will behave differently. For these cases I will need to specialise the 'Book' action.
|
inline |
Get the name of the weight branch.
The name returned will be the base name, not resolved for any systematic variation. If there is no weight set the empty string will be returned.
|
inline |
Is this anonymous?
|
inline |
Was 'MC' mode activated?
|
pure virtual |
Is the node the root?
Implemented in Node< Detail >.
|
protected |
Create child RNodes to be used for a filter from this node.
F | The functor type |
f | The functor |
columns | The input variables to the functor |
cutflowName | The cutflow name of these nodes |
|
protected |
Create child RNodes to be used for a filter from this node.
expression | The expression to describe the filter |
cutflowName | The cutflow name of these nodes |
|
protected |
Create child RNodes to be used for a filter from this node.
expression | The expression to describe the filter |
columns | The input variables to the expression |
cutflowName | The cutflow name of these nodes |
The expression should have the column names replaced by placeholders like {idx} (where idx is the index of the branch in the columns vector).
|
inline |
Get the name.
|
inline |
The namer.
|
protected |
Internal function to name the weight branch.
|
inline |
Iterate over the objects defined on this.
|
inline |
(Const) iterate over all the objects defined on this
|
inline |
Get the RNode objects.
|
inline |
Get the RNode objects.
|
protected |
Set the weight on this node.
F | the functor type |
f | The functor |
columns | The input columns to f (if any) |
parent | The parent (if any) of this node |
strategy | The weighting strategy to apply |
|
protected |
Set the weight on this node.
expression | The expression to calculate the weight |
parent | The parent (if any) of this node |
strategy | The weighting strategy to apply |
|
protected |
Base case for unwinding multiple define calls.
|
protected |
Unwind multiple define calls.
|
protected |
The name in the cutflow.
|
protected |
Whether or not 'MC' mode was activated.
|
protected |
The Node's name.
|
protected |
The branch namer.
|
protected |
Helper struct to force early initialisation of the namer.
|
protected |
Any TObject pointers declared on this.
|
protected |
The RNode objects, keyed by systematic.
|
protected |
Keep a pointer to the ROOT RNode of the whole chain.
|
protected |
The weight on this node.