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