Skip to content

Commit

Permalink
Add missing branch types; close histogram files in the proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
namapane committed Mar 7, 2024
1 parent 4551401 commit 9c122d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def beginJob(self, histFile=None, histDirName=None):
prevdir = ROOT.gDirectory
self.histFile = histFile
self.histFile.cd()
self.dir = self.histFile.mkdir(histDirName)
self.dir = self.histFile.mkdir(histDirName, "", True)
prevdir.cd()
self.objs = []

Expand All @@ -26,8 +26,6 @@ def endJob(self):
for obj in self.objs:
obj.Write()
prevdir.cd()
if hasattr(self, 'histFile') and self.histFile != None:
self.histFile.Close()

def beginFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
_rootBranchType2PythonArray = {
'b': 'B',
'B': 'b',
's': 'H',
'S': 'h',
'i': 'I',
'I': 'i',
'F': 'f',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ def run(self):
for m in self.modules:
m.endJob()

# close histogram file
if self.histFile != None:
self.histFile.Close()

print("Total time %.1f sec. to process %i events. Rate = %.1f Hz." % ((time.time() - t0), totEntriesRead, totEntriesRead / (time.time() - t0)))

if self.haddFileName:
Expand Down

0 comments on commit 9c122d3

Please sign in to comment.