Skip to content

Commit

Permalink
Add few printouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Nov 8, 2024
1 parent 3be38fb commit 16c3ad7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions python/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def get_entries(inpath: str) -> int | None:
try:
nevents = infile.Get("events").GetEntries()
except AttributeError:
LOGGER.error('Input file is missing "events" TTree!\nAborting...')
LOGGER.error('Input file is missing "events" TTree!\n - %s'
'\nAborting...', inpath)
sys.exit(3)

return nevents
Expand Down Expand Up @@ -63,15 +64,15 @@ def get_entries_sow(infilepath: str, nevents_max: Optional[int] = None, get_loca
sumOfWeightsTTree = 0.

# check for empty chunk (can this be improved? exception from RDF cannot be caught it seems?)
tree =infile.Get("events")
tree = infile.Get("events")
if not tree:
print("Tree not found in file", infilepath, " possibly empty chunk - continuing with next one.")
infile.Close()
return processEvents, eventsTTree, processSumOfWeights, sumOfWeightsTTree

try:

#use a RDF here too so the nevents restriction option can be imposed easily for the local events
# use a RDF here too so the nevents restriction option can be imposed easily for the local events
rdf_tmp = ROOT.ROOT.RDataFrame("events", infilepath)

if nevents_max:
Expand All @@ -85,7 +86,7 @@ def get_entries_sow(infilepath: str, nevents_max: Optional[int] = None, get_loca
# infile.Get("events").Draw('EventHeader.weight[0]>>histo')
# histo=ROOT.gDirectory.Get('histo')
histo = rdf_tmp.Histo1D(weight_name)
sumOfWeightsTTree=float(eventsTTree)*histo.GetMean()
sumOfWeightsTTree = float(eventsTTree) * histo.GetMean()
except cppyy.gbl.std.runtime_error:
LOGGER.error('Error: Event weights requested with do_weighted,'
'but input file does not contain weight column. Aborting.')
Expand Down
3 changes: 2 additions & 1 deletion python/run_final_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def get_entries(infilepath: str) -> tuple[int, int]:
try:
events_in_ttree = infile.Get("events").GetEntries()
except AttributeError:
LOGGER.error('Input file is missing "events" TTree!\nAborting...')
LOGGER.error('Input file is missing "events" TTree!\n - %s'
'\nAborting...')
sys.exit(3)

return events_processed, events_in_ttree
Expand Down

0 comments on commit 16c3ad7

Please sign in to comment.