10from array
import array
11from ROOT
import TCanvas, TF1, TFile
12from ROOT
import TGraph, TH2D, TLine
13from ROOT
import kFullCircle
16nWires = [160, 160, 160, 160, 160, 160, 160, 160,
17 160, 160, 160, 160, 160, 160,
18 192, 192, 192, 192, 192, 192,
19 224, 224, 224, 224, 224, 224,
20 256, 256, 256, 256, 256, 256,
21 288, 288, 288, 288, 288, 288,
22 320, 320, 320, 320, 320, 320,
23 352, 352, 352, 352, 352, 352,
24 384, 384, 384, 384, 384, 384]
32nWiresSL = [160 * 8, 160 * 6, 192 * 6, 224 * 6, 256 * 6, 288 * 6,
33 320 * 6, 352 * 6, 384 * 6]
36refT0 = 4905.0 * rfClock
48 call constructor of base class, required.
58 self.
histADC = [self.
f.Get(
'h' + str(100000 + i))
59 for i
in range(14336)]
61 self.
histTDC = [self.
f.Get(
'h' + str(200000 + i))
62 for i
in range(14336)]
64 self.
histHit = [self.
f.Get(
'h' + str(400000 + i))
70 line = TLine(refT0, 0, refT0, y)
72 self.
lines.append(line)
78 line = TLine(refMPV, 0, refMPV, y)
85 self.
sig = TF1(
"sig",
"landau", 0, 200)
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.)
95 self.
canvas = TCanvas(
"canvas",
"canvas", 800, 800)
101 self.
par = [-1.0
for i
in range(14336)]
105 self.
parT0 = [0.0
for i
in range(14336)]
107 self.
h2 = TH2D(
"h2d",
"MPV of all ADCs", 15000,
108 -500, 14500, 100, 0, 200)
112 self.
h2.GetXaxis().SetTitle(
'Cell ID')
114 self.
h2.GetYaxis().SetTitle(
'MPV')
123 self.
h2ADCvsLayer.GetYaxis().SetTitle(
'MPV (adc count)')
125 self.
x = array(
"d", [i
for i
in range(14336)])
127 self.
l_array = array(
"d", [i
for i
in range(56)])
131 self.
graph.SetMarkerStyle(kFullCircle)
133 self.
graph.SetMarkerSize(0.3)
138 self.
graph2.SetMarkerStyle(kFullCircle)
140 self.
graph2.SetMarkerSize(1.0)
142 self.
line = [TLine(0, 0, 0, 200)]
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)
155 Fit all ADC histgrams.
158 print(
"Fitting for ADC has been already applied.")
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)
169 Get Hist ID from (layer, wire) ID.
170 Return values : hist ID (cell ID)
172 hid = nWiresSum[lay - 1] + wire if lay > 0
else wire
177 Get (layer, wire) ID from cell ID.
178 Return values : [layer, wire]
180 if hid < nWiresSum[0]:
185 for (i, wsum)
in enumerate(nWiresSum):
187 if diff > 0
and diff < nWires[i]:
195 Draw ADC histgrams w.r.t (lay,wire).
198 for j
in range(self.
ndiv):
209 Draw TDC histgrams w.r.t (lay,wire).
212 for j
in range(self.
ndiv):
223 Draw Hit histgrams w.r.t layer ID.
225 for j
in range(self.
ndiv):
236 Draw TDC histgrams w.r.t cell ID (0-14336).
238 for j
in range(self.
ndiv):
249 Draw ADC histgrams w.r.t cell ID (0-14336).
251 for j
in range(self.
ndiv):
265 if self.
type ==
'adc':
268 elif self.
type ==
'tdc':
271 elif self.
type ==
'hit':
275 print(
'Undefined type: ' + type)
279 Divide Tcanvas by (i,j).
287 Show the MPV of ADC distribution
292 for (i, p)
in enumerate(self.
par):
293 self.
graph.SetPoint(i, self.
x[i], p)
296 for line
in self.
line:
303 Set x range of MPV plot.
305 self.h2.GetXaxis().SetRangeUser(xmin, xmax)
309 Set x range of Hit distributions.
312 h.GetXaxis().SetRangeUser(xmin, xmax)
316 Set x range of TDC distributions.
319 h.GetXaxis().SetRangeUser(xmin, xmax)
323 Set x range of ADC distributions.
326 h.GetXaxis().SetRangeUser(xmin, xmax)
330 Print the current plot.
346 def da(self, lay, w):
352 def dt(self, lay, w):
359if __name__ ==
"__main__":
362 parser = argparse.ArgumentParser()
363 parser.add_argument(
'input', help=
'Input file to be processed (unpacked CDC data).')
364 args = parser.parse_args()
365 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)