Skip to content

Commit

Permalink
- Still issue with the btagSF
Browse files Browse the repository at this point in the history
- Updated the method for modules to run
- Added PUWeightProducer
  • Loading branch information
ram1123 committed Sep 26, 2023
1 parent 9973c87 commit a232a10
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions post_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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))
Expand All @@ -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"

0 comments on commit a232a10

Please sign in to comment.