forked from osWW-VBS/nanoAOD_vvVBS
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add golden json & fix submodule utils (#16) * - Removed the submodule utils * - Minor update in condor submission script. - Added summary of additional script information in the README file * Added golden json information to post-proc * - replaced string "nanoAOD_vvVBS" to "nanoAOD_skim" in few files - Fix the json bug (For MC we don't need to provide) - Added modules createJMECorrector, btagSFProducer, etc * - Still issue with the btagSF - Updated the method for modules to run - Added PUWeightProducer * Added a text file having list of MC samples * Added additional cuts for 2l2q channel * - Improved post-proc for the condor jobs submission * Fix a bug in root file name
- Loading branch information
Showing
8 changed files
with
164 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Data | ||
/SingleMuon/Run2018B-UL2018_MiniAODv2_NanoAODv9_GT36-v1/NANOAOD | ||
# | ||
# MC | ||
/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM | ||
/GluGluHToZZTo2L2Q_M1000_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,4 @@ keep FatJet_* | |
keep Gen* | ||
keep Jet_* | ||
keep Muon* | ||
keep pass* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,115 @@ | ||
#!/usr/bin/env python | ||
import os,sys | ||
import os | ||
import sys | ||
import argparse | ||
|
||
from PhysicsTools.NanoAODTools.postprocessing.framework.postprocessor import PostProcessor | ||
from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetHelperRun2 import createJMECorrector | ||
from PhysicsTools.NanoAODTools.postprocessing.modules.btv.btagSFProducer import btagSFProducer | ||
from PhysicsTools.NanoAODTools.postprocessing.modules.common.puWeightProducer import * | ||
|
||
# Custom module imports | ||
from H4Lmodule import * | ||
from H4LCppModule import * | ||
from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetHelperRun2 import * | ||
from PhysicsTools.NanoAODTools.postprocessing.modules.btv.btagSFProducer import * | ||
from JetSFMaker import * | ||
|
||
ifRunningOnCondor = False | ||
def parse_arguments(): | ||
"""Parse command line arguments.""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-i", "--inputFile", default="", type=str, help="Input 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") | ||
return parser.parse_args() | ||
|
||
|
||
def getListFromFile(filename): | ||
"""Read file list from a text file.""" | ||
with open(filename, "r") as file: | ||
return ["root://cms-xrd-global.cern.ch/" + line.strip() for line in file] | ||
|
||
|
||
def main(): | ||
args = parse_arguments() | ||
|
||
# Initial setup | ||
testfilelist = [] | ||
modulesToRun = [] | ||
isMC = True | ||
isFSR = False | ||
year = None | ||
cfgFile = None | ||
jsonFileName = None | ||
sfFileName = None | ||
|
||
entriesToRun = int(args.entriesToRun) | ||
DownloadFileToLocalThenRun = args.DownloadFileToLocalThenRun | ||
|
||
# Determine list of files to process | ||
if args.inputFile.endswith(".txt"): | ||
testfilelist = getListFromFile(args.inputFile) | ||
elif args.inputFile.endswith(".root"): | ||
testfilelist.append(args.inputFile) | ||
else: | ||
print("INFO: No input file specified. Using default file list.") | ||
testfilelist = getListFromFile("ExampleInputFileList.txt") | ||
print("DEBUG: Input file list: {}".format(testfilelist)) | ||
if len(testfilelist) == 0: | ||
print("ERROR: No input files found. Exiting.") | ||
exit(1) | ||
|
||
# Determine the year and type (MC or Data) | ||
first_file = testfilelist[0] | ||
isMC = "/data/" not in first_file | ||
|
||
if "UL18" in first_file or "UL2018" in first_file: | ||
"""UL2018 for identification of 2018 UL data and UL18 for identification of 2018 UL MC | ||
""" | ||
year = 2018 | ||
cfgFile = "Input_2018.yml" | ||
jsonFileName = "golden_Json/Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt" | ||
sfFileName = "DeepCSV_102XSF_V2.csv" | ||
|
||
if "UL17" in first_file or "UL2017" in first_file: | ||
year = 2017 | ||
cfgFile = "Input_2017.yml" | ||
jsonFileName="golden_Json/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt" | ||
sfFileName = "DeepCSV_102XSF_V2.csv" | ||
|
||
if "UL16" in first_file or "UL2016" in first_file: | ||
year = 2016 | ||
jsonFileName = "golden_Json/Cert_271036-284044_13TeV_Legacy2016_Collisions16_JSON.txt" | ||
sfFileName = "DeepCSV_102XSF_V2.csv" | ||
|
||
H4LCppModule = lambda: HZZAnalysisCppProducer(year,cfgFile, isMC, isFSR) | ||
modulesToRun.extend([H4LCppModule()]) | ||
|
||
testfilelist = [] | ||
print("Input json file: {}".format(jsonFileName)) | ||
print("Input cfg file: {}".format(cfgFile)) | ||
print("isMC: {}".format(isMC)) | ||
print("isFSR: {}".format(isFSR)) | ||
|
||
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" | ||
testfilelist.append(testfile) | ||
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(era = "UL"+str(year), algo = "deepcsv") | ||
puidSF = lambda: JetSFMaker("%s" % year) | ||
modulesToRun.extend([jetmetCorrector(), fatJetCorrector(), puidSF()]) | ||
# # modulesToRun.extend([jetmetCorrector(), fatJetCorrector(), btagSF(), puidSF()]) | ||
|
||
else: | ||
if len(sys.argv) > 1: | ||
InputFileList = sys.argv[1] | ||
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: | ||
InputFileList = "ExampleInputFileList.txt" | ||
with open(InputFileList, 'r') as file: | ||
for line in file: | ||
# Remove newline characters | ||
line = line.strip() | ||
# 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 | ||
|
||
if testfilelist[0].find("UL18") != -1 or testfilelist[0].find("UL2018") != -1: # UL2018 for identification of 2018 UL data and UL18 for identification of 2018 UL MC | ||
year = 2018 | ||
cfgFile = 'Input_2018.yml' | ||
jsonFileName="golden_Json/Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt" | ||
sfFileName="DeepCSV_102XSF_V2.csv" | ||
|
||
if testfilelist[0].find("UL17") != -1 or testfilelist[0].find("UL2017") != -1: | ||
year = 2017 | ||
cfgFile = 'Input_2017.yml' | ||
jsonFileName="golden_Json/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt" | ||
sfFileName="DeepCSV_94XSF_V5_B_F.csv" | ||
|
||
if testfilelist[0].find("UL16") != -1 or testfilelist[0].find("UL2016") != -1: | ||
sfFileName="DeepCSV_2016LegacySF_V1.csv" | ||
|
||
H4LCppModule = lambda: HZZAnalysisCppProducer(year,cfgFile, isMC, isFSR) | ||
print("Input json file: {}".format(jsonFileName)) | ||
print("Input cfg file: {}".format(cfgFile)) | ||
print("isMC: {}".format(isMC)) | ||
print("isFSR: {}".format(isFSR)) | ||
|
||
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) | ||
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") | ||
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") | ||
|
||
p.run() | ||
print "DONE" | ||
jetmetCorrector = createJMECorrector(isMC=isMC, dataYear=year, jesUncert="All", jetType = "AK4PFchs") | ||
fatJetCorrector = createJMECorrector(isMC=isMC, dataYear=year, jesUncert="All", jetType = "AK8PFPuppi") | ||
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() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters