{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import flavio\n", "import numpy as np\n", "import clusterking as ck\n", "from clusterking.maths.metric import chi2_metric" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Define kinematic function using the flavio package\n", "def dBrdq2(w, q):\n", " return flavio.np_prediction(\"dBR/dq2(B+->Dtaunu)\", w, q)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Set up and configure Scanner\n", "s = ck.scan.WilsonScanner(scale=5, eft=\"WET\", basis=\"flavio\")\n", "# Set kinematic function\n", "s.set_dfunction(\n", " dBrdq2,\n", " binning=np.linspace(3.2, 11.6, 10),\n", " normalize=True\n", ")\n", "# Set sampling points in Wilson space\n", "s.set_spoints_equidist({\n", " \"CVL_bctaunutau\": (-0.5, 0.5, 3),\n", " \"CSL_bctaunutau\": (-0.5, 0.5, 3),\n", " \"CT_bctaunutau\": (-0.1, 0.1, 3)\n", "})" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run scanner and add errors\n", "d = ck.DataWithErrors() # Create data object to write results to\n", "r = s.run(d) # Run scanner\n", "r.write() # Write results back to data object\n", "d.add_err_poisson(1000) # statistical uncertainties\n", "d.add_rel_err_uncorr(0.1) # 0.1% relative system uncertainties, uncorrelated" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Clustering\n", "c = ck.cluster.HierarchyCluster() # Initialize worker class\n", "c.set_metric(chi2_metric)\n", "c.set_max_d(1) # \"Cut off\" value for hierarchy\n", "r = c.run(d) # Run clustering on d\n", "r.write() # Write results back to data object" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Benchmarking\n", "b = ck.Benchmark() # Initialize worker class\n", "b.set_metric(chi2_metric)\n", "r = b.run(d) # Run benchmarking\n", "r.write() # Write results back to data object" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Optional: Save data (kinematic distributions, clusters, BPs, ...)\n", "# d.write(\"btaunu_q2.sql\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Generate plots similar to figures 1, 2, 3, 4, respectively\n", "d.plot_clusters_scatter([\"CVL_bctaunutau\", \"CSL_bctaunutau\"])\n", "d.plot_dist_box()\n", "d.plot_clusters_scatter([\"CT_bctaunutau\", \"CVL_bctaunutau\", \"CSL_bctaunutau\"])\n", "d.plot_dist()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Find closest benchmark point to a new point in parameter space\n", "d.find_closest_bpoints({\"CT_bctaunutau\": 0, \"CVL_bctaunutau\": -0.2, \"CSL_bctaunutau\": 0.2}, n=1)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 2 }