pyBabyMaker.engine.functions¶
This module defines functions for template macro.
-
pyBabyMaker.engine.functions.func_deref_var(expr, vars_to_deref)¶ Dereference variables loaded from ntuple directly. For example:
TTreeReader reader("tree", input_file) TTreeReaderValue<double> Y_PT(reader, "Y_PT"); while (reader.Next()) { cout << (*Y_PT) }
The
Y_PTinside thewhileloop needs to be dereferenced.Parameters: - expr (str) – C++ expression that has variables to be dereferenced.
- vars_to_deref (list) – list of variables to be dereferenced.
-
pyBabyMaker.engine.functions.func_format_list(str_template, lst)¶ Return attribute if it exists; otherwise treat attribute as a dict key.
Parameters: - str_template (str) – string template to be formatted.
- lst (list) – list of arguments to be used to format string template.
-
pyBabyMaker.engine.functions.func_getattr(val, attr)¶ Return attribute if it exists; otherwise treat attribute as a dict key.
Parameters: - val (Any) – an object that either has attribute
attror is a dict and has a key namedattr - attr (str) – name of the attribute/dict key.
- val (Any) – an object that either has attribute
-
pyBabyMaker.engine.functions.func_guard(input_str, chars_to_replace=['*', '/'])¶ Return a string with chars illegal in variable names replaced.
Parameters: - input_str (str) – string to be replaced.
- chars_to_replace (list) – list of illegal chars.
-
pyBabyMaker.engine.functions.func_input(path)¶ Macro function to read literal input from path.
Parameters: path (str/pathlib.Path) – path to the input file.