-
Notifications
You must be signed in to change notification settings - Fork 8
/
run_cbyear_plots.py
107 lines (86 loc) · 6.63 KB
/
run_cbyear_plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import os
import argparse
# python run_model_independent_limits_unblinding.py -o unblinding
parser = argparse.ArgumentParser()
parser.add_argument('--channel',help= 'Channel to run limits for', default='all')
parser.add_argument('--output','-o', help= 'Name of output directory', default='output')
parser.add_argument('--year', help= 'Name of input year', default='all')
parser.add_argument('--all_perm', help= 'Run all permutations of year and channel inputs', default=False)
parser.add_argument('--bOnly', help= 'Use b-only fit result', action='store_true')
args = parser.parse_args()
channel = args.channel
output = args.output
year = args.year
all_perm = args.all_perm
analysis = 'bsm-model-indep'
if all_perm:
if channel == 'fake':
channel_perm = ['et','mt','tt','fake']
elif channel == 'all':
channel_perm = ['em','et','mt','tt','all']
else:
channel_perm = channel.split(",").append(channel)
if year == 'all':
year_perm = ['2016','2017','2018','all']
else:
year_perm = year.split(',').append(year)
else:
channel_perm = [channel]
year_perm = [year]
for year in year_perm:
for channel in channel_perm:
### Set up channel input ###
if channel == "all":
cat_file = 'mssm_classic_categories_nobtag.txt'
elif channel == "fake":
cat_file = 'mssm_fake_categories.txt'
elif channel in ["et","tt","mt","em"]:
cat_file = 'mssm_%(channel)s_categories_nobtag.txt' % vars()
### Set up year input ###
if year == "all":
year_text = "2016,2017,2018"
year_list = ["2016","2017","2018"]
else:
year_text = year
year_list = year.split(",")
### Datacard creation ###
dc_creation_cmd = 'morph_parallel.py --output model_independent_limits/%(output)s_%(channel)s_%(year)s --analysis "%(analysis)s" --eras %(year_text)s --category-list input/%(cat_file)s --variable "mt_tot_puppi" --sm-gg-fractions data/higgs_pt_reweighting_fullRun2_v2.root --parallel 5 --additional-arguments="--auto_rebin=1 --manual_rebin=1 --real_data=1 --cbyear_plot=true " --sub-analysis "sm-like-light" --hSM-treatment "hSM-in-bg" --categorization="classic" --sm-like-hists="sm125" ' % vars()
os.system(dc_creation_cmd)
# take btag cats from m_sv binned one
cat_file_btag = 'mssm_classic_categories_btag.txt'
dc_creation_cmd_2 = 'morph_parallel.py --output model_independent_limits/%(output)s_%(channel)s_%(year)s --analysis "%(analysis)s" --eras %(year_text)s --category-list input/%(cat_file_btag)s --variable "mt_tot_puppi" --sm-gg-fractions data/higgs_pt_reweighting_fullRun2_v2.root --parallel 5 --additional-arguments="--auto_rebin=1 --manual_rebin=1 --real_data=1 --cbyear_plot=true " --sub-analysis "sm-like-light" --hSM-treatment "hSM-in-bg" --categorization="classic" --sm-like-hists="sm125" ' % vars()
os.system(dc_creation_cmd_2)
cat_file = 'mssm_classic_categories_2d_to_1d.txt'
dc_creation_cmd = 'morph_parallel.py --output model_independent_limits/%(output)s_all_all --analysis "%(analysis)s" --eras %(year_text)s --category-list input/%(cat_file)s --variable "m_sv_VS_pt_tt_splitpT" --sm-gg-fractions data/higgs_pt_reweighting_fullRun2_v2.root --parallel 5 --additional-arguments="--auto_rebin=1 --manual_rebin=1 --real_data=1 --cbyear_plot=true " --sub-analysis "sm-like-light" --hSM-treatment "hSM-in-bg" --categorization="lowmass" --sm-like-hists="sm125" ' % vars()
os.system(dc_creation_cmd)
cat_file_btag = 'mssm_classic_categories_btag.txt'
dc_creation_cmd = 'morph_parallel.py --output model_independent_limits/%(output)s_all_all --analysis "%(analysis)s" --eras %(year_text)s --category-list input/%(cat_file_btag)s --variable "m_sv_puppi" --sm-gg-fractions data/higgs_pt_reweighting_fullRun2_v2.root --parallel 5 --additional-arguments="--auto_rebin=1 --manual_rebin=1 --real_data=1 --cbyear_plot=true " --sub-analysis "sm-like-light" --hSM-treatment "hSM-in-bg" --categorization="lowmass" --sm-like-hists="sm125" ' % vars()
os.system(dc_creation_cmd)
directory = "model_independent_limits/%(output)s_%(channel)s_%(year)s_%(analysis)s" % vars()
for c in ['em','lt','tt']:
bins = [32,33,34,35,36,37,132,232,332,432]
for b in bins:
if b in [32,33,34,35,36,37]:
mass = 1200
fit_directory="model_independent_limits/Apr08_mt_tot_all_all_bsm-model-indep/"
freeze='--freeze r_bbH=0.001,r_ggH=0.0031'
outfile= 'shapes_cbyears_%(c)s_%(b)s_mt_tot.root' % vars()
fitfile = 'multidimfitggH.m%(mass)s.bestfit.robustHesse.root' % vars()
if args.bOnly: # only do b-only for mt_tot
outfile= 'shapes_cbyears_bOnly_%(c)s_%(b)s_mt_tot.root' % vars()
fitfile = 'multidimfitggH.bkgOnly.bestfit.robustHesse.root' % vars()
print 'Doing (mt_tot) bin: htt_%(c)s_%(b)s_mt_tot' % vars()
os.system('combineTool.py -M T2W -o "ws.root" -P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel --PO '"'"'"map=^.*/ggh_(i|t|b).?$:r_ggH[0,0,200]"'"'"' --PO '"map=^.*/bbh$:r_bbH[0,0,200]"' --PO '"map=^.*/qqX$:r_qqX[0]"' --PO '"'"'"map=^.*/ggX_(i|t|b).?$:r_ggX[0,0,200]"'"'"' -i %(directory)s/htt_%(c)s_%(b)s_mt_tot -m %(mass)s --parallel 8' % vars())
os.system('PostFitShapesFromWorkspace -w %(directory)s/htt_%(c)s_%(b)s_mt_tot/ws.root -d %(directory)s/htt_%(c)s_%(b)s_mt_tot/combined.txt.cmb --fitresult %(fit_directory)s/combined/cmb/%(fitfile)s:fit_mdf -o %(outfile)s --skip-prefit=true --mass %(mass)s --total-shapes=true --postfit %(freeze)s' % vars())
if b in [132,232,332,432,35]:
mass = 100
fit_directory="model_independent_limits/Apr08_all_all_bsm-model-indep/"
freeze='--freeze r_bbH=5.834,r_ggH=5.834'
outfile= 'shapes_cbyears_%(c)s_%(b)s.root' % vars()
fitfile = 'multidimfitggH.m%(mass)s.bestfit.robustHesse.root' % vars()
if args.bOnly:
outfile= 'shapes_cbyears_bOnly_%(c)s_%(b)s.root' % vars()
fitfile = 'multidimfitggH.bkgOnly.bestfit.robustHesse.root' % vars()
print 'Doing bin: htt_%(c)s_%(b)s' % vars()
os.system('combineTool.py -M T2W -o "ws.root" -P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel --PO '"'"'"map=^.*/ggh_(i|t|b).?$:r_ggH[0,0,200]"'"'"' --PO '"map=^.*/bbh$:r_bbH[0,0,200]"' --PO '"map=^.*/qqX$:r_qqX[0]"' --PO '"'"'"map=^.*/ggX_(i|t|b).?$:r_ggX[0,0,200]"'"'"' -i %(directory)s/htt_%(c)s_%(b)s -m %(mass)s --parallel 8' % vars())
os.system('PostFitShapesFromWorkspace -w %(directory)s/htt_%(c)s_%(b)s/ws.root -d %(directory)s/htt_%(c)s_%(b)s/combined.txt.cmb --fitresult %(fit_directory)s/combined/cmb/%(fitfile)s:fit_mdf -o %(outfile)s --skip-prefit=true --mass %(mass)s --total-shapes=true --postfit %(freeze)s' % vars())