Home | News | Documentation | Download

[new script] Splitting a ROOT file tree into N files

Dear ROOT forum,

the possibility of splitting a ROOT file into many smaller files has been introduced in ROOT by means of the “rooteventselector” python script, However this script presents a bug: it does not work when multiple trees are present with the same name.
See:

I don’t know if the issue has been solved (with ROOT 6.16 it still does not work), but I created a small python script to get the work done. You can get it here:

The script works with python 2.7 + ROOT 6.x (it should also work with ROOT 5.x but it has not been tested) and it requires pyROOT + Numpy.
It is based on available tutorials and it could be much more pythonic… but I don’t have much time to improve it (i.e. suit yourself!)

Comments, questions, corrections?
Cheers,
Valentina

1 Like

Hi Valentina,

nice. We take your post as a reminder to fix for 6.18 rooteventselector.
Two curiosities:

  1. Why do you need to split your ROOT files? What are you trying to achieve?
  2. Why does your script depend on Numpy?

Cheers,
D

Hi!

    1. Why do you need to split your ROOT files? What are you trying to achieve?
      I use ROOT files as input for Geant4 simulations, and I needed to break the input file in smaller ones to reduce the CPU time by running many smaller jobs in a cluster.
      I am in early development phase, and everything is manual right now but I will likely integrate the script in a pipeline.
    1. Why does your script depend on Numpy?
      Oops, you are right! I use it for the ints and floats, but I could use python math in this code, since I don’t require any fancy numpy feature. I will remove it.

Thanks!
Valentina