Thanks to visit codestin.com
Credit goes to github.com

Skip to content

appINPP/root2data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

87 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ROOT2Data_1

DOI

Convert .root files to other data formats

from ROOT.. to HDF5/ SQLite/ Parquet πŸ’» βš™οΈ

Abstract

This repository provides a Python toolset for converting ROOT files to another format. It includes functionalities for reading data from ROOT files branches and saving them as other file formats.

Additionally, we can explore the file structure & print a dataframe. Ξ€he mutual compatibility and installation of the Python packages used to read and convert .root files ensure minimal dependency conflicts.

The scope of this work, was to create a general tool for converting ROOT files to other formats.

Usage

  1. Directory Structure - Construct the following directories in your project:

    • data/root: Ensure that you have this directory containing ROOT files.
    • data/h5: Directory where HDF5 files will be saved (if not present it will be created).
    • data/sqlite: Directory where SQLite files will be saved (if not present it will be created).
    • data/parquet: Directory where Parquet files will be saved (if not present it will be created).
  2. User Interface - Upon running the script, you'll be prompted to choose one of the following options:

    • Read a HDF5 | SQLite | Parquet file
    • Convert ROOT files to HDF5 | SQLite | Parquet
    • Exit the program.

Project structure

root2data/
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENCSE
β”œβ”€β”€ README.md
β”œβ”€β”€ create_env.sh
β”œβ”€β”€ main.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ data/ # this folder is created if not present
β”‚   β”œβ”€β”€ h5/
β”‚   β”œβ”€β”€ parquet/
β”‚   β”œβ”€β”€ root/
β”‚   └── sqlite/
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ __init__.py 
β”‚   β”œβ”€β”€ conversion.py
β”‚   β”œβ”€β”€ data_ops.py
β”‚   β”œβ”€β”€ file_ops.py
β”‚   β”œβ”€β”€ hdf5_ops.py
β”‚   β”œβ”€β”€ parquet_ops.py
β”‚   β”œβ”€β”€ sqlite_ops.py
β”‚   └── ui_ops.py
└── src/
    └── transform.py

ROOT file structure

Our ROOT files have the following simple structure:
root_file/
β”‚
β”œβ”€β”€ Tree;1/
β”‚   β”œβ”€β”€ variable_1.1
β”‚   β”œβ”€β”€ variable_1.2
β”‚   β”œβ”€β”€ variable_1.3
β”‚   ...
β”‚   └── variable1_N
β”‚
β”œβ”€β”€ Tree;2
β”‚   β”œβ”€β”€ variable_2.1
β”‚   β”œβ”€β”€ variable_2.2
β”‚   β”œβ”€β”€ variable_2.3
β”‚   ...
β”‚   └── variable_2.N
...
└── Tree;M/
    β”œβ”€β”€ variable_M.1
    β”œβ”€β”€ variable_M.2
    β”œβ”€β”€ variable_M.3
    ...
    └── variable_M.N

Prerequisites

Method 1:

The following will create a python virtual environment and at the same time activate it:

source create_env.sh

Method 2:

Another way is to create the virtual environment manually:

python3 -m venv root2data

After that, activate the virtual environment:

source root2data/bin/activate

Then execute the following to install required packages:

pip install -r requirements.txt

Both methods, assure that you have created a virtual env called root2data

Step-by-step instructions:

For step-by-step instructions check WALKTHROUGH.md

Conversion Time Comparisons

1 random ROOT file

Screenshot

10 ROOT files

Screenshot

1 bigger ROOT file

Screenshot

Communication

Please feel free to contact

[email protected]

License

This project is licensed under the Apache License. See the LICENSE for details.

Contributing

User contributions can be submitted via pull request on GitHub. We recommend that you create your own fork of root2data on GitHub and use it to submit your patches.