10Validation of KLM channel status calibration.
17from prompt
import ValidationSettings
19import matplotlib.pyplot
as plt
22settings = ValidationSettings(name=
'KLM channel status',
24 download_files=[
'stdout'],
31 parser = argparse.ArgumentParser()
32 parser.add_argument(
'job_path')
33 parser.add_argument(
'input_data_path')
34 parser.add_argument(
'requested_iov')
35 parser.add_argument(
'expert_config')
36 return parser.parse_args()
39def plot(run_num_arry, eklm_dead_arry, eklm_hot_arry, bklm_dead_arry, bklm_hot_arry,
40 fname='plots.pdf', drawLims=False):
41 fig, axs = plt.subplots(2, 2, sharex=
True)
44 axs[0].
plot(run_num_arry, eklm_dead_arry,
'.', color=
'C0')
45 axs[0].set_ylabel(
"EKLM dead channels")
46 axs[0].set_xlabel(
"Run numbers")
48 axs[1].
plot(run_num_arry, eklm_hot_arry,
'.', color=
'C1')
49 axs[1].set_ylabel(
"EKLM hot channels")
50 axs[1].set_xlabel(
"Run numbers")
52 axs[2].
plot(run_num_arry, bklm_dead_arry,
'.', color=
'C0')
53 axs[2].set_ylabel(
"BKLM dead channels")
54 axs[2].set_xlabel(
"Run numbers")
56 axs[3].
plot(run_num_arry, bklm_hot_arry,
'.', color=
'C1')
57 axs[3].set_ylabel(
"BKLM hot channels")
58 axs[3].set_xlabel(
"Run numbers")
61 axs[0].axhline(300, ls=
'--', color=
'r')
62 axs[1].axhline(8, ls=
'--', color=
'r')
63 axs[2].axhline(300, ls=
'--', color=
'r')
64 axs[3].axhline(8, ls=
'--', color=
'r')
69if __name__ ==
'__main__':
71 job_path = args.job_path
72 input_data_path = args.input_data_path
73 requested_iov = args.requested_iov
74 expert_config = args.expert_config
76 database_file = f
'{job_path}/KLMChannelStatus/outputdb/database.txt'
89 iovfile = open(database_file,
'r')
93 iov = lst[2].split(
',')
94 ini.append(int(iov[1]))
95 fin.append(int(iov[3]))
98 rev_num = numpy.zeros(1, dtype=str)
99 run_num = numpy.zeros(1, dtype=int)
101 eklm_normal = numpy.zeros(1, dtype=int)
102 eklm_dead = numpy.zeros(1, dtype=int)
103 eklm_hot = numpy.zeros(1, dtype=int)
105 bklm_normal = numpy.zeros(1, dtype=int)
106 bklm_dead = numpy.zeros(1, dtype=int)
107 bklm_hot = numpy.zeros(1, dtype=int)
109 tree = ROOT.TTree(
'tree',
'')
110 tree.Branch(
'rev_num', rev_num,
'rev_num/S')
111 tree.Branch(
'run_num', run_num,
'run_num/I')
112 tree.Branch(
'eklm_normal', eklm_normal,
'eklm_normal/I')
113 tree.Branch(
'eklm_dead', eklm_dead,
'eklm_dead/I')
114 tree.Branch(
'eklm_hot', eklm_hot,
'eklm_hot/I')
115 tree.Branch(
'bklm_normal', bklm_normal,
'bklm_normal/I')
116 tree.Branch(
'bklm_dead', bklm_dead,
'bklm_dead/I')
117 tree.Branch(
'bklm_hot', bklm_hot,
'bklm_hot/I')
126 for x
in range(0, len(rev)):
127 filename = f
'{job_path}/KLMChannelStatus/outputdb/dbstore_KLMChannelStatus_rev_'+str(rev[x])+
'.root'
128 channel_status_file = ROOT.TFile(filename)
129 channel_status_obj = channel_status_file.Get(
"KLMChannelStatus")
136 for i
in range(1, 65536):
137 status = channel_status_obj.getChannelStatus(i)
143 elif (status != 1
and status != 0):
154 channel_status_file.Close()
168 run_num_arry.append(run_num[0])
169 eklm_dead_arry.append(eklm_dead[0])
170 eklm_hot_arry.append(eklm_hot[0])
171 bklm_dead_arry.append(bklm_dead[0])
172 bklm_hot_arry.append(bklm_hot[0])
174 outfile = ROOT.TFile('validation.root',
'recreate')
178 plot(run_num_arry, eklm_dead_arry, eklm_hot_arry, bklm_dead_arry, bklm_hot_arry)