11 from array
import array
12 from ROOT
import TCanvas, TF1, TFile
13 from ROOT
import TGraph, TH2D, TLine
14 from ROOT
import kFullCircle
17 nWires = [160, 160, 160, 160, 160, 160, 160, 160,
18 160, 160, 160, 160, 160, 160,
19 192, 192, 192, 192, 192, 192,
20 224, 224, 224, 224, 224, 224,
21 256, 256, 256, 256, 256, 256,
22 288, 288, 288, 288, 288, 288,
23 320, 320, 320, 320, 320, 320,
24 352, 352, 352, 352, 352, 352,
25 384, 384, 384, 384, 384, 384]
33 nWiresSL = [160 * 8, 160 * 6, 192 * 6, 224 * 6, 256 * 6, 288 * 6,
34 320 * 6, 352 * 6, 384 * 6]
37 refT0 = 4905.0 * rfClock
49 call constructor of base class, required.
55 self.
ff = TFile(fname)
59 self.
histADChistADC = [self.
ff.Get(
'h' + str(100000 + i))
60 for i
in range(14336)]
62 self.
histTDChistTDC = [self.
ff.Get(
'h' + str(200000 + i))
63 for i
in range(14336)]
65 self.
histHithistHit = [self.
ff.Get(
'h' + str(400000 + i))
71 line = TLine(refT0, 0, refT0, y)
73 self.
lineslines.append(line)
79 line = TLine(refMPV, 0, refMPV, y)
86 self.
sigsig = TF1(
"sig",
"landau", 0, 200)
90 self.
ft0ft0 = TF1(
"ft0",
"[0]+[1]*(exp([2]*([3]-x))/(1+exp(-([4]-x)/[5])))", 2000, 4000)
91 self.
ft0ft0.SetParameters(0, 10, 0, 0, 3800, 3.)
92 self.
ft0ft0.FixParameter(0, 0.)
96 self.
canvascanvas = TCanvas(
"canvas",
"canvas", 800, 800)
102 self.
parpar = [-1.0
for i
in range(14336)]
106 self.
parT0parT0 = [0.0
for i
in range(14336)]
108 self.
h2h2 = TH2D(
"h2d",
"MPV of all ADCs", 15000,
109 -500, 14500, 100, 0, 200)
111 self.
h2h2.SetStats(0)
113 self.
h2h2.GetXaxis().SetTitle(
'Cell ID')
115 self.
h2h2.GetYaxis().SetTitle(
'MPV')
117 self.
h2ADCvsLayerh2ADCvsLayer = TH2D(
"h2dl",
"MPV for every Layer", 56,
122 self.
h2ADCvsLayerh2ADCvsLayer.GetXaxis().SetTitle(
'Layer')
124 self.
h2ADCvsLayerh2ADCvsLayer.GetYaxis().SetTitle(
'MPV (adc count)')
126 self.
xx = array(
"d", [i
for i
in range(14336)])
128 self.
l_arrayl_array = array(
"d", [i
for i
in range(56)])
132 self.
graphgraph.SetMarkerStyle(kFullCircle)
134 self.
graphgraph.SetMarkerSize(0.3)
139 self.
graph2graph2.SetMarkerStyle(kFullCircle)
141 self.
graph2graph2.SetMarkerSize(1.0)
143 self.
lineline = [TLine(0, 0, 0, 200)]
147 x0 = x0 + nWiresSL[i]
148 line = TLine(x0, 0, x0, 200)
149 self.
lineline.append(line)
150 for l_i
in self.
lineline:
151 l_i.SetLineColorAlpha(8, 0.5)
156 Fit all ADC histgrams.
159 print(
"Fitting for ADC has been already applied.")
162 for (i, h)
in enumerate(self.
histADChistADC):
163 if h.GetEntries() > 0:
164 h.Fit(self.
sigsig,
"Q",
"", xmin, xmax)
165 self.
parpar[i] = self.
sigsig.GetParameter(1)
170 Get Hist ID from (layer, wire) ID.
171 Return values : hist ID (cell ID)
173 hid = nWiresSum[lay - 1] + wire
if lay > 0
else wire
178 Get (layer, wire) ID from cell ID.
179 Return values : [layer, wire]
181 if hid < nWiresSum[0]:
186 for (i, wsum)
in enumerate(nWiresSum):
188 if diff > 0
and diff < nWires[i]:
196 Draw ADC histgrams w.r.t (lay,wire).
199 for j
in range(self.
ndivndiv):
201 self.
canvascanvas.cd(j + 1)
205 self.
typetype =
'adc'
206 self.
canvascanvas.Update()
210 Draw TDC histgrams w.r.t (lay,wire).
213 for j
in range(self.
ndivndiv):
215 self.
canvascanvas.cd(j + 1)
219 self.
canvascanvas.Update()
220 self.
typetype =
'tdc'
224 Draw Hit histgrams w.r.t layer ID.
226 for j
in range(self.
ndivndiv):
227 self.
hidhid = lay + j
230 self.
canvascanvas.cd(j + 1)
232 self.
canvascanvas.Update()
233 self.
typetype =
'hit'
237 Draw TDC histgrams w.r.t cell ID (0-14336).
239 for j
in range(self.
ndivndiv):
241 self.
canvascanvas.cd(j + 1)
245 self.
typetype =
'tdc'
246 self.
canvascanvas.Update()
250 Draw ADC histgrams w.r.t cell ID (0-14336).
252 for j
in range(self.
ndivndiv):
254 self.
canvascanvas.cd(j + 1)
258 self.
typetype =
'adc'
259 self.
canvascanvas.Update()
265 self.
hidhid = self.
hidhid + 1
266 if self.
typetype ==
'adc':
267 self.
canvascanvas.Clear(
'd')
269 elif self.
typetype ==
'tdc':
270 self.
canvascanvas.Clear(
'd')
272 elif self.
typetype ==
'hit':
273 self.
canvascanvas.Clear(
'd')
276 print(
'Undefined type: ' + type)
280 Divide Tcanvas by (i,j).
283 self.
canvascanvas.Divide(i, j)
284 self.
ndivndiv = i * j
288 Show the MPV of ADC distribution
293 for (i, p)
in enumerate(self.
parpar):
294 self.
graphgraph.SetPoint(i, self.
xx[i], p)
297 for line
in self.
lineline:
299 self.
graphgraph.Draw(
"P")
300 self.
canvascanvas.Update()
304 Set x range of MPV plot.
306 self.
h2h2.GetXaxis().SetRangeUser(xmin, xmax)
310 Set x range of Hit distributions.
313 h.GetXaxis().SetRangeUser(xmin, xmax)
317 Set x range of TDC distributions.
320 h.GetXaxis().SetRangeUser(xmin, xmax)
324 Set x range of ADC distributions.
327 h.GetXaxis().SetRangeUser(xmin, xmax)
331 Print the current plot.
333 self.
canvascanvas.Print(fname)
347 def da(self, lay, w):
353 def dt(self, lay, w):
360 if __name__ ==
"__main__":
363 parser = argparse.ArgumentParser()
364 parser.add_argument(
'input', help=
'Input file to be processed (unpacked CDC data).')
365 args = parser.parse_args()
366 dqm =
DQM(args.input)
def print(self, fname='test.png')
lines
Line for guide of TDC T0.
def xrangeADC(self, xmin=0, xmax=200)
def xrange(self, xmin=-500, xmax=14500)
def fitADC(self, xmin=8, xmax=200)
def xrangeTDC(self, xmin=0, xmax=4000)
histHit
Hit distribution histograms.
m_fitStatus
Fit status True if fitting has been finished.
type
plot type (adc/tdc/hit)
def getHistID(self, lay=0, wire=0)
sig
Fitting function for ADC histogram.
ft0
Fitting function for TDC histogram.
def drawTDCByCell(self, i)
def xrangeHit(self, xmin=0, xmax=350)
lineMPVs
Line for guide of ADC MPV.
def drawTDC(self, lay=0, w=0)
def __init__(self, fname='output.root')
parADCinLayer
MPV values w.r.t.
ndiv
Number of division for canvas.
def drawADCByCell(self, i)
def drawADC(self, lay=0, w=0)
def getLayerWireID(self, hid=0)