4 from array
import array
5 from ROOT
import gROOT, gStyle
6 from ROOT
import TFile, TF1, TH1D, TCanvas
7 from ROOT
import TH2D, TGraph, TLine, TBox
8 from ROOT
import kFullCircle, kOpenCircle
9 from ROOT
import kRed, kBlue, kGreen
10 from ROOT
import TGraphErrors
13 nWires = [160, 160, 160, 160, 160, 160, 160, 160,
14 160, 160, 160, 160, 160, 160,
15 192, 192, 192, 192, 192, 192,
16 224, 224, 224, 224, 224, 224,
17 256, 256, 256, 256, 256, 256,
18 288, 288, 288, 288, 288, 288,
19 320, 320, 320, 320, 320, 320,
20 352, 352, 352, 352, 352, 352,
21 384, 384, 384, 384, 384, 384]
29 nWiresSL = [160 * 8, 160 * 6, 192 * 6, 224 * 6, 256 * 6, 288 * 6,
30 320 * 6, 352 * 6, 384 * 6]
33 refT0 = 4905.0 * rfClock
45 call constructor of base class, required.
55 self.
histADC = [self.
f.Get(
'h' + str(100000 + i))
56 for i
in range(14336)]
58 self.
histTDC = [self.
f.Get(
'h' + str(200000 + i))
59 for i
in range(14336)]
61 self.
histHit = [self.
f.Get(
'h' + str(400000 + i))
67 line = TLine(refT0, 0, refT0, y)
69 self.
lines.append(line)
75 line = TLine(refMPV, 0, refMPV, y)
82 self.
sig = TF1(
"sig",
"landau", 0, 200)
86 self.
ft0 = TF1(
"ft0",
"[0]+[1]*(exp([2]*([3]-x))/(1+exp(-([4]-x)/[5])))", 2000, 4000)
87 self.
ft0.SetParameters(0, 10, 0, 0, 3800, 3.)
88 self.
ft0.FixParameter(0, 0.)
92 self.
canvas = TCanvas(
"canvas",
"canvas", 800, 800)
98 self.
par = [-1.0
for i
in range(14336)]
102 self.
parT0 = [0.0
for i
in range(14336)]
104 self.
h2 = TH2D(
"h2d",
"MPV of all ADCs", 15000,
105 -500, 14500, 100, 0, 200)
109 self.
h2.GetXaxis().SetTitle(
'Cell ID')
111 self.
h2.GetYaxis().SetTitle(
'MPV')
120 self.
h2ADCvsLayer.GetYaxis().SetTitle(
'MPV (adc count)')
122 self.
x = array(
"d", [i
for i
in range(14336)])
124 self.
l = array(
"d", [i
for i
in range(56)])
128 self.
graph.SetMarkerStyle(kFullCircle)
130 self.
graph.SetMarkerSize(0.3)
135 self.
graph2.SetMarkerStyle(kFullCircle)
137 self.
graph2.SetMarkerSize(1.0)
139 self.
line = [TLine(0, 0, 0, 200)]
143 x0 = x0 + nWiresSL[i]
144 line = TLine(x0, 0, x0, 200)
145 self.
line.append(line)
147 l.SetLineColorAlpha(8, 0.5)
152 Fit all ADC histgrams.
155 print(
"Fitting for ADC has been already applied.")
158 for (i, h)
in enumerate(self.
histADC):
159 if h.GetEntries() > 0:
160 h.Fit(self.
sig,
"Q",
"", xmin, xmax)
161 self.
par[i] = self.
sig.GetParameter(1)
166 Get Hist ID from (layer, wire) ID.
167 Return values : hist ID (cell ID)
169 hid = nWiresSum[lay - 1] + wire
if lay > 0
else wire
174 Get (layer, wire) ID from cell ID.
175 Return values : [layer, wire]
177 if hid < nWiresSum[0]:
182 for (i, wsum)
in enumerate(nWiresSum):
184 if diff > 0
and diff < nWires[i]:
192 Draw ADC histgrams w.r.t (lay,wire).
195 for j
in range(self.
ndiv):
206 Draw TDC histgrams w.r.t (lay,wire).
209 for j
in range(self.
ndiv):
220 Draw Hit histgrams w.r.t layer ID.
222 for j
in range(self.
ndiv):
233 Draw TDC histgrams w.r.t cell ID (0-14336).
235 for j
in range(self.
ndiv):
246 Draw ADC histgrams w.r.t cell ID (0-14336).
248 for j
in range(self.
ndiv):
262 if self.
type ==
'adc':
265 elif self.
type ==
'tdc':
268 elif self.
type ==
'hit':
272 print(
'Undefined type: ' + type)
276 Divide Tcanvas by (i,j).
284 Show the MPV of ADC distribution
289 for (i, p)
in enumerate(self.
par):
290 self.
graph.SetPoint(i, self.
x[i], p)
293 for line
in self.
line:
300 Set x range of MPV plot.
302 self.
h2.GetXaxis().SetRangeUser(xmin, xmax)
306 Set x range of Hit distributions.
309 h.GetXaxis().SetRangeUser(xmin, xmax)
313 Set x range of TDC distributions.
316 h.GetXaxis().SetRangeUser(xmin, xmax)
320 Set x range of ADC distributions.
323 h.GetXaxis().SetRangeUser(xmin, xmax)
327 Print the current plot.
356 if __name__ ==
"__main__":
359 parser = argparse.ArgumentParser()
360 parser.add_argument(
'input', help=
'Input file to be processed (unpacked CDC data).')
361 args = parser.parse_args()
362 dqm =
DQM(args.input)