MaCh3PythonUtils.file_handling package
Submodules
MaCh3PythonUtils.file_handling.chain_handler module
Python tool to load in some generic TTree objects and export to numpy array/pandas dataframe
- class ChainHandler(file_name: str, ttree_name: str = 'posteriors', verbose=False)[source]
Bases:
object
Class to load in ROOT files containing a single TTree
- Parameters:
file_name (str) – Name of ROOT file containing useful TTree
ttree_name (str, optional) – Name of TTree contained in ROOT file
- add_additional_plots(additional_branches: List[str] | str, exact=False) None [source]
To add more branches to the plotting branch list :param additional_branches: List of branches to add to the plotting list :type additional_branches: list
- add_new_cuts(new_cuts: str | List[str]) None [source]
Specifies list of cuts to apply to the TTree (something like [‘step>80000’, ‘dm23>0’]) :param new_cuts: List of/single cut to apply :type new_cuts: list, str
- convert_ttree_to_array(close_file=True) None [source]
Converts the TTree table to array :param close_file: Do you want to close the ROOT file after calling this method? :type close_file: bool, optional
- ignore_plots(ignored_branches: List[str] | str) None [source]
List of plots to ignore
- Parameters:
ignored_branches (List[str] | str) – _description_
- property lower_bounds: ndarray[Any, dtype[_ScalarType_co]]
- property ndim: int
- property plot_branches: List[str]
Getter for list of useful branches :return: List of branches used in file :rtype: list
- property ttree_array: DataFrame
Getter for the converted TTree array :return: Table containing TTree in non-ROOT format :rtype: Union[np.array, pd.DataFrame, ak.Array]
- property upper_bounds: ndarray[Any, dtype[_ScalarType_co]]