40def badEtaPhi_forAllMaskPatterns(inputs):
41 Th = 0.5
42 LB = inputs[0][0]['LB']
43 rv = []
44 rv1 = []
45 rv_IBL = ROOT.TH2F()
46 rv_BLayer = ROOT.TH2F()
47 rv_Layer1 = ROOT.TH2F()
48 rv_Layer2 = ROOT.TH2F()
49 totalDeg = 0.0
50 degfactor_IBLtotal=0
51 for i in range(len(inputs[0][1])):
52 plots = [_[1][i] for _ in inputs]
53 for m, plot in enumerate(plots):
54
55
56 etaMin = []
57 etaMax = []
58 phiMin = []
59 phiMax = []
60 sec = inputs[m][0]['sec']
61
62
63 rv.append(ROOT.TH2F('defectPlot', 'badFERegion', 500, -2.5, 2.5, 500, -math.pi, math.pi))
64 rv[m].SetTitle('badFE_EtaPhi_' + sec)
65 rv[m].GetXaxis().SetTitle('#eta')
66 rv[m].GetYaxis().SetTitle('#phi')
67
68
71 with importlib.resources.open_text('PixelMonitoring', 'FE_EtaEdge_' + sec + '.txt') as etaInfo:
72 for line in etaInfo.readlines():
73 toks = line.split()
74 etaMin.append(float(toks[3]))
75 etaMax.append(float(toks[4]))
76 with importlib.resources.open_text('PixelMonitoring', 'FE_PhiEdge_' + sec + '.txt') as phiInfo:
77 for line in phiInfo.readlines():
78 toks = line.split()
79 if float(toks[3]) < -math.pi:
80 phiMin.append(float(toks[3]) + 2*math.pi)
81 else:
82 phiMin.append(float(toks[3]))
83 if float(toks[4]) > math.pi:
84 phiMax.append(float(toks[4]) - 2*math.pi)
85 else:
86 phiMax.append(float(toks[4]))
87
88
92 for xbin in range(plot.GetNbinsX()):
93 for ybin in range(plot.GetNbinsY()):
94 if(plot.GetBinContent(xbin+1, ybin+1) < Th):
95 continue
96 if sec=='IBL':
97 degfactor_IBLtotal=degfactor_IBLtotal+(1-degfactor_IBL[xbin])
98
99
100
101
102 etaMin_bin = rv[m].GetXaxis().FindBin(etaMin[xbin] + 2.5/500)
103 etaMax_bin = rv[m].GetXaxis().FindBin(etaMax[xbin] + 2.5/500)
104 phiMin_bin = rv[m].GetYaxis().FindBin(phiMin[ybin] + math.pi/500)
105 phiMax_bin = rv[m].GetYaxis().FindBin(phiMax[ybin] + math.pi/500)
106
107
108 for eta_bin in range(etaMin_bin, etaMax_bin):
109 eta = rv[m].GetXaxis().GetBinCenter(eta_bin)
110 for phi_bin in range(phiMin_bin, phiMax_bin):
111 phi = rv[m].GetYaxis().GetBinCenter(phi_bin)
112 rv[m].Fill(eta, phi)
113 if phiMin[ybin] > phiMax[ybin]:
114 for phi_bin in range(1, phiMax_bin):
115 phi = rv[m].GetYaxis().GetBinCenter(phi_bin)
116 rv[m].Fill(eta, phi)
117 for phi_bin in range(phiMin_bin, rv[m].GetNbinsY()+1):
118 phi = rv[m].GetYaxis().GetBinCenter(phi_bin)
119 rv[m].Fill(eta, phi)
120
121
122 if sec == 'IBL':
123 rv_IBL = rv[m].Clone()
124 rv_IBL.SetName('badFE_EtaPhi_IBL_new')
125 elif sec == 'BLayer':
126 rv_BLayer = rv[m].Clone()
127 rv_BLayer.SetName('badFE_EtaPhi_BLayer_new')
128 elif sec == 'Layer1':
129 rv_Layer1 = rv[m].Clone()
130 rv_Layer1.SetName('badFE_EtaPhi_Layer1_new')
131 elif sec == 'Layer2':
132 rv_Layer2 = rv[m].Clone()
133 rv_Layer2.SetName('badFE_EtaPhi_Layer2_new')
134
135
138
139
140 for m in range(0, 15):
141
142
143 rv1.append(ROOT.TH2F('defectPlot', 'badFEOverlaps', 500, -2.5, 2.5, 500, -math.pi, math.pi))
144 rv1[m].GetXaxis().SetTitle('#eta')
145 rv1[m].GetYaxis().SetTitle('#phi')
146
147
148 for xbin in range(rv[0].GetNbinsX()):
149 eta = rv[0].GetXaxis().GetBinCenter(xbin+1)
150 for ybin in range(rv[0].GetNbinsY()):
151 phi = rv[0].GetYaxis().GetBinCenter(ybin+1)
152 entIBL = rv_IBL.GetBinContent(xbin+1, ybin+1)
153 entBLayer = rv_BLayer.GetBinContent(xbin+1, ybin+1)
154 entLayer1 = rv_Layer1.GetBinContent(xbin+1, ybin+1)
155 entLayer2 = rv_Layer2.GetBinContent(xbin+1, ybin+1)
156
157
158 if entIBL >= 1 and entBLayer >= 1 and entLayer1 >= 1 and entLayer2 >= 1:
159 rv1[0].SetTitle('badFE_EtaPhi_IBL_BLayer_Layer1_Layer2')
160 rv1[0].Fill(eta, phi)
161 elif entIBL >= 1 and entBLayer >= 1 and entLayer1 >= 1:
162 rv1[1].SetTitle('badFE_EtaPhi_IBL_BLayer_Layer1')
163 rv1[1].Fill(eta, phi)
164 elif entIBL >= 1 and entBLayer >= 1 and entLayer2 >= 1:
165 rv1[2].SetTitle('badFE_EtaPhi_IBL_BLayer_Layer2')
166 rv1[2].Fill(eta, phi)
167 elif entIBL >= 1 and entLayer1 >= 1 and entLayer2 >= 1:
168 rv1[3].SetTitle('badFE_EtaPhi_IBL_Layer1_Layer2')
169 rv1[3].Fill(eta, phi)
170 elif entBLayer >= 1 and entLayer1 >= 1 and entLayer2 >= 1:
171 rv1[4].SetTitle('badFE_EtaPhi_BLayer_Layer1_Layer2')
172 rv1[4].Fill(eta, phi)
173 elif entIBL >= 1 and entBLayer >= 1:
174 rv1[5].SetTitle('badFE_EtaPhi_IBL_BLayer')
175 rv1[5].Fill(eta, phi)
176 elif entIBL >= 1 and entLayer1 >= 1:
177 rv1[6].SetTitle('badFE_EtaPhi_IBL_Layer1')
178 rv1[6].Fill(eta, phi)
179 elif entIBL >= 1 and entLayer2 >= 1:
180 rv1[7].SetTitle('badFE_EtaPhi_IBL_Layer2')
181 rv1[7].Fill(eta, phi)
182 elif entBLayer >= 1 and entLayer1 >= 1:
183 rv1[8].SetTitle('badFE_EtaPhi_BLayer_Layer1')
184 rv1[8].Fill(eta, phi)
185 elif entBLayer >= 1 and entLayer2 >= 1:
186 rv1[9].SetTitle('badFE_EtaPhi_BLayer_Layer2')
187 rv1[9].Fill(eta, phi)
188 elif entLayer1 >= 1 and entLayer2 >= 1:
189 rv1[10].SetTitle('badFE_EtaPhi_Layer1_Layer2')
190 rv1[10].Fill(eta, phi)
191 elif entIBL >= 1:
192 rv1[11].SetTitle('badFE_EtaPhi_onlyIBL')
193 rv1[11].Fill(eta, phi)
194 elif entBLayer >= 1:
195 rv1[12].SetTitle('badFE_EtaPhi_onlyBLayer')
196 rv1[12].Fill(eta, phi)
197 elif entLayer1 >= 1:
198 rv1[13].SetTitle('badFE_EtaPhi_onlyLayer1')
199 rv1[13].Fill(eta, phi)
200 elif entLayer2 >= 1:
201 rv1[14].SetTitle('badFE_EtaPhi_onlyLayer2')
202 rv1[14].Fill(eta, phi)
203
204
205
206 for m in range(0, 15):
207 if m==11:
208 deg = degfactor_IBLtotal
209 else:
210 nBadRegion = rv1[m].Integral()
211 badFrac = nBadRegion/(500*500)
212 deg = (1.0-degFactor70[m])*badFrac
213 totalDeg = totalDeg + deg
214
215 a = LB.split('_')
216 LB_deg.Fill(int(a[1]), totalDeg)
217 binNum = LB_deg.FindBin(int(a[1]))
218 LB_deg.SetBinError(binNum, 0)
219
220 return [rv_IBL, rv_BLayer, rv_Layer1, rv_Layer2, rv1[0], rv1[1], rv1[2], rv1[3], rv1[4], rv1[5], rv1[6], rv1[7], rv1[8], rv1[9], rv1[10], rv1[11], rv1[12], rv1[13], rv1[14], LB_deg]
221