def draw_mean_pedestals(self,
                         sigma=False,
                         irr=False,
                         redo=False,
                         show=True):
     y = array([
         mean_sigma(tc_values[1 if sigma else 0])[0]
         for tc_values in self.get_pedestals(redo)
     ])
     x = self.get_irradiations(string=False) / 1e14 if irr else arange(
         y.size)
     g = Draw.make_tgrapherrors(
         x,
         y,
         title='Mean {}'.format('Noise' if sigma else 'Pedestals'),
         x_tit='Irradation [10^{14} n/cm^{2}]' if irr else 'Run Plan',
         y_tit='Pulse Height [mV]')
     format_histo(g,
                  y_off=1.2,
                  x_range=ax_range(x, fl=.1, fh=.1) if irr else ax_range(
                      0, y.size - 1, .3, .3),
                  x_off=2.5)
     self.set_bin_labels(g) if not irr else do_nothing()
     self.Draw(g,
               self.get_savename('PedestalMeans'),
               show,
               draw_opt='ap',
               bm=.2,
               w=1.5,
               h=.75,
               gridy=True)
 def show_pulse_heights(self):
     rows = [[sel.TCString, sel.RunPlan] + [
         '{:2.2f}'.format(i)
         for i in mean_sigma([dic['ph'] for dic in phs.values()])
     ] for phs, sel in zip(self.get_pulse_heights(), self.Info)]
     print_table(
         rows, header=['Test Campaign', 'Run Plan', 'PH [mv]', 'STD [mV]'])
Beispiel #3
0
 def x(self, chi2=None, slope=None, _redo=False):
     self.Cut.set_chi2(chi2)
     self.Cut.set_slope(slope)
     return usqrt(
         max(ufloat(1 / 12, 0),
             mean_sigma(self.Residuals.dx())[1]**2) -
         1 / 12) * self.Plane.PX * 1e3
Beispiel #4
0
 def draw_signals(self, step=.1, max_sig=10, rel=True):
     s = arange(0, max_sig + step, step)
     data = [self.get_bucket(), self.get_signal()]
     res = array([
         mean_sigma(
             concatenate([data[0][0][invert(cb)],
                          data[1][0][invert(cs)]]))[0]
         for cb, cs in [self.get_bucket_cut(data, i, i) for i in s]
     ])
     real = mean(data[1][0])
     no_cut = mean(concatenate([data[0][0], data[1][0]
                                ])) / (real if rel else 1)
     res /= real if rel else 1
     g = self.Draw.graph(
         s,
         res,
         x_tit='N Sigma',
         y_tit=
         f'{"Relative " if rel else ""}Pulse Height {"" if rel else "[mV]"}',
         draw_opt='ae3',
         lw=2,
         fill_color=2,
         y_range=ax_range(no_cut,
                          max(res).n, .1, .2))
     lc = Draw.horizontal_line(no_cut, w=2)
     lr = Draw.horizontal_line(1 if rel else real, w=2, color=3)
     self.Draw.legend([g, lr, lc], ['w/ cut', 'real signal', 'w/o cut'],
                      ['f', 'l', 'l'])
 def get_pulser_stability(self):
     """ returns: relative standard deviation of the pulser """
     d = [
         s / m * 100 for m, s in
         [mean_sigma(v) for v in self.get_pulser_pulse_heights()]
     ]
     for i, v in enumerate(d):
         print(f'Pulser stability for {self.Info[i]}: {v:.3f}')
     return d
 def draw_scaled_distribution(self, excluded=None):
     values = concatenate(([
         vals / mean_sigma(vals)[0]
         for i, vals in enumerate(self.get_pulse_heights())
         if i not in make_list(excluded)
     ]))
     self.Draw.distribution(values, [40, .9, 1.1],
                            'Scaled Pulse Height Distribution',
                            x_tit='Scaled Pulse Height')
     return values
 def draw_pulser_pulse_heights(self, avrg=False, scaled=True, ym=.01):
     data = zip(self.get_fluxes(avrg), self.get_pulser_pulse_heights(avrg))
     g = [
         self.Draw.graph(x,
                         y / (mean_sigma(y)[0].n if scaled else 1),
                         y_tit='Pulser Pulse Height [mV]',
                         show=False) for x, y in data
     ]
     mg = self.Draw.multigraph(
         g,
         'Pulser Pulse Heights',
         [f'{i.PulserType}al @ {make_bias_str(i.Bias)}' for i in self.Info],
         **self.Ana.get_x_args(draw=True),
         wleg=.3)
     format_histo(mg, **self.Ana.get_x_args(), y_range=1 + array([-ym, ym]))
 def draw_means(self, **dkw):
     y = array([
         ufloat(*mean_sigma(ph_list, err=False))
         for ph_list in self.get_pulse_heights()
     ])
     g = self.Draw.graph(arange(y.size),
                         y,
                         title='Pulse Height Evolution',
                         x_tit='Run Plan',
                         y_tit='Mean Pulse Height [mV]',
                         show=False,
                         x_range=ax_range(0, y.size - 1, .3, .3))
     self.set_bin_labels(g, rp=False)
     self.Draw(g,
               file_name=self.get_savename('Means'),
               **prep_kw(dkw, **Draw.mode(2), gridy=True, x_off=2.5))
 def print_mean_rd(self, avrg=True, tex=False):
     s, r = [
         mean_sigma(i)[0] * 100 for i in self.get_rate_dependencies(avrg).T
     ]
     if tex:
         print(
             latex.table(False, [
                 [self.DUTName] +
                 latex.si(self.get_bias_voltages()[0], fmt='.0f', unt='V') +
                 latex.si(s, r, unt='percent')
             ]))
     else:
         info(
             f'Mean rel STD:    {si(s, unit="percent") if latex else f"{s:.1f} %"}'
         )
         info(
             f'Mean rel Spread: {si(r, unit="percent") if latex else f"{r:.1f} %"}'
         )
 def draw_sigmas(self, y_range=None, show=True):
     y = array(
         [mean_sigma(ph_list)[1] for ph_list in self.get_pulse_heights()])
     g = Draw.make_tgrapherrors(arange(y.size),
                                y=y,
                                title='Pulse Height STD Evolution',
                                x_tit='Run Plan',
                                y_tit='Pulse Height Standard Deviation [%]')
     format_histo(g,
                  y_off=1.2,
                  x_range=ax_range(0, y.size - 1, .3, .3),
                  x_off=2.5,
                  y_range=y_range)
     self.set_bin_labels(g)
     self.Draw(g,
               self.get_savename('Sigmas'),
               show,
               draw_opt='ap',
               bm=.2,
               w=1.5,
               h=.75,
               gridy=True)
 def get_noise_spread(self, redo=False):
     noise = array(self.get_pedestals(redo), object)[:, 1]
     return mean_sigma(
         [v - mean_sigma(lst)[0] for lst in noise for v in lst])[1]
Beispiel #12
0
 def y(self, chi2=None, slope=None, _redo=False):
     self.Cut.set_chi2(chi2)
     self.Cut.set_slope(slope)
     return usqrt(mean_sigma(self.Residuals.dy())[1]**2 -
                  1 / 12) * self.Plane.PY * 1e3