Esempio n. 1
0
 def draw_fit_chi2s(self, e=18, g=None, fit=False, show_cut=False, **dkw):
     h = [
         self.Draw.distribution(x,
                                normalise=True,
                                x0=0,
                                x_tit='#chi^{2} / DOF',
                                show=False,
                                file_name=f'chi_{["x", "y"][i]}')
         for i, x in enumerate(self.get_chi2s(e, g))
     ]
     s = self.Draw.stack(h, 'FitChi2', None, **dkw)
     self.Draw.make_tf1(
         'fd',
         lambda x: TMath.GammaDist(x, 1, 0, 2) * h[1].GetBinWidth(1),
         0,
         20,
         npx=500).Draw('same') if fit else do_nothing()
     b = self.Draw.box(self.get_chi2_cut(e=e, g=g),
                       -1,
                       100,
                       1,
                       line_color=2,
                       width=2,
                       fillcolor=2,
                       style=7,
                       opacity=.2) if show_cut else do_nothing()
     self.Draw.legend(h + [b], ['x', 'y', 'cut'],
                      styles=['l', 'l', 'lf'],
                      margin=.45,
                      w=.2)
     format_histo(s, **prep_kw(dkw, lw=2))
     self.Draw.save_plots('FitChi2')
Esempio n. 2
0
def get_chi2(k=2, s=1):
    return Draw.make_tf1('fd',
                         lambda x: TMath.GammaDist(x, k / 2, 0, 2) * s,
                         0,
                         20,
                         npx=500)