63def EvoMon(old_calib, new_calib, mapping, old_iov, new_iov):
64
65 save = 1
66 log_info = {}
67
68 slopes = []
69 information = {"Total_mods": 0,
70 "Total_FE" : 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}
76 }
77
78
79 for mod in range(2048):
80
81 mod_str = mapping[str(mod)]
82 mod_layer = ""
83 print(
"%-18s - %4i" % (mod_str, mod), end=
'\r')
84 plot_range = np.array([0,75000])
85
86 if str(mod) not in new_calib:
87 continue
88
89 if mod_str.startswith("L0"):
90 mod_layer = "Blayer"
91 elif mod_str.startswith("L1"):
92 mod_layer = "L1"
93 elif mod_str.startswith("L2"):
94 mod_layer = "L2"
95 elif mod_str.startswith("D"):
96 mod_layer = "Disk"
97 else:
98 mod_layer = "IBL"
99 if mod_str.startswith("LI_S15"):
100 continue
101
102 information["Total_mods"] += 1
103 fig = Figure(figsize=(13,10))
104 axs = fig.add_subplot(1,1,1)
105 status = "_OK"
106
107 for fe in range(len(new_calib[str(mod)])):
108
109 information["Total_FE"] += 1
110 newQ = []
111 oldQ = []
112 boolTOT = False
113 realQ = []
114
115 if mod_layer != "IBL":
116 newCal_normal_pix = new_calib[str(mod)][fe][12:15]
117 oldCal_normal_pix = old_calib[str(mod)][fe][12:15]
118 boolTOT, realQ = failsCheckTuning(newCal_normal_pix, mod_layer)
119
120
121 newQ = arrayCharge(newCal_normal_pix,mod_layer)
122 oldQ = arrayCharge(oldCal_normal_pix,mod_layer)
123 else:
124
125 newQ = new_calib[str(mod)][fe][4:20]
126 oldQ = old_calib[str(mod)][fe][4:20]
127
128 plot_range = np.array([0,35000])
129 boolTOT, realQ = failsCheckTuning(newQ, mod_layer)
130
131 m,b = np.polyfit(newQ ,oldQ,1)
132 slopes.append(m)
133 boolFit = (abs((1-m)/m)*100) > MaxThreshold
134
135 if boolFit or boolTOT:
136 key = "%-18s - %i" % (mod_str, mod)
137 if boolFit:
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)
140 else:
141 log_info[key] += "\tFE%02i ---> slope: %5.2f - dev: %5.1f%%\n" % (fe,m, abs((1-m)/m)*100)
142 if boolTOT:
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])
145 else:
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])
147
148 information[mod_layer]["bad"] += 1
149 status = "_BAD"
150 if boolTOT:
151
152 status += "_Q"
153 if boolFit:
154
155 status += "_Slope"
156 else:
157 information[mod_layer]["ok"] += 1
158
159
160 if save:
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)
165
166 if save:
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)
172
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")
179 else:
180 axs.plot([20000,20000],plot_range,"k:",lw=1)
181 axs.text(21000,1000,"TOT@30 = 20 ke")
182
183 storage = "plots/" + mod_layer + "/"
184
185 canvas = FigureCanvasAgg(fig)
186 canvas.print_figure(storage+"Id"+str(mod)+ "_" +mod_str+status+".png", dpi=150)
187
189 fig = Figure(figsize=(13,10))
190 fig.suptitle("Fit slopes for all modules")
191 axs = fig.add_subplot(1,1,1)
192 axs.hist(np.clip(slopes, -1, 2), bins=100)
193 axs.set_xlabel("Fit slope")
194 axs.set_ylabel("Counts")
195
196 stats = (f'$\\mu$ = {np.mean(np.clip(slopes, -1, 2)):.3f}\n'
197 f'$\\sigma$ = {np.std(np.clip(slopes, -1, 2)):.3f}')
198 bbox = dict(boxstyle='round', fc='blanchedalmond', ec='orange', alpha=0.5)
199 axs.text(0.95, 0.07, stats, fontsize=9, bbox=bbox, transform=axs.transAxes)
200
201 FigureCanvasAgg(fig).print_figure("plots/FitSlopes.png", dpi=150)
202
203 return information, log_info
204
205
void print(char *figname, TCanvas *c1)