27 from ROOT
import Belle2
28 from array
import array
31 parser = argparse.ArgumentParser(description=
"Plot hotpixel maps")
32 parser.add_argument(
'--maps', dest=
'maps', action=
"store_true", help=
'Create maps from payloads. This can be slow!')
33 args = parser.parse_args()
49 histofile = ROOT.TFile(
'hotpixel_histos.root',
'RECREATE')
51 histofile.mkdir(
"maps")
54 rfile = ROOT.TFile(
"hot_payloads.root",
"READ")
55 b2.conditions = rfile.Get(
"conditions")
57 hotpixel_table = dict()
58 for sensorID
in sensor_list:
59 hotpixel_table[sensorID.getID()] = list()
62 for condition
in b2.conditions:
63 if condition.PXDMaskedPixelPar_valid:
64 print(
"Starting on run {}".format(condition.run))
65 run_list.append(condition.run)
67 for sensorID
in sensor_list:
72 hotpixelmap = condition.PXDMaskedPixelPar.getMaskedPixelMap()
74 layer = sensorID.getLayerNumber()
75 ladder = sensorID.getLadderNumber()
76 sensor = sensorID.getSensorNumber()
78 counter = len(hotpixelmap[sensorID.getID()])
81 name =
"MaskedPixels_{:d}_{:d}_{:d}_run_{:d}".format(layer, ladder, sensor, condition.run)
82 title =
"Masked Pixels Sensor={:d}.{:d}.{:d} run={:d}".format(layer, ladder, sensor, condition.run)
83 hot_map = ROOT.TH2F(name, title, nUCells, 0, nUCells, nVCells, 0, nVCells)
84 hot_map.GetXaxis().SetTitle(
"uCell")
85 hot_map.GetYaxis().SetTitle(
"vCell")
86 hot_map.GetZaxis().SetTitle(
"isMasked")
89 for uCell
in range(nUCells):
90 for vCell
in range(nVCells):
91 pixID = uCell * nVCells + vCell
92 isMasked =
not condition.PXDMaskedPixelPar.pixelOK(sensorID.getID(), pixID)
93 hot_map.SetBinContent(int(uCell + 1), int(vCell + 1), isMasked)
98 hotfraction = counter / (nUCells * nVCells)
99 hotpixel_table[sensorID.getID()].append(hotfraction)
103 c = ROOT.TCanvas(
'hotpixels_vs_runno',
'Hotpixel evolution vs. run number', 200, 10, 700, 500)
106 for sensorID
in sensor_list:
109 x, y = array(
'd'), array(
'd')
110 for value
in hotpixel_table[sensorID.getID()]:
115 gr = ROOT.TGraph(n, x, y)
116 gr.SetLineColor(ROOT.kBlue)
118 gr.SetName(
"graph_{}".format(sensorID.getID()))
119 gr.SetMarkerColor(ROOT.kBlue)
120 gr.SetMarkerStyle(21)
121 gr.SetTitle(
'Hotpixel evolution Sensor={}'.format(sensorID))
122 gr.GetXaxis().SetTitle(
'run number')
123 gr.GetYaxis().SetTitle(
'hotpixel fraction')
124 gr.GetYaxis().SetRangeUser(0.0, 1.0)
129 c.Print(
'hotpixel_vs_runno_{}.png'.format(sensorID.getID()))
Class to uniquely identify a any structure of the PXD and SVD.