ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/algomez/FourTop/TreeAnalyzer/test/diffMC.py
Revision: 1.1
Committed: Mon Nov 5 01:25:15 2012 UTC (12 years, 6 months ago) by algomez
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 algomez 1.1 #!/usr/bin/env python
2     ###################################################
3     # This python script ...
4     ####################################################
5    
6     import os,sys,string,re,math
7     from array import array
8    
9     try:
10     from ROOT import *
11     except:
12     print "\nCannot load PYROOT, make sure you have setup ROOT in the path"
13     print "and pyroot library is also defined in the variable PYTHONPATH, try:\n"
14     if (os.getenv("PYTHONPATH")):
15     print " setenv PYTHONPATH ${PYTHONPATH}:$ROOTSYS/lib\n"
16     else:
17     print " setenv PYTHONPATH $ROOTSYS/lib\n"
18     #sys.exit()
19    
20     #import Inspector
21     #import Style
22    
23     gROOT.SetStyle("Plain")
24     gStyle.SetOptStat(0)
25     DEBUG = False
26    
27     # style
28     #thestyle = Style.Style()
29     HasCMSStyle = False
30     style = None
31     if os.path.isfile('tdrstyle.C'):
32     gROOT.ProcessLine('.L tdrstyle.C')
33     ROOT.setTDRStyle()
34     print "Found tdrstyle.C file, using this style."
35     HasCMSStyle = True
36     if os.path.isfile('CMSTopStyle.cc'):
37     gROOT.ProcessLine('.L CMSTopStyle.cc+')
38     style = CMSTopStyle()
39     print "Found CMSTopStyle.cc file, use TOP style if requested in xml file."
40     if not HasCMSStyle:
41     print "No CMSTopStyle.cc"
42    
43     #FOpen = ['results_ttbar.root',
44     # 'results_STtch.root',
45     # 'results_STtch_bar.root',
46     # 'results_STsch.root',
47     # 'results_STsch_bar.root',
48     # 'results_STtWch.root']
49     #
50     ########################################
51     ##def Disc(ofile, name):
52     #######################################
53     #for ofile in FOpen:
54     # tmpname = ofile.replace('results_','')
55     # name = tmpname.replace('.root','')
56     #
57     # infile = TFile(ofile)
58     # histo1 = infile.Get("/MET/Stlep_"+name)
59     # histo2 = infile.Get("/MET/Ht_"+name)
60     #
61     # scale1 = 1/histo1.Integral()
62     # scale2 = 1/histo2.Integral()
63     #
64     # histo1.Scale(scale1)
65     # histo2.Scale(scale2)
66     #
67     # #totalhisto = TH1F(histo1*histo2)
68     #
69     # #if ofile[1]:
70     # # c1.cd()
71     # # histo1.Draw("Hist")
72     # #else:
73     # # c1.cd()
74     # # histo1.Draw("Hist same")
75     # #if ofile[len(FOpen)]: c1.SaveAs("test.png")
76    
77     def legend():
78     leg = TLegend(0.75,0.65,0.93,0.93)
79     leg.SetMargin(0.12)
80     leg.SetTextSize(0.035)
81     leg.SetFillColor(0)
82     leg.SetFillStyle(0)
83     leg.SetBorderSize(0)
84     leg.AddEntry(httbar_1, style.TtbarText, "l" )
85     leg.AddEntry(hSTsch_bar_1,style.ST_t_sText, "l" )
86     leg.AddEntry(hSTtWch_bar_1,style.ST_tWText, "l" )
87     leg.Draw()
88     return leg
89    
90    
91     # Open files
92     fttbar = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_ttbar.root")
93     httbar_1 = fttbar.Get("/MET/Stjet_ttbar")
94     httbar_1.Scale(1/httbar_1.Integral())
95     httbar_2 = fttbar.Get("/MET/Ht_ttbar")
96     httbar_2.Scale(1/httbar_2.Integral())
97     httbar_3 = fttbar.Get("/MET/Stlep_ttbar")
98     httbar_3.Scale(1/httbar_3.Integral())
99     httbar_4 = fttbar.Get("/jets/Njets_cut1_ttbar")
100     httbar_4.Scale(1/httbar_4.Integral())
101     httbar_5 = fttbar.Get("/jets/Nbjets_CSVL_ttbar")
102     httbar_5.Scale(1/httbar_5.Integral())
103     #httbar_6 = fttbar.Get("/jets/Nbjets_CSVL_ttbar")
104     #httbar_6.Scale(1/httbar_6.Integral())
105    
106     fSTtch = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_STtch.root")
107     hSTtch_1 = fSTtch.Get("/MET/Stjet_STtch")
108     hSTtch_2 = fSTtch.Get("/MET/Ht_STtch")
109     hSTtch_3 = fSTtch.Get("/MET/Stlep_STtch")
110     hSTtch_4 = fSTtch.Get("/jets/Njets_cut1_STtch")
111     hSTtch_5 = fSTtch.Get("/jets/Nbjets_CSVL_STtch")
112    
113     fSTtch_bar = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_STtch_bar.root")
114     hSTtch_bar_1 = fSTtch_bar.Get("/MET/Stjet_STtch_bar")
115     hSTtch_bar_1.Add(hSTtch_1)
116     hSTtch_bar_2 = fSTtch_bar.Get("/MET/Ht_STtch_bar")
117     hSTtch_bar_2.Add(hSTtch_2)
118     hSTtch_bar_3 = fSTtch_bar.Get("/MET/Stlep_STtch_bar")
119     hSTtch_bar_3.Add(hSTtch_3)
120     hSTtch_bar_4 = fSTtch_bar.Get("/jets/Njets_cut1_STtch_bar")
121     hSTtch_bar_4.Add(hSTtch_4)
122     hSTtch_bar_5 = fSTtch_bar.Get("/jets/Nbjets_CSVL_STtch_bar")
123     hSTtch_bar_5.Add(hSTtch_5)
124    
125     fSTsch = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_STsch.root")
126     hSTsch_1 = fSTsch.Get("/MET/Stjet_STsch")
127     hSTsch_1.Add(hSTtch_bar_1)
128     hSTsch_2 = fSTsch.Get("/MET/Ht_STsch")
129     hSTsch_2.Add(hSTtch_bar_2)
130     hSTsch_3 = fSTsch.Get("/MET/Stlep_STsch")
131     hSTsch_3.Add(hSTtch_bar_3)
132     hSTsch_4 = fSTsch.Get("/jets/Njets_cut1_STsch")
133     hSTsch_4.Add(hSTtch_bar_4)
134     hSTsch_5 = fSTsch.Get("/jets/Nbjets_CSVL_STsch")
135     hSTsch_5.Add(hSTtch_bar_5)
136    
137     fSTsch_bar = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_STsch_bar.root")
138     hSTsch_bar_1 = fSTsch_bar.Get("/MET/Stjet_STsch_bar")
139     hSTsch_bar_1.Add(hSTsch_1)
140     hSTsch_bar_1.Sumw2()
141     hSTsch_bar_1.Scale(1/hSTsch_bar_1.Integral())
142     hSTsch_bar_2 = fSTsch_bar.Get("/MET/Ht_STsch_bar")
143     hSTsch_bar_2.Add(hSTsch_2)
144     hSTsch_bar_2.Sumw2()
145     hSTsch_bar_2.Scale(1/hSTsch_bar_2.Integral())
146     hSTsch_bar_3 = fSTsch_bar.Get("/MET/Stlep_STsch_bar")
147     hSTsch_bar_3.Add(hSTsch_3)
148     hSTsch_bar_3.Sumw2()
149     hSTsch_bar_3.Scale(1/hSTsch_bar_3.Integral())
150     hSTsch_bar_4 = fSTsch_bar.Get("/jets/Njets_cut1_STsch_bar")
151     hSTsch_bar_4.Add(hSTsch_4)
152     hSTsch_bar_4.Sumw2()
153     hSTsch_bar_4.Scale(1/hSTsch_bar_4.Integral())
154     hSTsch_bar_5 = fSTsch_bar.Get("/jets/Nbjets_CSVL_STsch_bar")
155     hSTsch_bar_5.Add(hSTsch_5)
156     hSTsch_bar_5.Sumw2()
157     hSTsch_bar_5.Scale(1/hSTsch_bar_5.Integral())
158    
159     fSTtWch = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_STtWch.root")
160     hSTtWch_1 = fSTtWch.Get("/MET/Stjet_STtWch")
161     hSTtWch_2 = fSTtWch.Get("/MET/Ht_STtWch")
162     hSTtWch_3 = fSTtWch.Get("/MET/Stlep_STtWch")
163     hSTtWch_4 = fSTtWch.Get("/jets/Njets_cut1_STtWch")
164     hSTtWch_5 = fSTtWch.Get("/jets/Nbjets_CSVL_STtWch")
165    
166     fSTtWch_bar = TFile("/eos/uscms/store/user/algomez/FourTop/resultsTreeAnalyzer/results09/results_STtWch_bar.root")
167     hSTtWch_bar_1 = fSTtWch_bar.Get("/MET/Stjet_STtWch_bar")
168     hSTtWch_bar_1.Add(hSTtWch_1)
169     hSTtWch_bar_1.Sumw2()
170     hSTtWch_bar_1.Scale(1/hSTtWch_bar_1.Integral())
171     hSTtWch_bar_2 = fSTtWch_bar.Get("/MET/Ht_STtWch_bar")
172     hSTtWch_bar_2.Add(hSTtWch_2)
173     hSTtWch_bar_2.Sumw2()
174     hSTtWch_bar_2.Scale(1/hSTtWch_bar_2.Integral())
175     hSTtWch_bar_3 = fSTtWch_bar.Get("/MET/Stlep_STtWch_bar")
176     hSTtWch_bar_3.Add(hSTtWch_3)
177     hSTtWch_bar_3.Sumw2()
178     hSTtWch_bar_3.Scale(1/hSTtWch_bar_3.Integral())
179     hSTtWch_bar_4 = fSTtWch_bar.Get("/jets/Njets_cut1_STtWch_bar")
180     hSTtWch_bar_4.Add(hSTtWch_4)
181     hSTtWch_bar_4.Sumw2()
182     hSTtWch_bar_4.Scale(1/hSTtWch_bar_4.Integral())
183     hSTtWch_bar_5 = fSTtWch_bar.Get("/jets/Nbjets_CSVL_STtWch_bar")
184     hSTtWch_bar_5.Add(hSTtWch_5)
185     hSTtWch_bar_5.Sumw2()
186     hSTtWch_bar_5.Scale(1/hSTtWch_bar_5.Integral())
187    
188    
189     can1 = TCanvas('can1', '', 800,600)
190     can1.cd()
191     can1.SetLogy()
192    
193     httbar_1.SetLineColor(style.TtbarColor)
194     httbar_1.SetMaximum(1)
195     httbar_1.SetYTitle('1/N dN/dx')
196     httbar_1.Draw("Hist")
197    
198     hSTsch_bar_1.SetLineColor(style.ST_t_sColor)
199     hSTsch_bar_1.SetLineWidth(1)
200     hSTsch_bar_1.Draw("Hist same")
201    
202     hSTtWch_bar_1.SetLineColor(style.ST_tWColor)
203     hSTtWch_bar_1.SetLineWidth(2)
204     hSTtWch_bar_1.Draw("Hist same")
205    
206     leg = legend()
207     can1.SaveAs("diff_Stjet_Top.png")
208    
209     can2 = TCanvas('can2', '', 800,600)
210     can2.cd()
211     can2.SetLogy()
212    
213     httbar_2.SetLineColor(style.TtbarColor)
214     httbar_2.SetMaximum(1)
215     httbar_2.SetYTitle('1/N dN/dx')
216     httbar_2.Draw("Hist")
217    
218     hSTsch_bar_2.SetLineColor(style.ST_t_sColor)
219     hSTsch_bar_2.SetLineWidth(1)
220     hSTsch_bar_2.Draw("Hist same")
221    
222     hSTtWch_bar_2.SetLineColor(style.ST_tWColor)
223     hSTtWch_bar_2.SetLineWidth(2)
224     hSTtWch_bar_2.Draw("Hist same")
225    
226     leg = legend()
227     can2.SaveAs("diff_Ht_Top.png")
228    
229     can3 = TCanvas('can3', '', 800,600)
230     can3.cd()
231     can3.SetLogy()
232    
233     httbar_3.SetLineColor(style.TtbarColor)
234     httbar_3.SetMaximum(1)
235     httbar_3.SetYTitle('1/N dN/dx')
236     httbar_3.Draw("Hist")
237    
238     hSTsch_bar_3.SetLineColor(style.ST_t_sColor)
239     hSTsch_bar_3.SetLineWidth(1)
240     hSTsch_bar_3.Draw("Hist same")
241    
242     hSTtWch_bar_3.SetLineColor(style.ST_tWColor)
243     hSTtWch_bar_3.SetLineWidth(2)
244     hSTtWch_bar_3.Draw("Hist same")
245    
246     leg = legend()
247     can3.SaveAs("diff_Stlep_Top.png")
248    
249     can4 = TCanvas('can4', '', 800,600)
250     can4.cd()
251     can4.SetLogy()
252    
253     httbar_4.SetLineColor(style.TtbarColor)
254     httbar_4.SetMaximum(1)
255     httbar_4.SetYTitle('1/N dN/dx')
256     httbar_4.Draw("Hist")
257    
258     hSTsch_bar_4.SetLineColor(style.ST_t_sColor)
259     hSTsch_bar_4.SetLineWidth(1)
260     hSTsch_bar_4.Draw("Hist same")
261    
262     hSTtWch_bar_4.SetLineColor(style.ST_tWColor)
263     hSTtWch_bar_4.SetLineWidth(2)
264     hSTtWch_bar_4.Draw("Hist same")
265     leg = legend()
266     can4.SaveAs("diff_Njets_Top.png")
267    
268     can5 = TCanvas('can5', '', 800,600)
269     can5.cd()
270     can5.SetLogy()
271    
272     httbar_5.SetLineColor(style.TtbarColor)
273     httbar_5.SetMaximum(1)
274     httbar_5.SetYTitle('1/N dN/dx')
275     httbar_5.Draw("Hist")
276    
277     hSTsch_bar_5.SetLineColor(style.ST_t_sColor)
278     hSTsch_bar_5.SetLineWidth(1)
279     hSTsch_bar_5.Draw("Hist same")
280    
281     hSTtWch_bar_5.SetLineColor(style.ST_tWColor)
282     hSTtWch_bar_5.SetLineWidth(2)
283     hSTtWch_bar_5.Draw("Hist same")
284    
285     leg = legend()
286     can5.SaveAs("diff_Nbjets_CSVL_Top.png")