Hi,
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…)
Cheers,
Riccardo
#!/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
file.Close()
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