22 from ROOT
import Belle2
23 from array
import array
26 parser = argparse.ArgumentParser(description=
"Plot dead pixel 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(
'deadpixel_histos.root',
'RECREATE')
46 histofile.mkdir(
"maps")
49 rfile = ROOT.TFile(
"dead_payloads.root",
"READ")
50 conditions = rfile.Get(
"conditions")
52 deadpixel_table = dict()
53 for sensorID
in sensor_list:
54 deadpixel_table[sensorID.getID()] = list()
57 for condition
in conditions:
58 if condition.PXDDeadPixelPar_valid:
59 print(
"Starting on run {}".format(condition.run))
60 run_list.append(condition.run)
62 for sensorID
in sensor_list:
67 deadsensormap = condition.PXDDeadPixelPar.getDeadSensorMap()
68 deaddrainmap = condition.PXDDeadPixelPar.getDeadDrainMap()
69 deadrowmap = condition.PXDDeadPixelPar.getDeadRowMap()
70 deadsinglesmap = condition.PXDDeadPixelPar.getDeadSinglePixelMap()
72 layer = sensorID.getLayerNumber()
73 ladder = sensorID.getLadderNumber()
74 sensor = sensorID.getSensorNumber()
77 counter = len(deaddrainmap[sensorID.getID()]) * 192
82 counter += len(deadrowmap[sensorID.getID()]) * 250
85 counter += len(deadsinglesmap[sensorID.getID()])
90 name =
"DeadPixels_{:d}_{:d}_{:d}_run_{:d}".format(layer, ladder, sensor, condition.run)
91 title =
"Dead Pixels Sensor={:d}.{:d}.{:d} run={:d}".format(layer, ladder, sensor, condition.run)
92 dead_map = ROOT.TH2F(name, title, nUCells, 0, nUCells, nVCells, 0, nVCells)
93 dead_map.GetXaxis().SetTitle(
"uCell")
94 dead_map.GetYaxis().SetTitle(
"vCell")
95 dead_map.GetZaxis().SetTitle(
"isDead")
98 for uCell
in range(nUCells):
99 for vCell
in range(nVCells):
100 pixID = uCell * nVCells + vCell
101 isDeadSinglePixel = condition.PXDDeadPixelPar.isDeadSinglePixel(sensorID.getID(), pixID)
102 isDeadRow = condition.PXDDeadPixelPar.isDeadRow(sensorID.getID(), vCell)
103 isDeadDrain = condition.PXDDeadPixelPar.isDeadDrain(sensorID.getID(), uCell * 4 + vCell % 4)
104 isDead = isDeadSinglePixel
or isDeadRow
or isDeadDrain
108 dead_map.SetBinContent(int(uCell + 1), int(vCell + 1), isDead)
113 deadfraction = counter / (nUCells * nVCells)
114 deadpixel_table[sensorID.getID()].append(deadfraction)
118 c = ROOT.TCanvas(
'dead_vs_runno',
'Deadpixel evolution vs. run number', 200, 10, 700, 500)
121 for sensorID
in sensor_list:
124 x, y = array(
'd'), array(
'd')
125 for value
in deadpixel_table[sensorID.getID()]:
130 gr = ROOT.TGraph(n, x, y)
131 gr.SetLineColor(ROOT.kBlue)
133 gr.SetName(
"graph_{}".format(sensorID.getID()))
134 gr.SetMarkerColor(ROOT.kBlue)
135 gr.SetMarkerStyle(21)
136 gr.SetTitle(
'Deadpixel evolution Sensor={}'.format(sensorID))
137 gr.GetXaxis().SetTitle(
'run number')
138 gr.GetYaxis().SetTitle(
'dead fraction')
139 gr.GetYaxis().SetRangeUser(0.0, 1.0)
144 c.Print(
'deadpixels_vs_runno_{}.png'.format(sensorID.getID()))