A Python package to compare cutflow histograms from ROOT files.
Project description
cutflow_compare
Overview
cutflow_compare is a Python package designed to simplify the comparison of cutflow histograms from ROOT files. It provides an intuitive command-line interface for analyzing and visualizing differences in cutflow data across multiple regions and files. Whether you're working with high-energy physics datasets or other ROOT-based analyses, cutflow_compare helps you streamline your workflow by automating comparisons and generating detailed reports.
Features
- Compare multiple ROOT files: Analyze cutflow histograms from two or more ROOT files simultaneously.
- Custom labels: Assign custom labels to files for better clarity in the output.
- Relative error and standard deviation: Automatically calculate relative errors and standard deviations across all files for each selection.
- CSV reports: Generate separate CSV files for each region, summarizing the comparison results.
- Colored terminal output: Use the
--coloredoption to display results with contrasting colors for better readability. - Flexible options: Keep selections separate or merge them, and optionally save results to custom filenames.
Why Use cutflow_compare?
When working with ROOT files, comparing cutflow histograms across different datasets or regions can be tedious and error-prone. cutflow_compare automates this process, ensuring consistency and accuracy while saving time. Its ability to handle multiple files and regions simultaneously makes it an essential tool for data analysts and researchers.
Installation
You can install the package using pip:
pip install cutflow_compare
Alternatively, you can clone the repository and install it manually:
git clone https://github.com/ibeuler/cutflow_compare.git
cd cutflow_compare
python setup.py install
Usage
After installation, you can use the command-line tool directly:
cutflow_compare --files histoOut-compared.root histoOut-reference.root -r region1 region2 region3 --labels Compared Reference
Or, if running from source:
python cutflow_compare.py --files histoOut-compared.root histoOut-reference.root -r region1 region2 region3 --labels Compared Reference
Arguments
--files: List of input ROOT files to compare. Required.--regions: List of regions to compare within the cutflow histograms. Required.--labels: Custom labels for each file, used in the output CSV and terminal display. Optional.--separate-selections: Keep selections separate instead of merging them. Optional.--relative-error: Include relative error calculations in the output. Optional.--save: Save the results to CSV files. Optionally, specify a custom filename prefix. Optional.--colored: Display table with colored columns for better contrast in the terminal. Optional.
Output
The tool generates separate CSV files for each region when the --save option is used. Each CSV file contains:
- Columns for each file's event counts after cuts.
- Calculated relative errors and standard deviations for each selection (if multiple files are compared).
Example Output
For a region WZ and files histoOut-compared.root, histoOut-reference.root, and histoOut-third.root, the output CSV might look like this:
| Selection | Compared_Event_After_Cut | Reference_Event_After_Cut | Third_Event_After_Cut | RelativeError_AllFiles |
|---|---|---|---|---|
| Selection 1 | 100 ± 5 | 105 ± 6 | 102 ± 4 | 0.03 |
| Selection 2 | 200 ± 10 | 195 ± 9 | 198 ± 8 | 0.02 |
Examples
Basic Comparison
cutflow_compare --files histoOut-compared.root histoOut-reference.root -r region1 region2
This compares region1 and region2 in the two ROOT files and prints the results to the terminal.
Save Results to CSV
cutflow_compare --files histoOut-compared.root histoOut-reference.root -r region1 region2 --save
This saves the results for each region to separate CSV files, e.g., cutflow_comparison_region1.csv and cutflow_comparison_region2.csv.
Custom Filename for Saved Results
cutflow_compare --files histoOut-compared.root histoOut-reference.root -r region1 region2 --save my_results
This saves the results to my_results_region1.csv and my_results_region2.csv.
Colored Output
cutflow_compare --files histoOut-compared.root histoOut-reference.root -r region1 region2 --colored
This displays the results in the terminal with contrasting colors for each file's data.
Requirements
- Python 3.6+
- ROOT (must be installed separately, e.g., via conda:
conda install -c conda-forge root) - pandas (automatically installed with the package)
- uncertainties (automatically installed with the package)
- prettytable (automatically installed with the package)
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributing
Contributions are welcome! If you have ideas for new features, bug fixes, or improvements, feel free to submit a pull request or open an issue on the GitHub repository.
Acknowledgments
This package leverages the ROOT framework for data analysis and visualization. Special thanks to the open-source community for providing the tools and libraries that make this project possible.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cutflow_compare-2.0.3.tar.gz.
File metadata
- Download URL: cutflow_compare-2.0.3.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ed4f37ccf7486409ed6d7733d6e9d2a5152807c1a8a1263f903cc7036cbcb54
|
|
| MD5 |
c23dd383e2a16fa93b9e9be04e201046
|
|
| BLAKE2b-256 |
f8959ace5a6c48176ce71e800fa2b91f28cf7a91844c81bb75b095db8129de1f
|
File details
Details for the file cutflow_compare-2.0.3-py3-none-any.whl.
File metadata
- Download URL: cutflow_compare-2.0.3-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1404a795eb28ca7ee5742af1bed3f75764e41e15c372dfe70f1e70d350257052
|
|
| MD5 |
fddac745b64f124f5d3fe4f30eab4f2c
|
|
| BLAKE2b-256 |
e4b5cd0d0820e3350a67126aa95f0c281f4a3cb43cf8012cef0c477e1ac2428b
|