diff --git a/PhysicsTools/NanoAODTools/python/postprocessing/framework/eventloop.py b/PhysicsTools/NanoAODTools/python/postprocessing/framework/eventloop.py index 98689bf5ceab5..46566fef5d1a1 100644 --- a/PhysicsTools/NanoAODTools/python/postprocessing/framework/eventloop.py +++ b/PhysicsTools/NanoAODTools/python/postprocessing/framework/eventloop.py @@ -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 = [] @@ -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 diff --git a/PhysicsTools/NanoAODTools/python/postprocessing/framework/output.py b/PhysicsTools/NanoAODTools/python/postprocessing/framework/output.py index d81a724016dd0..ce2281c6e6ea3 100644 --- a/PhysicsTools/NanoAODTools/python/postprocessing/framework/output.py +++ b/PhysicsTools/NanoAODTools/python/postprocessing/framework/output.py @@ -7,6 +7,8 @@ _rootBranchType2PythonArray = { 'b': 'B', 'B': 'b', + 's': 'H', + 'S': 'h', 'i': 'I', 'I': 'i', 'F': 'f', diff --git a/PhysicsTools/NanoAODTools/python/postprocessing/framework/postprocessor.py b/PhysicsTools/NanoAODTools/python/postprocessing/framework/postprocessor.py index 80a0d7940c5b5..3fd0c0a55bd43 100755 --- a/PhysicsTools/NanoAODTools/python/postprocessing/framework/postprocessor.py +++ b/PhysicsTools/NanoAODTools/python/postprocessing/framework/postprocessor.py @@ -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) @@ -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: