62 def EvoMon(old_calib, new_calib, mapping, old_iov, new_iov):
66 plot_range = np.array([0,75000])
69 information = {
"Total_mods": 0,
71 "IBL" :{
"bad":0,
"ok":0},
72 "Blayer":{
"bad":0,
"ok":0},
73 "L1" :{
"bad":0,
"ok":0},
74 "L2" :{
"bad":0,
"ok":0},
75 "Disk" :{
"bad":0,
"ok":0}
79 for mod
in range(2048):
81 mod_str = mapping[
str(mod)]
83 print(
"%-18s - %4i" % (mod_str, mod), end=
'\r')
86 if str(mod)
not in new_calib:
89 if mod_str.startswith(
"L0"):
91 elif mod_str.startswith(
"L1"):
93 elif mod_str.startswith(
"L2"):
95 elif mod_str.startswith(
"D"):
99 if mod_str.startswith(
"LI_S15"):
102 information[
"Total_mods"] += 1
103 fig = Figure(figsize=(13,10))
104 axs = fig.add_subplot(1,1,1)
109 for fe
in range(len(new_calib[
str(mod)])):
110 information[
"Total_FE"] += 1
116 if mod_layer !=
"IBL":
117 newCal_normal_pix = new_calib[
str(mod)][fe][12:15]
118 oldCal_normal_pix = old_calib[
str(mod)][fe][12:15]
126 newQ = new_calib[
str(mod)][fe][4:20]
127 oldQ = old_calib[
str(mod)][fe][4:20]
128 plot_range = np.array([0,35000])
131 m,b = np.polyfit(newQ ,oldQ,1)
133 boolFit = (abs((1-m)/m)*100) > 5
135 if boolFit
or boolTOT:
136 key =
"%-18s - %i" % (mod_str, mod)
138 if key
not in log_info:
139 log_info[key] =
"\tFE%02i ---> slope: %5.2f - dev: %5.1f%%\n" % (fe,m, abs((1-m)/m)*100)
141 log_info[key] +=
"\tFE%02i ---> slope: %5.2f - dev: %5.1f%%\n" % (fe,m, abs((1-m)/m)*100)
143 if key
not in log_info:
144 log_info[key] =
"\tFE%02i ---> Charge= %5ie (dev %6.2f%%) out of error bars. Expected: %5ie\n" % (fe, realQ[0], realQ[1], realQ[2])
146 log_info[key] +=
"\tFE%02i ---> Charge= %5ie (dev %6.2f%%) out of error bars. Expected: %5ie\n" % (fe, realQ[0], realQ[1], realQ[2])
148 information[mod_layer][
"bad"] += 1
157 information[mod_layer][
"ok"] += 1
161 lstyle =
"dotted" if fe < 8
else "solid"
162 axs.plot(newQ ,oldQ, marker=
'o', linestyle=lstyle, label = (
"FE%02d" % (fe)))
163 axs.set_xlim(plot_range)
164 axs.set_ylim(plot_range)
167 fig.suptitle(
"Hash ID %d - %s" % (mod, mod_str))
168 axs.legend(loc=
'upper left', ncol=4)
169 axs.set_xlabel(new_iov+
" - Charge[e]")
170 axs.set_ylabel(old_iov+
" - Charge[e]")
171 axs.plot(plot_range,plot_range,
"k:",lw=1)
173 if mod_layer ==
'IBL':
174 axs.plot([16000,16000],plot_range,
"k:",lw=1)
175 axs.text(17000,1000,
"TOT@10 = 16 ke")
176 elif mod_layer ==
'Blayer':
177 axs.plot([20000,20000],plot_range,
"k:",lw=1)
178 axs.text(21000,1000,
"TOT@18 = 20 ke")
180 axs.plot([20000,20000],plot_range,
"k:",lw=1)
181 axs.text(21000,1000,
"TOT@30 = 20 ke")
183 storage =
"plots/" + mod_layer +
"/"
185 canvas = FigureCanvasAgg(fig)
186 canvas.print_figure(storage+
"Id"+
str(mod)+
"_" +mod_str+status+
".png", dpi=150)
189 fig = Figure(figsize=(13,10))
190 fig.suptitle(
"All modules")
191 axs = fig.add_subplot(1,1,1)
192 axs.hist(np.clip(slopes, -1, 1.49), bins=100)
193 axs.set_xlabel(
"Fit slope")
194 axs.set_ylabel(
"Counts")
195 FigureCanvasAgg(fig).print_figure(
"plots/slopes.png", dpi=150)
198 print(
"-"*20+
" SUMMARY "+
"-"*20 )
199 print(
"%-20s: %5i" % (
"Total mods in det.", information[
"Total_mods"]))
200 print(
"%-20s: %5i" % (
"Total FE in det." , information[
"Total_FE"] ))
201 print(
"%-20s: %5i" % (
"Total FE IBL" , information[
"IBL"][
"ok"] +information[
"IBL"][
"bad"] ))
202 print(
"%-20s: %5i" % (
"Total FE Blayer" , information[
"Blayer"][
"ok"]+information[
"Blayer"][
"bad"]))
203 print(
"%-20s: %5i" % (
"Total FE L1" , information[
"L1"][
"ok"] +information[
"L1"][
"bad"] ))
204 print(
"%-20s: %5i" % (
"Total FE L2" , information[
"L2"][
"ok"] +information[
"L2"][
"bad"] ))
205 print(
"%-20s: %5i\n" % (
"Total FE Disk" , information[
"Disk"][
"ok"] +information[
"Disk"][
"bad"] ))
208 print(
'FrontEnds deviating more than 5% of TOT vs charge gradient between new and previous calibration:')
209 print(
"%-11s: %-4i (%6.2f%%)" % (
"IBL FEs" , information[
"IBL"][
"bad"] ,
percent(information[
"IBL"][
"bad"] ,information[
"IBL"][
"ok"]) ))
210 print(
"%-11s: %-4i (%6.2f%%)" % (
"Blayer FEs", information[
"Blayer"][
"bad"],
percent(information[
"Blayer"][
"bad"],information[
"Blayer"][
"ok"])))
211 print(
"%-11s: %-4i (%6.2f%%)" % (
"L1 FEs" , information[
"L1"][
"bad"] ,
percent(information[
"L1"][
"bad"] ,information[
"L1"][
"ok"]) ))
212 print(
"%-11s: %-4i (%6.2f%%)" % (
"L2 FEs" , information[
"L2"][
"bad"] ,
percent(information[
"L2"][
"bad"] ,information[
"L2"][
"ok"]) ))
213 print(
"%-11s: %-4i (%6.2f%%)\n" % (
"Disk FEs" , information[
"Disk"][
"bad"] ,
percent(information[
"Disk"][
"bad"] ,information[
"Disk"][
"ok"]) ))
216 print(
"+"*20+
" List of bad FE "+
"+"*20 )
217 print(
"Expected TOT vs. charge for the different layers:")
218 print(
"%-10s: TOT@%2i = %2ike" % (
"IBL" , 10, 16))
219 print(
"%-10s: TOT@%2i = %2ike" % (
"Blayer" , 18, 20))
220 print(
"%-10s: TOT@%2i = %2ike\n" % (
"L1/L2/Disk", 30, 20))
221 for key, val
in log_info.items():