7 |
|
|
8 |
|
class StackMaker: |
9 |
|
def __init__(self, config, var,region,SignalRegion): |
10 |
– |
plotConfig = BetterConfigParser() |
11 |
– |
plotConfig.read('vhbbPlotDef.ini') |
10 |
|
section='Plot:%s'%region |
11 |
|
self.var = var |
12 |
+ |
self.SignalRegion=SignalRegion |
13 |
|
self.normalize = eval(config.get(section,'Normalize')) |
14 |
|
self.log = eval(config.get(section,'log')) |
15 |
< |
if plotConfig.has_option('plotDef:%s'%var,'log') and not self.log: |
16 |
< |
self.log = eval(plotConfig.get('plotDef:%s'%var,'log')) |
15 |
> |
if config.has_option('plotDef:%s'%var,'log') and not self.log: |
16 |
> |
self.log = eval(config.get('plotDef:%s'%var,'log')) |
17 |
|
self.blind = eval(config.get(section,'blind')) |
18 |
|
if self.blind: blindopt='blind' |
19 |
|
else: blindopt = 'noblind' |
28 |
|
if config.has_option(section,'nBins'): |
29 |
|
self.nBins = int(eval(config.get(section,'nBins'))/self.rebin) |
30 |
|
else: |
31 |
< |
self.nBins = int(eval(plotConfig.get('plotDef:%s'%var,'nBins'))/self.rebin) |
31 |
> |
self.nBins = int(eval(config.get('plotDef:%s'%var,'nBins'))/self.rebin) |
32 |
|
print self.nBins |
33 |
|
if config.has_option(section,'min'): |
34 |
|
self.xMin = eval(config.get(section,'min')) |
35 |
|
else: |
36 |
< |
self.xMin = eval(plotConfig.get('plotDef:%s'%var,'min')) |
36 |
> |
self.xMin = eval(config.get('plotDef:%s'%var,'min')) |
37 |
|
if config.has_option(section,'max'): |
38 |
|
self.xMax = eval(config.get(section,'max')) |
39 |
|
else: |
40 |
< |
self.xMax = eval(plotConfig.get('plotDef:%s'%var,'max')) |
41 |
< |
self.name = plotConfig.get('plotDef:%s'%var,'relPath') |
40 |
> |
self.xMax = eval(config.get('plotDef:%s'%var,'max')) |
41 |
> |
self.name = config.get('plotDef:%s'%var,'relPath') |
42 |
|
self.mass = config.get(section,'Signal') |
43 |
|
data = config.get(section,'Datas') |
44 |
|
if '<mass>' in self.name: |
51 |
|
self.colorDict=eval(config.get('Plot_general','colorDict')) |
52 |
|
self.typLegendDict=eval(config.get('Plot_general','typLegendDict')) |
53 |
|
self.anaTag = config.get("Analysis","tag") |
54 |
< |
self.xAxis = plotConfig.get('plotDef:%s'%var,'xAxis') |
54 |
> |
self.xAxis = config.get('plotDef:%s'%var,'xAxis') |
55 |
> |
self.plotDir = config.get('Directories','plotpath') |
56 |
|
self.options = [self.name,'',self.xAxis,self.nBins,self.xMin,self.xMax,'%s_%s.pdf'%(region,var),region,datacut,self.mass,data,blindopt] |
57 |
+ |
self.maxRatioUncert = 0.5 |
58 |
+ |
if self.SignalRegion: |
59 |
+ |
self.maxRatioUncert = 1000. |
60 |
|
self.config = config |
61 |
|
self.datas = None |
62 |
|
self.datatyps = None |
143 |
|
addFlag = 'Z(e^{-}e^{+})H(b#bar{b})' |
144 |
|
elif 'Zmm' in self.datanames: |
145 |
|
addFlag = 'Z(#mu^{-}#mu^{+})H(b#bar{b})' |
146 |
+ |
elif 'Znn' in self.datanames: |
147 |
+ |
addFlag = 'Z(#nu#nu)H(b#bar{b})' |
148 |
+ |
elif 'Wmn' in self.datanames: |
149 |
+ |
addFlag = 'W(#mu#nu)H(b#bar{b})' |
150 |
+ |
elif 'Wen' in self.datanames: |
151 |
+ |
addFlag = 'W(e#nu)H(b#bar{b})' |
152 |
|
for i in range(0,len(self.datas)): |
153 |
|
d1.Add(self.datas[i],1) |
154 |
|
print "\033[1;32m\n\tDATA integral = %s\033[1;m"%d1.Integral() |
173 |
|
stackhists=allStack.GetHists() |
174 |
|
for blabla in stackhists: |
175 |
|
if MC_integral != 0: blabla.Scale(stackscale) |
176 |
< |
|
177 |
< |
allMC=allStack.GetStack().Last().Clone() |
176 |
> |
|
177 |
> |
if self.SignalRegion: |
178 |
> |
allMC=allStack.GetStack().At(allStack.GetStack().GetLast()-1).Clone() |
179 |
> |
else: |
180 |
> |
allMC=allStack.GetStack().Last().Clone() |
181 |
|
|
182 |
|
allStack.SetTitle() |
183 |
|
allStack.Draw("hist") |
184 |
|
allStack.GetXaxis().SetTitle('') |
185 |
|
yTitle = 'Entries' |
186 |
|
if not '/' in yTitle: |
187 |
< |
yAppend = '%s' %(allStack.GetXaxis().GetBinWidth(1)) |
187 |
> |
yAppend = '%.2f' %(allStack.GetXaxis().GetBinWidth(1)) |
188 |
|
yTitle = '%s / %s' %(yTitle, yAppend) |
189 |
|
allStack.GetYaxis().SetTitle(yTitle) |
190 |
|
allStack.GetXaxis().SetRangeUser(self.xMin,self.xMax) |
226 |
|
#l2.SetTextSize(0.035) |
227 |
|
l2.SetNColumns(2) |
228 |
|
|
229 |
< |
ratio, error = getRatio(d1,allMC,self.xMin,self.xMax) |
229 |
> |
|
230 |
> |
ratio, error = getRatio(d1,allMC,self.xMin,self.xMax,"",self.maxRatioUncert) |
231 |
|
ksScore = d1.KolmogorovTest( allMC ) |
232 |
|
chiScore = d1.Chi2Test( allMC , "UWCHI2/NDF") |
233 |
|
print ksScore |
266 |
|
t0.SetTextFont(ROOT.gStyle.GetLabelFont()) |
267 |
|
if not self.log: |
268 |
|
t0.DrawTextNDC(0.1059,0.96, "0") |
269 |
< |
|
270 |
< |
name = '%s/%s' %(self.config.get('Directories','plotpath'),self.options[6]) |
269 |
> |
if not os.path.exists(self.plotDir): |
270 |
> |
os.makedirs(os.path.dirname(self.plotDir)) |
271 |
> |
name = '%s/%s' %(self.plotDir,self.options[6]) |
272 |
|
c.Print(name) |