Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:19

0001 #!/usr/bin/env python
0002 
0003 import sys,os
0004 sys.argv.append("-b")
0005 import ROOT as rt
0006 
0007 ifile = sys.argv[1]
0008 odir = sys.argv[2]
0009 
0010 os.system("mkdir -p " + odir)
0011 tfile = rt.TFile(ifile)
0012 observed = tfile.Get("observed")
0013 predicted = tfile.Get("prediction")
0014 
0015 for key in observed.GetListOfKeys():
0016     name = key.GetName()
0017     h_observed = observed.Get(name)
0018     h_predicted = predicted.Get(name)
0019     _max = max(1,h_observed.GetMaximum())
0020     nbins = h_observed.GetNbinsX()
0021     h_observed.SetMarkerStyle(rt.kCircle)
0022     h_observed.SetMarkerColor(rt.kBlue)
0023     h_observed.SetLineColor(rt.kBlue)
0024     l = rt.TLegend(0.15,0.75,0.5,0.89)
0025     l.SetFillStyle(0)
0026     l.SetLineWidth(1)
0027     l.AddEntry(h_observed,"observed","l,p")
0028     if not h_predicted == None:
0029         _max = max(_max,h_predicted.GetMaximum())*1.3
0030         h_predicted.Scale(h_observed.Integral(0,nbins+1)/h_predicted.Integral(0,nbins+1))
0031         h_predicted.SetLineColor(rt.kRed)
0032         l.AddEntry(h_predicted,"predicted","l")
0033     h_observed.SetMaximum(_max);
0034     _max = _max*1.3
0035     h_observed.Draw("E")
0036     if not h_predicted == None:
0037         h_predicted.Draw("same")
0038     l.Draw()
0039     rt.gPad.Print(odir + "/" + name + ".png")
0040     
0041