TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
Public Member Functions | List of all members
CollectionOrganizer Class Reference

Tracks the available collections, collection attributes, and solo branches in the dataframe while processing. More...

Public Member Functions

def __init__ (self, rdf)
 Constructor. More...
 
def AddBranch (self, b, btype='')
 Add a branch to track. More...
 
def AddCollection (self, c)
 Add a collection to tracking. More...
 
def Alias (self, alias, name)
 Add an alias for a solo branch, collection, or collection attribute. More...
 
def BuildCppCollection (self, collection, node, silent=True)
 Build the collection as a struct in C++ so that it's accessible to the RDataFrame loop. More...
 
def CollectionDefCheck (self, action_str, node)
 Checks if a collection C++ struct is needed in the action string. More...
 
def GetCollectionAttributes (self, c)
 Get all attributes of a collection. More...
 
def GetCollectionNames (self)
 Return the list of all collection names. More...
 

Detailed Description

Tracks the available collections, collection attributes, and solo branches in the dataframe while processing.

The initial set of branches will be read on startup and any new branch will be added accordingly. Collection names are deduced from the branch name by being the string before the first underscore (if there is an underscore).

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  rdf 
)

Constructor.

Parameters
rdf(RDataFrame): RDataFrame from which to organize.

Member Function Documentation

◆ AddBranch()

def AddBranch (   self,
  b,
  btype = '' 
)

Add a branch to track.

Will deduce if it is in a collection in which case, the attribute will be added to the tracked collection.

Parameters
b(str): Branch name
btype(str, optional): Type of branch. Defaults to '' but should only be left this way in rare cases.

◆ AddCollection()

def AddCollection (   self,
  c 
)

Add a collection to tracking.

Parameters
c(str): Collection name only.

◆ Alias()

def Alias (   self,
  alias,
  name 
)

Add an alias for a solo branch, collection, or collection attribute.

Parameters
alias(str): Alias name.
name(str): Full branch name or a collection name. If an alias for a collection attribute is desired, provide the full branch name (ie. collectionName_attributeName).
Exceptions
ValueErrorEntries do not exist so an alias cannot be added.

◆ BuildCppCollection()

def BuildCppCollection (   self,
  collection,
  node,
  silent = True 
)

Build the collection as a struct in C++ so that it's accessible to the RDataFrame loop.

Parameters
collection(str): Collection name.
node(Node): Node on which to act.
silent(bool, optional): Whether output should be silenced. Defaults to True.
Exceptions
RuntimeErrorCollection already built.
Returns
Node Manipulated node with the collection struct now defined.

◆ CollectionDefCheck()

def CollectionDefCheck (   self,
  action_str,
  node 
)

Checks if a collection C++ struct is needed in the action string.

If in the string but not defined, this function builds it. Does not apply the action.

Parameters
action_str(str): Action being performed on the Node/RDataFrame.
node(Node): Node being acted on.
Returns
Node Manipulated node with the C++ struct built (the action string is not applied though).

◆ GetCollectionAttributes()

def GetCollectionAttributes (   self,
  c 
)

Get all attributes of a collection.

Example, for the 'Electron' collection, will return a list of `['pt', 'eta', ...]`.

Parameters
c(str): Collection name.
Returns
list List of attributes for the collection.

◆ GetCollectionNames()

def GetCollectionNames (   self)

Return the list of all collection names.

Returns
list All tracked collection names.

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