Project
Loading...
Searching...
No Matches
o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor > Struct Template Reference

BranchDef is used to define the mapping between inputs and branches. More...

#include <RootTreeWriter.h>

Public Types

using type = T
 
using key_type = KeyType
 
using key_extractor = KeyExtractor
 
using Fill = std::function< void(TBranch &branch, T const &)>
 
using FillExt = std::function< void(TBranch &branch, T const &, DataRef const &)>
 
using Spectator = std::function< void(T const &)>
 
using SpectatorExt = std::function< void(T const &, DataRef const &)>
 
using BranchCallback = std::variant< std::monostate, Fill, FillExt, Spectator, SpectatorExt >
 

Public Member Functions

 BranchDef (key_type key, std::string _branchName, size_t _nofBranches=1)
 
template<typename... Args>
 BranchDef (key_type key, std::string _branchName, Args &&... args)
 
template<typename... Args>
 BranchDef (std::vector< key_type > vec, std::string _branchName, Args &&... args)
 
template<typename Arg , typename... Args>
void init (Arg &&arg, Args &&... args)
 recursively init member variables from parameter pack
 
template<typename Arg >
void assertNoMatchingType (Arg &&arg)
 

Public Attributes

std::vector< key_typekeys
 
std::string branchName
 
size_t nofBranches = 1
 number of branches controlled by this definition for the same type
 
IndexExtractor getIndex = nullptr
 extractor function for the index for parallel branches
 
BranchNameMapper getName = nullptr
 get name of branch from base name and index
 
BranchCallback callback
 

Detailed Description

template<typename T, typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
struct o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >

BranchDef is used to define the mapping between inputs and branches.

A branch definition is always bound to a particular data type of the object to be written to tree branch. The type must be provided as template parameter.

KeyType and KeyExtractor:
Each branch definition is identified by a key which describes the input binding, i.e. it is used as argument in the input function. The RootTreeWriter uses std::string as internal key type to store a map of all dranch definitions. An extractor must be defined for the key type provided to BranchDef. In simple cases, defaults RootTreeWriter::key_type and RootTreeWriter::DefaultKeyExtractor can be used directly and are thus default template parameters.
Multiple branches:
The same definition can handle more than one branch as target for writing the objects, which is indicated by specifying the number of branches as parameter. The mapping of input objects to branch names is provided by the two callbacks getIndex and getName. The getIndex callback may extract the relavent information from the data object e.g. from the header stack and returns an index. The getName callback must return the branch name for writing based on this index.
Multiple branches of identical data type:
Multiple branches of identical data type can be served by one branch definition simply using a vector of inputs. Again, number of branches and getIndex and getName callbacks need to be provided
Multiple inputs:
The ability to serve more than one input can be used to write all data to the same branch, the exact behavior is controlled by the callbacks.

branch specification for the RootTreeWriter

Definition at line 182 of file RootTreeWriter.h.

Member Typedef Documentation

◆ BranchCallback

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::BranchCallback = std::variant<std::monostate, Fill, FillExt, Spectator, SpectatorExt>

Definition at line 199 of file RootTreeWriter.h.

◆ Fill

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::Fill = std::function<void(TBranch& branch, T const&)>

Definition at line 195 of file RootTreeWriter.h.

◆ FillExt

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::FillExt = std::function<void(TBranch& branch, T const&, DataRef const&)>

Definition at line 196 of file RootTreeWriter.h.

◆ key_extractor

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::key_extractor = KeyExtractor

Definition at line 185 of file RootTreeWriter.h.

◆ key_type

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::key_type = KeyType

Definition at line 184 of file RootTreeWriter.h.

◆ Spectator

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::Spectator = std::function<void(T const&)>

Definition at line 197 of file RootTreeWriter.h.

◆ SpectatorExt

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::SpectatorExt = std::function<void(T const&, DataRef const&)>

Definition at line 198 of file RootTreeWriter.h.

◆ type

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
using o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::type = T

Definition at line 183 of file RootTreeWriter.h.

Constructor & Destructor Documentation

◆ BranchDef() [1/3]

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::BranchDef ( key_type  key,
std::string  _branchName,
size_t  _nofBranches = 1 
)
inline

simple constructor for single input and one branch the definition is ignored if number of branches is zero

Parameters
keyinput key
_branchNamename of the target branch
_nofBranchesnumber of branches

Definition at line 207 of file RootTreeWriter.h.

◆ BranchDef() [2/3]

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
template<typename... Args>
o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::BranchDef ( key_type  key,
std::string  _branchName,
Args &&...  args 
)
inline

constructor for single input and multiple output branches the definition is ignored if number of branches is zero

Parameters
keyinput key
_branchNamename of the target branch
_nofBranchesthe number of target branches
argsparameter pack can contain the following argument types: IndexExtractor: index callback BranchNameMapper: branch name callback Fill: fill handler Spectator: spectator handler

Definition at line 220 of file RootTreeWriter.h.

◆ BranchDef() [3/3]

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
template<typename... Args>
o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::BranchDef ( std::vector< key_type vec,
std::string  _branchName,
Args &&...  args 
)
inline

constructor for multiple inputs and multiple output branches the definition is ignored if number of branches is zero

Parameters
keyvector of input keys
_branchNamename of the target branch
_nofBranchesthe number of target branches
argsparameter pack can contain the following argument types: IndexExtractor: index callback BranchNameMapper: branch name callback Fill: fill handler Spectator: spectator handler

Definition at line 236 of file RootTreeWriter.h.

Member Function Documentation

◆ assertNoMatchingType()

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
template<typename Arg >
void o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::assertNoMatchingType ( Arg &&  arg)
inline

Definition at line 271 of file RootTreeWriter.h.

◆ init()

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
template<typename Arg , typename... Args>
void o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::init ( Arg &&  arg,
Args &&...  args 
)
inline

recursively init member variables from parameter pack

Definition at line 243 of file RootTreeWriter.h.

Member Data Documentation

◆ branchName

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
std::string o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::branchName

Definition at line 187 of file RootTreeWriter.h.

◆ callback

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
BranchCallback o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::callback

Definition at line 200 of file RootTreeWriter.h.

◆ getIndex

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
IndexExtractor o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::getIndex = nullptr

extractor function for the index for parallel branches

Definition at line 191 of file RootTreeWriter.h.

◆ getName

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
BranchNameMapper o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::getName = nullptr

get name of branch from base name and index

Definition at line 193 of file RootTreeWriter.h.

◆ keys

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
std::vector<key_type> o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::keys

Definition at line 186 of file RootTreeWriter.h.

◆ nofBranches

template<typename T , typename KeyType = key_type, typename KeyExtractor = DefaultKeyExtractor>
size_t o2::framework::RootTreeWriter::BranchDef< T, KeyType, KeyExtractor >::nofBranches = 1

number of branches controlled by this definition for the same type

Definition at line 189 of file RootTreeWriter.h.


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