-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot-features
executable file
·97 lines (82 loc) · 2.95 KB
/
plot-features
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
#!/usr/bin/env python
"""
Create variable plots
"""
from mva.cmd import get_parser
args = get_parser(actions=False).parse_args()
year = args.year
# rootpy imports
from rootpy.io import root_open
from rootpy.tree import Cut
import rootpy.plotting.utils as rootpy_utils
# local imports
from mva.plotting import draw_channel_array, uncertainty_band
from mva.systematics import get_systematics, parse_systematics
from mva.categories import CATEGORIES
from mva.massregions import MassRegions
from mva.variables import VARIABLES, YEAR_VARIABLES, get_label
from mva.analysis import get_analysis
from mva import log
SYSTEMATICS = get_systematics(year)
args.systematics_components = parse_systematics(args.systematics_components)
mass_regions = MassRegions(
low=args.low_mass_cut,
high=args.high_mass_cut,
high_sideband_in_control=args.high_sideband_in_control,
mass_window_signal_region=False,
#args.no_mmc,
# not enough events to only train in signal region
train_signal_region=False)
control_region = mass_regions.control_region
signal_region = mass_regions.signal_region
#signal_region = control_region # for creating control workspaces
train_region = mass_regions.train_region
categories = CATEGORIES[args.categories]
category_names = args.category_names
target_region = args.target_region
analysis = get_analysis(args)
output_suffix = analysis.get_suffix()
cat_defs = [args.categories]
if args.categories != 'presel':
cat_defs.append(args.controls)
for category in analysis.iter_categories(*cat_defs, names=args.category_names):
is_control = category.analysis_control
cuts = Cut(args.plot_cut)
if args.plot_expr is not None:
VARS = {
tuple(args.plot_expr.split(',')): {
'title': args.plot_name,
'range': (args.plot_min, args.plot_max),
'bins': args.plot_bins,
'filename': 'expr_' + args.plot_name.replace(' ', '_')}}
else:
VARS = VARIABLES
VARS.update(YEAR_VARIABLES[args.year])
clf = None
if not is_control:
clf = analysis.get_clf(category, load=True, transform=True)
figs = draw_channel_array(
analysis,
vars=VARS,
mass=125,
mode='combined',
signal_scale=(
50 if is_control or 'preselection' in category.name else 20),
plot_label=(
'Signal Region' if not is_control and
not ('preselection' in category.name) else None),
category=category,
region=target_region,
#systematics_components=args.systematics_components,
output_formats=args.output_formats,
weighted=not args.no_weight,
plots=args.plots,
output_suffix=output_suffix,
unblind=args.unblind, # or is_control,
cuts=cuts,
show_ratio=args.show_ratio,
#clf=clf,
#min_score=0.5924344731341187,
#no_data=args.no_data,
#top_label="Fakes Model: {0}".format(analysis.fakes_region),
)