1 |
demattia |
1.1 |
#!/usr/bin/python
|
2 |
|
|
|
3 |
|
|
import string
|
4 |
|
|
from math import sqrt
|
5 |
|
|
|
6 |
|
|
# Define the tuple containing the cross sections
|
7 |
|
|
# Including high luminosity factor
|
8 |
|
|
crossSections = [ 163000000.*0.01,
|
9 |
|
|
21600000.*0.01,
|
10 |
|
|
3080000.*0.01,
|
11 |
|
|
494000.*0.01,
|
12 |
|
|
101000.*0.01,
|
13 |
|
|
24500.*0.01,
|
14 |
|
|
6240.*0.01]
|
15 |
|
|
|
16 |
|
|
# Define the tuple with the names
|
17 |
|
|
qcdNames = [ "30-50", "50-80", "80-120", "120-170",
|
18 |
|
|
"170-230", "230-300", "300-380" ]
|
19 |
|
|
|
20 |
|
|
singleBinMultijetRate = [ 0, 0, 0, 0, 0, 0, 0 ]
|
21 |
|
|
singleBinMultijetOfflineRate = [0] * 7
|
22 |
|
|
singleBinMEtJetRate = [ 0, 0, 0, 0, 0, 0, 0 ]
|
23 |
|
|
singleBinMEtJetOfflineRate = [0] * 7
|
24 |
|
|
binEvents = [ 0, 0, 0, 0, 0, 0, 0 ]
|
25 |
|
|
binEffPassingMultijet = [ 0, 0, 0, 0, 0, 0, 0 ]
|
26 |
|
|
binEffPassingMultijetOffline = [0] * 7
|
27 |
|
|
binEffPassingMEtJet = [ 0, 0, 0, 0, 0, 0, 0 ]
|
28 |
|
|
binEffPassingMEtJetOffline = [0] * 7
|
29 |
|
|
|
30 |
|
|
counter = 0
|
31 |
|
|
cumulativeMultijetRate = 0.
|
32 |
|
|
cumulativeMultijetOfflineRate = 0.
|
33 |
|
|
cumulativeMEtJetRate = 0.
|
34 |
|
|
cumulativeMEtJetOfflineRate = 0.
|
35 |
|
|
# Loop on the cross sections
|
36 |
|
|
for x in crossSections:
|
37 |
|
|
|
38 |
|
|
# Open a file in read mode
|
39 |
|
|
name = "/data/demattia/Merge/TK3/Efficiency_QCD_" + qcdNames[counter] + "_tk3.txt"
|
40 |
|
|
f=open(name, 'r')
|
41 |
|
|
|
42 |
|
|
# ',' at the end needed to avoid newline
|
43 |
|
|
for line in f:
|
44 |
|
|
# No parenthesys needed, put them for clarity
|
45 |
|
|
# if "Eff multijet" in line:
|
46 |
|
|
if (line.find("Eff multijet") != -1) & (line.find("no-forward") == -1):
|
47 |
|
|
""" Using string.split and .join to produce a
|
48 |
|
|
tuple and emulate a simple awk"""
|
49 |
|
|
tupleLine = string.split(line)
|
50 |
|
|
cumulativeMultijetRate += float(tupleLine[3])*x
|
51 |
|
|
singleBinMultijetRate[counter] = float(tupleLine[3])*x
|
52 |
|
|
binEffPassingMultijet[counter] = float(tupleLine[3])
|
53 |
|
|
elif (line.find("offline efficiency after multijet") != -1):
|
54 |
|
|
tupleLine = string.split(line)
|
55 |
|
|
cumulativeMultijetOfflineRate += float(tupleLine[6])*x
|
56 |
|
|
singleBinMultijetOfflineRate[counter] = float(tupleLine[6])*x
|
57 |
|
|
binEffPassingMultijetOffline[counter] = float(tupleLine[6])
|
58 |
|
|
elif (line.find("Eff MEt + Jet") != -1) & (line.find("no-forward") == -1):
|
59 |
|
|
tupleLine = string.split(line)
|
60 |
|
|
cumulativeMEtJetRate += float(tupleLine[5])*x
|
61 |
|
|
singleBinMEtJetRate[counter] = float(tupleLine[5])*x
|
62 |
|
|
binEffPassingMEtJet[counter] = float(tupleLine[5])
|
63 |
|
|
elif (line.find("offline efficiency after MEt + Jet") != -1):
|
64 |
|
|
tupleLine = string.split(line)
|
65 |
|
|
cumulativeMEtJetOfflineRate += float(tupleLine[8])*x
|
66 |
|
|
singleBinMEtJetOfflineRate[counter] = float(tupleLine[8])*x
|
67 |
|
|
binEffPassingMEtJetOffline[counter] = float(tupleLine[8])
|
68 |
|
|
elif "Total events" in line:
|
69 |
|
|
tupleLine = string.split(line)
|
70 |
|
|
binEvents[counter] = int(tupleLine[3])
|
71 |
|
|
counter = counter+1
|
72 |
|
|
|
73 |
|
|
# Print the Multijet trigger rates in each qcd bin
|
74 |
|
|
print "Multijet rates"
|
75 |
|
|
print "--------------"
|
76 |
|
|
counter = 0
|
77 |
|
|
effTotalErr = 0.
|
78 |
|
|
for rate in singleBinMultijetRate:
|
79 |
|
|
# print "events passing = ",
|
80 |
|
|
# print binEffPassingMultijet[counter]*binEvents[counter]
|
81 |
|
|
print "QCD_" + qcdNames[counter] + " Multijet rate = ",
|
82 |
|
|
print rate,
|
83 |
|
|
print " +- ",
|
84 |
|
|
effErr = sqrt(binEffPassingMultijet[counter]*binEvents[counter])/binEvents[counter]
|
85 |
|
|
effTotalErr += effErr*effErr*crossSections[counter]*crossSections[counter]
|
86 |
|
|
print crossSections[counter]*effErr
|
87 |
|
|
counter += 1
|
88 |
|
|
|
89 |
|
|
print
|
90 |
|
|
print "Offline after Multijet cumulative rate = ",
|
91 |
|
|
print cumulativeMultijetRate,
|
92 |
|
|
print " +- ",
|
93 |
|
|
print sqrt(effTotalErr)
|
94 |
|
|
print
|
95 |
|
|
|
96 |
|
|
# Print the offline rate after Multijet
|
97 |
|
|
print "Offline after Multijet rates"
|
98 |
|
|
print "----------------------------"
|
99 |
|
|
counter = 0
|
100 |
|
|
effTotalErr = 0.
|
101 |
|
|
for rate in singleBinMultijetOfflineRate:
|
102 |
|
|
# print "events passing = ",
|
103 |
|
|
# print binEffPassingMultijetOffline[counter]*binEvents[counter]
|
104 |
|
|
print "QCD_" + qcdNames[counter] + " Offline after Multijet rate = ",
|
105 |
|
|
print rate,
|
106 |
|
|
print " +- ",
|
107 |
|
|
effErr = sqrt(binEffPassingMultijetOffline[counter]*binEvents[counter])/binEvents[counter]
|
108 |
|
|
effTotalErr += effErr*effErr*crossSections[counter]*crossSections[counter]
|
109 |
|
|
print crossSections[counter]*effErr
|
110 |
|
|
counter += 1
|
111 |
|
|
|
112 |
|
|
print
|
113 |
|
|
print "Offline after Multijet cumulative rate = ",
|
114 |
|
|
print cumulativeMultijetOfflineRate,
|
115 |
|
|
print " +- ",
|
116 |
|
|
print sqrt(effTotalErr)
|
117 |
|
|
print
|
118 |
|
|
|
119 |
|
|
# Print the MEt + Jet trigger rates in each qcd bin
|
120 |
|
|
print "MEt + Jet rates"
|
121 |
|
|
print "---------------"
|
122 |
|
|
counter = 0
|
123 |
|
|
effTotalErr = 0.
|
124 |
|
|
for rate in singleBinMEtJetRate:
|
125 |
|
|
print "QCD_" + qcdNames[counter] + " MEt + Jet rate = ",
|
126 |
|
|
print rate,
|
127 |
|
|
print " +- ",
|
128 |
|
|
effErr = sqrt(binEffPassingMEtJet[counter]*binEvents[counter])/binEvents[counter]
|
129 |
|
|
effTotalErr += effErr*effErr*crossSections[counter]*crossSections[counter]
|
130 |
|
|
print crossSections[counter]*effErr
|
131 |
|
|
counter += 1
|
132 |
|
|
|
133 |
|
|
print
|
134 |
|
|
print "MEt + Jet cumulative rate = ",
|
135 |
|
|
print cumulativeMEtJetRate,
|
136 |
|
|
print " +- ",
|
137 |
|
|
print sqrt(effTotalErr)
|
138 |
|
|
print
|
139 |
|
|
|
140 |
|
|
# Print the Offline rates after MEt + Jet trigger in each qcd bin
|
141 |
|
|
print "Offline after MEt + Jet rates"
|
142 |
|
|
print "---------------"
|
143 |
|
|
counter = 0
|
144 |
|
|
effTotalErr = 0.
|
145 |
|
|
for rate in singleBinMEtJetOfflineRate:
|
146 |
|
|
print "QCD_" + qcdNames[counter] + " MEt + Jet rate = ",
|
147 |
|
|
print rate,
|
148 |
|
|
print " +- ",
|
149 |
|
|
effErr = sqrt(binEffPassingMEtJetOffline[counter]*binEvents[counter])/binEvents[counter]
|
150 |
|
|
effTotalErr += effErr*effErr*crossSections[counter]*crossSections[counter]
|
151 |
|
|
print crossSections[counter]*effErr
|
152 |
|
|
counter += 1
|
153 |
|
|
|
154 |
|
|
print
|
155 |
|
|
print "MEt + Jet cumulative rate = ",
|
156 |
|
|
print cumulativeMEtJetOfflineRate,
|
157 |
|
|
print " +- ",
|
158 |
|
|
print sqrt(effTotalErr)
|
159 |
|
|
print
|
160 |
|
|
|
161 |
|
|
# Print the total number of events in each bin
|
162 |
|
|
print "Number of events"
|
163 |
|
|
print "----------------"
|
164 |
|
|
counter = 0
|
165 |
|
|
for num in binEvents:
|
166 |
|
|
print "Events in qcd bin " + qcdNames[counter] + " = ",
|
167 |
|
|
print num
|
168 |
|
|
counter += 1
|