Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/python/Sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,23 @@ def fromDPMDirectory(cls, name, directory, redirector='root://hephyse.oeaw.ac.at
files = []
for d in directories:
cmd = [ "xrdfs", redirector, "ls", d ]
fileList = []
for i in range(10):
try:
fileList = [ file for file in subprocess.check_output( cmd ).split("\n")[:-1] ]
break
except:
if i<9: pass
counter = 0
for filename in fileList:
if filename.endswith(".root"):
files.append( redirector + os.path.join( d, filename ) )
counter += 1
if maxN is not None and maxN>0 and len(files)>=maxN:
break
if counter==0:
raise helpers.EmptySampleError( "No root files found in directory %s." %d )

sample = cls(name = name, treeName = treeName, files = files, normalization = normalization, xSection = xSection,\
selectionString = selectionString, weightString = weightString,
isData = isData, color=color, texName = texName)
Expand Down Expand Up @@ -710,7 +716,8 @@ def __loadChain(self):
except IOError as e:
logger.error( "Could not load file %s", f )
#raise e

if counter==0:
raise helpers.EmptySampleError( "No root files for sample %s." %self.name )
logger.debug( "Loaded %i files for sample '%s'.", counter, self.name )

# Add friends
Expand Down
5 changes: 4 additions & 1 deletion examples/example_treeMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import logging
import ROOT
import os

#RootTools
from RootTools.core.standard import *
Expand All @@ -25,7 +26,7 @@


# from files
s0 = Sample.fromFiles("s0", files = ["example_data/file_0.root"], treeName = "Events")
s0 = Sample.fromFiles("s0", files = [os.path.expandvars("$CMSSW_BASE/src/RootTools/examples/example_data/file_0.root")], treeName = "Events")

read_variables = [ TreeVariable.fromString( "nJet/I"), TreeVariable.fromString('Jet[pt/F,eta/F,phi/F]' ) ] \
+ [ TreeVariable.fromString(x) for x in [ 'met_pt/F', 'met_phi/F' ] ]
Expand All @@ -51,3 +52,5 @@ def filler(event):
maker.start()
while reader.run():
maker.run()

logger.info("Success!")
2 changes: 1 addition & 1 deletion fwlite/python/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def getObjects(self, key):
return objs

except sqlite3.DatabaseError as e:
logger.error( "There seems to be an issue with the database, trying to read again." )
logger.error( "There seems to be an issue with the database, trying to read again from %s.", self.database_file )
logger.info( "Attempt no %i", i )
self.close()
self.connect()
Expand Down