Skip to content

Commit

Permalink
Merge remote-tracking branch 'lucas/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cmantill committed Jan 15, 2021
2 parents 637ce7b + f76a35f commit d3eddc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 3 additions & 9 deletions bs_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# TIMBER
from TIMBER.Analyzer import *
from TIMBER.Tools.Common import *
import helpers
# Other
import argparse
import time, sys
Expand All @@ -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",
Expand Down Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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

Expand Down

0 comments on commit d3eddc0

Please sign in to comment.