13 This module contains classes for plotting calibration constants.
16 from abc
import ABC, abstractmethod
17 from ROOT
import Belle2
18 from ROOT.Belle2
import PXDMaskedPixelPar, PXDDeadPixelPar, PXDOccupancyInfoPar
20 from copy
import deepcopy
22 from pxd.utils import get_sensor_graphs, sensorID_list
29 __cal_checker_dict__ = {
30 "PXDHotPixelMaskCalibrationChecker": set([PXDMaskedPixelPar, PXDDeadPixelPar, PXDOccupancyInfoPar]),
37 Abstract base class for generating plots from calibrations which save multiple payloads.
43 objType_list (list): a list of db objects used as keys to their checker.
44 e.g., [Belle2.PXDMaskedPixelPar, Belle2.PXDDeadPixelPar]
48 for objType
in objType_list:
53 Initialize condition_checker according to condition objType
55 checker_list (list): list of objType checkers
58 for checker
in checker_list:
60 if objType == checker.objType:
64 print(f
"root file path: {checker.tfile}")
87 Method to fill TGraphs
93 Generate summary plots from TGraphs of all condition checkers
98 function to be executed at the beginning of a run
105 Execute when terminating a basf2 module.
106 All required TGraphs should be ready at this stage.
114 Checker for PXDHotPixelMaskCalibration
119 Initial with related condition db object types
129 Define TGraphs for filling
140 legsum = ROOT.TLegend(0.75, 0.65, 0.90, 0.85)
141 legsum.SetFillStyle(0)
142 legsum.SetBorderSize(0)
143 legsum.SetTextFont(43)
144 legsum.SetTextSize(18)
145 legocc = deepcopy(legsum)
146 self.
sum_graphssum_graphs[
"TLegends"] = {
"sum": legsum,
"occ": legocc}
148 for category, style_dict
in plot_type_dict.items():
149 agraph = ROOT.TGraph()
150 agraph.SetLineColor(style_dict[
"color"])
151 agraph.SetMarkerColor(style_dict[
"color"])
152 agraph.SetMarkerStyle(20)
153 if category ==
"hot_dead":
154 agraph.GetYaxis().SetTitle(
'Total Hot/Dead pixels [%]')
155 agraph.SetMaximum(style_dict[
"max"])
156 elif category ==
"occ_no_mask":
157 agraph.GetYaxis().SetTitle(
'Average occupancy [%]')
158 agraph.SetMaximum(style_dict[
"max"])
159 agraph.GetXaxis().SetTitle(
'run #')
160 agraph.GetYaxis().SetTitleOffset(0.9)
161 agraph.SetMinimum(0.0)
166 Fill TGraphs, will be executed for each run
173 current_run = dead_checker.run
177 sum_deadfraction = 0.
178 sum_hotdeadfraction = 0.
179 sum_occupancymasked = 0.
180 sum_occupancynomask = 0.
181 for sensorID
in sensorID_list:
182 numID = sensorID.getID()
184 g1 = masked_graphs[numID]
185 g2 = dead_graphs[numID]
186 g3 = occ_graphs[numID]
188 hotfraction = g1.GetPointY(g1.GetN() - 1)
189 deadfraction = g2.GetPointY(g2.GetN() - 1)
190 occupancymasked = g3.GetPointY(g3.GetN() - 1)
193 saved_run = max(g1.GetPointX(g1.GetN() - 1), g2.GetPointX(g2.GetN() - 1))
194 saved_run_occ = max(saved_run, g3.GetPointX(g3.GetN() - 1))
195 if current_run == saved_run:
196 self.
hotdead_graphshotdead_graphs[numID].append(current_run, hotfraction + deadfraction)
197 sum_hotfraction += hotfraction
198 sum_deadfraction += deadfraction
199 sum_hotdeadfraction += hotfraction + deadfraction
200 if current_run == saved_run_occ:
203 if deadfraction != 100.:
204 occupancynomask = (occupancymasked + hotfraction) / (1. - deadfraction / 100)
205 occupancymasked = occupancymasked / (1. - deadfraction / 100)
208 sum_occupancymasked += occupancymasked
209 sum_occupancynomask += occupancynomask
217 nSensors = len(sensorID_list)
218 if current_run == saved_run:
219 self.
sum_graphssum_graphs[
"hot"].append(current_run, sum_hotfraction / nSensors)
220 self.
sum_graphssum_graphs[
"dead"].append(current_run, sum_deadfraction / nSensors)
221 self.
sum_graphssum_graphs[
"hot_dead"].append(current_run, sum_hotdeadfraction / nSensors)
223 nSensors = nSensors - len(dead_checker.dbObj.getDeadSensorMap())
224 if current_run == saved_run_occ
and nSensors > 0:
225 self.
sum_graphssum_graphs[
"occ_masked"].append(current_run, sum_occupancymasked / nSensors)
226 self.
sum_graphssum_graphs[
"occ_no_mask"].append(current_run, sum_occupancynomask / nSensors)
230 Generate summary plots from TGraphs of all condition checkers
240 canvas = ROOT.TCanvas(
'c_pxd',
'c_pxd', 1000, 400)
247 canvas=canvas, cname=
"PXDHotnDeadPixel", ymin=0., ymax=plot_type_dict[
"hot_dead"][
"max"])
248 checker.draw_plots(canvas=canvas, cname=
"PXDHotnDeadPixel", ymin=0., ymax=
None, logy=
True)
253 canvas=canvas, cname=
"PXDOccupancyWithMask", ymin=0., ymax=plot_type_dict[
"occ_masked"][
"max"])
254 checker.draw_plots(canvas=canvas, cname=
"PXDOccupancyWithMask", ymin=0., ymax=
None, logy=
True)
258 canvas=canvas, cname=
"PXDOccupancyNoMask", ymin=0., ymax=plot_type_dict[
"occ_no_mask"][
"max"])
259 checker.draw_plots(canvas=canvas, cname=
"PXDOccupancyNoMask", ymin=0., ymax=
None, logy=
True)
270 leg = self.
sum_graphssum_graphs[
"TLegends"][
"sum"]
274 leg.AddEntry(g1,
'Hot+Dead pixels',
'p')
275 leg.AddEntry(g2,
'Hot pixels',
'p')
276 leg.AddEntry(g3,
'Dead pixels',
'p')
278 checker.save_canvas(canvas,
"PXDTotalHotnDeadPixel", logy=
True)
280 checker.save_canvas(canvas,
"PXDTotalHotnDeadPixel", logy=
False)
285 leg = self.
sum_graphssum_graphs[
"TLegends"][
"occ"]
288 leg.AddEntry(g1,
'No Mask',
'p')
289 leg.AddEntry(g2,
'With Mask',
'p')
291 checker.save_canvas(canvas,
"PXDTotalOccupancy", logy=
True)
293 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.