ATLAS Offline Software
Loading...
Searching...
No Matches
PixelPostProcessing Namespace Reference

Functions

 normalize_perEvent (inputs)
 badEtaPhi_forAllMaskPatterns (inputs)
 evaluateModuleHistograms (inputs, minBinStat=5, mvaThr=0.5, excludeOutOfAcc=True, historyDepth=10)

Variables

 LB_deg = ROOT.TH1F('TotalDegradationPerLumi', 'b-tag degradation;LB;total b-tag degradation', 3000, -0.5, 2999.5)
list degFactor70 = [0.0032, 0.0078, 0.011, 0.020, 0.023, 0.018, 0.098, 0.10, 0.26, 0.36, 0.33, 0.17, 0.65, 0.79, 0.81]

Function Documentation

◆ badEtaPhi_forAllMaskPatterns()

PixelPostProcessing.badEtaPhi_forAllMaskPatterns ( inputs)

Definition at line 28 of file PixelPostProcessing.py.

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] # all plots passed as first element of list
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: # IBL, B-Layer, Layer1, Layer2
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: # IBL, B-Layer, Layer1
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: # IBL, B-Layer, Layer2
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: # IBL, Layer2, Layer2
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: # B-Layer, Layer2, Layer2
125 rv1[4].SetTitle('badFE_EtaPhi_BLayer_Layer1_Layer2')
126 rv1[4].Fill(eta, phi)
127 elif entIBL >= 1 and entBLayer >= 1: # IBL, B-Layer
128 rv1[5].SetTitle('badFE_EtaPhi_IBL_BLayer')
129 rv1[5].Fill(eta, phi)
130 elif entIBL >= 1 and entLayer1 >= 1: # IBL, Layer1
131 rv1[6].SetTitle('badFE_EtaPhi_IBL_BLayer')
132 rv1[6].Fill(eta, phi)
133 elif entIBL >= 1 and entLayer2 >= 1: # IBL, Layer2
134 rv1[7].SetTitle('badFE_EtaPhi_IBL_BLayer')
135 rv1[7].Fill(eta, phi)
136 elif entBLayer >= 1 and entLayer1 >= 1: # B-Layer, Layer1
137 rv1[8].SetTitle('badFE_EtaPhi_BLayer_Layer1')
138 rv1[8].Fill(eta, phi)
139 elif entBLayer >= 1 and entLayer2 >= 1: # B-Layer, Layer2
140 rv1[9].SetTitle('badFE_EtaPhi_BLayer_Layer2')
141 rv1[9].Fill(eta, phi)
142 elif entLayer1 >= 1 and entLayer2 >= 1: # Layer1, Layer2
143 rv1[10].SetTitle('badFE_EtaPhi_Layer1_Layer2')
144 rv1[10].Fill(eta, phi)
145 elif entIBL >= 1: # IBL
146 rv1[11].SetTitle('badFE_EtaPhi_onlyIBL')
147 rv1[11].Fill(eta, phi)
148 elif entBLayer >= 1: # B-Layer
149 rv1[12].SetTitle('badFE_EtaPhi_onlyBLayer')
150 rv1[12].Fill(eta, phi)
151 elif entLayer1 >= 1: # Layer1
152 rv1[13].SetTitle('badFE_EtaPhi_onlyLayer1')
153 rv1[13].Fill(eta, phi)
154 elif entLayer2 >= 1: # Layer2
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
if(febId1==febId2)

◆ evaluateModuleHistograms()

PixelPostProcessing.evaluateModuleHistograms ( inputs,
minBinStat = 5,
mvaThr = 0.5,
excludeOutOfAcc = True,
historyDepth = 10 )

Definition at line 172 of file PixelPostProcessing.py.

172def evaluateModuleHistograms(inputs, minBinStat=5, mvaThr=0.5, excludeOutOfAcc=True, historyDepth=10):
173 layer = inputs[0][0]['layer']
174 ohisto = inputs[0][1][1].Clone()
175 ohisto.Reset()
176 i_layer = baselayers.index(layer)
177
178 # from this histo get current LB
179 lbhisto = inputs[0][1][2]
180 lbn = lbhisto.FindLastBinAbove(0)
181 currentLB = lbn + 1
182 if currentLB<historyDepth: # do nothing, return empty histogram
183 return [ohisto]
184
185 histos = [_[1][0] for _ in inputs]
186 for ih, histo in enumerate(histos):
187 #
188 # collect info from module's past behaviour
189 #
190 stat = 0
191 cont = 0
192 for inputbin in range(currentLB-historyDepth, currentLB):
193 stat += histo.GetBinEntries(inputbin)
194 cont += histo.GetBinContent(inputbin)*histo.GetBinEntries(inputbin)
195 #
196 # from module name get binx, biny of output histo
197 #
198 splits = histo.GetName().split('_')
199 if (layer in ['BLayer','Layer1','Layer2']):
200 x = splits[3]
201 y = splits[1] + '_' + splits[2]
202 elif layer=='IBL':
203 #S0_M1A -> A1_0
204 x = splits[3][2] + splits[3][1] + '_' + splits[2][1]
205 #B14 -> #S14
206 y = 'S'+splits[1][1:]
207 else:
208 # D1 -> Disk 1
209 x = 'Disk ' + splits[0][1]
210 # remove 'A' or 'C'
211 y = splits[1] + '_' + splits[2] + '_' + splits[3][:-1]
212 i_x = LabelX[i_layer].index(x)+1
213 i_y = LabelY[i_layer].index(y)+1
214 i_bin = i_y*(xbinsl[i_layer]+2) + i_x
215
216 # assessment
217 if (i_x<5 or i_x>ohisto.GetNbinsX()-4) and layer=='IBL' and excludeOutOfAcc :
218 ohisto.SetBinContent(i_x,i_y,0)
219 ohisto.SetBinEntries(i_bin,1) #OK (out of acceptance)
220 elif (i_x==1 or i_x==ohisto.GetNbinsX()) and layer=='BLayer' and excludeOutOfAcc :
221 ohisto.SetBinContent(i_x,i_y,0)
222 ohisto.SetBinEntries(i_bin,1) #OK (out of acceptance)
223 else:
224 if stat>=minBinStat:
225 if cont/stat>mvaThr: #not OK
226 ohisto.SetBinContent(i_x,i_y,1.0)
227 ohisto.SetBinEntries(i_bin,1)
228 else: #OK
229 ohisto.SetBinContent(i_x,i_y,0)
230 ohisto.SetBinEntries(i_bin,1)
231 else: #not enough info - empty
232 ohisto.SetBinContent(i_x,i_y,0)
233 ohisto.SetBinEntries(i_bin,0)
234
235
236 if layer=='IBL':
237 ohisto.SetBinContent(11,13,0) # FE S13-C3-M0 - OK
238 ohisto.SetBinEntries(ohisto.GetBin(11,13),1)
239
240 ohisto.SetName('FixMe_'+str(layer))
241 if 'IBL' in layer:
242 ohisto.SetTitle('Front-Ends to fix, '+str(layer))
243 else:
244 ohisto.SetTitle('Modules to fix, '+str(layer))
245 ohisto.SetOption("colztext")
246 return [ohisto]
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
Definition index.py:1

◆ normalize_perEvent()

PixelPostProcessing.normalize_perEvent ( inputs)

Definition at line 13 of file PixelPostProcessing.py.

13def normalize_perEvent(inputs):
14 layer = inputs[0][0]['sec']
15 nEventLB = inputs[0][1][1]
16 nAllEvents = nEventLB.Integral(1, nEventLB.GetNbinsX()+1)
17
18 histoName = inputs[0][1][0].GetName()
19 histo = inputs[0][1][0].Clone()
20 errorName = histoName.split('_')[0]
21 histo.SetName(errorName + '_Norm_' + layer)
22 histoTitle = histo.GetTitle().split(",")[0]
23 if nAllEvents != 0:
24 histo.Scale(1.0/nAllEvents)
25 histo.SetTitle(histoTitle + " per event, " + layer)
26 return [histo]
27

Variable Documentation

◆ degFactor70

list PixelPostProcessing.degFactor70 = [0.0032, 0.0078, 0.011, 0.020, 0.023, 0.018, 0.098, 0.10, 0.26, 0.36, 0.33, 0.17, 0.65, 0.79, 0.81]

Definition at line 11 of file PixelPostProcessing.py.

◆ LB_deg

PixelPostProcessing.LB_deg = ROOT.TH1F('TotalDegradationPerLumi', 'b-tag degradation;LB;total b-tag degradation', 3000, -0.5, 2999.5)

Definition at line 10 of file PixelPostProcessing.py.