Skip to content

Commit

Permalink
Added output Dir option when running locally
Browse files Browse the repository at this point in the history
  • Loading branch information
ram1123 committed Aug 20, 2024
1 parent 7585c14 commit 06d85d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion GenVarsProducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def analyze(self, event):
self.out.fillBranch("Pz_neutrino1", neutrino1_pz)
self.out.fillBranch("delta_pz_neutrino", delta_pz_neutrino)

self.out.fillBranch("Pz_neutrino", Pz)
# self.out.fillBranch("Pz_neutrino", Pz)
self.out.fillBranch("BoostZ1", boost_Z1_mag)
self.out.fillBranch("BoostZ2", boost_Z2_mag)
self.out.fillBranch("Boostdiff", boost_diff_mag)
Expand Down
12 changes: 8 additions & 4 deletions external/nanoAODTools_py2to3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ index 405b055..53613a7 100644
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import *
import sys
diff --git a/python/postprocessing/framework/postprocessor.py b/python/postprocessing/framework/postprocessor.py
index c7cc3ca..c82361d 100755
index c7cc3ca..ea54b4a 100755
--- a/python/postprocessing/framework/postprocessor.py
+++ b/python/postprocessing/framework/postprocessor.py
@@ -1,4 +1,4 @@
Expand All @@ -38,22 +38,26 @@ index c7cc3ca..c82361d 100755
from PhysicsTools.NanoAODTools.postprocessing.framework.jobreport import JobReport
from PhysicsTools.NanoAODTools.postprocessing.framework.preskimming import preSkim
from PhysicsTools.NanoAODTools.postprocessing.framework.output import FriendOutput, FullOutput
@@ -261,8 +261,16 @@ class PostProcessor:
@@ -261,8 +261,18 @@ class PostProcessor:
if self.haddFileName:
haddnano = "./haddnano.py" if os.path.isfile(
"./haddnano.py") else "haddnano.py"
+ print("Merging output files into %s" % self.haddFileName)
+ print("")
+ os.system('date')
+ startTime = time.time()
+ print("%s %s %s" %
+ (haddnano, self.outputDir + "/" + self.haddFileName, " ".join(outFileNames)))
os.system("%s %s %s" %
(haddnano, self.haddFileName, " ".join(outFileNames)))
- (haddnano, self.haddFileName, " ".join(outFileNames)))
+ (haddnano, self.outputDir + "/" + self.haddFileName, " ".join(outFileNames)))
+ os.system('date')
+ print("Total time to merge %i files: %.1f sec" %
+ (len(outFileNames), time.time() - startTime))
+ print("Done")
if self.jobReport:
self.jobReport.addOutputFile(self.haddFileName)
- self.jobReport.addOutputFile(self.haddFileName)
+ self.jobReport.addOutputFile( self.outputDir + "/" + self.haddFileName)
self.jobReport.save()
diff --git a/python/postprocessing/modules/common/puWeightProducer.py b/python/postprocessing/modules/common/puWeightProducer.py
index b9062b4..7c5a1da 100644
Expand Down
5 changes: 3 additions & 2 deletions post_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--inputFile", default="", type=str, help="Input file name")
parser.add_argument('-o', '--outputFile', default="skimmed_nano.root", type=str, help="Output file name")
parser.add_argument('-outDir', '--outputDir', default=".", type=str, help="Output directory")
parser.add_argument('-c', '--cutFlowFile', default="cutFlow.json", type=str, help="Cut flow file name")
parser.add_argument("-n", "--entriesToRun", default=100, type=int, help="Set to 0 if need to run over all entries else put number of entries to run")
parser.add_argument("-d", "--DownloadFileToLocalThenRun", default=True, type=bool, help="Download file to local then run")
Expand Down Expand Up @@ -127,7 +128,7 @@ def main():
# otherwise the output file will have larger size then expected. Reference: https://github.com/cms-nanoAOD/nanoAOD-tools/issues/249
temp_keep_drop_file = create_temp_keep_drop_file(keep_drop_rules_GEN + keep_drop_rules_Data_MC)
print("DEBUG: Keep and drop file: {}".format(temp_keep_drop_file))
p=PostProcessor("/eos/user/a/avijay/signal/sig_300/",testfilelist, None, None,modules = modulesToRun,
p=PostProcessor(args.outputDir,testfilelist, None, None,modules = modulesToRun,
provenance=True,fwkJobReport=True,
haddFileName=args.outputFile,
maxEntries=entriesToRun,
Expand All @@ -141,7 +142,7 @@ def main():

temp_keep_drop_file = create_temp_keep_drop_file(keep_drop_rules_Data_MC)
print("DEBUG: Keep and drop file: {}".format(temp_keep_drop_file))
p=PostProcessor("/eos/user/a/avijay/signal/sig_300/",testfilelist, None, None, modules = modulesToRun,
p=PostProcessor(args.outputDir,testfilelist, None, None, modules = modulesToRun,
provenance=True, fwkJobReport=True,
haddFileName=args.outputFile,
jsonInput=jsonFileName,
Expand Down

0 comments on commit 06d85d5

Please sign in to comment.