Skip to content

Commit

Permalink
Merge pull request #44310 from namapane/NAT-44293
Browse files Browse the repository at this point in the history
Add standard open file message; minor updates
  • Loading branch information
cmsbuild authored Mar 6, 2024
2 parents c54e931 + 354f217 commit 4c67638
Show file tree
Hide file tree
Showing 3 changed files with 8 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 @@ -159,6 +159,7 @@ def run(self):
fname = subprocess.check_output(['edmFileUtil', '-d', '-f '+fname]).decode("utf-8").strip()

# open input file
print(time.strftime("%d-%b-%Y %H:%M:%S %Z", time.localtime()), " Initiating request to open file %s" %(fname), flush=True) # CMSSW-syle message, required by eos caching scripts
if self.prefetch:
ftoread, toBeDeleted = self.prefetchFile(fname)
inFile = ROOT.TFile.Open(ftoread)
Expand Down Expand Up @@ -262,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 4c67638

Please sign in to comment.