Belle II Software development
PXDOccupancyInfoChecker Class Reference
Inheritance diagram for PXDOccupancyInfoChecker:
ConditionCheckerBase

Public Member Functions

 __init__ (self, name, tfile, rundir="")
 
 define_graphs (self)
 
 get_db_content (self)
 
 get_graph_value (self, sensor_db_content)
 
 draw_plots (self, canvas=None, **kwargs)
 
 objType (self)
 
 run (self)
 
 exp (self)
 
 beginRun (self)
 
 define_hists (self, name=None, title=None, ztitle=None, **kwargs)
 
 get_graph_value_from_hist (self, h2=None)
 
 set_hist_content (self, h2, sensor_db_content)
 
 fill_plots (self)
 
 save_canvas (self, canvas, cname, logy=False)
 

Public Attributes

 name = name
 DBObj name.
 
 dbObj = Belle2.PyDBObj(self.name, self.objType.Class())
 DBObjPtr for the condition.
 
 eventMetaData = Belle2.PyStoreObj("EventMetaData")
 pointer to the event metadata
 
 tfile = tfile
 TFile for saving plots.
 
 rundir = rundir
 Directory for writing histograms of each run.
 
dict graphs = {}
 Dictionary of plots (TGraph) summarizing variables vs run.
 
dict hists = {}
 Dictionary of plots (TH1) to be saved for each run.
 
str hist_title_suffix = ""
 Hist title suffix.
 
int runstart = 999999
 The 1st run.
 
int runend = -1
 The last run.
 
int expstart = 999999
 The 1st exp.
 
 use_hist = use_hist
 Flag to get TGraph values from a histogram (TH2F)
 

Protected Attributes

 _objType = objType
 DBObj type.
 

Detailed Description

Checker for PXDOccupancyInfoPar

Definition at line 277 of file condition_checker.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
name,
tfile,
rundir = "" )
 

Definition at line 282 of file condition_checker.py.

282 def __init__(self, name, tfile, rundir=""):
283 """
284 """
285 super().__init__(name, Belle2.PXDOccupancyInfoPar, tfile, "")
286
The payload collecting some meta information from running the masking algorithm.

Member Function Documentation

◆ beginRun()

beginRun ( self)
inherited
Call functions at beginning of a run

Definition at line 109 of file condition_checker.py.

109 def beginRun(self):
110 """
111 Call functions at beginning of a run
112 """
113 self.define_hists()
114 self.fill_plots()
115

◆ define_graphs()

define_graphs ( self)
Method to define TGraph

Reimplemented from ConditionCheckerBase.

Definition at line 287 of file condition_checker.py.

287 def define_graphs(self):
288 """
289 Method to define TGraph
290 """
291 super().define_graphs(ytitle="Occupancy (With Mask) [%]")
292

◆ define_hists()

define_hists ( self,
name = None,
title = None,
ztitle = None,
** kwargs )
inherited
Method to define TH2
Parameters:
  name (str): name for TH2, to which sensor name will be attached
  title (str): title for TH2
  ztitle (str): title for z-axis (color bar)
  kwargs: additional arguments

Reimplemented in PXDDeadPixelsChecker, PXDGainMapChecker, and PXDMaskedPixelsChecker.

Definition at line 125 of file condition_checker.py.

125 def define_hists(self, name=None, title=None, ztitle=None, **kwargs):
126 """
127 Method to define TH2
128 Parameters:
129 name (str): name for TH2, to which sensor name will be attached
130 title (str): title for TH2
131 ztitle (str): title for z-axis (color bar)
132 kwargs: additional arguments
133 """
134 if self.rundir:
135 self.tfile.cd(self.rundir)
136 # \cond false positive doxygen warning
137 self.hists.update(get_sensor_maps(name, title, ztitle, self.run, **kwargs))
138 # \endcond
139

◆ draw_plots()

draw_plots ( self,
canvas = None,
** kwargs )
Method to draw plots on a TCanvas

Reimplemented from ConditionCheckerBase.

Definition at line 306 of file condition_checker.py.

306 def draw_plots(self, canvas=None, **kwargs):
307 """
308 Method to draw plots on a TCanvas
309 """
310 # We don't use raw occupanncy. They will be corrected after takig out dead pixels
311 pass
312 # super().draw_plots(canvas=canvas, cname="OccupancyWithMask", ymin=0., ymax=plot_type_dict["occ_masked"]["max"])
313
314

◆ exp()

exp ( self)
inherited
Experiment number

Definition at line 103 of file condition_checker.py.

103 def exp(self):
104 """
105 Experiment number
106 """
107 return self.eventMetaData.getExperiment()
108

◆ fill_plots()

fill_plots ( self)
inherited
Method to fill plot objects

Definition at line 172 of file condition_checker.py.

172 def fill_plots(self):
173 """
174 Method to fill plot objects
175 """
176 if self.exp < self.expstart:
177 self.expstart = self.exp
178 if self.run < self.runstart:
179 self.runstart = self.run
180 if self.run > self.runend:
181 self.runend = self.run
182
183 db_content = self.get_db_content()
184 values_dict = {}
185 pre_values_dict = {}
186 for sensorID in sensorID_list:
187 sensor_db_content = db_content[sensorID.getID()]
188 if self.graphs:
189 if not self.use_hist:
190 values_dict[sensorID.getID()] = self.get_graph_value(sensor_db_content)
191 gr = self.graphs[sensorID.getID()]
192 pre_values_dict[sensorID.getID()] = gr.GetPointY(gr.GetN() - 1)
193 # Saving graph points only for different values (sensor-wise)
194 # value = self.get_graph_value(sensor_db_content)
195 # pre_value = gr.GetPointY(gr.GetN()-1)
196 # if value != pre_value:
197 # gr.SetPoint(gr.GetN(), self.run, value)
198 # Saving masked map
199 if self.rundir != "" and self.hists:
200 h2 = self.hists[sensorID.getID()]
201 self.set_hist_content(h2, sensor_db_content)
202 # Update title with total count
203 h2.SetTitle(h2.GetTitle() + self.hist_title_suffix)
204 self.tfile.cd(self.rundir)
205 h2.Write()
206 if self.use_hist:
207 values_dict[sensorID.getID()] = self.get_graph_value_from_hist(h2)
208 # Saving graph points only for different conditions
209 if values_dict != pre_values_dict:
210 for sensorID in sensorID_list:
211 gr = self.graphs[sensorID.getID()]
212 # \cond false positive doxygen warning
213 gr.SetPoint(gr.GetN(), self.run, values_dict[sensorID.getID()])
214 # \endcond
215

◆ get_db_content()

get_db_content ( self)
Abstract method to get content of a payload
Should return a Dictionary with sensorID.getID() as key and relaated calibration results as value

Reimplemented from ConditionCheckerBase.

Definition at line 293 of file condition_checker.py.

293 def get_db_content(self):
294 content_dic = {}
295 for sensorID in sensorID_list:
296 numID = sensorID.getID()
297 raw_occ = self.dbObj.getOccupancy(numID)
298 # The default value is -1. It seems 0 will not be updated into the payload.
299 content_dic[numID] = raw_occ if raw_occ >= 0 else 0
300
301 return content_dic
302

◆ get_graph_value()

get_graph_value ( self,
sensor_db_content )
Abstract method to get a value for each TGraph
Parameters:
  sensor_db_content (Any): Calibration results of a module

Reimplemented from ConditionCheckerBase.

Definition at line 303 of file condition_checker.py.

303 def get_graph_value(self, sensor_db_content):
304 return sensor_db_content * 100
305

◆ get_graph_value_from_hist()

get_graph_value_from_hist ( self,
h2 = None )
inherited
Method to get a value for each TGraph
Parameters:
  h2 (TH2): If not none, get value from h2

Reimplemented in PXDDeadPixelsChecker.

Definition at line 155 of file condition_checker.py.

155 def get_graph_value_from_hist(self, h2=None):
156 """
157 Method to get a value for each TGraph
158 Parameters:
159 h2 (TH2): If not none, get value from h2
160 """
161 return None
162

◆ objType()

objType ( self)
inherited
DBObj type (read only)

Definition at line 89 of file condition_checker.py.

89 def objType(self):
90 """
91 DBObj type (read only)
92 """
93 return self._objType
94

◆ run()

run ( self)
inherited
Run number

Definition at line 96 of file condition_checker.py.

96 def run(self):
97 """
98 Run number
99 """
100 return self.eventMetaData.getRun()
101

◆ save_canvas()

save_canvas ( self,
canvas,
cname,
logy = False )
inherited
Save TCanvas to png/pdf format and do not write it to the ROOT file by default
Parameters:
  canvas (TCanvas): ROOT TCanvas for plotting
  canme (str): Name of the canvas
  logy (bool): Flag to use log scale for y-axis

Definition at line 250 of file condition_checker.py.

250 def save_canvas(self, canvas, cname, logy=False):
251 """
252 Save TCanvas to png/pdf format and do not write it to the ROOT file by default
253 Parameters:
254 canvas (TCanvas): ROOT TCanvas for plotting
255 canme (str): Name of the canvas
256 logy (bool): Flag to use log scale for y-axis
257 """
258 if cname:
259 canvas.SetName(cname)
260 exp_run = f"e{self.expstart:05}_r{self.runstart:04}-{self.runend:04}"
261 # Draw Belle II label
262 latex_r.DrawLatex(0.95, 0.92, "Belle II Experiment: " + exp_run.replace("_", " "))
263 # Print and write TCanvas
264 if logy:
265 canvas.SetLogy(1)
266 canvas.Update()
267 canvas.Modified()
268 canvas.Print(f"{exp_run}_{cname}_vs_run_logy.png")
269 canvas.Print(f"{exp_run}_{cname}_vs_run_logy.pdf")
270 else:
271 canvas.SetLogy(0)
272 canvas.Print(f"{exp_run}_{cname}_vs_run.png")
273 canvas.Print(f"{exp_run}_{cname}_vs_run.pdf")
274 self.tfile.cd()
275
276

◆ set_hist_content()

set_hist_content ( self,
h2,
sensor_db_content )
inherited
Method to set TH2 bins
Parameters:
  h2 (TH2): TH2F object for handling values of a pixel matrix
  sensor_db_content (Any): Calibration results of a module

Reimplemented in PXDDeadPixelsChecker, PXDGainMapChecker, and PXDMaskedPixelsChecker.

Definition at line 163 of file condition_checker.py.

163 def set_hist_content(self, h2, sensor_db_content):
164 """
165 Method to set TH2 bins
166 Parameters:
167 h2 (TH2): TH2F object for handling values of a pixel matrix
168 sensor_db_content (Any): Calibration results of a module
169 """
170 pass
171

Member Data Documentation

◆ _objType

_objType = objType
protectedinherited

DBObj type.

Definition at line 59 of file condition_checker.py.

◆ dbObj

dbObj = Belle2.PyDBObj(self.name, self.objType.Class())
inherited

DBObjPtr for the condition.

Definition at line 61 of file condition_checker.py.

◆ eventMetaData

eventMetaData = Belle2.PyStoreObj("EventMetaData")
inherited

pointer to the event metadata

Definition at line 63 of file condition_checker.py.

◆ expstart

int expstart = 999999
inherited

The 1st exp.

Definition at line 82 of file condition_checker.py.

◆ graphs

dict graphs = {}
inherited

Dictionary of plots (TGraph) summarizing variables vs run.

Definition at line 72 of file condition_checker.py.

◆ hist_title_suffix

hist_title_suffix = ""
inherited

Hist title suffix.

Definition at line 76 of file condition_checker.py.

◆ hists

dict hists = {}
inherited

Dictionary of plots (TH1) to be saved for each run.

Definition at line 74 of file condition_checker.py.

◆ name

name = name
inherited

DBObj name.

Definition at line 57 of file condition_checker.py.

◆ rundir

rundir = rundir
inherited

Directory for writing histograms of each run.

Definition at line 67 of file condition_checker.py.

◆ runend

int runend = -1
inherited

The last run.

Definition at line 80 of file condition_checker.py.

◆ runstart

int runstart = 999999
inherited

The 1st run.

Definition at line 78 of file condition_checker.py.

◆ tfile

tfile = tfile
inherited

TFile for saving plots.

Definition at line 65 of file condition_checker.py.

◆ use_hist

use_hist = use_hist
inherited

Flag to get TGraph values from a histogram (TH2F)

Definition at line 84 of file condition_checker.py.


The documentation for this class was generated from the following file: