forked from vinzenzstampf/PlotFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_overlap.py
168 lines (152 loc) · 6.69 KB
/
plot_overlap.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
##########################
# Configuration
##########################
import ROOT
import plotfactory as pf
import numpy as np
from array import array
import sys
from pdb import set_trace
pf.setpfstyle()
output_dir = 'temp/'
chain = ROOT.TChain('tree')
file = '/Users/dehuazhu/lxplus/CMSSW_10_2_X_2018-05-24-2300/src/overlap_ntuple.root'
chain.Add(file)
c_pt = ROOT.TCanvas('c_pt','c_pt')
binsx = np.arange(-1.,1.,0.05)
h_pt=ROOT.TH1F('h_pt','',len(binsx)-1,binsx)
h_pt.SetTitle(';(pt_{dsa} - pt_{smu}) / pt_{smu};entries')
chain.Draw('(dSAMu_pt-sMu_pt)/sMu_pt >> h_pt','dSAMu_pt > 0. & sMu_pt > 0.')
h_pt.Draw()
pf.showlumi('ttbar %d entries'%(h_pt.GetEntries()))
c_pt.Update()
c_pt.SaveAs(output_dir + 'c_pt.root')
c_pt.SaveAs(output_dir + 'c_pt.pdf')
c_ptscatter = ROOT.TCanvas('c_ptscatter','c_ptscatter')
c_ptscatter.cd()
binsx = np.arange(0.,100.,2.)
binsy = np.arange(0.,100.,2.)
h_ptscatter = ROOT.TH2F('h_ptscatter','',len(binsx)-1,binsx,len(binsy)-1,binsy)
h_ptscatter.SetTitle(';pt_{sMu};pt_{dSAMu}')
chain.Draw('dSAMu_pt:sMu_pt >> h_ptscatter','dSAMu_pt>0. & sMu_pt>0.')
h_ptscatter.Draw('colz')
pf.showlumi('ttbar %d entries'%(h_ptscatter.GetEntries()))
c_ptscatter.SetLogz()
c_ptscatter.Update()
c_ptscatter.SaveAs(output_dir + 'c_ptscatter.root')
c_ptscatter.SaveAs(output_dir + 'c_ptscattter.pdf')
c_cov00 = ROOT.TCanvas('c_cov00','c_cov00')
binsx = np.arange(-2.,3.,0.05)
h_cov00=ROOT.TH1F('h_cov00','',len(binsx)-1,binsx)
h_cov00.SetTitle(';(cov00_{dsa} - cov00_{smu}) / cov00_{smu};entries')
chain.Draw('(dSAMu_cov00-sMu_cov00)/sMu_cov00 >> h_cov00','dSAMu_cov00 > 0. & sMu_cov00 > 0.')
h_cov00.Draw()
pf.showlumi('ttbar %d entries'%(h_cov00.GetEntries()))
c_cov00.Update()
c_cov00.SaveAs(output_dir + 'c_cov00.root')
c_cov00.SaveAs(output_dir + 'c_cov00.pdf')
c_cov00scatter = ROOT.TCanvas('c_cov00scatter','c_cov00scatter')
c_cov00scatter.cd()
binsx = np.arange(0.,0.000005,0.0000001)
binsy = np.arange(0.,0.00001,0.0000002)
h_cov00scatter = ROOT.TH2F('h_cov00scatter','',len(binsx)-1,binsx,len(binsy)-1,binsy)
h_cov00scatter.SetTitle(';cov00_{sMu};cov00_{dSAMu}')
chain.Draw('dSAMu_cov00:sMu_cov00 >> h_cov00scatter','dSAMu_cov00>0. & sMu_cov00>0.')
h_cov00scatter.Draw('colz')
pf.showlumi('ttbar %d entries'%(h_cov00scatter.GetEntries()))
# c_cov00scatter.SetLogz()
c_cov00scatter.Update()
c_cov00scatter.SaveAs(output_dir + 'c_cov00scatter.root')
c_cov00scatter.SaveAs(output_dir + 'c_cov00scattter.pdf')
c_cov11 = ROOT.TCanvas('c_cov11','c_cov11')
binsx = np.arange(-2.,3.,0.05)
h_cov11=ROOT.TH1F('h_cov11','',len(binsx)-1,binsx)
h_cov11.SetTitle(';(cov11{dsa} - cov11{smu}) / cov11{smu};entries')
chain.Draw('(dSAMu_cov11-sMu_cov11)/sMu_cov11 >> h_cov11','dSAMu_cov11 > 0. & sMu_cov11 > 0.')
h_cov11.Draw()
pf.showlumi('ttbar %d entries'%(h_cov11.GetEntries()))
c_cov11.Update()
c_cov11.SaveAs(output_dir + 'c_cov11.root')
c_cov11.SaveAs(output_dir + 'c_cov11.pdf')
c_cov11scatter = ROOT.TCanvas('c_cov11scatter','c_cov11scatter')
c_cov11scatter.cd()
binsx = np.arange(0.,0.00001,0.0000002)
binsy = np.arange(0.,0.00001,0.0000002)
h_cov11scatter = ROOT.TH2F('h_cov11scatter','',len(binsx)-1,binsx,len(binsy)-1,binsy)
h_cov11scatter.SetTitle(';cov11_{sMu};cov11_{dSAMu}')
chain.Draw('dSAMu_cov11:sMu_cov11 >> h_cov11scatter','dSAMu_cov11>0. & sMu_cov11>0.')
h_cov11scatter.Draw('colz')
pf.showlumi('ttbar %d entries'%(h_cov11scatter.GetEntries()))
# c_cov11scatter.SetLogz()
c_cov11scatter.Update()
c_cov11scatter.SaveAs(output_dir + 'c_cov11scatter.root')
c_cov11scatter.SaveAs(output_dir + 'c_cov11scattter.pdf')
c_cov22 = ROOT.TCanvas('c_cov22','c_cov22')
binsx = np.arange(-2.,30.,0.5)
h_cov22=ROOT.TH1F('h_cov22','',len(binsx)-1,binsx)
h_cov22.SetTitle(';(cov22{dsa} - cov22{smu}) / cov22{smu};entries')
chain.Draw('(dSAMu_cov22-sMu_cov22)/sMu_cov22 >> h_cov22','dSAMu_cov22 > 0. & sMu_cov22 > 0.')
h_cov22.Draw()
pf.showlumi('ttbar %d entries'%(h_cov22.GetEntries()))
c_cov22.Update()
c_cov22.SaveAs(output_dir + 'c_cov22.root')
c_cov22.SaveAs(output_dir + 'c_cov22.pdf')
c_cov22scatter = ROOT.TCanvas('c_cov22scatter','c_cov22scatter')
c_cov22scatter.cd()
binsx = np.arange(0.,0.00005,0.000001)
binsy = np.arange(0.,0.001,0.00002)
h_cov22scatter = ROOT.TH2F('h_cov22scatter','',len(binsx)-1,binsx,len(binsy)-1,binsy)
h_cov22scatter.SetTitle(';cov22_{sMu};cov22_{dSAMu}')
chain.Draw('dSAMu_cov22:sMu_cov22 >> h_cov22scatter','dSAMu_cov22>0. & sMu_cov22>0.')
h_cov22scatter.Draw('colz')
pf.showlumi('ttbar %d entries'%(h_cov22scatter.GetEntries()))
# c_cov22scatter.SetLogz()
c_cov22scatter.Update()
c_cov22scatter.SaveAs(output_dir + 'c_cov22scatter.root')
c_cov22scatter.SaveAs(output_dir + 'c_cov22scattter.pdf')
c_cov33 = ROOT.TCanvas('c_cov33','c_cov33')
binsx = np.arange(-10.,2200.,50)
h_cov33=ROOT.TH1F('h_cov33','',len(binsx)-1,binsx)
h_cov33.SetTitle(';(cov33{dsa} - cov33{smu}) / cov33{smu};entries')
chain.Draw('(dSAMu_cov33-sMu_cov33)/sMu_cov33 >> h_cov33','dSAMu_cov33 > 0. & sMu_cov33 > 0.')
h_cov33.Draw()
pf.showlumi('ttbar %d entries'%(h_cov33.GetEntries()))
c_cov33.Update()
c_cov33.SaveAs(output_dir + 'c_cov33.root')
c_cov33.SaveAs(output_dir + 'c_cov33.pdf')
c_cov33scatter = ROOT.TCanvas('c_cov33scatter','c_cov33scatter')
c_cov33scatter.cd()
binsx = np.arange(0.00997,0.01,0.0000006)
binsy = np.arange(0.,50.,1.)
h_cov33scatter = ROOT.TH2F('h_cov33scatter','',len(binsx)-1,binsx,len(binsy)-1,binsy)
h_cov33scatter.SetTitle(';cov33_{sMu};cov33_{dSAMu}')
chain.Draw('dSAMu_cov33:sMu_cov33 >> h_cov33scatter','dSAMu_cov33>0. & sMu_cov33>0.')
h_cov33scatter.Draw('colz')
pf.showlumi('ttbar %d entries'%(h_cov33scatter.GetEntries()))
# c_cov33scatter.SetLogz()
c_cov33scatter.Update()
c_cov33scatter.SaveAs(output_dir + 'c_cov33scatter.root')
c_cov33scatter.SaveAs(output_dir + 'c_cov33scattter.pdf')
c_cov44 = ROOT.TCanvas('c_cov44','c_cov44')
binsx = np.arange(-2.,3.,0.05)
h_cov44=ROOT.TH1F('h_cov44','',len(binsx)-1,binsx)
h_cov44.SetTitle(';(cov44{dsa} - cov44{smu}) / cov44{smu};entries')
chain.Draw('(dSAMu_cov44-sMu_cov44)/sMu_cov44 >> h_cov44','dSAMu_cov44 > 0. & sMu_cov44 > 0.')
h_cov44.Draw()
pf.showlumi('ttbar %d entries'%(h_cov44.GetEntries()))
c_cov44.Update()
c_cov44.SaveAs(output_dir + 'c_cov44.root')
c_cov44.SaveAs(output_dir + 'c_cov44.pdf')
c_cov44scatter = ROOT.TCanvas('c_cov44scatter','c_cov44scatter')
c_cov44scatter.cd()
binsx = np.arange(0.,5.,0.1)
binsy = np.arange(0.,5.,0.1)
h_cov44scatter = ROOT.TH2F('h_cov44scatter','',len(binsx)-1,binsx,len(binsy)-1,binsy)
h_cov44scatter.SetTitle(';cov44_{sMu};cov44_{dSAMu}')
chain.Draw('dSAMu_cov44:sMu_cov44 >> h_cov44scatter','dSAMu_cov44>0. & sMu_cov44>0.')
h_cov44scatter.Draw('colz')
pf.showlumi('ttbar %d entries'%(h_cov44scatter.GetEntries()))
# c_cov44scatter.SetLogz()
c_cov44scatter.Update()
c_cov44scatter.SaveAs(output_dir + 'c_cov44scatter.root')
c_cov44scatter.SaveAs(output_dir + 'c_cov44scattter.pdf')