2 |
|
import ROOT |
3 |
|
from ROOT import TFile |
4 |
|
from Ratio import getRatio |
5 |
+ |
import TdrStyles |
6 |
+ |
from BetterConfigParser import BetterConfigParser |
7 |
+ |
from optparse import OptionParser |
8 |
+ |
import sys |
9 |
+ |
|
10 |
+ |
argv = sys.argv |
11 |
+ |
parser = OptionParser() |
12 |
+ |
parser.add_option("-C", "--config", dest="config", default=[], action="append", |
13 |
+ |
help="configuration file") |
14 |
+ |
(opts, args) = parser.parse_args(argv) |
15 |
+ |
config = BetterConfigParser() |
16 |
+ |
config.read(opts.config) |
17 |
|
|
18 |
|
|
19 |
< |
#Abin='RMed4' |
8 |
< |
#mass='125' |
9 |
< |
#channel='Zee' |
10 |
< |
path='~/VHbb/Limits/ICHEP' |
11 |
< |
outpath='~/VHbb/Stacks/ICHEP/' |
12 |
< |
|
19 |
> |
#---------- yes, this is not in the config yet--------- |
20 |
|
xMin=-1 |
21 |
|
xMax=1 |
22 |
< |
#MC='ZjCF' |
23 |
< |
#syst='CMS_beff' |
22 |
> |
masses = ['125'] |
23 |
> |
Abins = ['HighPt','LowPt'] |
24 |
> |
channels= ['Zee','Zmm'] |
25 |
> |
#------------------------------------------------------ |
26 |
> |
|
27 |
> |
|
28 |
> |
|
29 |
> |
path = samplesinfo=config.get('Directories','limits') |
30 |
> |
outpath = samplesinfo=config.get('Directories','plotpath') |
31 |
> |
|
32 |
> |
setup = eval(config.get('LimitGeneral','setup')) |
33 |
> |
Dict = eval(config.get('LimitGeneral','Dict')) |
34 |
> |
MCs = [Dict[s] for s in setup] |
35 |
> |
|
36 |
> |
sys_BDT= eval(config.get('LimitGeneral','sys_BDT')) |
37 |
> |
systematicsnaming8TeV = eval(config.get('LimitGeneral','systematicsnaming8TeV')) |
38 |
> |
systs=[systematicsnaming8TeV[s] for s in sys_BDT] |
39 |
|
|
40 |
< |
for mass in ['110','115','120','125','130','135']: |
19 |
< |
for Abin in ['RMed4','RTight4']: |
20 |
< |
for channel in ['Zee','Zmm']: |
40 |
> |
if eval(config.get('LimitGeneral','weightF_sys')): systs.append('UEPS') |
41 |
|
|
42 |
< |
input = TFile.Open(path+'/vhbb_TH_BDT'+Abin+'_M'+mass+'_'+channel+'.root','read') |
42 |
> |
def myText(txt="CMS Preliminary",ndcX=0,ndcY=0,size=0.8): |
43 |
> |
ROOT.gPad.Update() |
44 |
> |
text = ROOT.TLatex() |
45 |
> |
text.SetNDC() |
46 |
> |
text.SetTextColor(ROOT.kBlack) |
47 |
> |
text.SetTextSize(text.GetTextSize()*size) |
48 |
> |
text.DrawLatex(ndcX,ndcY,txt) |
49 |
> |
return text |
50 |
|
|
51 |
|
|
52 |
< |
for MC in ['VH','ZjLF','ZjHF','VV','TT','s_Top']: |
53 |
< |
for syst in ['JER','JEC','Btag','BtagFake']: |
52 |
> |
#for mass in ['110','115','120','125','130','135']: |
53 |
> |
for mass in masses: |
54 |
> |
for Abin in Abins: |
55 |
> |
for channel in channels: |
56 |
> |
|
57 |
> |
input = TFile.Open(path+'/vhbb_TH_BDT_M'+mass+'_'+channel+Abin+'_8TeV.root','read') |
58 |
> |
|
59 |
> |
|
60 |
> |
for MC in MCs: |
61 |
> |
for syst in systs: |
62 |
> |
#['CMS_res_j','CMS_scale_j','CMS_eff_b','CMS_fake_b_8TeV','UEPS']: |
63 |
|
#for syst in ['CMS_vhbb_stats_']: |
64 |
|
|
65 |
< |
ROOT.gROOT.SetStyle("Plain") |
66 |
< |
c = ROOT.TCanvas('canvas','canvas', 800, 700) |
67 |
< |
oben = ROOT.TPad('oben','oben',0,0.2 ,1.0,1.0,10) |
68 |
< |
unten = ROOT.TPad('unten','unten',0,0.05,1.0,0.2,10) |
65 |
> |
|
66 |
> |
TdrStyles.tdrStyle() |
67 |
> |
|
68 |
> |
c = ROOT.TCanvas('','', 600, 600) |
69 |
> |
c.SetFillStyle(4000) |
70 |
> |
c.SetFrameFillStyle(1000) |
71 |
> |
c.SetFrameFillColor(0) |
72 |
> |
oben = ROOT.TPad('oben','oben',0,0.3 ,1.0,1.0) |
73 |
> |
oben.SetBottomMargin(0) |
74 |
> |
oben.SetFillStyle(4000) |
75 |
> |
oben.SetFrameFillStyle(1000) |
76 |
> |
oben.SetFrameFillColor(0) |
77 |
> |
unten = ROOT.TPad('unten','unten',0,0.0,1.0,0.3) |
78 |
> |
unten.SetTopMargin(0.) |
79 |
> |
unten.SetBottomMargin(0.35) |
80 |
> |
unten.SetFillStyle(4000) |
81 |
> |
unten.SetFrameFillStyle(1000) |
82 |
> |
unten.SetFrameFillColor(0) |
83 |
|
oben.Draw() |
84 |
|
unten.Draw() |
85 |
|
oben.cd() |
86 |
+ |
|
87 |
|
ROOT.gPad.SetTicks(1,1) |
88 |
|
|
89 |
|
|
92 |
|
#Utotal=input.Get(MC+syst+MC+'_'+channel+'Up') |
93 |
|
Dtotal=input.Get(MC+syst+'Down') |
94 |
|
#Dtotal=input.Get(MC+syst+MC+'_'+channel+'Down') |
95 |
< |
l = ROOT.TLegend(0.11, 0.89, 0.3, 0.7) |
95 |
> |
l = ROOT.TLegend(0.17, 0.8, 0.37, 0.65) |
96 |
> |
|
97 |
> |
l.SetLineWidth(2) |
98 |
> |
l.SetBorderSize(0) |
99 |
> |
l.SetFillColor(0) |
100 |
> |
l.SetFillStyle(4000) |
101 |
> |
l.SetTextFont(62) |
102 |
> |
l.SetTextSize(0.035) |
103 |
> |
|
104 |
> |
|
105 |
|
l.AddEntry(Ntotal,'nominal','PL') |
106 |
|
l.AddEntry(Utotal,'up','PL') |
107 |
|
l.AddEntry(Dtotal,'down','PL') |
108 |
+ |
Ntotal.GetYaxis().SetRangeUser(0,1.5*Ntotal.GetBinContent(Ntotal.GetMaximumBin())) |
109 |
|
Ntotal.SetMarkerStyle(8) |
110 |
|
Ntotal.SetLineColor(1) |
111 |
|
Ntotal.SetStats(0) |
124 |
|
l.SetBorderSize(0) |
125 |
|
l.Draw() |
126 |
|
|
127 |
+ |
title=myText('Shape Systematic %s in %s'%(syst,MC),0.17,0.85) |
128 |
+ |
|
129 |
+ |
print 'Shape Systematic %s in %s'%(syst,MC) |
130 |
+ |
print 'Up: \t%s'%Utotal.Integral() |
131 |
+ |
print 'Nominal:\t%s'%Ntotal.Integral() |
132 |
+ |
print 'Down: \t%s'%Dtotal.Integral() |
133 |
|
|
134 |
|
unten.cd() |
135 |
|
ROOT.gPad.SetTicks(1,1) |
136 |
|
|
137 |
< |
ratioU, errorU, ksScoreU, chiScoreU = getRatio(Utotal,Ntotal,xMin,xMax,"Ratio",10,True) |
138 |
< |
ratioD, errorD, ksScoreD, chiScoreD = getRatio(Dtotal,Ntotal,xMin,xMax,"Ratio",10,True) |
137 |
> |
ratioU, errorU = getRatio(Utotal,Ntotal,xMin,xMax) |
138 |
> |
ratioD, errorD = getRatio(Dtotal,Ntotal,xMin,xMax) |
139 |
> |
|
140 |
> |
ksScoreU = Ntotal.KolmogorovTest( Utotal ) |
141 |
> |
chiScoreU = Ntotal.Chi2Test( Utotal , "WWCHI2/NDF") |
142 |
> |
ksScoreD = Ntotal.KolmogorovTest( Dtotal ) |
143 |
> |
chiScoreD = Ntotal.Chi2Test( Dtotal , "WWCHI2/NDF") |
144 |
> |
|
145 |
> |
|
146 |
> |
|
147 |
|
|
148 |
|
ratioU.SetStats(0) |
149 |
|
ratioU.GetYaxis().SetRangeUser(0.5,1.5) |
150 |
|
ratioU.GetYaxis().SetNdivisions(502,0) |
151 |
< |
ratioU.GetYaxis().SetLabelSize(0.2) |
152 |
< |
ratioU.GetYaxis().SetTitleSize(0.2) |
153 |
< |
ratioU.GetYaxis().SetTitleOffset(0.2) |
154 |
< |
ratioU.GetXaxis().SetLabelColor(10) |
151 |
> |
#ratioU.GetYaxis().SetLabelSize(0.2) |
152 |
> |
#ratioU.GetYaxis().SetTitleSize(0.2) |
153 |
> |
#ratioU.GetYaxis().SetTitleOffset(0.2) |
154 |
> |
#ratioU.GetXaxis().SetLabelColor(10) |
155 |
|
ratioU.SetLineColor(4) |
156 |
|
ratioU.SetLineStyle(4) |
157 |
< |
ratioU.SetLineWidth(2) |
157 |
> |
ratioU.SetLineWidth(2) |
158 |
> |
ratioU.GetXaxis().SetTitle('BDT output') |
159 |
> |
ratioU.GetYaxis().SetTitle('Ratio') |
160 |
|
ratioU.Draw("hist") |
161 |
|
ratioU.SetTitle("") |
162 |
|
ratioD.SetStats(0) |
163 |
|
ratioD.GetYaxis().SetRangeUser(0.5,1.5) |
164 |
|
ratioD.GetYaxis().SetNdivisions(502,0) |
165 |
< |
ratioD.GetYaxis().SetLabelSize(0.2) |
166 |
< |
ratioD.GetYaxis().SetTitleSize(0.2) |
167 |
< |
ratioD.GetYaxis().SetTitleOffset(0.2) |
168 |
< |
ratioD.GetXaxis().SetLabelColor(10) |
165 |
> |
#ratioD.GetYaxis().SetLabelSize(0.2) |
166 |
> |
#ratioD.GetYaxis().SetTitleSize(0.2) |
167 |
> |
#ratioD.GetYaxis().SetTitleOffset(0.2) |
168 |
> |
#ratioD.GetXaxis().SetLabelColor(10) |
169 |
|
ratioD.SetLineColor(2) |
170 |
|
ratioD.SetLineStyle(3) |
171 |
|
ratioD.SetLineWidth(2) |
176 |
|
m_one_line.SetLineColor(4) |
177 |
|
m_one_line.Draw("Same") |
178 |
|
|
102 |
– |
|
179 |
|
|
180 |
|
#name = outpath+Abin+'_M'+mass+'_'+channel+'_'+MC+syst+'.png' |
181 |
|
#c.Print(name) |
183 |
|
c.Print(name) |
184 |
|
|
185 |
|
|
186 |
< |
input.Close() |
186 |
> |
input.Close() |