12This module contains classes for plotting calibration constants.
15from abc
import ABC, abstractmethod
16from ROOT
import Belle2
17from ROOT.Belle2
import PXDMaskedPixelPar, PXDDeadPixelPar, PXDOccupancyInfoPar
19from copy
import deepcopy
21from pxd.utils import get_sensor_graphs, sensorID_list
28__cal_checker_dict__ = {
29 "PXDHotPixelMaskCalibrationChecker": {PXDMaskedPixelPar, PXDDeadPixelPar, PXDOccupancyInfoPar},
36 Abstract base class for generating plots from calibrations which save multiple payloads.
42 objType_list (list): a list of db objects used as keys to their checker.
47 for objType
in objType_list:
52 Initialize condition_checker according to condition objType
54 checker_list (list): list of objType checkers
57 for checker
in checker_list:
59 if objType == checker.objType:
63 print(f
"root file path: {checker.tfile}")
86 Method to fill TGraphs
92 Generate summary plots from TGraphs of all condition checkers
97 function to be executed at the beginning of a run
104 Execute when terminating a basf2 module.
105 All required TGraphs should be ready at this stage.
113 Checker for PXDHotPixelMaskCalibration
118 Initial with related condition db object types
128 Define TGraphs for filling
139 legsum = ROOT.TLegend(0.75, 0.65, 0.90, 0.85)
140 legsum.SetFillStyle(0)
141 legsum.SetBorderSize(0)
142 legsum.SetTextFont(43)
143 legsum.SetTextSize(18)
144 legocc = deepcopy(legsum)
145 self.
sum_graphs[
"TLegends"] = {
"sum": legsum,
"occ": legocc}
147 for category, style_dict
in plot_type_dict.items():
148 agraph = ROOT.TGraph()
149 agraph.SetLineColor(style_dict[
"color"])
150 agraph.SetMarkerColor(style_dict[
"color"])
151 agraph.SetMarkerStyle(20)
152 if category ==
"hot_dead":
153 agraph.GetYaxis().SetTitle(
'Total Hot/Dead pixels [%]')
154 agraph.SetMaximum(style_dict[
"max"])
155 elif category ==
"occ_no_mask":
156 agraph.GetYaxis().SetTitle(
'Average occupancy [%]')
157 agraph.SetMaximum(style_dict[
"max"])
158 agraph.GetXaxis().SetTitle(
'run #')
159 agraph.GetYaxis().SetTitleOffset(0.9)
160 agraph.SetMinimum(0.0)
165 Fill TGraphs, will be executed for each run
172 current_run = dead_checker.run
176 sum_deadfraction = 0.
177 sum_hotdeadfraction = 0.
178 sum_occupancymasked = 0.
179 sum_occupancynomask = 0.
180 for sensorID
in sensorID_list:
181 numID = sensorID.getID()
183 g1 = masked_graphs[numID]
184 g2 = dead_graphs[numID]
185 g3 = occ_graphs[numID]
187 hotfraction = g1.GetPointY(g1.GetN() - 1)
188 deadfraction = g2.GetPointY(g2.GetN() - 1)
189 occupancymasked = g3.GetPointY(g3.GetN() - 1)
192 saved_run = max(g1.GetPointX(g1.GetN() - 1), g2.GetPointX(g2.GetN() - 1))
193 saved_run_occ = max(saved_run, g3.GetPointX(g3.GetN() - 1))
194 if current_run == saved_run:
195 self.
hotdead_graphs[numID].append(current_run, hotfraction + deadfraction)
196 sum_hotfraction += hotfraction
197 sum_deadfraction += deadfraction
198 sum_hotdeadfraction += hotfraction + deadfraction
199 if current_run == saved_run_occ:
202 if deadfraction != 100.:
203 occupancynomask = (occupancymasked + hotfraction) / (1. - deadfraction / 100)
204 occupancymasked = occupancymasked / (1. - deadfraction / 100)
207 sum_occupancymasked += occupancymasked
208 sum_occupancynomask += occupancynomask
216 nSensors = len(sensorID_list)
217 if current_run == saved_run:
218 self.
sum_graphs[
"hot"].append(current_run, sum_hotfraction / nSensors)
219 self.
sum_graphs[
"dead"].append(current_run, sum_deadfraction / nSensors)
220 self.
sum_graphs[
"hot_dead"].append(current_run, sum_hotdeadfraction / nSensors)
222 nSensors = nSensors - len(dead_checker.dbObj.getDeadSensorMap())
223 if current_run == saved_run_occ
and nSensors > 0:
224 self.
sum_graphs[
"occ_masked"].append(current_run, sum_occupancymasked / nSensors)
225 self.
sum_graphs[
"occ_no_mask"].append(current_run, sum_occupancynomask / nSensors)
229 Generate summary plots from TGraphs of all condition checkers
239 canvas = ROOT.TCanvas(
'c_pxd',
'c_pxd', 1000, 400)
246 canvas=canvas, cname=
"PXDHotnDeadPixel", ymin=0., ymax=plot_type_dict[
"hot_dead"][
"max"])
247 checker.draw_plots(canvas=canvas, cname=
"PXDHotnDeadPixel", ymin=0., ymax=
None, logy=
True)
252 canvas=canvas, cname=
"PXDOccupancyWithMask", ymin=0., ymax=plot_type_dict[
"occ_masked"][
"max"])
253 checker.draw_plots(canvas=canvas, cname=
"PXDOccupancyWithMask", ymin=0., ymax=
None, logy=
True)
257 canvas=canvas, cname=
"PXDOccupancyNoMask", ymin=0., ymax=plot_type_dict[
"occ_no_mask"][
"max"])
258 checker.draw_plots(canvas=canvas, cname=
"PXDOccupancyNoMask", ymin=0., ymax=
None, logy=
True)
273 leg.AddEntry(g1,
'Hot+Dead pixels',
'p')
274 leg.AddEntry(g2,
'Hot pixels',
'p')
275 leg.AddEntry(g3,
'Dead pixels',
'p')
277 checker.save_canvas(canvas,
"PXDTotalHotnDeadPixel", logy=
True)
279 checker.save_canvas(canvas,
"PXDTotalHotnDeadPixel", logy=
False)
287 leg.AddEntry(g1,
'No Mask',
'p')
288 leg.AddEntry(g2,
'With Mask',
'p')
290 checker.save_canvas(canvas,
"PXDTotalOccupancy", logy=
True)
292 checker.save_canvas(canvas,
"PXDTotalOccupancy", logy=
False)
The payload telling which PXD pixel is dead (=Readout system does not receive signals)
The payload telling which PXD pixel to mask (ignore)
The payload collecting some meta information from running the masking algorithm.
def initialize(self, checker_list=[])
def __init__(self, objType_list=[])
condition_checkers
condition checkers which are assoicated to this calibration.
occupancy_no_mask_graphs
Dictionary to save TGraph of module occupancy (without mask)
occupancy_masked_graphs
Dictionary to save TGraph of module occupancy (with mask)
hotdead_graphs
Dictionary to save TGraphs of hot/dead pixel fractions with sensor id as key.
sum_graphs
Dictionary of summary TGraphs and their TLegend.