TChain does not recognize files with extension ".root.N"


I noticed a potential harmful behaviour of ROOT6. I have a number of files in a directory called ntuples_data/mydataset.root . Most of the files in the folder mydataset.root have in turn extension .root, but some of them have extension e.g. .root.N (if the attempt N-1 to create them on the grid failed). I can’t change this naming convention.

When adding file paths to a TChain, I noticed that in the latter case ROOT reports the following error

SysError in TFile::ReadBuffer: error reading from file ntuples_data (Is a directory)
Error in TFile::Init: ntuples_data failed to read the file type data.

If I change the file name from file.root.1 to file.root, it works perfectly. The problem does not arise if I open the file individually and read the TTree, but I’d prefer to use a TChain. Is there any workaround that does not look too ugly? The only solution I have found so far is to change manually the name of the file (.root.N -> .root) or remove “.root” from the name of the folder.

I think this behaviour should be fixed in a subsequent release (or convince the ATLAS Collaboration to change its file naming convention…)


#!/usr/bin/env python

import sys
from ROOT import TFile, TTree, TChain

filelist = sys.argv[1]

chain = TChain( "nominal", "nominal" )
n_entries_tot = 0
for filename in open(filelist).readlines():
   filename = filename.strip()

   chain.Add( filename )

   file = TFile.Open( filename )

   tree = file.Get( "nominal" ) 

   if tree == None: 
     print "no tree", filename.split('/')[-1]

   n = tree.GetEntries()
   print "INFO: %i entries in file %s" % ( n, filename )
   n_entries_tot += n


n_entries_chain = chain.GetEntries()

print "INFO: total number of entries (trees):", n_entries_tot
print "INFO: total number of entries (chain):", n_entries_chain

ROOT Version 6.11/01:
gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Python 2.7.12

Ciao Riccardo,
I confirm I can reproduce your issue with ROOT 6.10 if the root file has a path similar to /foo/bar.root/foobar.root.N .
The problem is not present with ROOT 6.08, has the way the strings are parsed changed when moving to ROOT 6.10?


1 Like

I could not yet reproduce the problem (in C++).
Are the files on a local device or a remote one?

G Ganis

Hi ganis,
I tried with a file mounted on /eos/
I.e. something like:

Hi Matteo,

The tricky part is the directory name. As reported in, TChain is currently confused with the directory being named like a ROOT file (i.e. ending in .root).



I have updated the JIRA ticket.

G Ganis

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.