diff --git a/bs_select.py b/bs_select.py index 6be23b8..20ed08f 100644 --- a/bs_select.py +++ b/bs_select.py @@ -19,6 +19,7 @@ # TIMBER from TIMBER.Analyzer import * from TIMBER.Tools.Common import * +import helpers # Other import argparse import time, sys @@ -37,6 +38,7 @@ ########################################### # Deduce set name from input file setname = args.input.replace('.root','').split('/')[-1] +setname = '_'.join(setname.split('_')[:-1]) # Flags - https://twiki.cern.ch/twiki/bin/view/CMS/MissingETOptionalFiltersRun2 flags = ["Flag_goodVertices", @@ -65,17 +67,9 @@ def run(args): ROOT.ROOT.EnableImplicitMT(4) a = analyzer(args.input) - # Config loading - will have cuts, xsec, and lumi - config = OpenJSON(args.config) - cuts = config['CUTS'][args.year] - xsec, lumi = 1., 1. - if setname in config['XSECS'].keys() and not a.isData: - xsec = config['XSECS'][setname] - lumi = config['lumi'] - # Determine normalization weight if not a.isData: - norm = (xsec*lumi)/config['NEVENTS'][args.year]['_'.join(setname.split('_')[:-1])] + norm = helpers.getNormFactor(setname,args.year,args.config) else: norm = 1. diff --git a/helpers.py b/helpers.py index 970030d..c8e0925 100644 --- a/helpers.py +++ b/helpers.py @@ -9,7 +9,7 @@ def getNormFactor(setname,year,configPath): else: config = configPath cuts = config['CUTS'][year] lumi = config['lumi'+str(year)] - genEventCount = config['NEVENTS'][str(year)] + genEventCount = config['NEVENTS'][str(year)][setname] # Deal with unique ttbar cases if setname == 'ttbar' and year == '16': @@ -23,6 +23,7 @@ def getNormFactor(setname,year,configPath): raise KeyError('Key "%s" does not exist in config["XSECS"]'%setname) norm = (xsec*lumi)/genEventCount + print ('%s = %s * %s / %s'%(norm,xsec,lumi,genEventCount)) return norm