예제 #1
0
            lin_pull_sigma.SetBinContent(x,fit.GetParameter(2))
            lin_pull_sigma.SetBinError(x,fit.GetParError(2))

        fit = root.TF1("line","pol1",-0.8,0.8)
        for a,h in (a1,lin_result),(a2,lin_pull_mean),(a3,lin_pull_sigma):
            if par is not "yield_signal_br":
                h.Fit(fit,"Q")
            else:
                h.Fit(fit,"Q")
            r2mpl.plot(h, axes=a, errors=True, color=colors[par])
            r2mpl.plot(fit, axes=a, color=colors[par])
            utils.text_box(a, "tl", r"\begin{align*}m&=%s\\t&=%s\end{align*}" % (utils.format_error(fit.GetParameter(1), fit.GetParError(1)), utils.format_error(fit.GetParameter(0), fit.GetParError(0))))

        lin_res = lin_result.Clone("tmp")
        for i in range(1,lin_res.GetNbinsX()+1):
            lin_res.SetBinContent(i,lin_res.GetBinContent(i)-lin_res.GetBinCenter(i))
        r2mpl.plot(lin_res, axes=a1, errors=True, color="k")

        if par is not "yield_signal_br":
            #ymin = result.GetYaxis().GetXmin()
            #ymax = result.GetYaxis().GetXmax()
            a1.set_ylim(-1.2,1.2)
        a2.set_ylim(-1,1)
        a3.set_ylim(0,2)

    elif isinstance(result,root.TH1D):
        toymc.draw_toyMC(result,title)
        toymc.draw_toyMC(pull,title + ", pull")

r2mpl.save_all(infile,png=False,single_pdf=True)
예제 #2
0
import sys
import os
import glob
import dspdsmks
import utils
import matplotlib
from matplotlib import pyplot as pl
import pyroot as pr
import r2mpl
import toymc

params = dspdsmks.Parameters()

lifetime = root.TH1D("b_lifetime", "b_lifetime", 40, 1.20, 1.55)
pull_lifetime = root.TH1D("p_lifetime", "b_lifetime", 40, -3, 3)

for par in glob.glob("toymc/ctrl-dt/*.out"):
    params.load(par)
    v = params("signal_dt_blifetime").value
    e = params("signal_dt_blifetime").error
    lifetime.Fill(v)
    pull_lifetime.Fill((v-1.519)/(e**2+0.007**2)**.5)

toymc.draw_toyMC(lifetime, r"fit result", r"$\tau_{\PBz}$ / ps", ylabel=r"Entries / \num{%s}" % lifetime.GetBinWidth(1), box="tr")[0].axvline(1.519,c="b",ls="--")
toymc.draw_toyMC(pull_lifetime, r"pull distribution", r"Pull($\tau_{\PBz}$)", ylabel=r"Entries / \num{%s}" % pull_lifetime.GetBinWidth(1), box="tr")[0].axvline(0,c="b",ls="--")

r2mpl.save_all("vary_lifetime", png=False, single_pdf=True)