From a232a10894755c4e9c12a279d25f859c266906ef Mon Sep 17 00:00:00 2001 From: Ram Krishna Sharma Date: Tue, 26 Sep 2023 12:00:43 +0200 Subject: [PATCH] - Still issue with the btagSF - Updated the method for modules to run - Added PUWeightProducer --- post_proc.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/post_proc.py b/post_proc.py index f0b8483..1c110ce 100755 --- a/post_proc.py +++ b/post_proc.py @@ -6,11 +6,21 @@ from H4LCppModule import * from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetHelperRun2 import * from PhysicsTools.NanoAODTools.postprocessing.modules.btv.btagSFProducer import * +from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import * from JetSFMaker import * ifRunningOnCondor = False testfilelist = [] +modulesToRun = [] +isMC = True +isFSR = False +jsonFileName = "" +# Keep DownloadFileToLocalThenRun=True this should reduce the file read error from eos. +DownloadFileToLocalThenRun=True +# Set entriesToRun = 0 if need to run over all entries else put number of entries to run +entriesToRun = 0 if ifRunningOnCondor else 100 + if ifRunningOnCondor: testfile = "root://cms-xrd-global.cern.ch//store/mc/RunIISummer20UL18NanoAODv9/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/NANOAODSIM/106X_upgrade2018_realistic_v16_L1v1-v1/120000/3ED05633-EBB7-4A44-8F9D-CD956490BCFD.root" @@ -28,15 +38,6 @@ # Append the line to the list with the "root://cms-xrd-global.cern.ch//" prefix testfilelist.append("root://cms-xrd-global.cern.ch/" + line) -# Set entriesToRun = 0 if need to run over all entries else put number of entries to run -entriesToRun = 0 if ifRunningOnCondor else 100 - -isMC = True -isFSR = False -jsonFileName = "" -# Keep DownloadFileToLocalThenRun=True this should reduce the file read error from eos. -DownloadFileToLocalThenRun=True - if testfilelist[0].find("/data/") != -1: isMC = False @@ -56,6 +57,8 @@ sfFileName="DeepCSV_2016LegacySF_V1.csv" H4LCppModule = lambda: HZZAnalysisCppProducer(year,cfgFile, isMC, isFSR) +modulesToRun.extend([H4LCppModule()]) + print("Input json file: {}".format(jsonFileName)) print("Input cfg file: {}".format(cfgFile)) print("isMC: {}".format(isMC)) @@ -64,14 +67,21 @@ if isMC: jetmetCorrector = createJMECorrector(isMC=isMC, dataYear=year, jesUncert="All", jetType = "AK4PFchs") fatJetCorrector = createJMECorrector(isMC=isMC, dataYear=year, jesUncert="All", jetType = "AK8PFPuppi") - btagSF = lambda: btagSFProducer("UL"+str(year), algo="deepjet",selectedWPs=['L','M','T','shape_corr'], sfFileName=sfFileName) + # btagSF = lambda: btagSFProducer("UL"+str(year), algo="deepjet",selectedWPs=['L','M','T','shape_corr'], sfFileName=sfFileName) + btagSF = lambda: btagSFProducer(era = "UL"+str(year), algo = "deepcsv") puidSF = lambda: JetSFMaker("%s" % year) - # p=PostProcessor(".",testfilelist, None, None,[H4LCppModule(), jetmetCorrector(), fatJetCorrector(), btagSF(), puidSF()], provenance=True,fwkJobReport=False,haddFileName="nano_M125_cpp.root", maxEntries=entriesToRun, prefetch=DownloadFileToLocalThenRun, outputbranchsel="keep_and_drop.txt") - p=PostProcessor(".",testfilelist, None, None,[H4LCppModule(), jetmetCorrector(), fatJetCorrector(), puidSF()], provenance=True,fwkJobReport=False,haddFileName="nano_M125_cpp.root", maxEntries=entriesToRun, prefetch=DownloadFileToLocalThenRun, outputbranchsel="keep_and_drop.txt") + modulesToRun.extend([jetmetCorrector(), fatJetCorrector(), puidSF()]) + if year == 2018: modulesToRun.extend([puAutoWeight_2018()]) + if year == 2017: modulesToRun.extend([puAutoWeight_2017()]) + if year == 2016: modulesToRun.extend([puAutoWeight_2016()]) + + p=PostProcessor(".",testfilelist, None, None,modules = modulesToRun, provenance=True,fwkJobReport=False,haddFileName="skimmed_nano_mc.root", maxEntries=entriesToRun, prefetch=DownloadFileToLocalThenRun, outputbranchsel="keep_and_drop.txt") else: jetmetCorrector = createJMECorrector(isMC=isMC, dataYear=year, jesUncert="All", jetType = "AK4PFchs") fatJetCorrector = createJMECorrector(isMC=isMC, dataYear=year, jesUncert="All", jetType = "AK8PFPuppi") - p=PostProcessor(".",testfilelist, None, None,[H4LCppModule(), jetmetCorrector(), fatJetCorrector()], provenance=False, fwkJobReport=False,haddFileName="nano_M125_cpp.root", jsonInput=jsonFileName, maxEntries=entriesToRun, prefetch=DownloadFileToLocalThenRun, outputbranchsel="keep_and_drop_data.txt") + modulesToRun.extend([jetmetCorrector(), fatJetCorrector()]) + + p=PostProcessor(".",testfilelist, None, None, modules = modulesToRun, provenance=True, fwkJobReport=False,haddFileName="skimmed_nano_data.root", jsonInput=jsonFileName, maxEntries=entriesToRun, prefetch=DownloadFileToLocalThenRun, outputbranchsel="keep_and_drop_data.txt") p.run() print "DONE"