A question about ROOT

Great, thanks for sharing!

The problem is because you’re having a bunch of TFiles opened, and any newly created histogram is automatically owned by the currently-opened file. At the end of the Python process (in this case your exit()), the ROOT objects are deleted in a random order, and if the histogram is deleted after the file there will be an invalid memory access and a crash.

We’ll avoid this problem in the next ROOT release by telling PyROOT that is should not delete these histograms created by Clone() itself.

For now, the workaround is to manually unset the owning directory of these histograms:

new_iso_tight.SetDirectory(ROOT.nullptr)