Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions limits/LimitsLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
#"----------------User's decision board-----------------"

# choose which scripts to run
do_combineDatacards = False
do_produceLimits = False
do_producePlots = True #note that this flag can be turned to true only when the limit results have been produced
do_combineDatacards = True
do_produceLimits = True
do_producePlots = False #note that this flag can be turned to true only when the limit results have been produced


version_label = 'test3'
version_label = 'test00'

# path to datacards # Note that it will get /<year>/<channel> appended
path_to_datacards = './datacards'
path_to_datacards = '/work/manzoni/hnl_limits/CMSSW_10_2_13/src/HiggsAnalysis/CombinedLimit/WHNL_code/limits/datacards_july_talk/'

# which years to process
years = ['2016', '2017', '2018']
years = ['2018']

# which channels
channels = ['mmm', 'mem_os', 'mem_ss']
Expand All @@ -50,7 +50,7 @@
signal_type = 'majorana'

# you may want to select the mass values you would like to run on
mass_whiteList = ['10.0', '6.0'] #['10.0']
mass_whiteList = [] #['10.0']

# you may want to select the mass values you would like to ignore
mass_blackList = []
Expand Down Expand Up @@ -100,6 +100,7 @@ def getStringParser(input):
print 'Will run the limits production tool'

os.system('mkdir -p results/limits/{}'.format(version_label))
os.system('mkdir -p logs/{}'.format(version_label))

if run_blind: flag_blind = 1
else: flag_blind = 0
Expand Down Expand Up @@ -140,7 +141,7 @@ def getStringParser(input):

print 'will run the limit plotter'

command_plotter = 'python limit_plotter.py --version {ver} --signal {sig} --channels {ch} --mass_whitelist {mwl} --mass_blacklist {mbl} --coupling_whitelist {cwl} --coupling_blacklist {cbl}'.format(ver=version_label, sig=signal_type, ch=getStringParser(channels), mwl=getStringParser(mass_whiteList), mbl=getStringParser(mass_blackList), cwl=getStringParser(coupling_whiteList), cbl=getStringParser(coupling_blackList))
command_plotter = 'python limit_plotter.py --version {ver} --signal {sig} --years {ys} --channels {ch} --mass_whitelist {mwl} --mass_blacklist {mbl} --coupling_whitelist {cwl} --coupling_blacklist {cbl}'.format(ver=version_label, sig=signal_type, ys=getStringParser(years), ch=getStringParser(channels), mwl=getStringParser(mass_whiteList), mbl=getStringParser(mass_blackList), cwl=getStringParser(coupling_whiteList), cbl=getStringParser(coupling_blackList))
if run_blind:
command_plotter += ' --run_blind'

Expand Down
5 changes: 4 additions & 1 deletion limits/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Limits Analysis Tool

## Installation

Note: it is preferable to use a bash environment.

```
cmsrel CMSSW_10_2_13
cd CMSSW_10_2_13/src
Expand All @@ -15,7 +18,7 @@ make -j 8; make

```
git clone git@github.com:rmanzoni/plotter.git WHNL_code
cd plotter/limits
cd WHNLcode/limits
```

## Running the limits
Expand Down
4 changes: 2 additions & 2 deletions limits/combine_datacards.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def getOptions():

for channel in channels:
for year in years:
all_datacards[channel][year] = glob('/'.join([path_year[year], path_channel['mmm'], datacard_wildcard]))
all_datacards[channel][year] = [dd for dd in all_datacards[channel][year] if 'coarse' not in dd and signal_type in dd]
all_datacards[channel][year] = glob('/'.join([path_year[year], path_channel[channels[0]], datacard_wildcard]))
all_datacards[channel][year] = [dd for dd in all_datacards[channel][year] if signal_type in dd]
all_datacards[channel][year].sort()
print '... datacards {a}_{b} loaded'.format(a=channel, b=year)

Expand Down
11 changes: 4 additions & 7 deletions limits/limit_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def sortList(input):
limits2D[mass]['exp_plus_two' ] = x_plus_two
if not opt.run_blind:
limits2D[mass]['obs'] = x_obs


print '\nwill plot 2D limits'
with open('{}/results.pck'.format(plotDir), 'w') as ff:
Expand All @@ -237,20 +236,18 @@ def sortList(input):
obs.append( min(limits2D[mass]['obs']) )
masses_obs.append(mass)

if len(limits2D[mass]['exp_minus_one'])==len(limits2D[mass]['exp_plus_one']) and len(limits2D[mass]['exp_minus_two'])==len(limits2D[mass]['exp_plus_two']):
if len(limits2D[mass]['exp_central'])>0:
if len(limits2D[mass]['exp_central'])>0 and len(limits2D[mass]['exp_minus_one'])>0 and len(limits2D[mass]['exp_plus_one' ])>0 and len(limits2D[mass]['exp_minus_two'])>0 and len(limits2D[mass]['exp_plus_two' ])>0:
central.append( min(limits2D[mass]['exp_central']) )
masses_central.append(float(mass))

if len(limits2D[mass]['exp_minus_one'])>0 and len(limits2D[mass]['exp_plus_one' ])>0:
minus_one.append( min(limits2D[mass]['exp_minus_one']) )
plus_one .append( min(limits2D[mass]['exp_plus_one' ]) )
plus_one.append( min(limits2D[mass]['exp_plus_one' ]) )
masses_one_sigma.append(float(mass))

if len(limits2D[mass]['exp_minus_two'])>0 and len(limits2D[mass]['exp_plus_two' ])>0:
minus_two.append( min(limits2D[mass]['exp_minus_two']) )
plus_two .append( min(limits2D[mass]['exp_plus_two' ]) )
plus_two.append( min(limits2D[mass]['exp_plus_two' ]) )
masses_two_sigma.append(float(mass))


for mass in sorted(limits2D.keys(), key=sortList, reverse=True):

Expand Down
2 changes: 1 addition & 1 deletion nn/cfg/train_all_years.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
# 'l2_ptcone' ,
'log_hnl_2d_disp',
# 'isdata' ,
'log_hnl_2d_disp_sig_log',
# 'log_hnl_2d_disp_sig_log',

# 'l0_pt' ,
# 'abs_l0_eta' ,
Expand Down
10 changes: 7 additions & 3 deletions plotter/cfg/2017/plot_mem_ttbar.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
selection_mc = selection # + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']


training = 'run2/all_channels__200623_17h_51m'
#training = '2018/all_channels__200528_23h_35m'
training = 'all_channels_200213_14h_55m'
#training = 'all_channels_200213_14h_55m'
# training = 'all_channels_200526_12h_46m'
# training = 'all_channels_200525_19h_38m'
# training = 'all_channels_200525_18h_55m'
Expand Down Expand Up @@ -54,11 +56,13 @@
plot_signals = False,
blinded = False,

datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
#datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'],

mc_subtraction = True,

data_driven = False,
#data_driven = False,
data_driven = True,
)

if __name__ == '__main__':
Expand Down
17 changes: 10 additions & 7 deletions plotter/cfg/2017/plot_mmm.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200623_17h_51m'
#training = '2018/all_channels__200528_23h_35m'
#training = 'all_2017_channels_200116_15h_15m'
training = 'all_channels_200213_14h_55m'
#training = 'all_channels_200213_14h_55m'
# training = 'all_channels_200526_12h_46m'
# training = 'all_channels_200525_19h_38m'
# training = 'all_channels_200525_18h_55m'
Expand Down Expand Up @@ -61,12 +62,14 @@
plot_signals = False,
blinded = False,

datacards = ['log_hnl_2d_disp' ,
'hnl_m_12' ,
'hnl_m_12_lxy_lt_0p5' ,
'hnl_m_12_lxy_0p5_to_1p5',
'hnl_m_12_lxy_1p5_to_4p0',
'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
#datacards = ['log_hnl_2d_disp' ,
# 'hnl_m_12' ,
# 'hnl_m_12_lxy_lt_0p5' ,
# 'hnl_m_12_lxy_0p5_to_1p5',
# 'hnl_m_12_lxy_1p5_to_4p0',
# 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex

datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'],

mc_subtraction = True,

Expand Down
12 changes: 8 additions & 4 deletions plotter/cfg/2017/plot_mmm_zmm.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
selection_mc = selection # + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200623_17h_51m'
#training = '2018/all_channels__200528_23h_35m'
training = 'all_channels_200213_14h_55m'
#training = 'all_channels_200213_14h_55m'
# training = 'all_channels_200526_12h_46m'
# training = 'all_channels_200525_19h_38m'
# training = 'all_channels_200525_18h_55m'
Expand Down Expand Up @@ -60,11 +61,14 @@
plot_signals = False,
blinded = False,

datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
#datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'],

mc_subtraction = False,
#mc_subtraction = False,
mc_subtraction = True,

data_driven = False,
#data_driven = False,
data_driven = True,
)

if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion plotter/cfg/2018/plot_mem_os.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = '2018/all_channels__200528_23h_35m'
training = 'run2/all_channels__200623_17h_51m'
# training = '2018/all_channels__200528_23h_35m'
# training = 'all_channels_200526_12h_46m'
# training = 'all_channels_200525_19h_38m'
# training = 'all_channels_200525_18h_55m'
Expand Down
17 changes: 10 additions & 7 deletions plotter/cfg/2018/plot_mem_os_loose.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200604_15h_13m'
training = 'run2/all_channels__200623_17h_51m'
#training = 'run2/all_channels__200604_15h_13m'
# training = 'run2/all_channels__200602_17h_26m'
# training = 'run2/all_channels__200601_18h_20m'
# training = '2018/all_channels__200528_23h_35m'
Expand Down Expand Up @@ -76,13 +77,15 @@
plot_signals = False,
blinded = False,

datacards = ['log_hnl_2d_disp' ,
'hnl_m_12' ,
'hnl_m_12_lxy_lt_0p5' ,
'hnl_m_12_lxy_0p5_to_1p5',
'hnl_m_12_lxy_1p5_to_4p0',
'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
#datacards = ['log_hnl_2d_disp' ,
# 'hnl_m_12' ,
# 'hnl_m_12_lxy_lt_0p5' ,
# 'hnl_m_12_lxy_0p5_to_1p5',
# 'hnl_m_12_lxy_1p5_to_4p0',
# 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex

datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'],

mc_subtraction = False,

data_driven = True,
Expand Down
3 changes: 2 additions & 1 deletion plotter/cfg/2018/plot_mem_ss.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200623_17h_51m'
#training = '2018/all_channels__200528_23h_35m'
training = 'all_channels_200213_14h_55m'
#training = 'all_channels_200213_14h_55m'
# training = 'all_channels_200526_12h_46m'
# training = 'all_channels_200525_19h_38m'
# training = 'all_channels_200525_18h_55m'
Expand Down
3 changes: 2 additions & 1 deletion plotter/cfg/2018/plot_mem_ss_loose.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200604_15h_13m'
training = 'run2/all_channels__200623_17h_51m'
#training = 'run2/all_channels__200604_15h_13m'
# training = 'run2/all_channels__200602_17h_26m'
# training = 'run2/all_channels__200601_18h_20m'
# training = '2018/all_channels__200528_23h_35m'
Expand Down
20 changes: 12 additions & 8 deletions plotter/cfg/2018/plot_mmm.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
cuts.selections['vetoes_12_OS'],
cuts.selections['vetoes_01_OS'],
cuts.selections['vetoes_02_OS'],
# cuts.selections['signal_region'],
cuts.selections['sideband'],
cuts.selections['signal_region'],
# cuts.selections['sideband'],
'hlt_IsoMu24',
]

Expand All @@ -26,8 +26,11 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

#training = 'run2/all_channels__200601_18h_20m'
training = 'all_channels_200213_14h_55m'
# training = 'run2/all_channels__200623_19h_2m'
training = 'run2/all_channels__200623_16h_37m'
# training = 'run2/all_channels__200604_15h_13m'
# training = 'run2/all_channels__200602_17h_26m'
# training = 'run2/all_channels__200601_18h_20m'
# training = '2018/all_channels__200528_23h_35m'
# training = 'all_channels_200526_12h_46m'
# training = 'all_channels_200525_19h_38m'
Expand All @@ -43,8 +46,8 @@
plot_dir = '/'.join([env['BASE_DIR'], 'plotter', 'plots', '2018']),
base_dir = '/'.join([env['BASE_DIR'], 'ntuples', 'may20', '2018']),
post_fix = 'HNLTreeProducer_%s/tree.root' %ch,
# dir_suffix = 'signal_dd_datacards', #'signal',
dir_suffix = 'sideband',
dir_suffix = 'signal_dd_datacards_blinded', #'signal',
# dir_suffix = 'sideband',

selection_data = selection,
selection_mc = selection_mc,
Expand All @@ -58,9 +61,9 @@
features = '/'.join([env['BASE_DIR'], 'nn', 'trainings', training, 'input_features.pck' ]),

process_signals = True, # switch off for control regions
mini_signals = True, # process only the signals that you'll plot
mini_signals = False, # process only the signals that you'll plot
plot_signals = True,
blinded = False,
blinded = True,

datacards = ['log_hnl_2d_disp' ,
'hnl_m_12' ,
Expand All @@ -77,6 +80,7 @@
if __name__ == '__main__':
plotter.plot()
# save the plotter and all
#save_plotter_and_selections(plotter, selection, selection_mc, selection_tight, training)
save_plotter_and_selections(plotter, selection, selection_mc, selection_tight)
pass

17 changes: 10 additions & 7 deletions plotter/cfg/2018/plot_mmm_loose.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200604_15h_13m'
training = 'run2/all_channels__200623_17h_51m'
#training = 'run2/all_channels__200604_15h_13m'
# training = 'run2/all_channels__200602_17h_26m'
# training = 'run2/all_channels__200601_18h_20m'
# training = '2018/all_channels__200528_23h_35m'
Expand Down Expand Up @@ -76,12 +77,14 @@
plot_signals = False,
blinded = False,

datacards = ['log_hnl_2d_disp' ,
'hnl_m_12' ,
'hnl_m_12_lxy_lt_0p5' ,
'hnl_m_12_lxy_0p5_to_1p5',
'hnl_m_12_lxy_1p5_to_4p0',
'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex
#datacards = ['log_hnl_2d_disp' ,
# 'hnl_m_12' ,
# 'hnl_m_12_lxy_lt_0p5' ,
# 'hnl_m_12_lxy_0p5_to_1p5',
# 'hnl_m_12_lxy_1p5_to_4p0',
# 'hnl_m_12_lxy_mt_4p0'], # FIXME! improve this to accept wildcards / regex

datacards = ['hnl_m_12_lxy_lt_0p5', 'hnl_m_12_lxy_0p5_to_1p5', 'hnl_m_12_lxy_1p5_to_4p0', 'hnl_m_12_lxy_mt_4p0'],

mc_subtraction = False,

Expand Down
3 changes: 2 additions & 1 deletion plotter/cfg/2018/plot_mmm_signal.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
selection_mc = selection + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200623_17h_51m'
#training = 'all_channels_200526_12h_14m'
training = 'all_channels_200213_14h_55m'
#training = 'all_channels_200213_14h_55m'
# training = 'all_channels_200525_18h_55m'
# training = 'all_channels_200523_22h_39m' #<==== GOOD
# training = 'all_channels_200523_15h_53m'
Expand Down
3 changes: 2 additions & 1 deletion plotter/cfg/2018/plot_mmm_zmm.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
selection_mc = selection # + [cuts.selections['is_prompt_lepton']]
selection_tight = cuts.selections_pd['tight']

training = 'run2/all_channels__200623_17h_51m'
#training = '2018/all_channels__200528_18h_42m'
training = 'all_channels_200213_14h_55m'
#training = 'all_channels_200213_14h_55m'
# training = 'all_channels_200525_19h_38m'
# training = 'all_channels_200525_18h_55m'
# training = 'all_channels_200523_22h_39m' #<==== GOOD
Expand Down
4 changes: 3 additions & 1 deletion plotter/objects/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ def plot(self):

# data in tight
all_obs_prompt_norm = copy(all_obs_prompt)
all_obs_prompt_norm.Scale(np.nan_to_num(np.divide(1., all_obs_prompt_norm.integral())))
if all_obs_prompt_norm.integral() != 0:
all_obs_prompt_norm.Scale(np.nan_to_num(np.divide(1., all_obs_prompt_norm.integral())))
#import pdb; pdb.set_trace()
all_obs_prompt_norm.drawstyle = 'hist e'
all_obs_prompt_norm.linecolor = 'black'
all_obs_prompt_norm.markersize = 0
Expand Down