ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/nowaf/RootFilesInUse/MakeVertexPlots.py
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Mar 20 13:12:08 2012 UTC (13 years, 1 month ago) by nowak
Content type: text/x-python
Branch: rootFilesInUse, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
t files in use

File Contents

# User Rev Content
1 nowak 1.1 import ROOT
2     import sys, re
3     sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
4     import definitions as Def
5     import styles as Style
6     import MakeRealTauEst_cff as RT
7    
8     if __name__ == "__main__":
9    
10     #Def.SetGlobalStyles()
11    
12     Type = "allTau"
13    
14     saveToPS = False
15     saveToEPS = True
16    
17     removeSamplesAcc = []
18     removeSamplesAcc.append( "TTbar" )
19     removeSamplesAcc.append( "GVJets" )
20     removeSamplesAcc.append( "WWJets" )
21     removeSamplesAcc.append( "Zinv" )
22     removeSamplesAcc.append( "ZJets" )
23     #removeSamplesAcc.append( "WJets" )
24     removeSamplesAcc.append( "QCDFlat" )
25     removeSamplesAcc.append( "Data" )
26    
27     theSample = "WJets"
28     #theSample = "TTbar"
29    
30     rebin = 2
31    
32     fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/WJets_TauTemplate_viii/"
33     fileName = "_TauTemplate_viii"
34    
35     dirName = "TauTemplateLoose"
36     dirAdd = []
37     dirAdd.append( "VL" )
38     dirAdd.append( "VM" )
39     dirAdd.append( "VH" )
40     for dir in [ "VL", "VM", "VH" ]:
41     print dir
42     dirAdd.append( "G" + dir )
43     pass
44    
45     dirs = []
46     for dir in dirAdd:
47     dirs.append( dirName + dir + "/" )
48     pass
49    
50    
51     colorDict = {}
52     colorDict[ dirName + "VL" + "/" ] = ROOT.kBlue
53     colorDict[ dirName + "VM" + "/" ] = ROOT.kBlue - 9
54     colorDict[ dirName + "VH" + "/" ] = ROOT.kBlue - 5
55     colorDict[ dirName + "GVL" + "/" ] = ROOT.kBlue
56     colorDict[ dirName + "GVM" + "/" ] = ROOT.kBlue - 9
57     colorDict[ dirName + "GVH" + "/" ] = ROOT.kBlue - 5
58    
59     if theSample == "TTbar":
60     colorDict[ dirName + "VL" + "/" ] = ROOT.kRed
61     colorDict[ dirName + "VM" + "/" ] = ROOT.kRed - 9
62     colorDict[ dirName + "VH" + "/" ] = ROOT.kRed - 5
63     colorDict[ dirName + "GVL" + "/" ] = ROOT.kRed
64     colorDict[ dirName + "GVM" + "/" ] = ROOT.kRed - 9
65     colorDict[ dirName + "GVH" + "/" ] = ROOT.kRed - 5
66    
67     pass
68    
69     rebinDict = {}
70     rebinDict[ "resp_" + Type + "_genParticle_inverse" ] = rebin
71     rebinDict[ "resp_" + Type + "_genParticle_pt0to15_inverse" ] = rebin
72     rebinDict[ "resp_" + Type + "_genParticle_pt15to30_inverse" ] = rebin
73     rebinDict[ "resp_" + Type + "_genParticle_pt30to50_inverse" ] = rebin
74     rebinDict[ "resp_" + Type + "_genParticle_pt50to100_inverse" ] = rebin
75     rebinDict[ "resp_" + Type + "_genParticle_pt100_inverse" ] = rebin
76    
77     theTheTitle = "W+Jets Simulation only"
78     plotTitle = True
79     Def.SetGlobalStyles( withTitle=plotTitle )
80     ROOT.gStyle.SetTitleYOffset(2.0)
81    
82     saveName = "plots/Vertex_" + theSample + "_" + Type + fileName
83     if plotTitle and re.search( "CMS Simulation", theTheTitle ):
84     saveName = saveName + "_CMSSim"
85     pass
86    
87    
88     ##################################################################################
89     accReadIn = RT.ReadIn( fileDir, fileName, rebinDict=rebinDict )
90     accReadIn.removeSamples( removeSamplesAcc )
91     #accReadIn.addSamples( addSample )
92     accReadIn.doNormalization()
93     accReadIn.removeHists( [ "MHT" ] )
94     accReadIn.addHists( [ "resp_" + Type + "_genParticle_inverse",
95     "resp_" + Type + "_genParticle_pt0to15_inverse",
96     "resp_" + Type + "_genParticle_pt15to30_inverse",
97     "resp_" + Type + "_genParticle_pt30to50_inverse",
98     "resp_" + Type + "_genParticle_pt50to100_inverse",
99     "resp_" + Type + "_genParticle_pt100_inverse" ] )
100     histDict = {}
101     for dir in dirs:
102     histDict[ dir ] = accReadIn.getHists( dir )
103     for hist in histDict[ dir ].keys():
104     for sample in histDict[ dir ][ hist ].keys():
105     histDict[ dir ][ hist ][ sample ].UseCurrentStyle()
106     add = ""
107     if re.search( "pt0to15", hist ):
108     add = " (10-15 GeV)"
109     elif re.search( "pt15to30", hist ):
110     add = " (15-30 GeV)"
111     elif re.search( "pt30to50", hist ):
112     add = " (30-50 GeV)"
113     elif re.search( "pt50to10", hist ):
114     add = " (50-100 GeV)"
115     elif re.search( "pt100", hist ):
116     add = " (>100 GeV)"
117     pass
118     respType = "P_{T}^{jet}(uncorr)"
119     if Type == "allTau":
120     respType = "P_{T}^{#tau hyp}"
121     Style.setHistStyle( histDict[ dir ][ hist ][ sample ],
122     status="Signal",
123     color=colorDict[ dir ],
124     xTitle=respType + "/P_{T}^{#tau, gen}" + add,
125     yTitle="normalized",
126     title=theTheTitle )
127     pass
128     pass
129     ##################################################################################
130    
131    
132     cDict = {}
133     legDict = {}
134    
135     cDict[ "V" ] = ROOT.TCanvas( "V" , "V" )
136     cDict[ "V" ].cd()
137     histDict[ dirName + "VL" + "/" ][ "resp_" + Type + "_genParticle_inverse" ][ theSample ].Draw()
138     histDict[ dirName + "VM" + "/" ][ "resp_" + Type + "_genParticle_inverse" ][ theSample ].Draw( "same" )
139     histDict[ dirName + "VH" + "/" ][ "resp_" + Type + "_genParticle_inverse" ][ theSample ].Draw( "same" )
140     legDict[ "V" ] = Style.makeLegendSimple( [ histDict[ dirName + "VL" + "/" ]\
141     [ "resp_" + Type + "_genParticle_inverse" ]\
142     [ theSample ],
143     histDict[ dirName + "VM" + "/" ]\
144     [ "resp_" + Type + "_genParticle_inverse" ]\
145     [ theSample ],
146     histDict[ dirName + "VH" + "/" ]\
147     [ "resp_" + Type + "_genParticle_inverse" ]\
148     [ theSample ] ],
149     [ "nV < 6","nV < 10", "nV >= 10"],
150     position = "ur")
151     legDict[ "V" ].Draw( "same" )
152    
153     cDict[ "GV" ] = ROOT.TCanvas( "GV" , "GV" )
154     cDict[ "GV" ].cd()
155     histDict[ dirName + "GVL" + "/" ][ "resp_" + Type + "_genParticle_inverse" ][ theSample ].Draw()
156     histDict[ dirName + "GVM" + "/" ][ "resp_" + Type + "_genParticle_inverse" ][ theSample ].Draw( "same" )
157     histDict[ dirName + "GVH" + "/" ][ "resp_" + Type + "_genParticle_inverse" ][ theSample ].Draw( "same" )
158     legDict[ "GV" ] = Style.makeLegendSimple( [ histDict[ dirName + "GVL" + "/" ]\
159     [ "resp_" + Type + "_genParticle_inverse" ]\
160     [ theSample ],
161     histDict[ dirName + "GVM" + "/" ]\
162     [ "resp_" + Type + "_genParticle_inverse" ]\
163     [ theSample ],
164     histDict[ dirName + "GVH" + "/" ]\
165     [ "resp_" + Type + "_genParticle_inverse" ]\
166     [ theSample ] ],
167     [ "ngenV < 6","ngenV < 10", "ngenV >= 10"],
168     position = "ur")
169     legDict[ "GV" ].Draw( "same" )
170    
171    
172     cDict[ "015V" ] = ROOT.TCanvas( "015V" , "015V" )
173     cDict[ "015V" ].cd()
174     histDict[ dirName + "VL" + "/" ][ "resp_" + Type + "_genParticle_pt0to15_inverse" ][ theSample ].Draw()
175     histDict[ dirName + "VM" + "/" ][ "resp_" + Type + "_genParticle_pt0to15_inverse" ][ theSample ].Draw( "same" )
176     histDict[ dirName + "VH" + "/" ][ "resp_" + Type + "_genParticle_pt0to15_inverse" ][ theSample ].Draw( "same" )
177     legDict[ "015V" ] = Style.makeLegendSimple( [ histDict[ dirName + "VL" + "/" ]\
178     [ "resp_" + Type + "_genParticle_pt0to15_inverse" ]\
179     [ theSample ],
180     histDict[ dirName + "VM" + "/" ]\
181     [ "resp_" + Type + "_genParticle_pt0to15_inverse" ]\
182     [ theSample ],
183     histDict[ dirName + "VH" + "/" ]\
184     [ "resp_" + Type + "_genParticle_pt0to15_inverse" ]\
185     [ theSample ] ],
186     [ "nV < 6","nV < 10", "nV >= 10"],
187     position = "ur")
188     legDict[ "015V" ].Draw( "same" )
189    
190     cDict[ "1530V" ] = ROOT.TCanvas( "1530V" , "1530V" )
191     cDict[ "1530V" ].cd()
192     histDict[ dirName + "VL" + "/" ][ "resp_" + Type + "_genParticle_pt15to30_inverse" ][ theSample ].Draw()
193     histDict[ dirName + "VM" + "/" ][ "resp_" + Type + "_genParticle_pt15to30_inverse" ][ theSample ].Draw( "same" )
194     histDict[ dirName + "VH" + "/" ][ "resp_" + Type + "_genParticle_pt15to30_inverse" ][ theSample ].Draw( "same" )
195     legDict[ "1530V" ] = Style.makeLegendSimple( [ histDict[ dirName + "VL" + "/" ]\
196     [ "resp_" + Type + "_genParticle_pt15to30_inverse" ]\
197     [ theSample ],
198     histDict[ dirName + "VM" + "/" ]\
199     [ "resp_" + Type + "_genParticle_pt15to30_inverse" ]\
200     [ theSample ],
201     histDict[ dirName + "VH" + "/" ]\
202     [ "resp_" + Type + "_genParticle_pt15to30_inverse" ]\
203     [ theSample ] ],
204     [ "nV < 6","nV < 10", "nV >= 10"],
205     position = "ur")
206     legDict[ "1530V" ].Draw( "same" )
207    
208     cDict[ "3050V" ] = ROOT.TCanvas( "3050V" , "3050V" )
209     cDict[ "3050V" ].cd()
210     histDict[ dirName + "VL" + "/" ][ "resp_" + Type + "_genParticle_pt30to50_inverse" ][ theSample ].Draw()
211     histDict[ dirName + "VM" + "/" ][ "resp_" + Type + "_genParticle_pt30to50_inverse" ][ theSample ].Draw( "same" )
212     histDict[ dirName + "VH" + "/" ][ "resp_" + Type + "_genParticle_pt30to50_inverse" ][ theSample ].Draw( "same" )
213     legDict[ "3050V" ] = Style.makeLegendSimple( [ histDict[ dirName + "VL" + "/" ]\
214     [ "resp_" + Type + "_genParticle_pt30to50_inverse" ]\
215     [ theSample ],
216     histDict[ dirName + "VM" + "/" ]\
217     [ "resp_" + Type + "_genParticle_pt30to50_inverse" ]\
218     [ theSample ],
219     histDict[ dirName + "VH" + "/" ]\
220     [ "resp_" + Type + "_genParticle_pt30to50_inverse" ]\
221     [ theSample ] ],
222     [ "nV < 6","nV < 10", "nV >= 10"],
223     position = "ur")
224     legDict[ "3050V" ].Draw( "same" )
225    
226     cDict[ "50100V" ] = ROOT.TCanvas( "50100V" , "50100V" )
227     cDict[ "50100V" ].cd()
228     histDict[ dirName + "VL" + "/" ][ "resp_" + Type + "_genParticle_pt50to100_inverse" ][ theSample ].Draw()
229     histDict[ dirName + "VM" + "/" ][ "resp_" + Type + "_genParticle_pt50to100_inverse" ][ theSample ].Draw( "same" )
230     histDict[ dirName + "VH" + "/" ][ "resp_" + Type + "_genParticle_pt50to100_inverse" ][ theSample ].Draw( "same" )
231     legDict[ "50100V" ] = Style.makeLegendSimple( [ histDict[ dirName + "VL" + "/" ]\
232     [ "resp_" + Type + "_genParticle_pt50to100_inverse" ]\
233     [ theSample ],
234     histDict[ dirName + "VM" + "/" ]\
235     [ "resp_" + Type + "_genParticle_pt50to100_inverse" ]\
236     [ theSample ],
237     histDict[ dirName + "VH" + "/" ]\
238     [ "resp_" + Type + "_genParticle_pt50to100_inverse" ]\
239     [ theSample ] ],
240     [ "nV < 6","nV < 10", "nV >= 10"],
241     position = "ur")
242     legDict[ "50100V" ].Draw( "same" )
243    
244    
245     cDict[ "100V" ] = ROOT.TCanvas( "100V" , "100V" )
246     cDict[ "100V" ].cd()
247     histDict[ dirName + "VL" + "/" ][ "resp_" + Type + "_genParticle_pt100_inverse" ][ theSample ].Draw()
248     histDict[ dirName + "VM" + "/" ][ "resp_" + Type + "_genParticle_pt100_inverse" ][ theSample ].Draw( "same" )
249     histDict[ dirName + "VH" + "/" ][ "resp_" + Type + "_genParticle_pt100_inverse" ][ theSample ].Draw( "same" )
250     legDict[ "100V" ] = Style.makeLegendSimple( [ histDict[ dirName + "VL" + "/" ]\
251     [ "resp_" + Type + "_genParticle_pt100_inverse" ]\
252     [ theSample ],
253     histDict[ dirName + "VM" + "/" ]\
254     [ "resp_" + Type + "_genParticle_pt100_inverse" ]\
255     [ theSample ],
256     histDict[ dirName + "VH" + "/" ]\
257     [ "resp_" + Type + "_genParticle_pt100_inverse" ]\
258     [ theSample ] ],
259     [ "nV < 6","nV < 10", "nV >= 10"],
260     position = "ur")
261     legDict[ "100V" ].Draw( "same" )
262    
263    
264     if saveToPS:
265     Style.saveToPS( saveName, cDict )
266     if saveToEPS:
267     Style.saveToEPS( saveName, cDict )
268     pass
269    
270    
271     Def.DontQuit()