![]() |
TIMBER
beta
Tree Interface for Making Binned Events with RDataFrame
|
Class to handle C++ class modules generically. More...


Public Member Functions | |
| def | __init__ (self, name, script, constructor=[], mainFunc='eval', columnList=None, isClone=False, cloneFuncInfo=None) |
| Constructor. More... | |
| def | Clone (self, name, newMainFunc=None) |
| Makes a clone of current instance. More... | |
| def | GetCall (self, evalArgs={}, toCheck=None) |
| Gets the call to the method to be evaluated per-event. More... | |
| def | GetFuncNames (self) |
| Gets list of function names in C++ script. More... | |
| def | GetMainFunc (self) |
| Gets full main function name. More... | |
| def | MakeCall (self, inArgs={}, toCheck=None) |
| Makes the call (stored in class instance) to the method with the branch/column names deduced or added from input. More... | |
Public Attributes | |
| name | |
| str Correction name | |
Class to handle C++ class modules generically.
Uses clang in python to parse the C++ code and determine function names, namespaces, and argument names and types.
Writing the C++ modules requires the desired branch/column names must be specified or be used as the argument variable names to allow the framework to automatically determine what branch/column to use in GetCall().
| def __init__ | ( | self, | |
| name, | |||
| script, | |||
constructor = [], |
|||
mainFunc = 'eval', |
|||
columnList = None, |
|||
isClone = False, |
|||
cloneFuncInfo = None |
|||
| ) |
Constructor.
| name | (str): Unique name to identify the instantiated worker object. |
| script | (str): Path to C++ script with function to calculate correction. For a TIMBER module, use the header file. |
| constructor | ([str], optional): List of arguments to script class constructor. Defaults to []. |
| mainFunc | (str, optional): Name of the function to use inside script. Defaults to None and the class will try to deduce it. |
| columnList | ([str], optional): List of column names to search mainFunc arguments against. Defaults to None and the standard NanoAOD columns from LoadColumnNames() will be used. |
| isClone | (bool, optional): For internal use when cloning. Defaults to False. If True, will not duplicate compile the same script if two functions are needed in one C++ script. |
| cloneFuncInfo | (dict, optional): For internal use when cloning. Defaults to None. Should be the _funcInfo from the object from which this one is cloned. |
| def Clone | ( | self, | |
| name, | |||
newMainFunc = None |
|||
| ) |
Makes a clone of current instance.
If multiple functions are in the same script, one can clone the correction and reassign the mainFunc to avoid compiling the same script twice.
| name | (str): Clone name. |
| newMainFunc | (str, optional): Name of the function to use inside script. Defaults to None and the original is used. |
| def GetCall | ( | self, | |
evalArgs = {}, |
|||
toCheck = None |
|||
| ) |
Gets the call to the method to be evaluated per-event.
| evalArgs | (list, optional): Args to use for eval if MakeCall() has not already been called. Defaults to []. If MakeCall() has not already been called and inArgs == [], then the arguments to the method will be deduced from the C++ method definition argument names. |
| toCheck | (Node, ROOT.RDataFrame, list, optional): Object with column information to check argument names exist. Defaults to None in which case a default NanoAODv6 list is loaded. |
| def GetFuncNames | ( | self | ) |
Gets list of function names in C++ script.
| def GetMainFunc | ( | self | ) |
Gets full main function name.
| def MakeCall | ( | self, | |
inArgs = {}, |
|||
toCheck = None |
|||
| ) |
Makes the call (stored in class instance) to the method with the branch/column names deduced or added from input.
| inArgs | (dict, optional): Dict with keys as C++ method argument names and values as the actual argument to provide (branch/column names) for per-event evaluation. For any argument names where a key is not provided, will attempt to find branch/column that already matches based on name. Defaults to {} in which case ther will be automatic deduction from the argument names written in the C++ script. |
| toCheck | (Node, ROOT.RDataFrame, list, optional): Object with column information to check argument names exist. Defaults to None in which case a default NanoAODv6 list is loaded. |
| NameError | If argument written in C++ script cannot be found in available columns. |
| ValueError | If provided number of arguments does not match the number in the method. |
| Returns | |
| str | Call to function from C++ script. |
1.8.13