ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/tools/compareM3.py
Revision: 1.1
Committed: Fri Jan 7 21:54:06 2011 UTC (14 years, 3 months ago) by jengbou
Content type: text/x-python
Branch: MAIN
CVS Tags: gregj-20110224, gregj-20110223-v1, gregj-20110223, gregj-20110205, gregj-20110114, gregj-20110107, HEAD
Log Message:
update and add files

File Contents

# User Rev Content
1 jengbou 1.1 #!/usr/bin/env python
2     from ROOT import *
3    
4     import os,sys
5    
6     desDir = "M3Comparison/NEW/"
7     prefix = "M3"
8    
9     ##tfile = TFile("Results_20101224_PF/templates_Sel5_PF_TCHEM_M3M3_nominal.root") ## Old
10     tfile = TFile("Results_20110106_PF/templates_Sel5_PF_TCHEM_M3M3_nominal.root") ## New dPhi <= 2.0
11    
12     samples = ["TTbar","WJets","QCD"]
13     histList = ["Excl3","Incl4"]
14    
15     if not os.path.exists(desDir):
16     print "Creating output directory: " + desDir
17     os.makedirs(desDir)
18    
19     gROOT.Reset()
20     ## Plot Style
21     gROOT.ProcessLine('.L TopStyle/tdrstyle.C')
22     ROOT.setTDRStyle()
23     gROOT.ProcessLine('.L TopStyle/CMSTopStyle.cc+')
24     style = CMSTopStyle()
25     style.setupICHEPv1()
26    
27     color_={}
28     color_["TTbar"] = style.TtbarColor
29     color_["WJets"] = style.WJetsColor
30     color_["QCD"] = style.QCDColor
31    
32     text_={}
33     text_["TTbar"] = style.TtbarText
34     text_["WJets"] = style.WJetsText
35     text_["QCD"] = style.QCDText
36    
37     hs = {}
38     cvs = {}
39    
40     text_["Excl3"] = TLatex(1., 1., "#mu+jets N_{jets} = 3");
41     text_["Excl3"].SetNDC();
42     text_["Excl3"].SetTextAlign(13);
43     text_["Excl3"].SetX(0.6);
44     text_["Excl3"].SetY(0.83);
45     text_["Excl3"].SetTextFont(42);
46     text_["Excl3"].SetTextSize(0.034);
47     text_["Excl3"].SetTextSizePixels(20);
48    
49     text_["Incl4"] = TLatex(1., 1., "#mu+jets N_{jets} #geq 4");
50     text_["Incl4"].SetNDC();
51     text_["Incl4"].SetTextAlign(13);
52     text_["Incl4"].SetX(0.6);
53     text_["Incl4"].SetY(0.83);
54     text_["Incl4"].SetTextFont(42);
55     text_["Incl4"].SetTextSize(0.034);
56     text_["Incl4"].SetTextSizePixels(20);
57    
58     ##gStyle.SetErrorX(0.)
59     for ihist in histList:
60     tmp = prefix+"_"+ihist
61     cvs[tmp] = TCanvas(tmp,tmp,600,600)
62     leg1 = TLegend(0.58, 0.65, 0.88, 0.78)
63     leg1.SetFillColor(0)
64     leg1.SetFillStyle(0)
65    
66     ith = 0
67     for sample in samples:
68     tmpname = sample+"_"+ihist
69     print tmpname
70     hs[tmpname] = tfile.Get(tmpname)
71     hs[tmpname].Scale(1./hs[tmpname].Integral())
72     hs[tmpname].SetLineWidth(2)
73     hs[tmpname].SetLineColor(color_[sample])
74     hs[tmpname].SetMarkerColor(color_[sample])
75     ##hs[tmpname].SetFillColor(color_[sample])
76     if ith == 0:
77     hs[tmpname].GetXaxis().SetTitleOffset(1.2)
78     hs[tmpname].GetXaxis().SetLabelSize(0.035)
79     hs[tmpname].GetYaxis().SetTitleOffset(1.4)
80     hs[tmpname].GetYaxis().SetLabelSize(0.035)
81     hs[tmpname].GetYaxis().SetTitle("A.U.")
82     hs[tmpname].Draw("histe")
83     else:
84     hs[tmpname].Draw("histsamee")
85     leg1.AddEntry(hs[tmpname],text_[sample])
86    
87     ith += 1
88     leg1.Draw()
89     text_[ihist].Draw()
90     cvs[tmp].Print(desDir.rstrip("/")+"/"+tmp+".png")
91     cvs[tmp].Print(desDir.rstrip("/")+"/"+tmp+".pdf")
92    
93     var = raw_input("Enter anything to quit: ")
94     print "Done!", var