Exemplo n.º 1
0
    def get(self, par=1, redo=False):
        def f():
            return FitRes(
                self.draw_peaks(show=False, prnt=False,
                                redo=redo).GetListOfFunctions()[1])

        return fit2u(do_pickle(self.make_simple_pickle_path('PeakVals'),
                               f,
                               redo=redo),
                     par=par)
Exemplo n.º 2
0
 def get_pedestal(self, par=1, beam_on=True, redo=False):
     pickle_path = self.make_simple_pickle_path('Pedestal',
                                                str(int(beam_on)))
     fit = do_pickle(pickle_path,
                     partial(self.draw_pedestal_fit,
                             show=False,
                             prnt=False,
                             redo=redo,
                             beam_on=beam_on),
                     redo=redo)
     return fit[par]
Exemplo n.º 3
0
    def get_tc_correction(self, redo=False, show=False):
        def f():
            p = self.draw_cft_vs_triggercell(show=show)
            fit = TF1('f0', '[0]*TMath::Sin([1]*(x - [2])) + [3]', -50, 1024)
            fit.SetParameters(1, 1, 100, mean(get_hist_vec(p, err=False)))
            fit.FixParameter(1, 1 / 1024. * 2 * pi)
            p.Fit(fit, 'q{}'.format('' if show else 0))
            return '({0} * TMath::Sin({1} * (trigger_cell - {2})))'.format(
                *[fit.GetParameter(i) for i in range(3)])

        return do_pickle(self.make_simple_pickle_path('CFTTC'),
                         f,
                         redo=redo or show)
Exemplo n.º 4
0
    def get_fine_correction(self, cut=None, redo=False):
        def f():
            fit = self.draw_peaks_tc(show=False,
                                     prnt=False,
                                     cut=self.get_raw_cut(cut),
                                     redo=redo).GetListOfFunctions()[1]
            good_pars = fit.GetChisquare() / fit.GetNDF() < 100 and abs(
                fit.GetParameter(0)
            ) < 10  # require decent chi2 and a meaningful scaling of the sin(x)
            return '({0} * TMath::Sin({1} * (trigger_cell - {2})))'.format(
                *get_buf(fit.GetParameters(), 3)) if good_pars else '0'

        return do_pickle(self.make_simple_pickle_path('FineCorr',
                                                      self.Cut(cut).GetName()),
                         f,
                         redo=redo)
Exemplo n.º 5
0
    def draw_peaks_tc(self,
                      bin_size=4,
                      corr=True,
                      fine_corr=False,
                      fit=True,
                      cut=None,
                      show=True,
                      prnt=True,
                      save=True,
                      redo=False):
        def f():
            x, y = self.get_tree_vec(
                var=['trigger_cell',
                     self.get_peak_var(corr, fine_corr)],
                cut=self.TimingCut(cut))
            return self.Draw.profile(x,
                                     y,
                                     make_bins(0, self.Run.NSamples, bin_size),
                                     '{}Peak Position vs Trigger Cell'.format(
                                         'Corrected ' if corr else ''),
                                     show=False)

        h = do_pickle(self.make_simple_pickle_path(
            'PeakTC', '{}{}{}'.format(
                self.TimingCut(cut).GetName(), bin_size, int(fine_corr))),
                      f,
                      redo=redo)
        self.fit_sin(h, fit)
        format_histo(h,
                     x_tit='Trigger Cell',
                     y_tit='Signal Peak Time [ns]',
                     y_off=1.8,
                     stats=fit)
        self.Draw(h,
                  title='OriPeakPosVsTriggerCell',
                  show=show,
                  lm=.13,
                  prnt=prnt,
                  save=save,
                  stats=set_statbox(fit=True, center_x=True))
        return h
Exemplo n.º 6
0
    def draw_all_average(self,
                         corr=True,
                         n=100000,
                         cut=None,
                         x_range=None,
                         y_range=None,
                         show=True,
                         show_noise=False,
                         redo=False,
                         draw_opt='ap'):
        def f():
            t, v = self.get_times(corr, cut, n), self.get_values(cut, n=n)
            return Draw.make_graph_from_profile(
                self.Draw.profile(t,
                                  v,
                                  self.get_binning(),
                                  'Averaged Waveform',
                                  show=False))

        g = do_pickle(self.make_simple_pickle_path(
            'AWF', f'{count_nonzero(self.get_cut(cut))}'),
                      f,
                      redo=redo)
        x_range = ax_range(self.Ana.get_signal_range(), fl=.5,
                           fh=1) if x_range is None else x_range
        format_histo(g,
                     x_tit='Time [ns]',
                     y_tit='Pulse Height [mV]',
                     y_off=1.2,
                     lw=2,
                     stats=0,
                     markersize=.4,
                     x_range=x_range,
                     y_range=y_range)
        self.Draw(g, show=show, draw_opt=draw_opt, gridy=True)
        if show_noise:
            self.__draw_noise(pol=False)
        return g
Exemplo n.º 7
0
    def compare_signal_vs_peak_height(self,
                                      i0=0,
                                      i1=-1,
                                      ym=.055,
                                      cft=False,
                                      show=True,
                                      redo=False):
        """draws the pulse height ratio of two runs vs the peak time. """
        def f():
            func = self.Analysis.draw_signal_vs_cft if cft else self.Analysis.draw_ph_peaktime
            (x0, y0), y1 = get_hist_vecs(func(self.Analyses[i0],
                                              show=False)), get_hist_vec(
                                                  func(self.Analyses[i1],
                                                       show=False))
            return x0, y1 / where(y0 == 0, 1e10,
                                  y0)  # make ratio of zero entries 0

        x, y = do_pickle(self.make_simple_pickle_path('SigPeakRatio',
                                                      int(cft),
                                                      sub_dir='Peaks',
                                                      dut='{}{}'.format(
                                                          i0, i1)),
                         f,
                         redo=redo)
        flux0, flux1 = [
            flux2str(self.Analyses[i].get_flux().n) for i in [i0, i1]
        ]
        self.Draw.graph(x,
                        y,
                        title='Signal Ratio of {} and {}'.format(flux0, flux1),
                        x_tit='Signal Peak Time [ns]',
                        y_tit='Signal Ratio',
                        y_range=array([-ym, ym]) + 1,
                        gridy=True,
                        show=show)
        return mean_sigma(y[y > .1])[0]
Exemplo n.º 8
0
 def get_average_rise_time(self, p=.1, redo=False):
     return do_pickle(self.make_simple_pickle_path('RT', int(p * 100)),
                      self.draw_average_rise_time,
                      redo=redo,
                      p=p,
                      show=False)