22 from ROOT
import Belle2
23 from array
import array
26 parser = argparse.ArgumentParser(description=
"Plot hotpixel maps")
27 parser.add_argument(
'--maps', dest=
'maps', action=
"store_true", help=
'Create maps from payloads. This can be slow!')
28 args = parser.parse_args()
44 histofile = ROOT.TFile(
'hotpixel_histos.root',
'RECREATE')
46 histofile.mkdir(
"maps")
49 rfile = ROOT.TFile(
"hot_payloads.root",
"READ")
50 conditions = rfile.Get(
"conditions")
52 hotpixel_table = dict()
53 for sensorID
in sensor_list:
54 hotpixel_table[sensorID.getID()] = list()
57 for condition
in conditions:
58 if condition.PXDMaskedPixelPar_valid:
59 print(
"Starting on run {}".format(condition.run))
60 run_list.append(condition.run)
62 for sensorID
in sensor_list:
67 hotpixelmap = condition.PXDMaskedPixelPar.getMaskedPixelMap()
69 layer = sensorID.getLayerNumber()
70 ladder = sensorID.getLadderNumber()
71 sensor = sensorID.getSensorNumber()
73 counter = len(hotpixelmap[sensorID.getID()])
76 name =
"MaskedPixels_{:d}_{:d}_{:d}_run_{:d}".format(layer, ladder, sensor, condition.run)
77 title =
"Masked Pixels Sensor={:d}.{:d}.{:d} run={:d}".format(layer, ladder, sensor, condition.run)
78 hot_map = ROOT.TH2F(name, title, nUCells, 0, nUCells, nVCells, 0, nVCells)
79 hot_map.GetXaxis().SetTitle(
"uCell")
80 hot_map.GetYaxis().SetTitle(
"vCell")
81 hot_map.GetZaxis().SetTitle(
"isMasked")
84 for uCell
in range(nUCells):
85 for vCell
in range(nVCells):
86 pixID = uCell * nVCells + vCell
87 isMasked =
not condition.PXDMaskedPixelPar.pixelOK(sensorID.getID(), pixID)
88 hot_map.SetBinContent(int(uCell + 1), int(vCell + 1), isMasked)
93 hotfraction = counter / (nUCells * nVCells)
94 hotpixel_table[sensorID.getID()].append(hotfraction)
98 c = ROOT.TCanvas(
'hotpixels_vs_runno',
'Hotpixel evolution vs. run number', 200, 10, 700, 500)
101 for sensorID
in sensor_list:
104 x, y = array(
'd'), array(
'd')
105 for value
in hotpixel_table[sensorID.getID()]:
110 gr = ROOT.TGraph(n, x, y)
111 gr.SetLineColor(ROOT.kBlue)
113 gr.SetName(
"graph_{}".format(sensorID.getID()))
114 gr.SetMarkerColor(ROOT.kBlue)
115 gr.SetMarkerStyle(21)
116 gr.SetTitle(
'Hotpixel evolution Sensor={}'.format(sensorID))
117 gr.GetXaxis().SetTitle(
'run number')
118 gr.GetYaxis().SetTitle(
'hotpixel fraction')
119 gr.GetYaxis().SetRangeUser(0.0, 1.0)
124 c.Print(
'hotpixel_vs_runno_{}.png'.format(sensorID.getID()))