Belle II Software development
analyze_TOPFE_ntuple.py
1
8
9# Script to analyze the output of TOPFE_qualityPlots.py
10
11import sys
12import ROOT
13ROOT.gStyle.SetOptStat(0)
14ROOT.gROOT.SetBatch()
15
16if len(sys.argv) < 2:
17 print(f"Usage: {sys.argv[0]} <name of root ntuple>")
18 sys.exit(-1)
19
20f = ROOT.TFile.Open(sys.argv[1])
21
22t = f.Get("feProps")
23t.SetLineWidth(2)
24t.SetLineColor(6)
25calChannel = "ch % 8 == 0"
26signalChannel = "ch % 8 != 0"
27c = ROOT.TCanvas()
28
29nTRDHist = ROOT.TH1D("nTRDHist", "all channels;number of TOPRawDigits;waveforms", 1000, 0, 30)
30t.Draw("nTOPRawDigits>>nTRDHist")
31c.SaveAs("nTOPRawDigits_All.pdf")
32c.SetLogy()
33c.SaveAs("nTOPRawDigits_All_logy.pdf")
34c.SetLogy(False)
35c.Clear()
36nTRDHist.Reset()
37
38t.Draw("nTOPRawDigits>>nTRDHist", calChannel)
39c.SaveAs("nTOPRawDigits_cal.pdf")
40c.SetLogy()
41c.SaveAs("nTOPRawDigits_cal_logy.pdf")
42c.SetLogy(False)
43c.Clear()
44nTRDHist.Reset()
45
46t.Draw("nTOPRawDigits>>nTRDHist", signalChannel)
47c.SaveAs("nTOPRawDigits_sig.pdf")
48c.SetLogy()
49c.SaveAs("nTOPRawDigits_sig_logy.pdf")
50c.SetLogy(False)
51c.Clear()
52
53t.Draw("fePeakHt:fePeak1Ht", calChannel, "hist")
54c.SaveAs("fePeakHt_vs_fePeak1Ht_cal.pdf")
55c.Clear()
56
57wd_adcHist = ROOT.TH2D("wd_adcHist", "Width vs Pulse height;width;height", 130, 0, 130, 1100, 50, 1150)
58t.Draw("fePeakHt:fePeakWd>>wd_adcHist", "", "colz")
59c.SaveAs("fePeakWd_vs_fePeakHt.pdf")
60c.Clear()
61wd_adcHist.Reset()
62
63wd_adcHist.SetTitle("Width vs Pulse height in the calibration channel;width;height")
64t.Draw("fePeakHt:fePeakWd>>wd_adcHist", calChannel, "colz")
65c.SaveAs("fePeakWd_vs_fePeakHt_cal.pdf")
66c.Clear()
67wd_adcHist.Reset()
68
69wd_adcHist.SetTitle("Width vs Pulse height in the signal channel;width;height")
70t.Draw("fePeakHt:fePeakWd>>wd_adcHist", signalChannel, "colz")
71c.SaveAs("fePeakWd_vs_fePeakHt_sig.pdf")
72c.Clear()
73wd_adcHist.Reset()
74
75wd_tdcHist = ROOT.TH2D("wd_tdcHist", "Width vs TDC;TDC;width", 256, 1, 257, 130, 0, 130)
76t.Draw("fePeakWd:fePeakTDC>>wd_tdcHist", "", "colz")
77c.SaveAs("fePeakWd_vs_TDC.pdf")
78c.Clear()
79
80ht_tdcHist = ROOT.TH2D("ht_tdcHist", "Height vs TDC;TDC;height", 256, 1, 257, 1100, 50, 1150)
81t.Draw("fePeakHt:fePeakTDC>>ht_tdcHist", "", "colz")
82c.SaveAs("fePeakHt_vs_TDC.pdf")
83c.SetLogz()
84c.Clear()
85
86ch_tdcHist = ROOT.TH2D("ch_tdcHist", "Channel vs TDC;TDC;channel number", 256, 1, 257, 512, 0, 512)
87t.Draw("ch:fePeakTDC>>ch_tdcHist", "", "colz")
88c.SetLogz()
89c.SaveAs("fePeakTDC_vs_ch.pdf")
90c.Clear()
91#
92adcHist = ROOT.TH1D("adcHist", "ADC counts;ADC", 1000, 0, 1000)
93adcHist.SetLineWidth(2)
94adcHist.SetLineColor(4)
95t.Draw("fePeakHt>>adcHist", calChannel)
96adcHist.SetTitle("ADC counts in the calibration channel")
97c.SaveAs("ADC_distribution_peak0_cal.pdf")
98c.Clear()
99adcHist.Reset()
100
101adcHist.SetLineWidth(2)
102adcHist.SetLineColor(4)
103t.Draw("fePeakHt>>adcHist", signalChannel)
104adcHist.SetTitle("ADC counts in the signal channels")
105c.SaveAs("ADC_distribution_peak0_sig.pdf")
106c.Clear()
107
108tdcHist = ROOT.TH1D("tdcHist", "tdcHist;TDC;waveforms", 256, 1, 257)
109tdcHist.SetLineWidth(2)
110tdcHist.SetLineColor(4)
111t.Draw("fePeakTDC>>tdcHist", calChannel)
112tdcHist.SetTitle("TDC distribution calibration channel")
113c.SaveAs("TDC_distribution_peak0_cal.pdf")
114c.Clear()
115tdcHist.Reset()
116
117tdcHist.SetLineWidth(2)
118tdcHist.SetLineColor(4)
119t.Draw("fePeakTDC>>tdcHist", signalChannel)
120tdcHist.SetTitle("TDC distribution signal channels")
121c.SaveAs("TDC_distribution_peak0_signal.pdf")
122c.Clear()
123tdcHist.Reset()
124
125tdcHist.SetLineWidth(2)
126tdcHist.SetLineColor(4)
127t.Draw("fePeak1TDC>>tdcHist", calChannel + "&& nTOPRawDigits > 2")
128tdcHist.SetTitle("TDC distribution 2nd peak calibration channel")
129c.Update()
130c.SaveAs("fePeak1TDC_calChannel.pdf")
131c.BuildLegend()
132c.Clear()
133tdcHist.Reset()
134
135tdcHist.SetLineWidth(2)
136tdcHist.SetLineColor(4)
137t.Draw("fePeak1TDC>>tdcHist", signalChannel + "&& nTOPRawDigits > 1")
138tdcHist.SetTitle("TDC distribution 2nd peak signal channel")
139c.Update()
140c.SaveAs("fePeak1TDC_signalChannel.pdf")
141c.BuildLegend()
142c.Clear()
143tdcHist.Reset()
144
145hists = []
146c.Clear()
147c.Divide(3, 3)
148c.cd(9)
149h0 = ROOT.TH1D("feh0", "all Channels", 1000, 50, 1050)
150t.Draw("fePeakHt>>feh0")
151for iCanv in range(1, 9):
152 c.cd(iCanv)
153 h = ROOT.TH1D(f"feh{int(iCanv)}", f"channel {int(iCanv)};ADC;waveforms", 1000, 50, 1050)
154 t.Draw(f"fePeakHt>>feh{int(iCanv)}", f"ch % 8 == {int(iCanv - 1)}")
155 hists.append(h)
156c.SaveAs("fePeakHt_byChannel.pdf")
157
158hists = []
159c.Clear()
160c.Divide(3, 3)
161c.cd(5)
162h0 = ROOT.TH1D("fe_asic0", "all ASICs", 1000, 50, 1050)
163t.Draw("fePeakHt>>fe_asic0")
164for iASIC, iCanv in enumerate([1, 3, 7, 9]):
165 c.cd(iCanv)
166 h = ROOT.TH1D(f"fe_asic{int(iCanv)}", f"ASIC {int(iASIC)};ADC;waveforms", 1000, 50, 1050)
167 t.Draw(f"fePeakHt>>fe_asic{int(iCanv)}", f"(ch/8) % 4 == {int(iASIC)}")
168 hists.append(h)
169c.SaveAs("fePeakHt_byASIC.pdf")
170
171hists = []
172c.Clear()
173c.Divide(3, 3)
174c.cd(5)
175h0 = ROOT.TH1D("fe_carrier0", "all Carriers", 1000, 50, 1050)
176t.Draw("fePeakHt>>fe_carrier0")
177for iCarrier, iCanv in enumerate([1, 3, 7, 9]):
178 c.cd(iCanv)
179 h = ROOT.TH1D(f"fe_carrier{int(iCanv)}", f"Carrier {int(iCarrier)};ADC;waveforms", 1000, 50, 1050)
180 t.Draw(f"fePeakHt>>fe_carrier{int(iCanv)}", f"(ch/8/4) % 4 == {int(iCarrier)}")
181 hists.append(h)
182c.SaveAs("fePeakHt_byCarrier.pdf")
183
184hists = []
185c.Clear()
186c.Divide(3, 3)
187c.cd(5)
188h0 = ROOT.TH1D("fe_boardstack0", "all board stacks", 1000, 50, 1050)
189t.Draw("fePeakHt>>fe_boardstack0")
190for iBS, iCanv in enumerate([1, 3, 7, 9]):
191 c.cd(iCanv)
192 h = ROOT.TH1D(f"fe_boardstack{int(iCanv)}", f"board stack {int(iBS)};ADC;waveforms", 1000, 50, 1050)
193 t.Draw(f"fePeakHt>>fe_boardstack{int(iCanv)}", f"(ch/8/4/4) % 4 == {int(iBS)}")
194 hists.append(h)
195c.SaveAs("fePeakHt_byBoardStack.pdf")
196
197# Count the number of failure modes
198total = t.GetEntries()
199
200print(f"Fraction with width > 30: {1.0 * t.Draw('fePeakWd', 'fePeakWd>30', 'goff') / total:.3f}")
201print(f"Fraction with peaks at window borders: (average occupancy / bin = {1.0 / 256:.3f})")
202print(f"\ttdc < 2 : {1.0 * t.Draw('fePeakWd', 'fePeakTDC<2', 'goff') / total:.3f}")
203print(f"\t63 < tdc < 66 : {1.0 * t.Draw('fePeakWd', 'fePeakTDC>63 && fePeakTDC<66', 'goff') / total:.3f}")
204print(f"\t127 < tdc < 130: {1.0 * t.Draw('fePeakWd', 'fePeakTDC>127 && fePeakTDC<130', 'goff') / total:.3f}")
205print(f"\t191 < tdc < 194: {1.0 * t.Draw('fePeakWd', 'fePeakTDC>191 && fePeakTDC<194', 'goff') / total:.3f}")
206print(f"\ttdc > 255 : {1.0 * t.Draw('fePeakWd', 'fePeakTDC>255', 'goff') / total:.3f}")