25 print(
'usage: basf2', sys.argv[0],
'<path_to_files>')
26 print(
' <path_to_files> can include wildcards (prepended by backslash), example: tbc/\\*/\\*.root')
29files = glob.glob(sys.argv[1])
31 print(
'No root files found in ' + sys.argv[1])
37 Returns the number of samples with low occupancy.
38 :param h: histogram of occupancy (number of calpulses per sample)
42 cut = h.Integral() / h.GetNbinsX() * 0.8
45 for i
in range(h.GetNbinsX()):
46 y = h.GetBinContent(i + 1)
52 for i
in range(h.GetNbinsX()):
53 y = h.GetBinContent(i + 1)
59def print_table(title, table):
62 :param title: table title
68 table_rows = [['bs' + str(b) +
' '] + [str(table[s][b])
for s
in range(16)]
for b
in range(4)]
69 table_rows.insert(0, [
''] + [
's' + str(s)
for s
in range(1, 17)])
70 pretty_print_table(table_rows, [4
for i
in range(17)])
75numcal = [[0
for bs
in range(4)]
for slot
in range(16)]
76numlow = [[0
for bs
in range(4)]
for slot
in range(16)]
77for fileName
in sorted(files):
79 slot_bs = fileName.split(
'/')[-1].split(
'-')[0].split(
'tbcSlot')[1].split(
'_')
80 slot = int(slot_bs[0])
82 print(fileName,
'slot =', slot,
'bs =', bs)
84 print(fileName,
'--> file ignored')
86 tfile = TFile.Open(fileName)
88 print(
'--> Error: cannot open this file')
90 success = tfile.Get(
"success")
92 print(
'--> Error: histogram named success not found')
95 for chan
in range(success.GetNbinsX()):
96 if success.GetBinContent(chan + 1) == 0:
100 numcal[slot-1][bs] += 1
101 hname =
'sampleOccup_ch' + str(chan)
104 print(
'--> Error: sample occupancy histogram for channel ' + str(chan) +
' not found')
108 print(
' ' + h.GetTitle(),
'is low in', 2 * n,
'/ 256 samples')
110 numlow[slot-1][bs] += 1
111 print(
'-->', nc,
'channels calibrated')
113print_table(
'Number of successfully calibrated channels:', numcal)
114print_table(
'Number of channels with deeps in sample occupancy:', numlow)
116print(
'\nCalibration summary: ')
117print(
' - successfully calibrated channels:', ncal,
'/', 512 * 16)
118print(
' - constants maybe not reliable for', nlow,
'/', ncal,
'channels.',
119 'If this fraction is large, check calpulse selection window in runTBC.py.')