Skip to content

Commit

Permalink
Added the PDF systematics and sum of Bkg as observation for blinded r…
Browse files Browse the repository at this point in the history
…egion
  • Loading branch information
Matthew authored and Matthew committed Dec 5, 2019
1 parent 26eda86 commit 5c4b555
Show file tree
Hide file tree
Showing 22 changed files with 15,227 additions and 14,326 deletions.
2 changes: 2 additions & 0 deletions Datacards/python/runLimits.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ def calcLimit(config, signal):
runLimitsCommand = 'combine -M AsymptoticLimits ' + combinedDatacard + ' -n ' + signal
if (mstop<450 and 'fbd' not in sigtype) or (mstop >= 350 and mlsp < 350 and 'T2tt' in sigtype) :
runLimitsCommand = 'combine -M AsymptoticLimits ' + combinedDatacard + ' --rMin 0 --rMax 10 -n ' + signal
if ('T2tt' in sigtype and mstop>=350 and mlsp >= 350) :
runLimitsCommand = 'combine -M AsymptoticLimits ' + combinedDatacard + ' --rMin 0 --rMax 10 -n ' + signal
if ('fbd' in sigtype or '4bd' in sigtype) and (mstop<=250):
runLimitsCommand = 'combine -M AsymptoticLimits ' + combinedDatacard + ' --rMin 0 --rMax 1 -n ' + signal
if config.expectedonly :
Expand Down
49 changes: 45 additions & 4 deletions Datacards/python/writeDatacard_SUSYNano19.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,38 @@ def parseBinMap(process, cr_description, yields_dict):
parts = ['@%d*%f'%(i, values[i]) for i in range(len(values))]
results['rateParam'] = ('(%s)'%('+'.join(parts)), ','.join(params))
return results

def sumBkgYields(process, signal, cr_description, yields_dict):
values = []
params = []
sumE2 = 0
total = 0.
crproc = 'lepcr' if 'ttbar' in process else ('qcdcr' if 'qcd' in process else 'phocr')
for entry in cr_description.replace(' ','').split('+'):
crdata = 0
crunit = 0.
srunit = 0.
sr, cr = entry.split('*')
if '<' in cr: sr, cr = cr, sr
sr = sr.strip('<>')
cr = cr.strip('()')
crdata = yields[crproc + '_data'][cr][0]
srunit = yields_dict[process][sr][0]
if 'ttbar' in process:
crunit = yields_dict[crproc+'_'+process][cr][0]
crunit+=sigYields['lepcr_'+signal][cr][0]
if 'qcd' in process:
crunit = yields_dict[crproc+'_'+process][cr][0]
crunit+=yields['qcdcr_otherbkgs'][cr][0]
if 'znunu' in process:
crunit = yields_dict[crproc+'_gjets'][cr][0]
if yields['phocr_back'][cr][0]>=0:
crunit+=yields['phocr_back'][cr][0]
else:
crunit+=1e-06
total += crdata*srunit/crunit
return total

# ------ helper functions ------

# ------ process uncertainties ------
Expand Down Expand Up @@ -240,9 +272,9 @@ def writePhocr(signal):
cb.AddProcesses(procs = ['gjets', 'otherbkgs'], bin = [(0, crbin)], signal=False)
cb.ForEachObs(lambda obs : obs.set_rate(yields['phocr_data'][crbin][0]))
cb.cp().process(['gjets']).ForEachProc(lambda p : p.set_rate(yields['phocr_gjets'][crbin][0]))
cb.cp().process(['otherbkgs']).ForEachProc(lambda p : p.set_rate(yields['phocr_back'][crbin][0]))
#if yields['phocr_back'][crbin][0] > 0: cb.cp().process(['otherbkgs']).ForEachProc(lambda p : p.set_rate(yields['phocr_back'][crbin][0]))
#else: cb.cp().process(['otherbkgs']).ForEachProc(lambda p : p.set_rate(1e-06))
#cb.cp().process(['otherbkgs']).ForEachProc(lambda p : p.set_rate(yields['phocr_back'][crbin][0]))
if yields['phocr_back'][crbin][0] > 0: cb.cp().process(['otherbkgs']).ForEachProc(lambda p : p.set_rate(yields['phocr_back'][crbin][0]))
else: cb.cp().process(['otherbkgs']).ForEachProc(lambda p : p.set_rate(1e-06))
# stat uncs
cb.cp().process(['gjets']).AddSyst(cb, "R_$BIN", "rateParam", ch.SystMap()(1.0))
cb.AddSyst(cb, "mcstats_$PROCESS_$BIN", "lnN", ch.SystMap('process')
Expand Down Expand Up @@ -308,8 +340,17 @@ def writeSR(signal):
cb.AddObservations(['*'], ['stop'], ['13TeV'], ['0l'], [(0, bin)])
cb.AddProcesses(procs = ['signal'], bin = [(0, bin)], signal=True)
cb.AddProcesses(procs = ['ttbarplusw', 'znunu', 'qcd', 'ttZ', 'diboson'], bin = [(0, bin)], signal=False)
expected = 0.
for proc in ['ttZ', 'diboson']:
expected += yields[proc][bin][0]
for proc in ['ttbarplusw', 'znunu', 'qcd']:
if bin not in mergedbins:
expected += yields[proc][bin][0]
else:
expected += sumBkgYields(proc, signal, binMaps[processMap[proc]][bin], yields)

if not blind: cb.ForEachObs(lambda obs : obs.set_rate(yields['data'][bin][0]))
else: cb.ForEachObs(lambda obs : obs.set_rate(1))
else: cb.ForEachObs(lambda obs : obs.set_rate(expected))
cb.cp().process(['signal']).ForEachProc(lambda p : p.set_rate(sigYields[signal][bin][0]))
cb.cp().process(['ttZ','diboson']).ForEachProc(lambda p : p.set_rate(yields[p.process()][bin][0]))
cb.cp().process(['signal','ttZ','diboson']).AddSyst(cb, "mcstats_$PROCESS_$BIN", "lnN", ch.SystMap('process')
Expand Down
6 changes: 3 additions & 3 deletions Datacards/setup/SUSYNano19/Rare_pred.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@
0.00603928929194808,
0.013679943572341776
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt300to400": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt300to400": [
1.0128676891326904,
0.3290402918582859
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt400to500": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt400to500": [
0.1309640109539032,
0.04661689785173373
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt500toinf": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt500toinf": [
0.08032932877540588,
0.0360994671582333
],
Expand Down
6 changes: 3 additions & 3 deletions Datacards/setup/SUSYNano19/Rare_pred_2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@
0.0,
0.00810075265745082
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt300to400": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt300to400": [
0.12727287411689758,
0.04068478760681516
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt400to500": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt400to500": [
0.03303467482328415,
0.02678410574156789
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt500toinf": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt500toinf": [
0.022785251960158348,
0.01735169247646529
],
Expand Down
6 changes: 3 additions & 3 deletions Datacards/setup/SUSYNano19/TTZ_pred.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@
0.008211933076381683,
0.005812215469268774
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt300to400": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt300to400": [
0.10183428227901459,
0.0234249203201373
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt400to500": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt400to500": [
0.08097819983959198,
0.01618731283867701
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt500toinf": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt500toinf": [
0.014617698267102242,
0.012244001651545844
],
Expand Down
6 changes: 3 additions & 3 deletions Datacards/setup/SUSYNano19/TTZ_pred_2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@
0.0,
0.0043660076083225806
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt300to400": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt300to400": [
0.008347108960151672,
0.009658880325622713
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt400to500": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt400to500": [
0.01911473087966442,
0.0072951525218354655
],
"bin_lm_nb1_nivf1_lowmtb_lowptb_MET_pt500toinf": [
"bin_lm_nb1_nivf1_lowmtb_medptisr_lowptb_MET_pt500toinf": [
0.0,
0.0036518181100321815
],
Expand Down
Loading

0 comments on commit 5c4b555

Please sign in to comment.