-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplotRatePerSampleOne.py
More file actions
executable file
·276 lines (198 loc) · 6.2 KB
/
plotRatePerSampleOne.py
File metadata and controls
executable file
·276 lines (198 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
from ROOT import gROOT, gStyle, gSystem, TCanvas, TF1, TFile, TH1F, TPad, TGraphErrors
from ROOT import TColor, TLine, TLegend, TLatex
from ROOT import SetOwnership
import sys,string,math,os,ROOT
from array import array
sys.path.append('rootmacros')
from myPyRootSettings import prepPlot
from myPyRootMacros import GetHist, PrepLegend, drawErrorBarsUser, DrawText
from DataSets_MC_noprescl import DataSets
DoAll=True
UseLowPTQCD=False
UseEnriched=True
vsn2 = '721'
vsn1 = '721'
INPUTDIR='RatePerSample'
if DoAll:
WhichDS = sys.argv[1]
else:
## WhichDS="METParked"
#WhichDS="MET"
#WhichDS="SingleElectron"
#WhichDS="SingleMu"
#WhichDS="HTMHT"
#WhichDS="DoublePhoton"
#WhichDS="DoublePhotonHighPt"
#WhichDS="DoubleMu"
#WhichDS="SinglePhoton"
WhichDS="Higgs"
#WhichDS="DoubleElectron"
#WhichDS="PhotonHad"
#WhichDS="MultiJet"
#WhichDS="MuHad"
#WhichDS="MuOnia"
#WhichDS="BTag"
#WhichDS="ElectronHad"
#WhichDS="TauPlusX"
#WhichDS="Tau"
#WhichDS="BJetPlusX"
#WhichDS="MuEG"
#WhichDS="noprescl"
## WhichDS="MuEGTauPlusXBJetPlusX"
logx=True
#logx=False
## used to determine which lumi to scale to
## run="207884"
run="207889"
writePlot=True
# suffix="_MuEnr.gif"
suffix=".png"
lumiLen=23.3 # length (in seconds) of a lumi section
#===============================================================
def OpenFile(file_in,iodir):
""" file_in -- Input file name
iodir -- 'r' readonly 'r+' read+write """
try:
ifile=open(file_in, iodir)
# print "Opened file: ",file_in," iodir ",iodir
except:
print "Could not open file: ",file_in
sys.exit(1)
return ifile
def CloseFile(ifile):
ifile.close()
def prep2by1Plot(cname,ctitle,wtopx=300,wtopy=20,ww=840,wh=500):
c = TCanvas(cname,ctitle,wtopx,wtopy,ww,wh)
SetOwnership(c,1 )
bmargin=0.075
rmargin=0.02
lmargin=0.45
tmargin=0.01
## xlow ylow xup yup
pad1 = TPad("pad1","This is pad1",0.0,0.0,0.74,1.0);
pad2 = TPad("pad2","This is pad1",0.74,0.0,1.0,1.0);
pad1.SetTopMargin(0.02);
pad1.SetBottomMargin(0.1);
pad2.SetTopMargin(0.02);
pad2.SetBottomMargin(0.1);
rmargin=0.005
pad1.SetRightMargin(rmargin);
pad2.SetRightMargin(rmargin);
lmargin=0.025
pad1.SetLeftMargin(lmargin);
lmargin=0.01
pad2.SetLeftMargin(lmargin);
SetOwnership(pad1,1 )
SetOwnership(pad2,1 )
c.SetBottomMargin(bmargin);
c.SetRightMargin(rmargin);
c.SetLeftMargin(lmargin);
c.SetTopMargin(tmargin);
c.SetLogy(0);
c.SetLogx(0);
return c,pad1,pad2
if __name__ == '__main__':
if DoAll and len(sys.argv) < 2:
print 'Usage: ' + sys.argv[0] + ' whichds'
sys.exit()
gROOT.Reset()
#gROOT.SetStyle("MyStyle");
#gROOT.SetStyle("tdrStyle");
gROOT.SetStyle("Plain");
gStyle.SetOptLogy(0);
gStyle.SetPalette(1);
gStyle.SetOptTitle(0);
gStyle.SetOptStat(0);
gStyle.SetOptFit(0);
gStyle.SetPadTopMargin(0.02);
gStyle.SetPadTickX(1);
gStyle.SetLabelSize(0.035, "XYZ");
gStyle.SetLabelSize(0.035, "Y");
gStyle.SetTitleSize(0.05, "XYZ");
if DataSets.has_key(WhichDS)==0:
print "Could not dataset find",WhichDS," in dictionary"
sys.exit(1)
print "XXXXXXXXXXXXXXXXX -- ",INPUTDIR
MCFile1 = os.path.join(INPUTDIR,"hltmenu_13TeV_25ns_combinedRate_1.4e+34_" + WhichDS + '_' + vsn1 + ".root")
MCFile2 = os.path.join(INPUTDIR,"hltmenu_13TeV_25ns_combinedRate_1.4e+34_" + WhichDS + '_' + vsn2 + ".root")
ScaleMC=1.
theTriggers=DataSets[WhichDS]
outDir="Plots/MC13_721_NoMuEnr1212_Paths"
if not os.path.exists(outDir):
os.makedirs(outDir)
for trig in theTriggers:
hname=trig[:trig.rfind("_v")]
print "studying ", hname
hist1=GetHist(MCFile1,hname)
hist1.SetFillColor(ROOT.kRed-7)
print vsn1,hist1.GetEntries()
outplot= WhichDS +"_"+hname
outfile=os.path.join(outDir,outplot)
print outfile+suffix
### CCLA defaults
labelsz=0.033
lmargin=0.5
hmax=-1.
hmin=0.0001
xl1=.02;
if not logx:
xl1=.02
yl1=.01+.1;
rmax=10.
hist1.GetYaxis().SetLabelSize(.03);
hist1.GetYaxis().SetTitleSize(0.035);
hist1.GetYaxis().SetTitle("Rate (Hz)");
hist1.GetYaxis().SetTitleOffset(.95);
hist1.GetXaxis().SetLabelSize(labelsz);
hist1.GetXaxis().SetTitleOffset(0.11);
minRate=0.09
#hist2.SetMinimum(hmin)
#if hmax>-1.:
#hist2.SetMaximum(hmax)
hist1.SetBarWidth(0.45);
hist1.SetBarOffset(0.45);
## c1=prepPlot()
ylow=900
c1,p1,p2=prep2by1Plot("c1","Rates per MC sample ",575, 31, 1250, ylow)
p1.Draw()
p2.Draw()
p1.cd()
if logx:
p1.SetLogx(True)
p1.SetLeftMargin(lmargin)
#hist2.Draw("hbar2");
hist1.Draw("hbar2,e,same");
i1=1
i2=hist1.GetNbinsX()
print "minbin=",i1," maxbin=",i2
drawErrorBarsUser(p1,hist1,i1,i2,0.15,minRate)
xl2=xl1+.2; yl2=yl1+.085;
leg =TLegend(xl1,yl1,xl2,yl2);
leg.SetFillColor(0);
leg.SetLineColor(0);
leg.SetShadowColor(0);
la=ROOT.TLatex()
la.SetNDC()
la.SetTextAlign(11)
la.SetTextSize(0.026)
header=hname
xt=xl1-.01; yt=yl1+0.85
la.DrawLatex(xt,yt, header);
la.DrawLatex(xt,yt-0.03, "L=1.4e34 Hz/cm^{2}");
if not UseLowPTQCD:
la.DrawLatex(xt,yt-0.03-0.03, "no Low PT QCD");
if not UseEnriched:
la.DrawLatex(xt+0.2,yt-0.03-0.03, "no Enriched QCD");
leg.AddEntry(hist1,"721patch1_GRunv41","f");
leg.SetTextSize(0.026);
leg.Draw();
p1.Modified()
p1.Update()
p2.cd()
if writePlot:
plot=outfile + suffix
c1.SaveAs(plot)
if os.getenv("FROMGUI") == None:
print "Not from GUI"
if not DoAll:
raw_input('\npress return to end the program...')