Belle II Software development
DQM Class Reference

Public Member Functions

def __init__ (self, fname='output.root')
 
def fitADC (self, xmin=8, xmax=200)
 
def getHistID (self, lay=0, wire=0)
 
def getLayerWireID (self, hid=0)
 
def drawADC (self, lay=0, w=0)
 
def drawTDC (self, lay=0, w=0)
 
def drawHit (self, lay=0)
 
def drawTDCByCell (self, i)
 
def drawADCByCell (self, i)
 
def next (self)
 
def div (self, i=1, j=1)
 
def mpv (self)
 
def xrange (self, xmin=-500, xmax=14500)
 
def xrangeHit (self, xmin=0, xmax=350)
 
def xrangeTDC (self, xmin=0, xmax=4000)
 
def xrangeADC (self, xmin=0, xmax=200)
 
def print (self, fname='test.png')
 
def ne (self)
 
def dh (self, lay)
 
def da (self, lay, w)
 
def dt (self, lay, w)
 

Public Attributes

 f
 input file name
 
 type
 plot type (adc/tdc/hit)
 
 histADC
 ADC histograms.
 
 histTDC
 TDC histograms.
 
 histHit
 Hit distribution histograms.
 
 lines
 Line for guide of TDC T0.
 
 lineMPVs
 Line for guide of ADC MPV.
 
 sig
 Fitting function for ADC histogram.
 
 ft0
 Fitting function for TDC histogram.
 
 m_fitStatus
 Fit status True if fitting has been finished.
 
 canvas
 canvas
 
 hid
 histogram ID
 
 ndiv
 Number of division for canvas.
 
 par
 MPV values.
 
 parADCinLayer
 MPV values w.r.t.
 
 parT0
 T0 values.
 
 h2
 histogram
 
 h2ADCvsLayer
 Set stats.
 
 x
 Set stats.
 
 l_array
 array layer
 
 graph
 TGraph.
 
 graph2
 Marker style.
 
 line
 Marker style.
 

Detailed Description

DQM class.

Definition at line 40 of file dqm.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  fname = 'output.root' 
)
call constructor of base class, required.

Definition at line 46 of file dqm.py.

46 def __init__(self, fname='output.root'):
47 """
48 call constructor of base class, required.
49 """
50
51 super().__init__()
52
53
54 self.f = TFile(fname)
55
56 self.type = 'adc'
57
58 self.histADC = [self.f.Get('h' + str(100000 + i))
59 for i in range(14336)]
60
61 self.histTDC = [self.f.Get('h' + str(200000 + i))
62 for i in range(14336)]
63
64 self.histHit = [self.f.Get('h' + str(400000 + i))
65 for i in range(56)]
66
67 self.lines = []
68 for h in self.histTDC:
69 y = h.GetMaximum()
70 line = TLine(refT0, 0, refT0, y)
71 line.SetLineColor(2)
72 self.lines.append(line)
73
74
75 self.lineMPVs = []
76 for h in self.histADC:
77 y = h.GetMaximum()
78 line = TLine(refMPV, 0, refMPV, y)
79 line.SetLineColor(2)
80 self.lineMPVs.append(line)
81 # self.histADCinLayer = [self.f.Get('h' + str(500000 + i))
82 # for i in range(56)]
83
84
85 self.sig = TF1("sig", "landau", 0, 200)
86 # self.sig = TF1("sig", "landau+expo(3)", 0, 200)
87 # self.sig.SetParameters(300.0,60.0,20.0,1000,-1.0)
88
89 self.ft0 = TF1("ft0", "[0]+[1]*(exp([2]*([3]-x))/(1+exp(-([4]-x)/[5])))", 2000, 4000)
90 self.ft0.SetParameters(0, 10, 0, 0, 3800, 3.)
91 self.ft0.FixParameter(0, 0.)
92
93 self.m_fitStatus = False
94
95 self.canvas = TCanvas("canvas", "canvas", 800, 800)
96
97 self.hid = 0
98
99 self.ndiv = 1
100
101 self.par = [-1.0 for i in range(14336)]
102
103 self.parADCinLayer = [-1.0 for i in range(56)]
104
105 self.parT0 = [0.0 for i in range(14336)]
106
107 self.h2 = TH2D("h2d", "MPV of all ADCs", 15000,
108 -500, 14500, 100, 0, 200)
109
110 self.h2.SetStats(0)
111
112 self.h2.GetXaxis().SetTitle('Cell ID')
113
114 self.h2.GetYaxis().SetTitle('MPV')
115
116 self.h2ADCvsLayer = TH2D("h2dl", "MPV for every Layer", 56,
117 0, 56, 100, 0, 200)
118
119 self.h2ADCvsLayer.SetStats(0)
120
121 self.h2ADCvsLayer.GetXaxis().SetTitle('Layer')
122
123 self.h2ADCvsLayer.GetYaxis().SetTitle('MPV (adc count)')
124
125 self.x = array("d", [i for i in range(14336)])
126
127 self.l_array = array("d", [i for i in range(56)])
128
129 self.graph = TGraph(len(self.x))
130
131 self.graph.SetMarkerStyle(kFullCircle)
132
133 self.graph.SetMarkerSize(0.3)
134
135
136 self.graph2 = TGraph(len(self.l_array))
137
138 self.graph2.SetMarkerStyle(kFullCircle)
139
140 self.graph2.SetMarkerSize(1.0)
141
142 self.line = [TLine(0, 0, 0, 200)]
143
144 x0 = 0
145 for i in range(9):
146 x0 = x0 + nWiresSL[i]
147 line = TLine(x0, 0, x0, 200)
148 self.line.append(line)
149 for l_i in self.line:
150 l_i.SetLineColorAlpha(8, 0.5)
151 l_i.SetLineStyle(2)
152

Member Function Documentation

◆ da()

def da (   self,
  lay,
  w 
)
Alias to drawADC()

Definition at line 346 of file dqm.py.

346 def da(self, lay, w):
347 """
348 Alias to drawADC()
349 """
350 self.drawADC(lay, w)
351

◆ dh()

def dh (   self,
  lay 
)
Alias to drawHit()

Definition at line 340 of file dqm.py.

340 def dh(self, lay):
341 """
342 Alias to drawHit()
343 """
344 self.drawHit(lay)
345

◆ div()

def div (   self,
  i = 1,
  j = 1 
)
Divide Tcanvas by (i,j).

Definition at line 277 of file dqm.py.

277 def div(self, i=1, j=1):
278 """
279 Divide Tcanvas by (i,j).
280 """
281 self.canvas.Clear()
282 self.canvas.Divide(i, j)
283 self.ndiv = i * j
284

◆ drawADC()

def drawADC (   self,
  lay = 0,
  w = 0 
)
Draw ADC histgrams w.r.t (lay,wire).

Definition at line 193 of file dqm.py.

193 def drawADC(self, lay=0, w=0):
194 """
195 Draw ADC histgrams w.r.t (lay,wire).
196 """
197 i = self.getHistID(lay, w)
198 for j in range(self.ndiv):
199 self.hid = i + j
200 self.canvas.cd(j + 1)
201 self.histADC[self.hid].Draw()
202 self.lineMPVs[self.hid].Draw()
203
204 self.type = 'adc'
205 self.canvas.Update()
206

◆ drawADCByCell()

def drawADCByCell (   self,
  i 
)
Draw ADC histgrams w.r.t cell ID (0-14336).

Definition at line 247 of file dqm.py.

247 def drawADCByCell(self, i):
248 """
249 Draw ADC histgrams w.r.t cell ID (0-14336).
250 """
251 for j in range(self.ndiv):
252 self.hid = i + j
253 self.canvas.cd(j + 1)
254 self.histADC[self.hid].Draw()
255 self.lineMPVs[self.hid].Draw()
256
257 self.type = 'adc'
258 self.canvas.Update()
259

◆ drawHit()

def drawHit (   self,
  lay = 0 
)
Draw Hit histgrams w.r.t layer ID.

Definition at line 221 of file dqm.py.

221 def drawHit(self, lay=0):
222 """
223 Draw Hit histgrams w.r.t layer ID.
224 """
225 for j in range(self.ndiv):
226 self.hid = lay + j
227 if self.hid > 55:
228 break
229 self.canvas.cd(j + 1)
230 self.histHit[self.hid].Draw()
231 self.canvas.Update()
232 self.type = 'hit'
233

◆ drawTDC()

def drawTDC (   self,
  lay = 0,
  w = 0 
)
Draw TDC histgrams w.r.t (lay,wire).

Definition at line 207 of file dqm.py.

207 def drawTDC(self, lay=0, w=0):
208 """
209 Draw TDC histgrams w.r.t (lay,wire).
210 """
211 i = self.getHistID(lay, w)
212 for j in range(self.ndiv):
213 self.hid = i + j
214 self.canvas.cd(j + 1)
215 self.histTDC[self.hid].Draw()
216 self.lines[self.hid].Draw()
217
218 self.canvas.Update()
219 self.type = 'tdc'
220

◆ drawTDCByCell()

def drawTDCByCell (   self,
  i 
)
Draw TDC histgrams w.r.t cell ID (0-14336).

Definition at line 234 of file dqm.py.

234 def drawTDCByCell(self, i):
235 """
236 Draw TDC histgrams w.r.t cell ID (0-14336).
237 """
238 for j in range(self.ndiv):
239 self.hid = i + j
240 self.canvas.cd(j + 1)
241 self.histTDC[self.hid].Draw()
242 self.lines[self.hid].Draw()
243
244 self.type = 'tdc'
245 self.canvas.Update()
246

◆ dt()

def dt (   self,
  lay,
  w 
)
Alias to drawTDC()

Definition at line 352 of file dqm.py.

352 def dt(self, lay, w):
353 """
354 Alias to drawTDC()
355 """
356 self.drawTDC(lay, w)
357
358

◆ fitADC()

def fitADC (   self,
  xmin = 8,
  xmax = 200 
)
Fit all ADC histgrams.

Definition at line 153 of file dqm.py.

153 def fitADC(self, xmin=8, xmax=200):
154 """
155 Fit all ADC histgrams.
156 """
157 if self.m_fitStatus is True:
158 print("Fitting for ADC has been already applied.")
159 else:
160
161 for (i, h) in enumerate(self.histADC):
162 if h.GetEntries() > 0:
163 h.Fit(self.sig, "Q", "", xmin, xmax)
164 self.par[i] = self.sig.GetParameter(1)
165 self.m_fitStatus = True
166

◆ getHistID()

def getHistID (   self,
  lay = 0,
  wire = 0 
)
Get Hist ID from (layer, wire) ID.
Return values : hist ID (cell ID)

Definition at line 167 of file dqm.py.

167 def getHistID(self, lay=0, wire=0):
168 """
169 Get Hist ID from (layer, wire) ID.
170 Return values : hist ID (cell ID)
171 """
172 hid = nWiresSum[lay - 1] + wire if lay > 0 else wire
173 return hid
174

◆ getLayerWireID()

def getLayerWireID (   self,
  hid = 0 
)
Get (layer, wire) ID from cell ID.
Return values : [layer, wire]

Definition at line 175 of file dqm.py.

175 def getLayerWireID(self, hid=0):
176 """
177 Get (layer, wire) ID from cell ID.
178 Return values : [layer, wire]
179 """
180 if hid < nWiresSum[0]:
181 return [0, hid]
182 else:
183 layer = 0
184 wire = 0
185 for (i, wsum) in enumerate(nWiresSum):
186 diff = hid - wsum
187 if diff > 0 and diff < nWires[i]:
188 layer = i + 1
189 wire = diff
190 break
191 return [layer, wire]
192

◆ mpv()

def mpv (   self)
Show the MPV of ADC distribution
for all wires.

Definition at line 285 of file dqm.py.

285 def mpv(self):
286 """
287 Show the MPV of ADC distribution
288 for all wires.
289 """
290 self.canvas.Clear()
291
292 for (i, p) in enumerate(self.par):
293 self.graph.SetPoint(i, self.x[i], p)
294
295 self.h2.Draw()
296 for line in self.line:
297 line.Draw()
298 self.graph.Draw("P")
299 self.canvas.Update()
300

◆ ne()

def ne (   self)
Alias to next()

Definition at line 334 of file dqm.py.

334 def ne(self):
335 """
336 Alias to next()
337 """
338 self.next()
339

◆ next()

def next (   self)
Show next plots.

Definition at line 260 of file dqm.py.

260 def next(self):
261 """
262 Show next plots.
263 """
264 self.hid = self.hid + 1
265 if self.type == 'adc':
266 self.canvas.Clear('d')
267 self.drawADCByCell(self.hid)
268 elif self.type == 'tdc':
269 self.canvas.Clear('d')
270 self.drawTDCByCell(self.hid)
271 elif self.type == 'hit':
272 self.canvas.Clear('d')
273 self.drawHit(self.hid)
274 else:
275 print('Undefined type: ' + type)
276

◆ print()

def print (   self,
  fname = 'test.png' 
)
Print the current plot.

Definition at line 328 of file dqm.py.

328 def print(self, fname='test.png'):
329 """
330 Print the current plot.
331 """
332 self.canvas.Print(fname)
333

◆ xrange()

def xrange (   self,
  xmin = -500,
  xmax = 14500 
)
Set x range of MPV plot.

Definition at line 301 of file dqm.py.

301 def xrange(self, xmin=-500, xmax=14500):
302 """
303 Set x range of MPV plot.
304 """
305 self.h2.GetXaxis().SetRangeUser(xmin, xmax)
306

◆ xrangeADC()

def xrangeADC (   self,
  xmin = 0,
  xmax = 200 
)
Set x range of ADC distributions.

Definition at line 321 of file dqm.py.

321 def xrangeADC(self, xmin=0, xmax=200):
322 """
323 Set x range of ADC distributions.
324 """
325 for h in self.histADC:
326 h.GetXaxis().SetRangeUser(xmin, xmax)
327

◆ xrangeHit()

def xrangeHit (   self,
  xmin = 0,
  xmax = 350 
)
Set x range of Hit distributions.

Definition at line 307 of file dqm.py.

307 def xrangeHit(self, xmin=0, xmax=350):
308 """
309 Set x range of Hit distributions.
310 """
311 for h in self.histHit:
312 h.GetXaxis().SetRangeUser(xmin, xmax)
313

◆ xrangeTDC()

def xrangeTDC (   self,
  xmin = 0,
  xmax = 4000 
)
Set x range of TDC distributions.

Definition at line 314 of file dqm.py.

314 def xrangeTDC(self, xmin=0, xmax=4000):
315 """
316 Set x range of TDC distributions.
317 """
318 for h in self.histTDC:
319 h.GetXaxis().SetRangeUser(xmin, xmax)
320

Member Data Documentation

◆ canvas

canvas

canvas

Definition at line 95 of file dqm.py.

◆ f

f

input file name

Definition at line 54 of file dqm.py.

◆ ft0

ft0

Fitting function for TDC histogram.

Definition at line 89 of file dqm.py.

◆ graph

graph

TGraph.

Definition at line 129 of file dqm.py.

◆ graph2

graph2

Marker style.

Marker size

TGraph

Definition at line 136 of file dqm.py.

◆ h2

h2

histogram

Definition at line 107 of file dqm.py.

◆ h2ADCvsLayer

h2ADCvsLayer

Set stats.

Set title of X axis

Set title of Y axis

histogram

Definition at line 116 of file dqm.py.

◆ hid

hid

histogram ID

Definition at line 97 of file dqm.py.

◆ histADC

histADC

ADC histograms.

Definition at line 58 of file dqm.py.

◆ histHit

histHit

Hit distribution histograms.

Definition at line 64 of file dqm.py.

◆ histTDC

histTDC

TDC histograms.

Definition at line 61 of file dqm.py.

◆ l_array

l_array

array layer

Definition at line 127 of file dqm.py.

◆ line

line

Marker style.

Marker size

Reference line

Definition at line 142 of file dqm.py.

◆ lineMPVs

lineMPVs

Line for guide of ADC MPV.

Definition at line 75 of file dqm.py.

◆ lines

lines

Line for guide of TDC T0.

Definition at line 67 of file dqm.py.

◆ m_fitStatus

m_fitStatus

Fit status True if fitting has been finished.

Definition at line 93 of file dqm.py.

◆ ndiv

ndiv

Number of division for canvas.

Definition at line 99 of file dqm.py.

◆ par

par

MPV values.

Definition at line 101 of file dqm.py.

◆ parADCinLayer

parADCinLayer

MPV values w.r.t.

layer

Definition at line 103 of file dqm.py.

◆ parT0

parT0

T0 values.

Definition at line 105 of file dqm.py.

◆ sig

sig

Fitting function for ADC histogram.

Definition at line 85 of file dqm.py.

◆ type

type

plot type (adc/tdc/hit)

Definition at line 56 of file dqm.py.

◆ x

x

Set stats.

Set title of X axis

Set title of Y axis

array cell

Definition at line 125 of file dqm.py.


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