def plot_shower_pdf_cdf(vals, axespdf, axescdf, label='Parton Shower', z_cut=Z_CUT, beta=BETA, colnum=1, col=None, style=modstyle_ps, verbose=2): """Plots the pdf and cdf associated with the set of correlators (vals) on axespdf and axescdf. """ if BIN_SPACE == 'lin': bins = np.linspace(0, 1., NUM_BINS) else: bins = np.logspace(-10, 0., NUM_BINS) if SHOWER_CUTOFF == MU_NP\ else np.logspace(-18, 0., NUM_BINS) if FIXED_COUPLING: bins = np.append(1e-100, bins) bins = np.insert(bins, 0, 1e-100) ps_integrator = integrator() ps_integrator.setLastBinBndCondition([1., 'minus']) ps_integrator.bins = bins if verbose > 2: print("bins:", bins) print("vals:", vals) try: num_in_bin, _ = np.histogram(np.array(vals), bins) except TypeError: vals = vals[0] num_in_bin, _ = np.histogram(np.array(vals), bins) pdf, _ = np.histogram(vals, bins, density=True) pdf_error = pdf / (1e-100 + np.sqrt(num_in_bin)) ps_integrator.densityErr = pdf_error ps_integrator.density = pdf ps_integrator.hasMCDensity = True ps_integrator.integrate() integral = ps_integrator.integral interr = ps_integrator.integralErr if col is None: col = compcolors[(colnum, 'dark')] # col = compcolors[(colnum, 'medium')] # Analytic cdf and pdf: xs = (bins[:-1] + bins[1:]) / 2. # Numerically obtaining pdf for comparison plots: cdf_an = critSudakov_fc_LL(xs, z_cut, beta, f=F_SOFT, jet_type=JET_TYPE) _, pdf_an = histDerivative(cdf_an, bins, giveHist=True, binInput=BIN_SPACE) pdf_an = np.array(pdf_an.tolist(), dtype=float) # ------------------ # PDF plots: # ------------------ if BIN_SPACE == 'log': pdf = xs * pdf * np.log(10) # d sigma / d log10 C pdf_error = xs * pdf_error * np.log(10) # d sigma / d log10 C pdf_an = xs * pdf_an * np.log(10) # d sigma / d log10 C axespdf[0].errorbar(xs, pdf, yerr=pdf_error, xerr=(bins[1:] - bins[:-1]) / 2., **style, color=col, label=label) if len(axespdf) > 1: axespdf[1].errorbar(xs, pdf / pdf_an, yerr=pdf_error / pdf_an, xerr=(bins[1:] - bins[:-1]) / 2., **style, color=col) # ------------------ # CDF plots: # ------------------ xs = bins[:-1] cdf_an = critSudakov_fc_LL(xs, z_cut, beta, f=F_SOFT, jet_type=JET_TYPE) cdf_an = np.array(cdf_an.tolist(), dtype=float) _, _, bars = axescdf[0].errorbar(xs, integral, yerr=interr, **style_yerr_ps, color=col, ecolor=col, label=label) bars = [b.set_alpha(.5) for b in bars] if len(axescdf) > 1: _, _, bars_r = axescdf[1].errorbar(xs, integral / cdf_an, yerr=interr / cdf_an, **style_yerr_ps, color=col, ecolor=col) bars_r = [b.set_alpha(.5) for b in bars_r]
def test_critsub_lin_sudakov(): # Setting up integrator test_int = integrator() # Integrating to find a CDF test_int.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type+"_critsub_fc_linsud_test_"\ +"{:.0e}.pdf".format(NUM_SAMPLES) pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for ibeta, beta in enumerate(betas): _, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], ylim=(.8, 1.025), xlim=(0, 1.), title='Crit + Sub'\ +' '+jet_type +' Sudakov factor, ' +r'fixed $\alpha_s$', showdate=False, ratio_plot=False) # Plotting the one emission analytic results pnts = np.linspace(0, .5, 100) for i, z_c in enumerate(z_cuts): label = (r"$z_c=$" + str(z_c)) axes[0].plot(pnts, critSudakov_fc_LL(pnts, z_c, beta, jet_type=jet_type), **style_dashed, color=compcolors[(i, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.1, .2, .3]) for i, z_c in enumerate(z_cuts): # Critical Sampling crit_sampler = criticalSampler('lin', zc=z_c) crit_sampler.generateSamples(NUM_SAMPLES) samples = crit_sampler.getSamples() z_crit = samples[:, 0] theta_crit = samples[:, 1] # Subsequent Sampling sub_sampler = ungroomedSampler('lin') sub_sampler.generateSamples(NUM_SAMPLES) samples = sub_sampler.getSamples() c_sub = samples[:, 0] # Since z_sub and c_sub have the same range of integration, # we can pretend that we are instead sampling over c_sub here obs = (C_groomed(z_crit, theta_crit, z_c, beta, z_pre=0., f=1., acc='LL') + c_sub) # Weights, binned observables, and area test_int.setBins(NUM_BINS, obs, 'lin') weights = ( criticalEmissionWeight(z_crit, theta_crit, z_c, jet_type, fixedcoupling=True) * subPDFAnalytic_fc_LL(c_sub, beta, jet_type=jet_type) ) jacs = (np.array(crit_sampler.jacobians) * np.array(sub_sampler.jacobians)) area = (np.array(crit_sampler.area) * np.array(sub_sampler.area)) test_int.setDensity(obs, weights * jacs, area) test_int.integrate() integral = test_int.integral yerr = test_int.integralErr x_vals = test_int.bins[:-1] # Choosing color scheme col = compcolors[(i, 'dark')] ecol = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) bars = [b.set_alpha(.5) for b in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False, lightlabel='Analytic, SE') if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') if SAVE_PLOTS and not SHOW_PLOTS: pdffile.close()
def test_SubLinRadiator(): # Setting up integrator num_int = integrator() # Integral is positive, and is zero at the last bin num_int.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type + "_fc_linrads_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for ibeta, beta in enumerate(betas): # Setting up plot _, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], xlim=(0, .3), ylim=(0, ylims[jet_type][ibeta]), showdate=False, title='Ungroomed ' + jet_type + ' radiator, ' + r'fixed $\alpha_s$', ratio_plot=False) for i, radius in enumerate(radii): radius = radii[i] # Plotting analytic result pnts = np.linspace(0, radius**beta / 2., 100) label = (r"$R=$" + str(radius)) axes[0].plot(pnts, subRadAnalytic_fc_LL(pnts, beta, jet_type=jet_type, maxRadius=radius), **style_dashed, color=compcolors[(i, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.25, .12, .035, .02]) for i, radius in enumerate(radii): radius = radii[i] # Sampling test_sampler = ungroomedSampler('lin', radius=radius) test_sampler.generateSamples(NUM_SAMPLES) samples = test_sampler.getSamples() z = samples[:, 0] theta = samples[:, 1] obs = C_ungroomed(z, theta, beta, acc='LL') # Weights, binned observables, and area num_int.setBins(NUM_BINS, obs, 'lin') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=True, acc='LL') jacs = test_sampler.jacobians area = test_sampler.area num_int.setDensity(obs, weights * jacs, area) num_int.integrate() integral = num_int.integral yerr = num_int.integralErr x_vals = num_int.bins[:-1] col = compcolors[(i, 'dark')] ecol = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) bars = [b.set_alpha(.5) for b in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') if SAVE_PLOTS: pdffile.close()
def test_CritLinRadiator(): # Basic setup numSamples = 1000 numBins = 100 # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0.,'plus']) for jet_type in ['quark', 'gluon']: # Setting up plot fig, axes = aestheticfig(xlabel=r'$\theta$', ylabel=r'R($\theta$)', title = 'Critical '+jet_type+' radiator, ' + r'running $\alpha_s$', showdate=False, ratio_plot=False) for i in range(len(zcuts)): zc = zcuts[i] # Plotting analytic result pnts = np.linspace(0, 1, 100) label = (r"$z_c=$" + str(zc)) axes[0].plot(pnts, critRadAnalytic(pnts, zc,jet_type=jet_type), **style_dashed, color=compcolors[(i,'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.4,.45,.51,.65]) for i in range(len(zcuts)): zc = zcuts[i] # Sampling testSampler = criticalSampler('lin', zc=zc) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:,0]; theta = samples[:,1] # Weights, binned observables, and area testInt.setBins(numBins, samples, 'lin') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=False, acc='MLL') jacs = testSampler.jacobians obs = theta area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral yerr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(i, 'dark')] ecol = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(xs, integral, yerr=yerr, **style_yerr, color=col,ecolor=ecol) [bar.set_alpha(.5) for bar in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if showPlots: plt.show() elif savePlots: filename = (jet_type+'_rc_linrads_test.pdf') plt.savefig(filename)
def test_CritLinSudakov(): # Basic setup numSamples = 1000 numBins = 100 # Setting up integrator testInt = integrator() # Integrating to find a CDF testInt.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: if savePlots and not showPlots: filename = jet_type + "_rc_linsud_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for ibeta in range(len(betas)): beta = betas[ibeta] # Setting up plot fig, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], ylim=(.7, 1.1), xlim=(0, .5), title='Critical ' + jet_type + ' Sudakov factor, ' + r'running $\alpha_s$', showdate=False, ratio_plot=False) for i in range(len(zcuts)): zc = zcuts[i] # Plotting analytic result pnts = np.linspace(0, .5, 100) label = (r"$z_c=$" + str(zc)) axes[0].plot(pnts, critSudakov_fc_LL(pnts, zc, beta, jet_type=jet_type), **style_dashed, color=compcolors[(i, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.1, .2, .3]) for i in range(len(zcuts)): zc = zcuts[i] # Sampling testSampler = criticalSampler('lin', zc=zc) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] obs = C_groomed(z, theta, zc, beta) # Weights, binned observables, and area testInt.setBins(numBins, obs, 'lin') weights = criticalEmissionWeight(z, theta, zc, jet_type, fixedcoupling=False) weights = np.nan_to_num(weights) jacs = testSampler.jacobians area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral yerr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(i, 'dark')] ecol = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(xs, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) [bar.set_alpha(.5) for bar in bars] # Legend legend_darklight(axes[0], errtype='yerr', darklabel='Monte Carlo, r.c.', lightlabel='Analytic, f.c.', twosigma=False) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def angplot_shower(angs, axespdf, axescdf, z_cut, beta, f, radius=1., jet_type='quark', bin_space='lin', plotnum=0, label=LABEL_PS): """Plots the pdf and cdf associated with the set of angularities angs on axespdf and axescdf. """ verify_bin_space(bin_space) # Finding numerical pdf: showerInt = integrator() showerInt.setLastBinBndCondition([1., 'minus']) if bin_space == 'lin': bins = np.linspace(0, radius**beta, NUM_BINS) else: bins = np.logspace(-8, np.log10(radius**beta), NUM_BINS) bins = np.append(1e-50, bins) showerInt.bins = bins # angs = np.array(angs)*(1 - 1/(beta*(beta-1))) num_in_bin, _ = np.histogram(angs, bins) pdf, _ = np.histogram(angs, bins, density=True) showerInt.densityErr = pdf / np.sqrt(num_in_bin) showerInt.density = pdf showerInt.hasMCDensity = True # Finding cdf by integrating pdf: showerInt.integrate() integral = showerInt.integral interr = showerInt.integralErr col = compcolors[(plotnum, 'dark')] # Analytic cdf and pdf: xs = (bins[:-1] + bins[1:]) / 2. if axespdf is not None: # Numerically obtaining pdf: # cdf_an = critSudakov_fc_LL(xs, z_cut, beta, f=f, # jet_type=jet_type) cdf_an = critSudakov_fc_LL(xs, z_cut, beta, f=f, jet_type=jet_type) _, pdf_an = histDerivative(cdf_an, bins, giveHist=True, binInput=bin_space) pdf_an = np.array(pdf_an.tolist(), dtype=float) # ------------------ # PDF plots: # ------------------ if bin_space == 'log': pdf = xs * pdf pdf_an = xs * pdf_an axespdf[0].errorbar(xs, pdf, yerr=pdf / np.sqrt(num_in_bin), xerr=(bins[1:] - bins[:-1]) / 2., **modstyle, color=col, label=label) if len(axespdf) > 1: axespdf[1].errorbar(xs, pdf / pdf_an, yerr=pdf / (pdf_an * np.sqrt(num_in_bin)), xerr=(bins[1:] - bins[:-1]) / 2., **modstyle, color=col) if axescdf is not None: # ------------------ # CDF plots: # ------------------ xs = bins[:-1] cdf_an = critSudakov_fc_LL(xs, z_cut, beta, f=f, jet_type=jet_type) cdf_an = np.array(cdf_an.tolist(), dtype=float) _, _, bars = axescdf[0].errorbar(xs, integral, yerr=interr, **style_yerr, color=col, ecolor=col, label=label) bars = [b.set_alpha(.5) for b in bars] if len(axescdf) > 1: _, _, bars_r = axescdf[1].errorbar(xs, integral / cdf_an, yerr=interr / cdf_an, **style_yerr, color=col, ecolor=col) bars_r = [b.set_alpha(.5) for b in bars_r]
def test_SubLinSudakov(): # Basic setup num_samples = 1000 num_bins = 100 # Setting up integrator test_int = integrator() # Integrating to find a CDF test_int.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type + "_fc_linsud_sub_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) # Setting up plot _, axes = aestheticfig(xlabel=X_LABEL_0, ylabel=X_LABEL_0, ylim=(.7, 1.1), xlim=(0, .5), title='Subsequent ' + jet_type + ' Sudakov factor, ' + r'fixed $\alpha_s$', showdate=False, ratio_plot=False) for ibeta, beta in enumerate(betas): # Plotting analytic result pnts = np.linspace(0, .5, 100) label = (r"$\beta=$" + str(beta)) axes[0].plot( pnts, np.exp(-subRadAnalytic_fc_LL(pnts, beta, jet_type=jet_type)), **style_dashed, color=compcolors[(ibeta, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.1, .2, .3]) for ibeta, beta in enumerate(betas): # Subsequent Sampling: sub_sampler = ungroomedSampler('lin') sub_sampler.generateSamples(num_samples) samples = sub_sampler.getSamples() c_sub = samples[:, 0] # Since z_sub and c_sub have the same range of integration, # we can pretend that we are instead sampling over c_sub here # Setting up observables/integration variables: obs = c_sub #rather than C_ungroomed(z_sub, theta_sub, beta, acc='LL') # Setting up binning/integration region: test_int.setBins(num_bins, obs, 'lin') # Setting up weights/integrand: weights = subPDFAnalytic_fc_LL(c_sub, beta, jet_type=jet_type) # Rather than # weights = subsequentEmissionWeight(z_sub, theta_sub, # beta, jet_type, # fixedcoupling=True) # Setting up jacobians and integration region: jacs = np.array(sub_sampler.jacobians) area = np.array(sub_sampler.area) # Integrating: test_int.setDensity(obs, weights * jacs, area) test_int.integrate() integral = test_int.integral yerr = test_int.integralErr x_vals = test_int.bins[:-1] col = compcolors[(ibeta, 'dark')] ecol = compcolors[(ibeta, 'dark')] _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) bars = [b.set_alpha(.5) for b in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') pdffile.close()
if SAVE_SHOWER_EVENTS: pass else: pass # JET_LIST = gen_jets(NUM_SHOWER_EVENTS, beta=BETA, radius=1., # jet_type=JET_TYPE, acc=ACC, # cutoff=SHOWER_CUTOFF) # Angular ordering # JET_LIST = [angular_ordered(jet) for jet in JET_LIST] # ------------------------------------ # Integrator and Samplers (MC integration) # ------------------------------------ # Setting up integrator INTEGRATOR = integrator() # Integrating to find a CDF INTEGRATOR.setLastBinBndCondition([1., 'minus']) # Setting up samplers CRIT_SAMPLERS = [] PRE_SAMPLERS = [] SUB_SAMPLERS = [] print("Generating events for Monte Carlo integration:") for _, epsilon in enumerate(tqdm(EPSILONS)): print(" Generating events with cutoff epsilon={:.0e}".format(epsilon)) # Critical sampler crit_sampler_i = criticalSampler(BIN_SPACE, zc=Z_CUT, epsilon=epsilon) crit_sampler_i.generateSamples(NUM_MC_EVENTS)
def test_SubLogRadiatorDeriv(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: for ibeta in range(len(betas)): beta = betas[ibeta] if savePlots and not showPlots: filename = jet_type + "_rc_logradderivs_test_" + str( beta) + ".pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for i in range(len(radii)): radius = radii[i] # Setting up plot fig, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], xlim=(1e-5, .5), ylim=(0, 1000), showdate=False, title='Ungroomed ' + jet_type + ' radiator, ' + r'run. $\alpha_s$, ' + r"$R=$" + str(radius), ratio_plot=False) axes[0].set_xscale('log') axes[0].set_ylabel(ylabels[ibeta], labelpad=0) # Plotting analytic result pnts = np.logspace(-8.5, 0, 1000) axes[0].plot(pnts, subRadPrimeAnalytic(pnts, beta, jet_type=jet_type, maxRadius=radius), **style_dashed, label='Analytic', color='cornflowerblue') for ieps in range(len(epsilons)): eps = epsilons[ieps] # Sampling testSampler = ungroomedSampler('log', radius=radius, epsilon=eps) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] obs = C_ungroomed(z, theta, beta, acc='LL') # Weights, binned observables, and area testInt.setBins(numBins, obs, 'log') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=False, acc='MLL') jacs = testSampler.jacobians area = testSampler.area testInt.setDensity(obs, weights * jacs, area) deriv = testInt.density yerr = testInt.densityErr xs = np.sqrt(testInt.bins[1:] * testInt.bins[:-1]) xerr = (np.abs(xs - testInt.bins[:-1]), np.abs(testInt.bins[1:] - xs)) col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(xs, deriv, xerr=xerr, yerr=yerr, **modstyle, color=col, label=label) # Legend axes[0].legend() if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def test_SubLinPDF(): # Basic setup numSamples = 1000 numBins = 100 # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: if savePlots and not showPlots: filename = (jet_type + "_rc_linpdf_test.pdf") pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for ibeta in range(len(betas)): beta = betas[ibeta] # Setting up plot fig, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], title='Ungroomed (running) ' + jet_type + ' pdf', xlim=(0, 1), ylim=(0, ylims[ibeta]), showdate=False, ratio_plot=False) for j in range(len(radii)): radius = radii[j] # Plotting analytic result pnts = np.linspace(0, .5, 100) label = (r"$R=$" + str(radius)) axes[0].plot(pnts, subPDFAnalytic(pnts, beta, jet_type=jet_type, maxRadius=radius), label=label, **style_dashed, color=compcolors[(j, 'light')]) # Labelling if ibeta == 0: labelLines(axes[0].get_lines(), xvals=[.07, .085, .085, .068]) for j in range(len(radii)): radius = radii[j] # Sampling testSampler = ungroomedSampler('lin', radius=radius) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] # Weights, binned observables, and area weights = radiatorWeight(z, theta, jet_type, fixedcoupling=False, acc='MLL') jacs = testSampler.jacobians obs = C_ungroomed(z, theta, beta, acc='LL') area = testSampler.area testInt.setBins(numBins, obs, 'lin') testInt.setDensity(obs, weights * jacs, area) testInt.integrate() deriv = testInt.density deriverr = testInt.densityErr integral = testInt.integral interr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(j, 'dark')] ecol = compcolors[(j, 'dark')] PDF = (deriv * np.exp(-integral)) yerr = (np.exp(-integral) * np.sqrt(np.square(deriverr) + np.square(interr))) _, _, bars = axes[0].errorbar(xs, PDF, yerr=yerr, **style_yerr, color=col, ecolor=ecol) [bar.set_alpha(.5) for bar in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def test_pre_lin_radiator(): # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: # Setting up plot _, axes = aestheticfig(xlabel=r'$z_{\rm pre}$', ylabel=r'R($z_{\rm pre}$)', title='Precritical ' + JET_TYPE + ' radiator, ' + r'fixed $\alpha_s$', ratio_plot=False) for i, zc in enumerate(Z_CUTS): # Plotting analytic result pnts = np.linspace(0, 1, 100) label = (r"$z_c=$" + str(zc)) axes[0].plot(pnts, critRadAnalytic_fc_LL(pnts, zc, jet_type=jet_type), **style_dashed, color=compcolors[(i, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=np.linspace(.23, .65, 4)) for i, zc in enumerate(Z_CUTS): # Sampling testSampler = precriticalSampler('lin', zc=zc) testSampler.generateSamples(NUM_SAMPLES) z_pre = testSampler.getSamples() # Weights, binned observables, and area testInt.setBins(NUM_BINS, z_pre, 'lin') weights = radiatorWeight(z_pre, theta=1., jet_type=JET_TYPE, fixedcoupling=True, acc='LL') jacs = testSampler.jacobians obs = z_pre area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral yerr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(i, 'dark')] ecol = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(xs, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) [b.set_alpha(.5) for b in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if showPlots: plt.show() elif savePlots: filename = (jet_type + '_fc_linrads_test.pdf') plt.savefig(filename)
def test_SubLogPDF(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: for ibeta in range(len(betas)): beta = betas[ibeta] if savePlots and not showPlots: filename = (jet_type + "_rc_logpdf_test_" + str(beta) + ".pdf") pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for j in range(len(radii)): radius = radii[j] # Setting up plot fig, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], xlim=(5e-5, 1), ylim=(0, 50), title='Ungroomed (running) ' + jet_type + ' pdf, ' + r'$R=$' + str(radius), showdate=False, ratio_plot=False) axes[0].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8.5, 0., 1000) axes[0].plot(pnts, subPDFAnalytic(pnts, beta, jet_type=jet_type, maxRadius=radius), **style_dashed, label='Analytic', color='cornflowerblue') # Labelling for ieps in range(len(epsilons)): eps = epsilons[ieps] # Sampling testSampler = ungroomedSampler('lin', epsilon=eps, radius=radius) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] # Weights, binned observables, and area weights = radiatorWeight(z, theta, jet_type, fixedcoupling=False, acc='MLL') jacs = testSampler.jacobians obs = C_ungroomed(z, theta, beta, acc='LL') area = testSampler.area testInt.setBins(numBins, obs, 'lin') testInt.setDensity(obs, weights * jacs, area) testInt.integrate() deriv = testInt.density integral = testInt.integral deriverr = testInt.densityErr interr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] PDF = (deriv * np.exp(-integral)) yerr = (np.exp(-integral) * np.sqrt(np.square(deriverr) + np.square(interr))) label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(xs, PDF, yerr=yerr, **style_yerr, color=col, ecolor=ecol, label=label) [bar.set_alpha(.5) for bar in bars] # Legend legend_yerr(axes[0]) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def gen_numerical_radiator(rad_sampler, emission_type, jet_type='quark', obs_accuracy='LL', splitfn_accuracy='LL', beta=None, bin_space='lin', fixed_coupling=True, save=True, num_bins=100): """A function which takes in a sampler with generated data, and returns the associated numerically integrated radiator (dependent on a single parameter). Optionally, saves the radiator and the associated interpolation function. Parameters ---------- rad_sampler : sampler A sampler class which has sampled over the phase space of a certain type of emission. emission_type : str The type of emission whose phase space we have sampled. Must be 'crit', 'sub', or 'pre'. jet_type : str The type of jet. Must be 'quark' or 'gluon'. obs_accuracy : str The accuracy at which we calculate the relevant observable. Must be 'LL' or 'MLL'. splitfn_accuracy : str The accuracy at which we calculate the relevant splitting function. Must be 'LL' or 'MLL'. fixed_coupling : bool A boolean which determines whether the radiator is calculated using fixed coupling (True) or running coupling (False). save : bool A boolean which determines whether the radiator information, and the corresponding interpolation function, are saved. Returns ------- xs, radiator, radiator_error float, float, float The xs, radiator values, and radiator errors obtained by numerical integration for the given emission and jet type. """ # Verifying that the generation is proceeding with valid parameters assert (beta is None and not emission_type == 'sub')\ or (beta is not None and emission_type == 'sub'),\ str(emission_type)+' emissions must have a valid beta value.' # Setting up an integrator rad_integrator = integrator() # Integral is positive, and is zero at the last bin rad_integrator.setLastBinBndCondition([0., 'plus']) # Getting information from sampler samples = rad_sampler.getSamples() if emission_type == 'crit': z = samples[:, 0] theta = samples[:, 1] obs = theta elif emission_type == 'sub': z = samples[:, 0] theta = samples[:, 1] obs = C_ungroomed(z, theta, beta, acc=obs_accuracy) else: raise AssertionError("Invalid emission type. Emission must be " + "'crit', 'sub', or 'pre', but is" + str(emission_type)) # Weights, binned observables, and area rad_integrator.setBins(num_bins, samples, bin_space) weights = radiatorWeight(z, theta, jet_type, fixedcoupling=fixed_coupling, acc=splitfn_accuracy) jacs = rad_sampler.jacobians area = rad_sampler.area # Performing integration rad_integrator.setDensity(obs, weights * jacs, area) rad_integrator.integrate() radiator = rad_integrator.integral radiator_error = rad_integrator.integralErr xs = rad_integrator.bins[:-1] # Reminding the radiator where it needs to stop if emission_type == 'crit': bounds = [0, 1] if emission_type == 'sub': bounds = [0, .5] radiator = np.append(radiator, 0) radiator_error = np.append(radiator_error, 0) xs = np.append(xs, bounds[1]) rad_integrator.integral = radiator rad_integrator.integralErr = radiator_error rad_integrator.bins = np.append(xs, bounds[1]) # Generating an interpolating function rad_integrator.makeInterpolatingFn() unbounded_interp_function = rad_integrator.interpFn # Checking the interpolating function against our numerics # assert(unbounded_interp_function(xs) == radiator).all(),\ # "The interpolating radiator is not the same as the radiator "\ # +"obtained with numerical integration." # Bounding the interpolating function def bounded_interp_function(x): rad = (bounds[0] < x) * (x < bounds[1]) * unbounded_interp_function(x) return rad rad_integrator.interpFn = bounded_interp_function # Saving data and interpolating function if save: extra_info = '' if fixed_coupling: extra_info = 'fc_' else: extra_info = 'rc_' if emission_type == 'crit': extra_info += 'zc_' + str(rad_sampler.zc) elif beta is not None: extra_info += 'beta_' + str(beta) + '_' filename = 'radiator_'+jet_type+'_'+emission_type\ +'_obs'+obs_accuracy+'_splitfn'+splitfn_accuracy\ +'_'+str(len(samples))+extra_info\ +'_samples.py' rad_integrator.saveInterpolatingFn(filename) return rad_integrator.interpFn
def gen_crit_sub_num_rad(rad_sampler, jet_type='quark', obs_accuracy='LL', splitfn_accuracy='LL', beta=2., epsilon=1e-15, bin_space='log', fixed_coupling=True, num_bins=1000): """A function which takes in a sampler with generated data, and returns the associated numerically integrated radiator dependent on the variables over a sampled phase space as well as angles theta of associated critical emissions. Saves the radiator and the associated interpolation function. Parameters ---------- rad_sampler : sampler A sampler class which has sampled over the phase space of a certain type of emission. jet_type : str The type of jet. Must be 'quark' or 'gluon'. accuracy : str The accuracy at which we calculate the relevant observable. Must be 'LL' or 'MLL'. fixed_coupling : bool A boolean which determines whether the radiator is calculated using fixed coupling (True) or running coupling (False). Returns ------- function A 2d interpolating function for the critical-subsequent radiator. """ # Preparing lists to hold all radiator and angle data rads_all = [] rad_error_all = [] xs_all = [] thetas_all = [] # Getting information from sampler samples = rad_sampler.getSamples() # Preparing a list of theta_crits on which our radiator will depend: theta_calc_list = lin_log_mixed_list(epsilon, 1., num_bins) # Preparing observables from the subsequent sampler z_em = samples[:, 0] theta_samp = samples[:, 1] for i, theta_crit in enumerate(theta_calc_list): # Setting up an integrator rad_integrator = integrator() # Integral is positive, and is zero at the last bin rad_integrator.setLastBinBndCondition([0., 'plus']) # Preparing to integrate over the sampled phase space jacs = rad_sampler.jacobians area = rad_sampler.area # Rescaling the emission angles relative to the sampled angles: theta_em = theta_samp * theta_crit if bin_space == 'lin': area = area * theta_crit if bin_space == 'log': jacs = np.array(jacs) * theta_crit obs = C_ungroomed(z_em, theta_em, beta, acc=obs_accuracy) # Weights, binned observables, and area rad_integrator.setBins(num_bins, obs, bin_space, min_log_bin=theta_crit**beta * 1e-15) weights = radiatorWeight(z_em, theta_em, jet_type, fixedcoupling=fixed_coupling, acc=splitfn_accuracy) # Performing integration rad_integrator.setDensity(obs, weights * jacs, area) rad_integrator.integrate() # Radiator, given a maximum angle of theta radiator = rad_integrator.integral # radiator_error = rad_integrator.integralErr xs = rad_integrator.bins[:-1] radiator = np.append(radiator, 0) # radiator_error = np.append(radiator_error, 0) xs = np.append( xs, C_ungroomed_max(beta, radius=theta_crit, acc=obs_accuracy)) # Saving the function/radiator values, bin edges, and theta value rads_all.append(np.array(radiator)) # rad_error_all.append(np.array(radiator_error)) xs_all.append(np.array(xs)) thetas_all.append(np.ones(len(xs)) * theta_crit) xs_all = np.array(xs_all) thetas_all = np.array(thetas_all) rads_all = np.array(rads_all) points = np.array([xs_all.flatten(), thetas_all.flatten()]).T unbounded_rad_fn = NearestNDInterpolator(points, rads_all.flatten()) def bounded_rad_fn(x, theta): # Subsequent emission boundaries bnds = (x <= C_ungroomed_max(beta, radius=theta, acc=obs_accuracy)) rad = ((0 <= x) * bnds * (0 <= theta) * unbounded_rad_fn(x, theta)) return rad return bounded_rad_fn
def plot_pythia_pdf_cdf(vals, axespdf, axescdf, label='Pythia', z_cut=Z_CUT, beta=BETA, colnum=1, col=None, verbose=0): """Plots the pdf and cdf associated with the set of correlators (vals) on axespdf and axescdf. """ if BIN_SPACE == 'lin': bins = np.linspace(0, 1., NUM_BINS) else: bins = np.logspace(-10, 0., NUM_BINS) if SHOWER_CUTOFF == MU_NP\ else np.logspace(-18, 0., NUM_BINS) bins = np.append(1e-100, bins) ps_integrator = integrator() ps_integrator.setLastBinBndCondition([1., 'minus']) ps_integrator.bins = bins if verbose > 2: print("bins:", bins) print("vals:", vals) num_in_bin, _ = np.histogram(np.array(vals), bins) pdf, _ = np.histogram(vals, bins, density=True) pdf_error = pdf / (1e-100 + np.sqrt(num_in_bin)) ps_integrator.densityErr = pdf_error ps_integrator.density = pdf ps_integrator.hasMCDensity = True ps_integrator.integrate() integral = ps_integrator.integral interr = ps_integrator.integralErr if col is None: col = compcolors[(colnum, 'light')] # Analytic cdf and pdf: xs = (bins[:-1] + bins[1:]) / 2. # ------------------ # PDF plots: # ------------------ if BIN_SPACE == 'log': pdf = xs * pdf * np.log(10) # d sigma / d log10 C pdf_error = xs * pdf_error * np.log(10) # d sigma / d log10 C axespdf[0].errorbar(xs, pdf, yerr=pdf_error, xerr=(bins[1:] - bins[:-1]) / 2., **modstyle_ps, color=col, label=label) # ------------------ # CDF plots: # ------------------ xs = bins[:-1] _, _, bars = axescdf[0].errorbar(xs, integral, yerr=interr, **style_yerr_ps, color=col, ecolor=col, label=label) bars = [b.set_alpha(.5) for b in bars]
def test_SubLinRadiatorDeriv(): # Basic setup numSamples = 1000 numBins = 100 # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: if savePlots and not showPlots: filename = jet_type + "_rc_linradderivs_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for ibeta in range(len(betas)): beta = betas[ibeta] # Setting up plot fig, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], xlim=(0, .5), ylim=(0, 2.5), showdate=False, title='Ungroomed ' + jet_type + ' rad. deriv., ' + r'run. $\alpha_s$', ratio_plot=False) for i in range(len(radii)): radius = radii[i] # Plotting analytic result pnts = np.linspace(0, radius**beta / 2., 100) label = (r"$R=$" + str(radius)) axes[0].plot(pnts, subRadPrimeAnalytic(pnts, beta, jet_type=jet_type, maxRadius=radius), **style_dashed, color=compcolors[(i, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.25, .12, .055, .04]) for i in range(len(radii)): radius = radii[i] # Sampling testSampler = ungroomedSampler('lin', radius=radius) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] obs = C_ungroomed(z, theta, beta, acc='LL') # Weights, binned observables, and area testInt.setBins(numBins, obs, 'lin') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=False, acc='MLL') jacs = testSampler.jacobians area = testSampler.area testInt.setDensity(obs, weights * jacs, area) deriv = testInt.density yerr = testInt.densityErr xs = (testInt.bins[1:] + testInt.bins[:-1]) / 2. xerr = (testInt.bins[1:] - testInt.bins[:-1]) / 2. col = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(xs, deriv, xerr=xerr, yerr=yerr, **modstyle, color=col) # Legend legend_darklight(axes[0], errtype='modstyle', twosigma=False) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def test_SimpleLogIntegrator(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] lowerlims = [1e-3, 1e-3, 1e-3] def test_weight(x, n): return (n + 1.) * x**n for ieps in range(len(epsilons)): eps = epsilons[ieps] # Setting up plot fig, axes = aestheticfig(xlabel='x', ylabel='f(x)', xlim=(lowerlims[ieps], 1), ratio_plot=False) fig.suptitle('Logarithmic Monte Carlo Integration,\n' + r'$\epsilon$ = {:.0e}, '.format(eps) + '{:.0e} Samples'.format(numSamples)) axes[0].set_xscale('log') # Sampling testSampler = simpleSampler('log', epsilon=eps) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() # Setting up integrator testInt = integrator() testInt.setFirstBinBndCondition(0.) testInt.setBins(numBins, samples, 'log') # Plotting analytic result pnts = np.linspace(0, 1, 100) for n in range(4): if n == 0: label = r"$\int $d$x$" else: label = (r"$\int x^{pow}$d$x\ /\ {powplus}$".format(pow=n, powplus=n + 1)) axes[0].plot(pnts, pnts**(n + 1), **style_dashed, color=compcolors[(n, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.05, .5, .3, .58]) for n in range(4): # Weights, binned observables, and area weights = test_weight(samples, n) jacs = testSampler.jacobians obs = samples area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral yerr = testInt.integralErr xs = testInt.bins[1:] col = compcolors[(n, 'dark')] ecol = compcolors[(n, 'dark')] _, _, bars = axes[0].errorbar(xs, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) [bar.set_alpha(.5) for bar in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if showPlots: plt.show() elif savePlots: filename = ('simpleIntegrator_log_test_' + str(ieps) + '.pdf') plt.savefig(filename)
def test_onefromcritsub_lin_sudakov(emission_type='crit'): assert emission_type in ['crit', 'sub'], \ "Emission type must be 'crit' or 'sub'." # Setting up integrator test_int = integrator() # Integrating to find a CDF test_int.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type+'_'+emission_type\ +"fromcritsub_fc_linsud_test_"\ +"{:.0e}.pdf".format(NUM_SAMPLES) if emission_type == 'crit': pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) if emission_type == 'sub': pdffile = filename # Setting up plot without z_c for the subsequent emissions if emission_type == 'sub': _, axes = aestheticfig(xlabel=XLABEL_0, ylabel=YLABEL_0, ylim=(.8, 1.025), xlim=(0, .5), title=fulltype[emission_type] + ' ' + jet_type + ' Sudakov factor, ' + r'fixed $\alpha_s$', showdate=False, ratio_plot=False) for ibeta, beta in enumerate(betas): # Setting up one plot for every beta for crit emissions # to avoid crowding since we have a set of z_cs for # every beta value if emission_type == 'crit': _, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], ylim=(.8, 1.025), xlim=(0, .5), title=fulltype[emission_type] + ' ' + jet_type + ' Sudakov factor, ' + r'fixed $\alpha_s$', showdate=False, ratio_plot=False) # Plotting the one emission analytic results pnts = np.linspace(0, .5, 100) if emission_type == 'crit': for i, z_c in enumerate(z_cuts): label = (r"$z_c=$" + str(z_c)) axes[0].plot(pnts, critSudakov_fc_LL(pnts, z_c, beta, jet_type=jet_type), **style_dashed, color=compcolors[(i, 'light')], label=label) # Labelling labelLines(axes[0].get_lines(), xvals=[.1, .2, .3]) if emission_type == 'sub': label = (r"$\beta=$" + str(beta)) axes[0].plot( pnts, np.exp( -subRadAnalytic_fc_LL(pnts, beta, jet_type=jet_type)), **style_dashed, color=compcolors[(ibeta, 'light')], label=label) for i, z_c in enumerate(z_cuts): # Critical Sampling crit_sampler = criticalSampler('lin', zc=z_c) crit_sampler.generateSamples(NUM_SAMPLES) samples = crit_sampler.getSamples() z_crit = samples[:, 0] theta_crit = samples[:, 1] # Subsequent Sampling sub_sampler = ungroomedSampler('lin') sub_sampler.generateSamples(NUM_SAMPLES) samples = sub_sampler.getSamples() c_sub = samples[:, 0] # Since z_sub and c_sub have the same range of integration, # we can pretend that we are instead sampling over c_sub here if emission_type == 'crit': obs = C_groomed(z_crit, theta_crit, z_c, beta, z_pre=0., f=1., acc='LL') else: obs = c_sub # Weights, binned observables, and area test_int.setBins(NUM_BINS, obs, 'lin') weights = (criticalEmissionWeight( z_crit, theta_crit, z_c, jet_type, fixedcoupling=True) * subPDFAnalytic_fc_LL(c_sub, beta, jet_type=jet_type)) jacs = (np.array(crit_sampler.jacobians) * np.array(sub_sampler.jacobians)) area = (np.array(crit_sampler.area) * np.array(sub_sampler.area)) test_int.setDensity(obs, weights * jacs, area) test_int.integrate() integral = test_int.integral yerr = test_int.integralErr x_vals = test_int.bins[:-1] # Choosing color scheme if emission_type == 'crit': icol = i if emission_type == 'sub': icol = ibeta col = compcolors[(icol, 'dark')] ecol = compcolors[(icol, 'dark')] _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol) bars = [b.set_alpha(.5) for b in bars] if emission_type == 'sub': break # For critical emissions, one plot for every beta value if emission_type == 'crit': # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False, lightlabel='Analytic, SE') if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') # For subsequent emissions, one plot total containing all betas if emission_type == 'sub': # Labelling lines # labelLines(axes[0].get_lines(), xvals=[.1, .2, .3]) # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False, lightlabel='Analytic, SE') plt.savefig(pdffile, format='pdf') if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') if SAVE_PLOTS and not SHOW_PLOTS and emission_type == 'crit': pdffile.close()
def test_SubLogSudakov(): # Basic setup num_samples = 1000 num_bins = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator test_int = integrator() # Integrating to find a CDF test_int.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type + "_fc_logsud_sub_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for ibeta, beta in enumerate(betas): # Setting up plot _, axes = aestheticfig(xlabel=X_LABELS[ibeta], ylabel=Y_LABELS[ibeta], ylim=(0, 1), xlim=(1e-8, .5), title='Subsequent LL ' + jet_type + ' Sudakov factor,' + r'fixed $\alpha_s$', showdate=False, ratio_plot=True) axes[0].set_xscale('log') axes[1].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8, np.log10(.5), 100) axes[0].plot( pnts, np.exp(-subRadAnalytic_fc_LL(pnts, beta, jet_type=jet_type)), **style_dashed, color='dimgrey', label='Analytic') axes[1].plot(pnts, np.ones(len(pnts)), **style_dashed, color='dimgrey') for ieps, eps in enumerate(epsilons): # Subsequent Sampling sub_sampler = ungroomedSampler('log', epsilon=eps) sub_sampler.generateSamples(num_samples) samples = sub_sampler.getSamples() c_sub = samples[:, 0] # Since z_sub and c_sub have the same range of integration, # we can pretend that we are instead sampling over c_sub here obs = c_sub # Rather than: #C_groomed(z_sub, theta_sub, z_c, beta, # z_pre=0., f=1., acc='LL') # Weights, binned observables, and area test_int.setBins(num_bins, obs, 'log') weights = subPDFAnalytic_fc_LL(c_sub, beta, jet_type=jet_type) # Rather than # weights = subsequentEmissionWeight(z_sub, theta_sub, # beta, jet_type, # fixedcoupling=True) jacs = np.array(sub_sampler.jacobians) area = np.array(sub_sampler.area) test_int.setDensity(obs, weights * jacs, area) test_int.integrate() integral = test_int.integral yerr = test_int.integralErr x_vals = test_int.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol, label=label) bars = [b.set_alpha(.5) for b in bars] analytic = np.exp( -subRadAnalytic_fc_LL(x_vals, beta, jet_type=jet_type)) analytic = [float(a) for a in analytic] _, _, bars = axes[1].errorbar(x_vals, integral / analytic, yerr=yerr / analytic, color=col, ecolor=ecol, **style_yerr, label=label) bars = [b.set_alpha(.5) for b in bars] legend_yerr(axes[0]) if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') if SAVE_PLOTS and not SHOW_PLOTS: pdffile.close()
def test_CritLogRadiator(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: if savePlots and not showPlots: filename = jet_type + "_fc_logradderivs_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for izc in range(len(zcuts)): zc = zcuts[izc] # Setting up plot fig, axes = aestheticfig(xlabel=r'$\theta$', ylabel=r"$R'(\theta)$", xlim=(5e-5, 1), ylim=(0, 1000), title='Critical ' + jet_type + ' rad. deriv., ' + r'fixed $\alpha_s$, ' + r'$z_c$=' + str(zc), showdate=False, ratio_plot=False) axes[0].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8.5, 0, 1000) axes[0].plot(pnts, critRadPrimeAnalytic_fc_LL(pnts, zc, jet_type=jet_type), **style_dashed, label='Analytic', color='cornflowerblue') # Labelling for ieps in range(len(epsilons)): eps = epsilons[ieps] # Sampling testSampler = criticalSampler('log', zc=zc, epsilon=eps) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] # Weights, binned observables, and area testInt.setBins(numBins, samples, 'log') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=True, acc='LL') jacs = testSampler.jacobians obs = theta area = testSampler.area testInt.setDensity(obs, weights * jacs, area) deriv = testInt.density yerr = testInt.densityErr xs = np.sqrt(testInt.bins[1:] * testInt.bins[:-1]) xerr = (np.abs(xs - testInt.bins[:-1]), np.abs(testInt.bins[1:] - xs)) col = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(xs, deriv, xerr=xerr, yerr=yerr, **modstyle, color=col, label=label) # Legend axes[0].legend() if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def test_CritLogRadiator(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] ylims = {'quark': [20,15,10,5], 'gluon': [25,20,15,10]} # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0.,'plus']) for jet_type in ['quark', 'gluon']: if savePlots and not showPlots: filename = jet_type+"_rc_lograds_test.pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for izc in range(len(zcuts)): zc = zcuts[izc] # Setting up plot fig, axes = aestheticfig(xlabel=r'$\theta$', ylabel=r'R($\theta$)', xlim=(1e-8,1), ylim=(0,ylims[jet_type][izc]), title = 'Critical '+jet_type+' radiator, ' + r'running $\alpha_s$, ' + r'$z_c$='+str(zc), showdate=False, ratio_plot=False) axes[0].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8.5, 0, 1000) axes[0].plot(pnts, critRadAnalytic(pnts, zc,jet_type=jet_type), **style_dashed, label='Analytic', color='cornflowerblue') # Labelling for ieps in range(len(epsilons)): eps = epsilons[ieps] # Sampling testSampler = criticalSampler('log', zc=zc, epsilon=eps) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:,0]; theta = samples[:,1] # Weights, binned observables, and area testInt.setBins(numBins, samples, 'log') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=False, acc='MLL') jacs = testSampler.jacobians obs = theta area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral yerr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(xs, integral, yerr=yerr, **style_yerr, color=col,ecolor=ecol, label=label) [bar.set_alpha(.5) for bar in bars] # Legend legend_yerr(axes[0]) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def test_CritLinRadiatorDeriv(): # Basic setup numSamples = 1000 numBins = 100 # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: # Setting up plot fig, axes = aestheticfig(xlabel=r'$\theta$', ylabel=r"$R'(\theta)$", xlim=(0, 1), ylim=(0, 10), title='Critical ' + jet_type + ' radiator derivative, ' + r'fixed $\alpha_s$', showdate=False, ratio_plot=False) for i in range(len(zcuts)): zc = zcuts[i] # Plotting analytic result pnts = np.linspace(0, 1, 100) label = (r"$z_c=$" + str(zc)) axes[0].plot(pnts, critRadPrimeAnalytic_fc_LL(pnts, zc, jet_type=jet_type), **style_dashed, label=label, color=compcolors[(i, 'light')]) # Labelling labelLines(axes[0].get_lines(), xvals=[.085, .1, .14, .25]) for i in range(len(zcuts)): zc = zcuts[i] # Sampling testSampler = criticalSampler('lin', zc=zc) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] # Weights, binned observables, and area testInt.setBins(numBins, samples, 'lin') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=True, acc='LL') jacs = testSampler.jacobians obs = theta area = testSampler.area testInt.setDensity(obs, weights * jacs, area) deriv = testInt.density yerr = testInt.densityErr xs = (testInt.bins[1:] + testInt.bins[:-1]) / 2. xerr = (testInt.bins[1:] - testInt.bins[:-1]) / 2. col = compcolors[(i, 'dark')] _, _, bars = axes[0].errorbar(xs, deriv, xerr=xerr, yerr=yerr, **modstyle, color=col) # Legend legend_darklight(axes[0], errtype='modstyle') if showPlots: plt.show() elif savePlots: filename = (jet_type + '_fc_linradderivs_test.pdf') plt.savefig(filename)
def test_CritLogSudakov(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator testInt = integrator() # Integrating to find a CDF testInt.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: for ibeta in range(len(betas)): beta = betas[ibeta] if savePlots and not showPlots: filename = jet_type + "_fc_logsud_test_" + str(beta) + ".pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for izc in range(len(zcuts)): zc = zcuts[izc] # Setting up plot fig, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], ylim=(0, 1), xlim=(1e-8, .5), title='Critical LL ' + jet_type + ' Sudakov factor,' + r' $z_{\rm cut}$=' + str(zc), showdate=False, ratio_plot=True) axes[0].set_xscale('log') axes[1].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8, np.log10(.5), 100) axes[0].plot(pnts, critSudakov_fc_LL(pnts, zc, beta, jet_type=jet_type), **style_dashed, color='dimgrey', label='Analytic, f.c.') axes[1].plot(pnts, np.ones(len(pnts)), **style_dashed, color='dimgrey') for ieps in range(len(epsilons)): eps = epsilons[ieps] # Sampling testSampler = criticalSampler('log', zc=zc, epsilon=eps) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] obs = C_groomed(z, theta, zc, beta) # Weights, binned observables, and area testInt.setBins(numBins, obs, 'log') weights = criticalEmissionWeight(z, theta, zc, jet_type, fixedcoupling=False) weights = np.nan_to_num(weights) jacs = testSampler.jacobians area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral yerr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(xs, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol, label=label) [bar.set_alpha(.5) for bar in bars] analytic = critSudakov_fc_LL(xs, zc, beta, jet_type=jet_type) analytic = [float(a) for a in analytic] _, _, bars = axes[1].errorbar(xs, integral / analytic, yerr=yerr / analytic, color=col, ecolor=ecol, **style_yerr, label=label) [bar.set_alpha(.5) for bar in bars] legend_yerr(axes[0]) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots and not showPlots: pdffile.close()
def test_CritLogPDF(): # Basic setup numSamples = 1000 numBins = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: for izcut in range(len(zcuts)): if savePlots and not showPlots: filename = (jet_type + "_fc_logpdf_test_" + str(izcut) + ".pdf") pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) zc = zcuts[izcut] zs_pdf = zlist[zc] for j in range(len(zs_pdf)): z_pdf = zs_pdf[j] # Setting up plot fig, axes = aestheticfig(xlabel=r'$\theta$', ylabel=r'$\rho(z, \theta)$', xlim=(5e-5, 1), ylim=(0, 100), title='Critical (fixed) ' + jet_type + ' pdf, ' + r'$z_c=$' + str(zc) + r', $z=$' + str(z_pdf), showdate=False, ratio_plot=False) axes[0].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8.5, 0, 1000) axes[0].plot(pnts, critPDFAnalytic_fc_LL(z_pdf, pnts, zc, jet_type=jet_type), **style_dashed, label='Analytic', color='cornflowerblue') # Labelling for ieps in range(len(epsilons)): eps = epsilons[ieps] # Sampling testSampler = criticalSampler('log', zc=zc, epsilon=eps) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() z = samples[:, 0] theta = samples[:, 1] # Weights, binned observables, and area testInt.setBins(numBins, samples, 'log') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=True, acc='LL') jacs = testSampler.jacobians obs = theta area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral interr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] PDF = (splittingFn(z_pdf, jet_type, 'LL') * alpha_fixed / (np.pi * xs) * np.exp(-integral)) yerr = (splittingFn(z_pdf, jet_type, 'LL') * alpha_fixed / (np.pi * xs) * np.exp(-integral)) * interr label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(xs, PDF, yerr=yerr, **style_yerr, color=col, ecolor=ecol, label=label) [bar.set_alpha(.5) for bar in bars] # Legend legend_yerr(axes[0]) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def test_critsub_log_sudakov(): # Setting up integrator test_int = integrator() # Integrating to find a CDF test_int.setLastBinBndCondition([1., 'minus']) for jet_type in ['quark', 'gluon']: for ibeta, beta in enumerate(betas): if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type+"_critsub_fc_logsud_test_"\ +str(beta)\ +"_{:.0e}.pdf".format(NUM_SAMPLES) pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for _, z_c in enumerate(z_cuts): _, axes = aestheticfig(xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], ylim=(0., 1.025), xlim=(1e-8, 1.), title='Crit + Sub'\ +' '+jet_type +' Sudakov factor, ' +r'fixed $\alpha_s$', showdate=False, ratio_plot=True) axes[0].set_xscale('log') axes[1].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8, np.log10(.5), 100) axes[0].plot(pnts, critSudakov_fc_LL(pnts, z_c, beta, jet_type=jet_type), **style_dashed, color='dimgrey', label='Analytic, SE') axes[1].plot(pnts, np.ones(len(pnts)), **style_dashed, color='dimgrey') for ieps, eps in enumerate(epsilons): # Critical Sampling crit_sampler = criticalSampler('log', zc=z_c, epsilon=eps) crit_sampler.generateSamples(NUM_SAMPLES) samples = crit_sampler.getSamples() z_crit = samples[:, 0] theta_crit = samples[:, 1] # Subsequent Sampling sub_sampler = ungroomedSampler('log', epsilon=eps) sub_sampler.generateSamples(NUM_SAMPLES) samples = sub_sampler.getSamples() c_sub = samples[:, 0] # Since z_sub and c_sub have the same range of # integration,we can pretend that we are instead # sampling over c_sub here obs = (C_groomed(z_crit, theta_crit, z_c, beta, z_pre=0., f=1., acc='LL') + c_sub) # Weights, binned observables, and area test_int.setBins(NUM_BINS, obs, 'log') weights = ( criticalEmissionWeight(z_crit, theta_crit, z_c, jet_type, fixedcoupling=True) * subPDFAnalytic_fc_LL(c_sub, beta, jet_type=jet_type) ) jacs = (np.array(crit_sampler.jacobians) * np.array(sub_sampler.jacobians)) area = (np.array(crit_sampler.area) * np.array(sub_sampler.area)) test_int.setDensity(obs, weights * jacs, area) test_int.integrate() integral = test_int.integral yerr = test_int.integralErr x_vals = test_int.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol, label=label) bars = [b.set_alpha(.5) for b in bars] analytic = critSudakov_fc_LL(x_vals, z_c, beta, jet_type=jet_type) analytic = [float(a) for a in analytic] _, _, bars = axes[1].errorbar(x_vals, integral/analytic, yerr=yerr/analytic, color=col, ecolor=ecol, **style_yerr, label=label) bars = [b.set_alpha(.5) for b in bars] legend_yerr(axes[0]) if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') if SAVE_PLOTS and not SHOW_PLOTS: pdffile.close()
def test_CritLinPDF(): # Basic setup numSamples = 1000 numBins = 100 # Setting up integrator testInt = integrator() # Integral is positive, and is zero at the last bin testInt.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: if savePlots and not showPlots: filename = (jet_type + "_fc_linpdf_test.pdf") pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for izcut in range(len(zcuts)): zc = zcuts[izcut] zs_pdf = zlist[zc] # Setting up plot fig, axes = aestheticfig(xlabel=r'$\theta$', ylabel=r'$\rho(z, \theta)$', title='Critical ' + jet_type + ' pdf, ' + r'fixed $\alpha_s$, ' + r'$z_c=$' + str(zc), xlim=(0, 1), ylim=(0, ylims[izcut]), showdate=False, ratio_plot=False) for j in range(len(zs_pdf)): # z_pdf is the z that corresponds to a plot of rho(z, theta) z_pdf = zs_pdf[j] # Plotting analytic result pnts = np.linspace(0, 1, 100) label = (r"$z=$" + str(z_pdf)) axes[0].plot(pnts, critPDFAnalytic_fc_LL(z_pdf, pnts, zc, jet_type=jet_type), **style_dashed, label=label, color=compcolors[(j, 'light')]) # Labelling labelLines(axes[0].get_lines(), xvals=[.08, .1, .18, .33]) for j in range(len(zs_pdf)): # z_pdf is the z that corresponds to a plot of rho(z, theta) z_pdf = zs_pdf[j] # Sampling testSampler = criticalSampler('lin', zc=zc) testSampler.generateSamples(numSamples) samples = testSampler.getSamples() # z is the set of critical z samples z = samples[:, 0] theta = samples[:, 1] # Weights, binned observables, and area testInt.setBins(numBins, samples, 'lin') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=True, acc='LL') jacs = testSampler.jacobians obs = theta area = testSampler.area testInt.setDensity(obs, weights * jacs, area) testInt.integrate() integral = testInt.integral interr = testInt.integralErr xs = testInt.bins[:-1] col = compcolors[(j, 'dark')] ecol = compcolors[(j, 'dark')] PDF = (splittingFn(z_pdf, jet_type, 'LL') * alpha_fixed / (np.pi * xs) * np.exp(-integral)) yerr = (splittingFn(z_pdf, jet_type, 'LL') * alpha_fixed / (np.pi * xs) * np.exp(-integral)) * interr _, _, bars = axes[0].errorbar(xs, PDF, yerr=yerr, **style_yerr, color=col, ecolor=ecol) [bar.set_alpha(.5) for bar in bars] # Legend legend_darklight(axes[0], errtype='yerr', twosigma=False) if showPlots: plt.show() elif savePlots: plt.savefig(pdffile, format='pdf') if savePlots: pdffile.close()
def angplot_shower(angs, axespdf, axescdf, beta=2., radius=1., jet_type='quark', bin_space='lin', plotnum=0, acc='LL'): """Plots the pdf and cdf associated with the set of angularities angs on axespdf and axescdf. """ verify_bin_space(bin_space) # Finding pdf: showerInt = integrator() showerInt.setLastBinBndCondition([1., 'minus']) if bin_space == 'lin': bins = np.linspace(0, radius**beta, NUM_BINS) else: bins = np.logspace(-8, np.log10(radius**beta), NUM_BINS) bins = np.append([0], bins) showerInt.bins = bins num_in_bin, _ = np.histogram(angs, bins) pdf, _ = np.histogram(angs, bins, density=True) showerInt.densityErr = pdf / np.sqrt(num_in_bin) showerInt.density = pdf showerInt.hasMCDensity = True # Finding cdf by integrating pdf: showerInt.integrate() integral = showerInt.integral interr = showerInt.integralErr col = compcolors[(plotnum, 'dark')] if comparisonplot: if plotnum == 1: label = "Larkoski's algorithm" if plotnum == 2: label = "Reweighted algorithm" if plotnum == 3: label = "New algorithm" else: label = LABEL_PS if axespdf is not None: # ------------------ # PDF plots: # ------------------ xs = (bins[1:] + bins[:-1]) / 2. if acc == 'LL': pdf_an = pdf_ang_LL(xs, beta=beta, jet_type=jet_type, R=radius) if acc in ['MLL', 'ME']: _, pdf_an, angs = distrib_ang_MLL(bins, beta=beta, jet_type=jet_type, R=radius, binInput=bin_space, acc=acc) if bin_space == 'log': pdf = xs * pdf pdf_an = xs * pdf_an axespdf[0].errorbar(xs, pdf, yerr=pdf / np.sqrt(num_in_bin), xerr=(bins[1:] - bins[:-1]) / 2., **modstyle, color=col, label=label) if len(axespdf) > 1: axespdf[1].errorbar(xs, pdf / pdf_an, yerr=pdf / (pdf_an * np.sqrt(num_in_bin)), xerr=(bins[1:] - bins[:-1]) / 2., **modstyle, color=col) if axescdf is not None: # ------------------ # CDF plots: # ------------------ if acc == 'LL': cdf_an = cdf_ang_LL(xs, beta=beta, jet_type=jet_type, R=radius) if acc in ['MLL', 'ME']: cdf_an, _, _ = distrib_ang_MLL(bins, beta=beta, jet_type=jet_type, R=radius, binInput=bin_space, acc=acc) xs = bins[:-1] _, _, bars = axescdf[0].errorbar(xs, integral, yerr=interr, **style_yerr, color=col, ecolor=col, label=label) bars = [b.set_alpha(.5) for b in bars] if len(axescdf) > 1: _, _, bars_r = axescdf[1].errorbar(xs, integral / cdf_an, yerr=interr / cdf_an, **style_yerr, color=col, ecolor=col) bars_r = [b.set_alpha(.5) for b in bars_r]
def test_SubLogRadiator(): # Basic setup NUM_SAMPLES = 1000 NUM_BINS = 100 epsilons = [1e-3, 1e-5, 1e-10] # Setting up integrator num_int = integrator() # Integral is positive, and is zero at the last bin num_int.setLastBinBndCondition([0., 'plus']) for jet_type in ['quark', 'gluon']: for ibeta, beta in enumerate(betas): if SAVE_PLOTS and not SHOW_PLOTS: filename = jet_type + "_fc_lograds_test_" + str(beta) + ".pdf" pdffile = matplotlib.backends.backend_pdf.PdfPages(filename) for i, radius in enumerate(radii): radius = radii[i] # Setting up plot fig, axes = aestheticfig( xlabel=xlabels[ibeta], ylabel=ylabels[ibeta], xlim=(1e-8, .3), ylim=(0, ylimslog[jet_type][ibeta]), showdate=False, title='Ungroomed ' + jet_type + ' radiator, ' + r'fixed $\alpha_s$, ' + r"$R=$" + str(radius), ratio_plot=False) axes[0].set_xscale('log') # Plotting analytic result pnts = np.logspace(-8.5, 0, 1000) axes[0].plot(pnts, subRadAnalytic_fc_LL(pnts, beta, jet_type=jet_type, maxRadius=radius), **style_dashed, label='Analytic', color='cornflowerblue') for ieps, eps in enumerate(epsilons): # Sampling test_sampler = ungroomedSampler('log', radius=radius, epsilon=eps) test_sampler.generateSamples(NUM_SAMPLES) samples = test_sampler.getSamples() z = samples[:, 0] theta = samples[:, 1] obs = C_ungroomed(z, theta, beta, acc='LL') # Weights, binned observables, and area num_int.setBins(NUM_BINS, obs, 'log') weights = radiatorWeight(z, theta, jet_type, fixedcoupling=True, acc='LL') jacs = test_sampler.jacobians area = test_sampler.area num_int.setDensity(obs, weights * jacs, area) num_int.integrate() integral = num_int.integral yerr = num_int.integralErr x_vals = num_int.bins[:-1] col = compcolors[(ieps, 'dark')] ecol = compcolors[(ieps, 'dark')] label = r'Log MC, $\epsilon$={:.0e}'.format(eps) _, _, bars = axes[0].errorbar(x_vals, integral, yerr=yerr, **style_yerr, color=col, ecolor=ecol, label=label) bars = [b.set_alpha(.5) for b in bars] # Legend legend_yerr(axes[0]) if SHOW_PLOTS: plt.show() elif SAVE_PLOTS: plt.savefig(pdffile, format='pdf') if SAVE_PLOTS: pdffile.close()