-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmass
More file actions
executable file
·86 lines (74 loc) · 2.77 KB
/
mass
File metadata and controls
executable file
·86 lines (74 loc) · 2.77 KB
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
#!/usr/bin/env python
from rootpy.io import root_open
from rootpy.plotting import Hist, Canvas, Legend
from rootpy.plotting.utils import get_limits
from rootpy.plotting.style.atlas import ATLAS_label
from mva.cmd import get_parser
from mva.analysis import get_analysis
from mva.categories import Category_1J_Inclusive, Category_Boosted, Category_VBF
from mva.variables import VARIABLES
from mva import MMC_MASS
import ROOT
def fwhm(h1):
bin1 = h1.FindFirstBinAbove(h1.max() / 2)
bin2 = h1.FindLastBinAbove(h1.max() / 2)
return h1.GetBinCenter(bin2) - h1.GetBinCenter(bin1)
def plot_mass(ztt, higgs, category):
print "FWHM:"
print " Ztt %.1f" % fwhm(ztt)
print " Htt %.1f" % fwhm(higgs)
_, _, _, ymax = get_limits([ztt, higgs], ypadding=(0.3, 0))
plot = Canvas()
ztt.Draw()
ztt.yaxis.title = 'Fraction of Events / 5 GeV'
ztt.xaxis.title = '%s [GeV]' % VARIABLES[MMC_MASS]['root']
ztt.yaxis.SetLimits(0, ymax)
ztt.yaxis.SetRangeUser(0, ymax)
ztt.xaxis.SetNdivisions(507, True)
higgs.Draw('same')
leg = Legend(2, pad=plot,
leftmargin=0.03,
rightmargin=0.3,
topmargin=0.12,
entryheight=0.04,
margin=0.2,
textsize=22)
leg.AddEntry(ztt, style='L')
leg.AddEntry(higgs, style='L')
leg.Draw()
ATLAS_label(0.62, 0.89,
sep=0.14, pad=plot, sqrts=None,
text="Internal", textsize=22)
label = ROOT.TLatex(
plot.GetLeftMargin() + 0.03, 0.89,
category.label)
label.SetNDC()
label.SetTextFont(43)
label.SetTextSize(22)
label.Draw()
for fmt in ('eps', 'png'):
plot.SaveAs('mass_%s.%s' % (category.name, fmt))
args = get_parser(actions=False).parse_args()
analysis = get_analysis(args)
region = 'OS'
template = Hist(40, 0, 200, linewidth=3, drawstyle='hist')
with root_open('mmc_hadhad_histos.root', 'recreate') as out:
for category in (Category_1J_Inclusive, Category_Boosted, Category_VBF):
ztt = template.Clone(name="%s_ztt" % category.name, title=analysis.ztautau.label)
higgs = template.Clone(name="%s_htt" % category.name, title=analysis.higgs_125.label, linecolor='red', linestyle='dashed')
analysis.ztautau.draw_into(ztt, MMC_MASS, category, region)
analysis.higgs_125.draw_into(higgs, MMC_MASS, category, region)
# normalize
ztt /= ztt.integral()
higgs /= higgs.integral()
# fit and get resolutions
#ztt_fit = ztt.Fit('gaus', 'S')
#higgs_fit = higgs.Fit('gaus', 'S')
#ztt_sigma = ztt_fit.Parameter(2)
#higgs_sigma = higgs_fit.Parameter(2)
#ztt_fwhm = 2.355 * ztt_sigma
#higgs_fwhm = 2.355 * higgs_sigma
# plot the mass distributions
plot_mass(ztt, higgs, category)
ztt.Write()
higgs.Write()