Belle II Software development
DQM Class Reference

Public Member Functions

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

Public Attributes

 f = TFile(fname)
 input file name
 
str type = 'adc'
 plot type (adc/tdc/hit)
 
list histADC
 ADC histograms.
 
list histTDC
 TDC histograms.
 
list histHit
 Hit distribution histograms.
 
list lines = []
 Line for guide of TDC T0.
 
list lineMPVs = []
 Line for guide of ADC MPV.
 
 sig = TF1("sig", "landau", 0, 200)
 Fitting function for ADC histogram.
 
 ft0 = TF1("ft0", "[0]+[1]*(exp([2]*([3]-x))/(1+exp(-([4]-x)/[5])))", 2000, 4000)
 Fitting function for TDC histogram.
 
bool m_fitStatus = False
 Fit status True if fitting has been finished.
 
 canvas = TCanvas("canvas", "canvas", 800, 800)
 canvas
 
int hid = 0
 histogram ID
 
int ndiv = 1
 Number of division for canvas.
 
list par = [-1.0 for i in range(14336)]
 MPV values.
 
list parADCinLayer = [-1.0 for i in range(56)]
 MPV values w.r.t.
 
list parT0 = [0.0 for i in range(14336)]
 T0 values.
 
 h2
 histogram
 
 h2ADCvsLayer
 Set stats.
 
 x = array("d", [i for i in range(14336)])
 Set stats.
 
 l_array = array("d", [i for i in range(56)])
 array layer
 
 graph = TGraph(len(self.x))
 TGraph.
 
 graph2 = TGraph(len(self.l_array))
 Marker style.
 
list line = [TLine(0, 0, 0, 200)]
 Marker style.
 

Detailed Description

DQM class.

Definition at line 40 of file dqm.py.

Constructor & Destructor Documentation

◆ __init__()

__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
STL class.

Member Function Documentation

◆ da()

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()

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()

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()

drawADC ( self,
lay = 0,
w = 0 )
Draw ADC histograms 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 histograms 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()

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

Definition at line 247 of file dqm.py.

247 def drawADCByCell(self, i):
248 """
249 Draw ADC histograms 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()

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

Definition at line 221 of file dqm.py.

221 def drawHit(self, lay=0):
222 """
223 Draw Hit histograms 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()

drawTDC ( self,
lay = 0,
w = 0 )
Draw TDC histograms 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 histograms 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()

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

Definition at line 234 of file dqm.py.

234 def drawTDCByCell(self, i):
235 """
236 Draw TDC histograms 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()

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()

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

Definition at line 153 of file dqm.py.

153 def fitADC(self, xmin=8, xmax=200):
154 """
155 Fit all ADC histograms.
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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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 = TCanvas("canvas", "canvas", 800, 800)

canvas

Definition at line 95 of file dqm.py.

◆ f

f = TFile(fname)

input file name

Definition at line 54 of file dqm.py.

◆ ft0

ft0 = TF1("ft0", "[0]+[1]*(exp([2]*([3]-x))/(1+exp(-([4]-x)/[5])))", 2000, 4000)

Fitting function for TDC histogram.

Definition at line 89 of file dqm.py.

◆ graph

graph = TGraph(len(self.x))

TGraph.

Definition at line 129 of file dqm.py.

◆ graph2

graph2 = TGraph(len(self.l_array))

Marker style.

Marker size

TGraph

Definition at line 136 of file dqm.py.

◆ h2

h2
Initial value:
= TH2D("h2d", "MPV of all ADCs", 15000,
-500, 14500, 100, 0, 200)

histogram

Definition at line 107 of file dqm.py.

◆ h2ADCvsLayer

h2ADCvsLayer
Initial value:
= TH2D("h2dl", "MPV for every Layer", 56,
0, 56, 100, 0, 200)

Set stats.

Set title of X axis

Set title of Y axis

histogram

Definition at line 116 of file dqm.py.

◆ hid

hid = 0

histogram ID

Definition at line 97 of file dqm.py.

◆ histADC

histADC
Initial value:
= [self.f.Get('h' + str(100000 + i))
for i in range(14336)]

ADC histograms.

Definition at line 58 of file dqm.py.

◆ histHit

list histHit
Initial value:
= [self.f.Get('h' + str(400000 + i))
for i in range(56)]

Hit distribution histograms.

Definition at line 64 of file dqm.py.

◆ histTDC

list histTDC
Initial value:
= [self.f.Get('h' + str(200000 + i))
for i in range(14336)]

TDC histograms.

Definition at line 61 of file dqm.py.

◆ l_array

l_array = array("d", [i for i in range(56)])

array layer

Definition at line 127 of file dqm.py.

◆ line

list line = [TLine(0, 0, 0, 200)]

Marker style.

Marker size

Reference line

Definition at line 142 of file dqm.py.

◆ lineMPVs

list lineMPVs = []

Line for guide of ADC MPV.

Definition at line 75 of file dqm.py.

◆ lines

list lines = []

Line for guide of TDC T0.

Definition at line 67 of file dqm.py.

◆ m_fitStatus

bool m_fitStatus = False

Fit status True if fitting has been finished.

Definition at line 93 of file dqm.py.

◆ ndiv

ndiv = 1

Number of division for canvas.

Definition at line 99 of file dqm.py.

◆ par

par = [-1.0 for i in range(14336)]

MPV values.

Definition at line 101 of file dqm.py.

◆ parADCinLayer

list parADCinLayer = [-1.0 for i in range(56)]

MPV values w.r.t.

layer

Definition at line 103 of file dqm.py.

◆ parT0

list parT0 = [0.0 for i in range(14336)]

T0 values.

Definition at line 105 of file dqm.py.

◆ sig

sig = TF1("sig", "landau", 0, 200)

Fitting function for ADC histogram.

Definition at line 85 of file dqm.py.

◆ type

str type = 'adc'

plot type (adc/tdc/hit)

Definition at line 56 of file dqm.py.

◆ x

x = array("d", [i for i in range(14336)])

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: