def draw_toyMC(hist,title,xlabel="",ylabel="",exponent=None, box="tl"): fit = root.TF1("gauss","gaus") textbox = r"\begin{align*}\mu&=%s\\\sigma&=%s\end{align*}" fig, a = utils.get_plotaxes((4,3.2)) hist.Fit(fit,"LQ") r2mpl.plot(hist,axes=a, errors=True, color="k", zorder=1) r2mpl.plot(fit,axes=a, color="r", zorder=0) utils.text_box(a, box, textbox % ( utils.format_error(fit.GetParameter(1), fit.GetParError(1), exponent=exponent), utils.format_error(fit.GetParameter(2), fit.GetParError(2), exponent=exponent))) a.set_title(title) a.set_xlabel(xlabel) a.set_ylabel(ylabel) return a, (fit.GetParameter(1), fit.GetParError(1)), (fit.GetParameter(2), fit.GetParError(2))
def plot_mBCdE(data, label=None, title=None, **argk): """Make a 2D Plot of mBC and dE""" f, a = utils.get_plotaxes() #f = pl.figure(figsize=(4,4)) #a = f.add_axes((0.20,0.13,0.70,0.80)) p = r2mpl.plot(data, a, **argk) if label is None: label = r"Entries / $\num{%.3g} \times \num{%.3g}\text{ GeV}^2$" % \ (data.GetXaxis().GetBinWidth(1), data.GetYaxis().GetBinWidth(1)) if title is not None: a.set_title(title) formatter = matplotlib.ticker.ScalarFormatter(False,False) formatter.set_powerlimits((-3,3)) cb = f.colorbar(p, format=formatter, fraction=0.2) cb.set_label(label) a.grid() a.set_xlabel("$M_{BC}$ / GeV") a.set_ylabel("$\Delta E$ / GeV") #Draw rectangle to show signal enhanced area coords = (5.27,-0.04,5.29,0.04) a.add_patch(matplotlib.patches.Rectangle(coords[:2], coords[2]-coords[0], coords[3]-coords[1], edgecolor="k", facecolor="none"))
print "From fitter:", signal_yield print "From cuts: ", s2 ngenerated = np.array([(h_ngenerated.GetBinContent(i+1), h_ngenerated.GetBinContent(i+1)) for i in range(2)]) raw_eff = signal_yield / ngenerated rec_eff = raw_eff * eff_DDKs ctl_eff = raw_eff * eff_DsD0Km rec_eff_c = rec_eff * np.array([utils.correction_mc, utils.correction_mc]).T ctl_eff_c = ctl_eff * np.array([utils.correction_ctrl, utils.correction_ctrl]).T h_nB0 = b0.draw("nB0", range=(200,0,200), option="goff") b_mult = h_nB0.GetMean() f,a = utils.get_plotaxes() r2mpl.plot(h_nB0, axes=a, log=True) a.set_title("\PBz Multiplicity") a.set_xlabel("Number of reconstructed \PBz") a.set_ylabel("Number of events") r2mpl.save_all("bmult", png=False, single_pdf=False) print """ngenerated = np.array([ %d, %d, ]) efficiency_mc = np.array([ [%.7e, %.7e], [%.7e, %.7e], ])""" % (tuple(ngenerated[:,0]) + tuple(rec_eff.flat))
colors = { "yield_signal_br":"r", "signal_dt_Jc":"r", "signal_dt_Js1":"g", "signal_dt_Js2":"b", "signal_dt_blifetime":"k", "ratio_continuum_svd1":"r", "ratio_continuum_svd2":"r", } for par, title in zip(linearity_full.lintest_params, linearity_full.lintest_pnames): result = rfile.Get("%s" % par) pull = rfile.Get("%s_pull" % par) if isinstance(result,root.TH2D): fig1, a1 = utils.get_plotaxes((4,3.2)) fig2, a2 = utils.get_plotaxes((4,3.2)) fig3, a3 = utils.get_plotaxes((4,3.2)) a1.set_ylabel("fit result") a2.set_ylabel("mean of pull") a3.set_ylabel("sigma of pull") for a in a1,a2,a3: a.set_title(title) a.set_xlabel("input " + title) result.Rebin2D(2,1) pull.Rebin2D(2,1) fit = root.TF1("gauss","gaus") lin_result = root.TH1D( "lin_%s" % par, "", result.GetNbinsX(),
lin_params = ["Jc", "Js1", "Js2"] cpv_params = ["signal_dt_Jc", "signal_dt_Js1", "signal_dt_Js2"]#, "signal_dt_blifetime"] cpv_names = [r"$J_C/J_0$", r"$(2J_{s1}/J_0) \sin(2\phi_1)$", r"$(2J_{s2}/J_0) \cos(2\phi_1)$",r"$\tau$"] rfile = root.TFile(infile+".root") colors = { "signal_dt_Jc":"r", "signal_dt_Js1":"g", "signal_dt_Js2":"b", "signal_dt_blifetime":"k" } for lp, lp_name in zip(lin_params,cpv_names): fig1, a1 = utils.get_plotaxes() fig2, a2 = utils.get_plotaxes() fig3, a3 = utils.get_plotaxes() a1.set_ylabel("fit result") a2.set_ylabel("mean of pull") a3.set_ylabel("sigma of pull") for a in a1,a2,a3: a.set_title("%s, linearity" % lp_name) a.set_xlabel("input " + lp_name) for cpv, cpv_name in zip(cpv_params, cpv_names): result = rfile.Get("%s_%s" % (lp,cpv)) pull = rfile.Get("%s_%s_pull" % (lp,cpv)) fit = root.TF1("gauss","gaus")