28def badEtaPhi_forAllMaskPatterns(inputs):
29 Th = 0.5
30 LB = inputs[0][0]['LB']
31 rv = []
32 rv1 = []
33 rv_IBL = ROOT.TH2F()
34 rv_BLayer = ROOT.TH2F()
35 rv_Layer1 = ROOT.TH2F()
36 rv_Layer2 = ROOT.TH2F()
37 totalDeg = 0.0
38 for i in range(len(inputs[0][1])):
39 plots = [_[1][i] for _ in inputs]
40 for m, plot in enumerate(plots):
41 etaMin = []
42 etaMax = []
43 phiMin = []
44 phiMax = []
45 sec = inputs[m][0]['sec']
46 rv.append(ROOT.TH2F('defectPlot', 'badFERegion', 500, -3.0, 3.0, 500, -math.pi, math.pi))
47 rv[m].SetTitle('badFE_EtaPhi_' + sec)
48 rv[m].GetXaxis().SetTitle('#eta')
49 rv[m].GetYaxis().SetTitle('#phi')
50 with importlib.resources.open_text('PixelMonitoring', 'FE_EtaEdge_' + sec + '.txt') as etaInfo:
51 for line in etaInfo.readlines():
52 toks = line.split()
53 etaMin.append(float(toks[3]))
54 etaMax.append(float(toks[4]))
55 with importlib.resources.open_text('PixelMonitoring', 'FE_PhiEdge_' + sec + '.txt') as phiInfo:
56 for line in phiInfo.readlines():
57 toks = line.split()
58 if float(toks[3]) < -math.pi:
59 phiMin.append(float(toks[3]) + 2*math.pi)
60 else:
61 phiMin.append(float(toks[3]))
62 if float(toks[4]) > math.pi:
63 phiMax.append(float(toks[4]) - 2*math.pi)
64 else:
65 phiMax.append(float(toks[4]))
66 for xbin in range(plot.GetNbinsX()):
67 for ybin in range(plot.GetNbinsY()):
68 if(plot.GetBinContent(xbin+1, ybin+1) < Th):
69 continue
70 etaMin_bin = rv[m].GetXaxis().FindBin(etaMin[xbin] + 3.0/500)
71 etaMax_bin = rv[m].GetXaxis().FindBin(etaMax[xbin] + 3.0/500)
72 phiMin_bin = rv[m].GetYaxis().FindBin(phiMin[ybin] + math.pi/500)
73 phiMax_bin = rv[m].GetYaxis().FindBin(phiMax[ybin] + math.pi/500)
74 for eta_bin in range(etaMin_bin, etaMax_bin):
75 eta = rv[m].GetXaxis().GetBinCenter(eta_bin)
76 for phi_bin in range(phiMin_bin, phiMax_bin):
77 phi = rv[m].GetYaxis().GetBinCenter(phi_bin)
78 rv[m].Fill(eta, phi)
79 if phiMin[ybin] > phiMax[ybin]:
80 for phi_bin in range(1, phiMax_bin):
81 phi = rv[m].GetYaxis().GetBinCenter(phi_bin)
82 rv[m].Fill(eta, phi)
83 for phi_bin in range(phiMin_bin, rv[m].GetNbinsY()+1):
84 phi = rv[m].GetYaxis().GetBinCenter(phi_bin)
85 rv[m].Fill(eta, phi)
86
87 if sec == 'IBL':
88 rv_IBL = rv[m].Clone()
89 rv_IBL.SetName('badFE_EtaPhi_IBL_new')
90 elif sec == 'BLayer':
91 rv_BLayer = rv[m].Clone()
92 rv_BLayer.SetName('badFE_EtaPhi_BLayer_new')
93 elif sec == 'Layer1':
94 rv_Layer1 = rv[m].Clone()
95 rv_Layer1.SetName('badFE_EtaPhi_Layer1_new')
96 elif sec == 'Layer2':
97 rv_Layer2 = rv[m].Clone()
98 rv_Layer2.SetName('badFE_EtaPhi_Layer2_new')
99
100 for m in range(0, 15):
101 rv1.append(ROOT.TH2F('defectPlot', 'badFEOverlaps', 500, -3.0, 3.0, 500, -math.pi, math.pi))
102 rv1[m].GetXaxis().SetTitle('#eta')
103 rv1[m].GetYaxis().SetTitle('#phi')
104 for xbin in range(rv[0].GetNbinsX()):
105 eta = rv[0].GetXaxis().GetBinCenter(xbin+1)
106 for ybin in range(rv[0].GetNbinsY()):
107 phi = rv[0].GetYaxis().GetBinCenter(ybin+1)
108 entIBL = rv_IBL.GetBinContent(xbin+1, ybin+1)
109 entBLayer = rv_BLayer.GetBinContent(xbin+1, ybin+1)
110 entLayer1 = rv_Layer1.GetBinContent(xbin+1, ybin+1)
111 entLayer2 = rv_Layer2.GetBinContent(xbin+1, ybin+1)
112 if entIBL >= 1 and entBLayer >= 1 and entLayer1 >= 1 and entLayer2 >= 1:
113 rv1[0].SetTitle('badFE_EtaPhi_IBL_BLayer_Layer1_Layer2')
114 rv1[0].Fill(eta, phi)
115 elif entIBL >= 1 and entBLayer >= 1 and entLayer1 >= 1:
116 rv1[1].SetTitle('badFE_EtaPhi_IBL_BLayer_Layer1')
117 rv1[1].Fill(eta, phi)
118 elif entIBL >= 1 and entBLayer >= 1 and entLayer2 >= 1:
119 rv1[2].SetTitle('badFE_EtaPhi_IBL_BLayer_Layer2')
120 rv1[2].Fill(eta, phi)
121 elif entIBL >= 1 and entLayer1 >= 1 and entLayer2 >= 1:
122 rv1[3].SetTitle('badFE_EtaPhi_IBL_Layer1_Layer2')
123 rv1[3].Fill(eta, phi)
124 elif entBLayer >= 1 and entLayer1 >= 1 and entLayer2 >= 1:
125 rv1[4].SetTitle('badFE_EtaPhi_BLayer_Layer1_Layer2')
126 rv1[4].Fill(eta, phi)
127 elif entIBL >= 1 and entBLayer >= 1:
128 rv1[5].SetTitle('badFE_EtaPhi_IBL_BLayer')
129 rv1[5].Fill(eta, phi)
130 elif entIBL >= 1 and entLayer1 >= 1:
131 rv1[6].SetTitle('badFE_EtaPhi_IBL_BLayer')
132 rv1[6].Fill(eta, phi)
133 elif entIBL >= 1 and entLayer2 >= 1:
134 rv1[7].SetTitle('badFE_EtaPhi_IBL_BLayer')
135 rv1[7].Fill(eta, phi)
136 elif entBLayer >= 1 and entLayer1 >= 1:
137 rv1[8].SetTitle('badFE_EtaPhi_BLayer_Layer1')
138 rv1[8].Fill(eta, phi)
139 elif entBLayer >= 1 and entLayer2 >= 1:
140 rv1[9].SetTitle('badFE_EtaPhi_BLayer_Layer2')
141 rv1[9].Fill(eta, phi)
142 elif entLayer1 >= 1 and entLayer2 >= 1:
143 rv1[10].SetTitle('badFE_EtaPhi_Layer1_Layer2')
144 rv1[10].Fill(eta, phi)
145 elif entIBL >= 1:
146 rv1[11].SetTitle('badFE_EtaPhi_onlyIBL')
147 rv1[11].Fill(eta, phi)
148 elif entBLayer >= 1:
149 rv1[12].SetTitle('badFE_EtaPhi_onlyBLayer')
150 rv1[12].Fill(eta, phi)
151 elif entLayer1 >= 1:
152 rv1[13].SetTitle('badFE_EtaPhi_onlyLayer1')
153 rv1[13].Fill(eta, phi)
154 elif entLayer2 >= 1:
155 rv1[14].SetTitle('badFE_EtaPhi_onlyLayer2')
156 rv1[14].Fill(eta, phi)
157
158 for m in range(0, 15):
159 nBadRegion = rv1[m].Integral()
160 badFrac = nBadRegion/(500*500)
161 deg = (1.0-degFactor70[m])*badFrac
162 totalDeg = totalDeg + deg
163
164 a = LB.split('_')
165 LB_deg.Fill(int(a[1]), totalDeg)
166 binNum = LB_deg.FindBin(int(a[1]))
167 LB_deg.SetBinError(binNum, 0)
168 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]
169