ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/tree_stack.py
(Generate patch)

Comparing UserCode/VHbb/python/tree_stack.py (file contents):
Revision 1.14 by peller, Wed Oct 3 10:04:29 2012 UTC vs.
Revision 1.15 by nmohr, Wed Oct 3 12:03:49 2012 UTC

# Line 13 | Line 13 | from mvainfos import mvainfo
13   from Ratio import getRatio
14   from optparse import OptionParser
15   from HistoMaker import HistoMaker, orderandadd
16 + import TdrStyles
17  
18   #CONFIGURE
19   argv = sys.argv
# Line 151 | Line 152 | for v in range(0,len(vars)):
152      datatyps = Ldatatyps[v]
153      datanames= Ldatanames[v]
154  
155 <    ROOT.gROOT.SetStyle("Plain")
155 >    TdrStyles.tdrStyle()
156      
157 <    c = ROOT.TCanvas(vars[v],'', 700, 600)
157 >    c = ROOT.TCanvas(vars[v],'', 600, 600)
158      c.SetFillStyle(4000)
159      c.SetFrameFillStyle(1000)
160      c.SetFrameFillColor(0)
# Line 192 | Line 193 | for v in range(0,len(vars)):
193  
194  
195      k=len(histos)
196 +    
197      for j in range(0,k):
198          #print histos[j].GetBinContent(1)
199          i=k-j-1
# Line 215 | Line 217 | for v in range(0,len(vars)):
217      l.AddEntry(d1,datatitle,'PL')
218  
219      if Normalize:
220 <        stackscale=d1.Integral()/MC_integral
220 >        if MC_integral != 0:    stackscale=d1.Integral()/MC_integral
221          stackhists=allStack.GetHists()
222          for blabla in stackhists:
223 <            blabla.Scale(stackscale)
223 >                if MC_integral != 0: blabla.Scale(stackscale)
224 >    
225 >    allMC=ROOT.TH1F('allMC','allMC',nBins[v],xMin[v],xMax[v])
226 >    allMC.Sumw2()
227 >    for bin in range(0,nBins[v]):
228 >        allMC.SetBinContent(bin,allStack.GetStack().Last().GetBinContent(bin))
229 >        allMC.SetBinError(bin,allStack.GetStack().Last().GetBinError(bin))
230  
231      allStack.SetTitle()
232      allStack.Draw("hist")
233      allStack.GetXaxis().SetTitle('')
234 <    allStack.GetYaxis().SetTitle('Counts')
234 >    yTitle = 'Entries'
235 >    if not '/' in yTitle:
236 >            yAppend = '%s' %(allStack.GetXaxis().GetBinWidth(1))
237 >            yTitle = '%s / %s' %(yTitle, yAppend)
238 >    allStack.GetYaxis().SetTitle(yTitle)
239      allStack.GetXaxis().SetRangeUser(xMin[v],xMax[v])
240      allStack.GetYaxis().SetRangeUser(0,20000)
241 +    theErrorGraph = ROOT.TGraphErrors(allMC)
242 +    theErrorGraph.SetFillColor(ROOT.kGray+3)
243 +    theErrorGraph.SetFillStyle(3013)
244 +    theErrorGraph.Draw('SAME2')
245      Ymax = max(allStack.GetMaximum(),d1.GetMaximum())*1.3
246      allStack.SetMaximum(Ymax)
247      allStack.SetMinimum(0.1)
# Line 233 | Line 249 | for v in range(0,len(vars)):
249      if log:
250          ROOT.gPad.SetLogy()
251      ROOT.gPad.SetTicks(1,1)
252 <    allStack.Draw("hist")
253 <    d1.SetMarkerStyle(21)
238 <    d1.Draw("P,E1,X0,same")
252 >    #allStack.Draw("hist")
253 >    d1.Draw("E0same")
254      l.SetFillColor(0)
255      l.SetBorderSize(0)
256      l.Draw()
257  
258  
244    allMC=ROOT.TH1F('allMC','allMC',nBins[v],xMin[v],xMax[v])
245    allMC.Sumw2()
246    for bin in range(0,nBins[v]):
247        allMC.SetBinContent(bin,allStack.GetStack().Last().GetBinContent(bin))
259  
260      t = ROOT.TLatex()
261      t.SetNDC()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines