![]() |
TIMBER
beta
Tree Interface for Making Binned Events with RDataFrame
|
Commonly used functions available for use that can be generic or TIMBER specific. More...
Functions | |
| def | CutflowDict (node, initial=None) |
| Turns the RDataFrame cutflow report into an OrderedDict. More... | |
| def | CutflowHist (name, node, initial=None, efficiency=False) |
| Draws a cutflow histogram using the report feature of RDF. More... | |
| def | CutflowTxt (name, node, efficiency=False) |
| Writes out the cutflow as a text file using the report feature of RDF. More... | |
| def | StitchQCD (QCDdict, normDict=None) |
| Stitches together histograms in QCD hist groups. More... | |
| def | GetJMETag (t, year, setname) |
Return the latest JME tag corresponding to the type t (JES or JER), year, and setname (MC for simulation and A, B, C, etc for data). More... | |
| def | CompileCpp (blockcode, library=False) |
| Compiles C++ code via the gInterpreter. More... | |
| def | OpenJSON (filename) |
| Opens JSON file as a dictionary (accounting for unicode encoding) More... | |
| def | AsciiEncodeDict (data) |
| Encodes dict to ascii from unicode for python 2.7. More... | |
| def | ConcatCols (colnames, val='1', connector='&&') |
Concatenates a list of column names evaluating to a common val (usually 1 or 0) with some connector (bool logic operator). More... | |
| def | GetHistBinningTuple (h) |
| Gets the binning information for a histogram and returns it as a tuple ordered like the arguments to construct a new histogram. More... | |
| def | ColliMate (myString, width=18) |
| Collimates strings to have consistent spacing between first character of word i with the first character of word i+1 and i-1. More... | |
| def | DictStructureCopy (inDict) |
| Recursively copies the structure of a dictionary with non-dict items replaced with 0. More... | |
| def | DictCopy (inDict) |
| Recursively copy dictionary structure and values. More... | |
| def | ExecuteCmd (cmd, dryrun=False) |
Executes shell command via subprocess.call() and prints the command for posterity. More... | |
| def | DictToLatexTable (dict2convert, outfilename, roworder=[], columnorder=[]) |
| Converts a dictionary with two layers (ie. More... | |
| def | FindCommonString (string_list) |
| Finds a common string between a list of strings. More... | |
| def | GetStandardFlags () |
| List of the following recommended flags as of Jan. More... | |
| def | cd (newdir) |
| Context manager to cd to another folder in the middle of a python script. More... | |
Variables | |
| dictionary | JEStags |
| Dictionary of the JES/JEC tags corresponding to tarballs stored in TIMBER/data/JES. More... | |
| dictionary | JERtags |
| Dictionary of the JER tags corresponding to tarballs stored in TIMBER/data/JER. More... | |
Commonly used functions available for use that can be generic or TIMBER specific.
| def TIMBER.Tools.Common.AsciiEncodeDict | ( | data | ) |
Encodes dict to ascii from unicode for python 2.7.
Not needed for python 3.
Credit Andrew Clark on StackOverflow.
| data | (dict): Input dictionary. |
| def TIMBER.Tools.Common.cd | ( | newdir | ) |
Context manager to cd to another folder in the middle of a python script.
Useful to use if you're producing a lot of files in a dedicated folder. Change into the folder and then produce the files.
| newdir | (str): Directory to cd into. |
| def TIMBER.Tools.Common.ColliMate | ( | myString, | |
width = 18 |
|||
| ) |
Collimates strings to have consistent spacing between first character of word i with the first character of word i+1 and i-1.
Recommended instead to use format() method of python strings as described here.
| myString | (str): String to space (words only separated by single space). |
| width | (int, optional): Column widths. Defaults to 18. |
| def TIMBER.Tools.Common.CompileCpp | ( | blockcode, | |
library = False |
|||
| ) |
Compiles C++ code via the gInterpreter.
A python string (the actual code) can be passed or a file name (the file will be opened and read). If a file is passed, the C++ code can be compiled as a library and if in the future the C++ script is older than the library, then the library will be loaded instead.
| blockcode | (str): Either a block of C++ code or a file name to open. |
| library | (bool, optional): Compiles a library which can be later loaded to avoid compilation time. Defaults to False. |
| def TIMBER.Tools.Common.ConcatCols | ( | colnames, | |
val = '1', |
|||
connector = '&&' |
|||
| ) |
Concatenates a list of column names evaluating to a common val (usually 1 or 0) with some connector (bool logic operator).
| colnames | ([str]): List of column names. |
| val | (str): Value to test equality of all columns. Defaults to '1'. |
| connector | (str): C++ bool logic operator between column equality checks. Defaults to '&&'. |
| def TIMBER.Tools.Common.CutflowDict | ( | node, | |
initial = None |
|||
| ) |
Turns the RDataFrame cutflow report into an OrderedDict.
| node | (Node): Input Node from which to get the cutflow. |
| initial | (int): Initial number events. Defaults to None in which case the number in the top-most parent Node is used. |
| def TIMBER.Tools.Common.CutflowHist | ( | name, | |
| node, | |||
initial = None, |
|||
efficiency = False |
|||
| ) |
Draws a cutflow histogram using the report feature of RDF.
| name | (str): Name of output histogram |
| node | (Node): Input Node from which to get the cutflow. |
| initial | (int): Initial number events. Defaults to None in which case the number in the top-most parent Node is used. |
| efficiency | (bool, optional): Reports an efficiency instead of yields (relative to number of events before any cuts on Node). |
| def TIMBER.Tools.Common.CutflowTxt | ( | name, | |
| node, | |||
efficiency = False |
|||
| ) |
Writes out the cutflow as a text file using the report feature of RDF.
| name | (str): Name of output text file. |
| node | (Node): Input Node from which to get the cutflow. |
| efficiency | (bool, optional): Reports an efficiency instead of yields (relative to number of events before any cuts on Node). |
| def TIMBER.Tools.Common.DictCopy | ( | inDict | ) |
Recursively copy dictionary structure and values.
| inDict | (dict): Dictionary to copy. |
| def TIMBER.Tools.Common.DictStructureCopy | ( | inDict | ) |
Recursively copies the structure of a dictionary with non-dict items replaced with 0.
| inDict | (dict): Dictionary with structure to copy. |
| def TIMBER.Tools.Common.DictToLatexTable | ( | dict2convert, | |
| outfilename, | |||
roworder = [], |
|||
columnorder = [] |
|||
| ) |
Converts a dictionary with two layers (ie.
only one set of sub-keys) to a LaTeX table. First set of keys (ie. external) are rows, second (ie. internal) are columns. If the column entry for a given row is not provided (ie. missing key), then '-' is substituted.
| dict2convert | (dict): Input dictionary. |
| outfilename | (str): Output .tex file name. |
| roworder | (list, optional): Custom ordering of rows. Defaults to [] in which case the sorted keys are used. |
| columnorder | (list, optional): Custom ordering of columns. Defaults to [] in which case the sorted keys are used. |
| def TIMBER.Tools.Common.ExecuteCmd | ( | cmd, | |
dryrun = False |
|||
| ) |
Executes shell command via subprocess.call() and prints the command for posterity.
| cmd | (str): Shell command to run. |
| dryrun | (bool, optional): Prints command but doesn't execute it. Defaults to False. |
| def TIMBER.Tools.Common.FindCommonString | ( | string_list | ) |
Finds a common string between a list of strings.
| string_list | ([str]): List of strings to compare. |
| def TIMBER.Tools.Common.GetHistBinningTuple | ( | h | ) |
Gets the binning information for a histogram and returns it as a tuple ordered like the arguments to construct a new histogram.
Supports TH1, TH2, and TH3.
| h | (TH1): Input histogram from which to get the binning information. |
| TypeError | If histogram does not derive from TH1. |
| def TIMBER.Tools.Common.GetJMETag | ( | t, | |
| year, | |||
| setname | |||
| ) |
Return the latest JME tag corresponding to the type t (JES or JER), year, and setname (MC for simulation and A, B, C, etc for data).
Returned string is compatible with input needed by JME modules.
| t | JES or JER |
| year | 2016, 2017, 2018, 2017UL, or 2018UL |
| setname | MC for simulation. A, B, C, D, E, F, G, or H for data. |
| ValueError | Did not provide t that is either JES or JER. |
| def TIMBER.Tools.Common.GetStandardFlags | ( | ) |
List of the following recommended flags as of Jan.
6th, 2021.
| def TIMBER.Tools.Common.OpenJSON | ( | filename | ) |
Opens JSON file as a dictionary (accounting for unicode encoding)
| filename | (str): JSON file name to open. |
| def TIMBER.Tools.Common.StitchQCD | ( | QCDdict, | |
normDict = None |
|||
| ) |
Stitches together histograms in QCD hist groups.
| QCDdict | ({string:HistGroup}): Dictionary of HistGroup objects |
| normDict | ({string:float}): Factors to normalize each sample to where keys must match QCDdict keys. Default to None and assume normalization has already been done. |
| dictionary JERtags |
1.8.13