Newer
Older
Master_thesis / .ipynb_checkpoints / raremodel-nb-checkpoint.ipynb
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Import"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\zfit\\util\\execution.py:53: UserWarning: Not running on Linux. Determining available cpus for thread can failand be overestimated. Workaround (only if too many cpus are used):`zfit.run.set_n_cpu(your_cpu_number)`\n",
      "  warnings.warn(\"Not running on Linux. Determining available cpus for thread can fail\"\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.\n",
      "For more information, please see:\n",
      "  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md\n",
      "  * https://github.com/tensorflow/addons\n",
      "If you depend on functionality not listed there, please file an issue.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from pdg_const import pdg\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "import pickle as pkl\n",
    "import sys\n",
    "import time\n",
    "from helperfunctions import display_time, prepare_plot\n",
    "import cmath as c\n",
    "import scipy.integrate as integrate\n",
    "from scipy.optimize import fminbound\n",
    "from array import array as arr\n",
    "import collections\n",
    "from itertools import compress\n",
    "import tensorflow as tf\n",
    "import zfit\n",
    "from zfit import ztf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Build model and graphs\n",
    "## Create graphs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def formfactor( q2, subscript): #returns real value\n",
    "    #check if subscript is viable\n",
    "\n",
    "    if subscript != \"0\" and subscript != \"+\" and subscript != \"T\":\n",
    "        raise ValueError('Wrong subscript entered, choose either 0, + or T')\n",
    "\n",
    "    #get constants\n",
    "\n",
    "    mK = ztf.constant(pdg['Ks_M'])\n",
    "    mbstar0 = ztf.constant(pdg[\"mbstar0\"])\n",
    "    mbstar = ztf.constant(pdg[\"mbstar\"])\n",
    "    b0 = ztf.constant(pdg[\"b0\"])\n",
    "    bplus = ztf.constant(pdg[\"bplus\"])\n",
    "    bT = ztf.constant(pdg[\"bT\"])\n",
    "\n",
    "    mmu = ztf.constant(pdg['muon_M'])\n",
    "    mb = ztf.constant(pdg['bquark_M'])\n",
    "    ms = ztf.constant(pdg['squark_M'])\n",
    "    mB = ztf.constant(pdg['Bplus_M'])\n",
    "\n",
    "    #N comes from derivation in paper\n",
    "\n",
    "    N = 3\n",
    "\n",
    "    #some helperfunctions\n",
    "\n",
    "    tpos = (mB - mK)**2\n",
    "    tzero = (mB + mK)*(ztf.sqrt(mB)-ztf.sqrt(mK))**2\n",
    "\n",
    "    z_oben = ztf.sqrt(tpos - q2) - ztf.sqrt(tpos - tzero)\n",
    "    z_unten = ztf.sqrt(tpos - q2) + ztf.sqrt(tpos - tzero)\n",
    "    z = tf.divide(z_oben, z_unten)\n",
    "\n",
    "    #calculate f0\n",
    "\n",
    "    if subscript == \"0\":\n",
    "        prefactor = 1/(1 - q2/(mbstar0**2))\n",
    "        _sum = 0\n",
    "\n",
    "        for i in range(N):\n",
    "            _sum += b0[i]*(tf.pow(z,i))\n",
    "\n",
    "        return tf.complex(prefactor * _sum, ztf.constant(0.0))\n",
    "\n",
    "    #calculate f+ or fT\n",
    "\n",
    "    else:\n",
    "        prefactor = 1/(1 - q2/(mbstar**2))\n",
    "        _sum = 0\n",
    "\n",
    "        if subscript == \"T\":\n",
    "            b = bT\n",
    "        else:\n",
    "            b = bplus\n",
    "\n",
    "        for i in range(N):\n",
    "            _sum += b[i] * (tf.pow(z, i) - ((-1)**(i-N)) * (i/N) * tf.pow(z, N))\n",
    "\n",
    "        return tf.complex(prefactor * _sum, ztf.constant(0.0))\n",
    "\n",
    "def resonance(q, _mass, width, phase, scale):\n",
    "\n",
    "    q2 = tf.pow(q, 2)\n",
    "\n",
    "    mmu = ztf.constant(pdg['muon_M'])\n",
    "\n",
    "    p = 0.5 * ztf.sqrt(q2 - 4*(mmu**2))\n",
    "\n",
    "    p0 =  0.5 * ztf.sqrt(_mass**2 - 4*mmu**2)\n",
    "\n",
    "    gamma_j = tf.divide(p, q2) * _mass * width / p0\n",
    "\n",
    "    #Calculate the resonance\n",
    "\n",
    "    _top = tf.complex(_mass * width, ztf.constant(0.0))\n",
    "\n",
    "    _bottom = tf.complex(_mass**2 - q2, -_mass*gamma_j)\n",
    "\n",
    "    com = _top/_bottom\n",
    "\n",
    "    #Rotate by the phase\n",
    "\n",
    "    r = tf.abs(com)\n",
    "\n",
    "    _phase = tf.angle(com)\n",
    "\n",
    "    _phase += phase\n",
    "\n",
    "    x = tf.cos(phase)*r\n",
    "    y = tf.sin(phase)*r\n",
    "\n",
    "    com = tf.complex(scale* x, scale * y)\n",
    "\n",
    "    return com\n",
    "\n",
    "def bifur_gauss(q, mean, sigma_L, sigma_R, scale):\n",
    "\n",
    "    _exp = tf.where(q < mean, ztf.exp(- tf.pow((q-mean),2) / (2 * sigma_L**2)), ztf.exp(- tf.pow((q-mean),2) / (2 * sigma_R**2)))\n",
    "\n",
    "    #Scale so the total area under curve is 1 and the top of the cusp is continuous\n",
    "\n",
    "    dgamma = scale*_exp/(ztf.sqrt(2*np.pi))*2*(sigma_L*sigma_R)/(sigma_L+sigma_R)\n",
    "\n",
    "    com = ztf.complex(dgamma, ztf.constant(0.0))\n",
    "\n",
    "    return com\n",
    "\n",
    "def axiv_nonres(q):\n",
    "\n",
    "    GF = ztf.constant(pdg['GF'])\n",
    "    alpha_ew = ztf.constant(pdg['alpha_ew'])\n",
    "    Vtb = ztf.constant(pdg['Vtb'])\n",
    "    Vts = ztf.constant(pdg['Vts'])\n",
    "    C10eff = ztf.constant(pdg['C10eff'])\n",
    "\n",
    "    mmu = ztf.constant(pdg['muon_M'])\n",
    "    mb = ztf.constant(pdg['bquark_M'])\n",
    "    ms = ztf.constant(pdg['squark_M'])\n",
    "    mK = ztf.constant(pdg['Ks_M'])\n",
    "    mB = ztf.constant(pdg['Bplus_M'])\n",
    "\n",
    "    q2 = tf.pow(q, 2)\n",
    "\n",
    "    #Some helperfunctions\n",
    "\n",
    "    beta = ztf.sqrt(tf.abs(1. - 4. * mmu**2. / q2))\n",
    "\n",
    "    kabs = ztf.sqrt(mB**2. +tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2. * (mB**2. * mK**2. + mK**2. * q2 + mB**2. * q2) / mB**2.)\n",
    "\n",
    "    #prefactor in front of whole bracket\n",
    "\n",
    "    prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2. * kabs * beta / (128. * np.pi**5.)\n",
    "\n",
    "    #left term in bracket\n",
    "\n",
    "    bracket_left = 2./3. * kabs**2. * beta**2. *tf.abs(tf.complex(C10eff, ztf.constant(0.0))*formfactor(q2, \"+\"))**2.\n",
    "\n",
    "    #middle term in bracket\n",
    "\n",
    "    _top = 4. * mmu**2. * (mB**2. - mK**2.) * (mB**2. - mK**2.)\n",
    "\n",
    "    _under = q2 * mB**2.\n",
    "\n",
    "    bracket_middle = _top/_under *tf.pow(tf.abs(tf.complex(C10eff, ztf.constant(0.0)) * formfactor(q2, \"0\")), 2)\n",
    "\n",
    "    #Note sqrt(q2) comes from derivation as we use q2 and plot q\n",
    "\n",
    "    return prefactor1 * (bracket_left + bracket_middle) * 2 *ztf.sqrt(q2)\n",
    "\n",
    "def vec(q, funcs):\n",
    "    \n",
    "    q2 = tf.pow(q, 2)\n",
    "\n",
    "    GF = ztf.constant(pdg['GF'])\n",
    "    alpha_ew = ztf.constant(pdg['alpha_ew'])\n",
    "    Vtb = ztf.constant(pdg['Vtb'])\n",
    "    Vts = ztf.constant(pdg['Vts'])\n",
    "    C7eff = ztf.constant(pdg['C7eff'])\n",
    "\n",
    "    mmu = ztf.constant(pdg['muon_M'])\n",
    "    mb = ztf.constant(pdg['bquark_M'])\n",
    "    ms = ztf.constant(pdg['squark_M'])\n",
    "    mK = ztf.constant(pdg['Ks_M'])\n",
    "    mB = ztf.constant(pdg['Bplus_M'])\n",
    "\n",
    "    #Some helperfunctions\n",
    "\n",
    "    beta = ztf.sqrt(tf.abs(1. - 4. * mmu**2. / q2))\n",
    "\n",
    "    kabs = ztf.sqrt(mB**2. + tf.pow(q2, 2)/mB**2. + mK**4./mB**2. - 2 * (mB**2 * mK**2 + mK**2 * q2 + mB**2 * q2) / mB**2)\n",
    "\n",
    "    #prefactor in front of whole bracket\n",
    "\n",
    "    prefactor1 = GF**2. *alpha_ew**2. * (tf.abs(Vtb*Vts))**2 * kabs * beta / (128. * np.pi**5.)\n",
    "\n",
    "    #right term in bracket\n",
    "\n",
    "    prefactor2 = kabs**2 * (1. - 1./3. * beta**2)\n",
    "\n",
    "    abs_bracket = tf.abs(c9eff(q, funcs) * formfactor(q2, \"+\") + tf.complex(2.0 * C7eff * (mb + ms)/(mB + mK), ztf.constant(0.0)) * formfactor(q2, \"T\"))**2\n",
    "\n",
    "    bracket_right = prefactor2 * abs_bracket\n",
    "\n",
    "    #Note sqrt(q2) comes from derivation as we use q2 and plot q\n",
    "\n",
    "    return prefactor1 * bracket_right * 2 * ztf.sqrt(q2)\n",
    "\n",
    "def c9eff(q, funcs):\n",
    "\n",
    "    C9eff_nr = tf.complex(ztf.constant(pdg['C9eff']), ztf.constant(0.0))\n",
    "\n",
    "    c9 = C9eff_nr\n",
    "\n",
    "    c9 = c9 + funcs\n",
    "\n",
    "    return c9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def G(y):\n",
    "    \n",
    "    def inner_rect_bracket(q):\n",
    "        return tf.log(ztf.to_complex((1+tf.sqrt(q))/(1-tf.sqrt(q)))-tf.complex(ztf.constant(0), -1*ztf.constant(np.pi)))    \n",
    "    \n",
    "    def inner_right(q):\n",
    "        return ztf.to_complex(2 * tf.atan(1/tf.sqrt(-q)))\n",
    "    \n",
    "    big_bracket = tf.where(y > ztf.const(0.0), inner_rect_bracket(y), inner_right(y))\n",
    "    \n",
    "    return ztf.to_complex(tf.sqrt(tf.abs(y))) * big_bracket\n",
    "\n",
    "def h_S(m, q):\n",
    "    \n",
    "    return tf.constant(2) - G(tf.constant(1) - 4*tf.pow(m, 2) / tf.pow(q, 2))\n",
    "\n",
    "def h_P(m,q):\n",
    "    \n",
    "    return 2/3 + (1 - (tf.constant(1) - 4*tf.pow(m, 2) / tf.pow(q, 2))) * h_S(m,q)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Build pdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "class total_pdf(zfit.pdf.ZPDF):\n",
    "    _N_OBS = 1  # dimension, can be omitted\n",
    "    _PARAMS = ['jpsi_mass', 'jpsi_scale', 'jpsi_phase', 'jpsi_width',\n",
    "                'psi2s_mass', 'psi2s_scale', 'psi2s_phase', 'psi2s_width',\n",
    "                'cusp_mass', 'sigma_L', 'sigma_R', 'cusp_scale'\n",
    "                ]  # the name of the parameters\n",
    "\n",
    "    def _unnormalized_pdf(self, x):\n",
    "        \n",
    "        x = x.unstack_x()\n",
    "\n",
    "        def jpsi_res(q):\n",
    "            return resonance(q, _mass = self.params['jpsi_mass'], scale = self.params['jpsi_scale'], phase = self.params['jpsi_phase'], width = self.params['jpsi_width'])\n",
    "\n",
    "        def psi2s_res(q):\n",
    "            return resonance(q, _mass = self.params['psi2s_mass'], scale = self.params['psi2s_scale'], phase = self.params['psi2s_phase'], width = self.params['psi2s_width'])\n",
    "\n",
    "        def cusp(q):\n",
    "            return bifur_gauss(q, mean = self.params['cusp_mass'], sigma_L = self.params['sigma_L'], sigma_R = self.params['sigma_R'], scale = self.params['cusp_scale'])\n",
    "\n",
    "        funcs = jpsi_res(x) + psi2s_res(x) + cusp(x)\n",
    "\n",
    "        vec_f = vec(x, funcs)\n",
    "\n",
    "        axiv_nr = axiv_nonres(x)\n",
    "\n",
    "        tot = vec_f + axiv_nr\n",
    "\n",
    "        return tot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_min = 2*pdg['muon_M']\n",
    "x_max = (pdg[\"Bplus_M\"]-pdg[\"Ks_M\"]-0.1)\n",
    "\n",
    "obs = zfit.Space('q', limits = (x_min, x_max))\n",
    "\n",
    "with open(r\"./data/slim_points/slim_points_toy_0_range({0}-{1}).pkl\".format(int(x_min), int(x_max)), \"rb\") as input_file:\n",
    "    part_set = pkl.load(input_file)\n",
    "\n",
    "x_part = part_set['x_part']\n",
    "\n",
    "x_part = x_part.astype('float64')\n",
    "\n",
    "data = zfit.data.Data.from_numpy(array=x_part, obs=obs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From c:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\tensorflow\\python\\ops\\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Colocations handled automatically by placer.\n"
     ]
    }
   ],
   "source": [
    "#jpsi\n",
    "\n",
    "jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg[\"jpsi\"]\n",
    "\n",
    "jpsi_m = zfit.Parameter(\"jpsi_m\", ztf.constant(jpsi_mass), floating = False)\n",
    "jpsi_w = zfit.Parameter(\"jpsi_w\", ztf.constant(jpsi_width), floating = False)\n",
    "jpsi_p = zfit.Parameter(\"jpsi_p\", ztf.constant(jpsi_phase), floating = False)\n",
    "jpsi_s = zfit.Parameter(\"jpsi_s\", ztf.constant(jpsi_scale), floating = False)\n",
    "\n",
    "#psi2s\n",
    "\n",
    "psi2s_mass, psi2s_width, psi2s_phase, psi2s_scale = pdg[\"psi2s\"]\n",
    "\n",
    "psi2s_m = zfit.Parameter(\"psi2s_m\", ztf.constant(psi2s_mass), floating = False)\n",
    "psi2s_w = zfit.Parameter(\"psi2s_w\", ztf.constant(psi2s_width), floating = False)\n",
    "psi2s_p = zfit.Parameter(\"psi2s_p\", ztf.constant(psi2s_phase), floating = False)\n",
    "psi2s_s = zfit.Parameter(\"psi2s_s\", ztf.constant(psi2s_scale), floating = False)\n",
    "\n",
    "#cusp\n",
    "\n",
    "cusp_mass, sigma_R, sigma_L, cusp_scale = 3550, 3e-7, 200, 0\n",
    "\n",
    "cusp_m = zfit.Parameter(\"cusp_m\", ztf.constant(cusp_mass))\n",
    "sig_L = zfit.Parameter(\"sig_L\", ztf.constant(sigma_L))\n",
    "sig_R = zfit.Parameter(\"sig_R\", ztf.constant(sigma_R))\n",
    "cusp_s = zfit.Parameter(\"cusp_s\", ztf.constant(cusp_scale))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Test if graphs actually work and compute values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def total_test_tf(xq):\n",
    "\n",
    "    def jpsi_res(q):\n",
    "        return resonance(q, jpsi_m, jpsi_s, jpsi_p, jpsi_w)\n",
    "\n",
    "    def psi2s_res(q):\n",
    "        return resonance(q, psi2s_m, psi2s_s, psi2s_p, psi2s_w)\n",
    "\n",
    "    def cusp(q):\n",
    "        return bifur_gauss(q, cusp_m, sig_L, sig_R, cusp_s)\n",
    "\n",
    "    funcs = jpsi_res(xq) + psi2s_res(xq) + cusp(xq)\n",
    "\n",
    "    vec_f = vec(xq, funcs)\n",
    "\n",
    "    axiv_nr = axiv_nonres(xq)\n",
    "\n",
    "    tot = vec_f + axiv_nr\n",
    "    \n",
    "    return tot\n",
    "\n",
    "calcs = zfit.run(total_test_tf(x_part))\n",
    "\n",
    "test_q = np.linspace(x_min, x_max,20000000)\n",
    "\n",
    "calcs_test = zfit.run(total_test_tf(test_q))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.09\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEDCAYAAAAyZm/jAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGRhJREFUeJzt3X+QXWWB5vHvk3SSDvkhARqWJQTQQcXxB2gvssOWCrqASAV2hx3DiIMzsClcRcspS4eyCmextsqdqV2pqRkXMgw1OJREZcTJWPwwW8i4MxikMyAgPzTEKDFWpSFoiISQTp79454mpzu30+d230538j6fqlv33Pe85/R73tw8ffq97zlXtomIiHLMmu4GRETEwZXgj4goTII/IqIwCf6IiMIk+CMiCpPgj4gozIwNfkm3SNoq6fEu7OscSY/UHi9LuqQb7YyIONRops7jl/QuYAfwFdtv7uJ+jwI2AEttv9St/UZEHCpm7Bm/7e8B2+plkl4n6R5J6yX9P0lvnMCuLwXuTuhHRKlmbPCPYRVwje13AJ8GvjyBfawAbu9qqyIiDiE9092ApiQtBH4H+Iak4eJ51br/DFzfZrNf2D6/to/jgbcA905tayMiZq5DJvhp/XXyK9unj15h+5vANxvs4/eAO23v7nbjIiIOFYfMUI/t7cBPJf0XALW8rcPdXEaGeSKicI2CX9ImSY9VUyEH2qx/j6Rf16ZLXldbd4GkpyVtkPQnTRsm6Xbg+8AbJG2WdCXwIeBKST8EfgRc3MH+TgZOBP6p6TYREYejRtM5JW0C+m0/N8b69wCftn3RqPLZwI+B/whsBh4CLrP9xOS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+CbwYds/rq16CDi1miU2F1hBq98OGZ32he1TbJ9s+2Ran5P9N9vfYqa+L6b70+WD9QDeSmuWzqPA48B1VflraYXVBuAbwDzv+1T/fwNPAI9RzXap1v1RVX8D8IfTfWwHoS/eBPwLrdkZjwDn1fb1OVqfDzwNvH+6j62LffEJWmdrQ7TO0G6uvS/+qjrmx4D+At4XY/XFzcAL1XviEVq3cBne14W0btH+DPC56T62qe6LUdv+LdWsnpn6vsgtGyIiClPMUE9ERLQk+CMiCpPgj4goTII/IqIwCf6IiMIk+CMiCpPgj4gozP8HJyhkqnhWc6oAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plt.plot(x_part, calcs, '.')\n",
    "plt.plot(test_q, calcs_test)\n",
    "plt.ylim(3.5e-7, 5.5e-7)\n",
    "plt.xlim(3050, 3150)\n",
    "plt.savefig('test.png')\n",
    "print(jpsi_width)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup pdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "total_f = total_pdf(obs=obs, jpsi_mass = jpsi_m, jpsi_scale = jpsi_s, jpsi_phase = jpsi_p, jpsi_width = jpsi_w,\n",
    "            psi2s_mass = psi2s_m, psi2s_scale = psi2s_s, psi2s_phase = psi2s_p, psi2s_width = psi2s_w,\n",
    "            cusp_mass = cusp_m, sigma_L = sig_L, sigma_R = sig_R, cusp_scale = cusp_s)\n",
    "\n",
    "# print(total_pdf.obs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Sampling\n",
    "## One sample"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From c:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\zfit\\core\\sample.py:98: to_int64 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use tf.cast instead.\n"
     ]
    }
   ],
   "source": [
    "nevents = 440000\n",
    "\n",
    "samp = total_f.sample(n=nevents)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD8CAYAAACCRVh7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAFHNJREFUeJzt3XusHGd5x/HvU5sk3J3LCU1tS8cIKyVFtKRWmpYKoZhALgjnj9A6QuBCJEsltFAqwYmQGvWCFNqKm0qDDElxKkqgARQLB4KVgFAlEji5EBJM8CG4+OA0PtRJgCIIhqd/7Hvw5njnXPZ2dna+H2m1M++8szvznjPz23dmdjYyE0mSOvmN1V4ASdLoMiQkSZUMCUlSJUNCklTJkJAkVTIkJEmVDAlJUiVDQpJUyZCQJFVau9oLsJgzzjgjJycnV3sxJKlW7r777h9m5kQ/XmukQ2JycpLp6enVXgxJqpWI+O9+vZaHmyRJlQwJSVIlQ0KSVMmQkCRVMiQkSZUMCUlSJUNCklTJkJAkVTIkJEmVDAlJUiVDQpJUyZCQJFUyJCRJlQwJSbUwObV3KPPoqQwJSatuEDtzA6I/DAlJUiVDQtLAzX+q7/ene3sLg2dISBp57WFgMAyXISFpZFUFwuTUXk9kD4khIan22g9nGR79ZUhIGjmDOLw0qPMi486QkLRqFtthuzMfDUuGRETcEBFHIuKBtrJ/iohvR8T9EfHZiFjXNu3qiJiJiIci4lVt5ReVspmImOr/qkiqs9UKBcNoccvpSXwMuGhB2T7gRZn5YuA7wNUAEXEOsB34nTLPv0bEm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288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sam = samp.unstack_x()\n",
    "\n",
    "sam = zfit.run(sam)\n",
    "\n",
    "bins = int((x_max-x_min)/7)\n",
    "\n",
    "calcs = zfit.run(total_test_tf(samp))\n",
    "\n",
    "plt.hist(sam, bins = bins, range = (x_min,x_max))\n",
    "\n",
    "# plt.plot(sam, calcs, '.')\n",
    "# plt.plot(test_q, calcs_test)\n",
    "# plt.ylim(0, 0.0000007)\n",
    "# plt.xlim(3000, 3750)\n",
    "\n",
    "plt.savefig('test.png')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Toys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0      |\n",
      "+-----------+--------+\n",
      "+-----------+----------+\n",
      "| Parameter | Gradient |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550     |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0        |\n",
      "+-----------+----------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+----------+\n",
      "| Parameter | Gradient |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550     |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.499 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.501 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.490 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.510 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.021  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.019  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.030  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.010  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.001  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | -0.001 |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.010  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | -0.010 |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550.002 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3549.998 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550.022 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3549.978 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.004  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.002  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.013  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | -0.007 |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+---------+\n",
      "| Parameter |  Value  |\n",
      "+===========+=========+\n",
      "| psi2s_p   | -1.500  |\n",
      "+-----------+---------+\n",
      "| jpsi_s    | 0.020   |\n",
      "+-----------+---------+\n",
      "| sig_R     | 0.000   |\n",
      "+-----------+---------+\n",
      "| cusp_m    | 3550    |\n",
      "+-----------+---------+\n",
      "| psi2s_s   | 0.003   |\n",
      "+-----------+---------+\n",
      "| sig_L     | 200.001 |\n",
      "+-----------+---------+\n",
      "| jpsi_p    | -1.500  |\n",
      "+-----------+---------+\n",
      "| cusp_s    | 0.000   |\n",
      "+-----------+---------+\n",
      "+-----------+---------+\n",
      "| Parameter |  Value  |\n",
      "+===========+=========+\n",
      "| psi2s_p   | -1.500  |\n",
      "+-----------+---------+\n",
      "| jpsi_s    | 0.020   |\n",
      "+-----------+---------+\n",
      "| sig_R     | 0.000   |\n",
      "+-----------+---------+\n",
      "| cusp_m    | 3550    |\n",
      "+-----------+---------+\n",
      "| psi2s_s   | 0.003   |\n",
      "+-----------+---------+\n",
      "| sig_L     | 199.999 |\n",
      "+-----------+---------+\n",
      "| jpsi_p    | -1.500  |\n",
      "+-----------+---------+\n",
      "| cusp_s    | 0.000   |\n",
      "+-----------+---------+\n",
      "+-----------+---------+\n",
      "| Parameter |  Value  |\n",
      "+===========+=========+\n",
      "| psi2s_p   | -1.500  |\n",
      "+-----------+---------+\n",
      "| jpsi_s    | 0.020   |\n",
      "+-----------+---------+\n",
      "| sig_R     | 0.000   |\n",
      "+-----------+---------+\n",
      "| cusp_m    | 3550    |\n",
      "+-----------+---------+\n",
      "| psi2s_s   | 0.003   |\n",
      "+-----------+---------+\n",
      "| sig_L     | 200.010 |\n",
      "+-----------+---------+\n",
      "| jpsi_p    | -1.500  |\n",
      "+-----------+---------+\n",
      "| cusp_s    | 0.000   |\n",
      "+-----------+---------+\n",
      "+-----------+---------+\n",
      "| Parameter |  Value  |\n",
      "+===========+=========+\n",
      "| psi2s_p   | -1.500  |\n",
      "+-----------+---------+\n",
      "| jpsi_s    | 0.020   |\n",
      "+-----------+---------+\n",
      "| sig_R     | 0.000   |\n",
      "+-----------+---------+\n",
      "| cusp_m    | 3550    |\n",
      "+-----------+---------+\n",
      "| psi2s_s   | 0.003   |\n",
      "+-----------+---------+\n",
      "| sig_L     | 199.990 |\n",
      "+-----------+---------+\n",
      "| jpsi_p    | -1.500  |\n",
      "+-----------+---------+\n",
      "| cusp_s    | 0.000   |\n",
      "+-----------+---------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.499 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.501 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.490 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.510 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.001  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | -0.001 |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.010  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | -0.010 |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.490 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.510 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.030  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.010  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.010  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | -0.010 |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 0.100  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | -0.100 |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 1.000  |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | -1.000 |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+--------+\n",
      "| Parameter | Value  |\n",
      "+===========+========+\n",
      "| psi2s_p   | -1.500 |\n",
      "+-----------+--------+\n",
      "| jpsi_s    | 0.020  |\n",
      "+-----------+--------+\n",
      "| sig_R     | 10.000 |\n",
      "+-----------+--------+\n",
      "| cusp_m    | 3550   |\n",
      "+-----------+--------+\n",
      "| psi2s_s   | 0.003  |\n",
      "+-----------+--------+\n",
      "| sig_L     | 200    |\n",
      "+-----------+--------+\n",
      "| jpsi_p    | -1.500 |\n",
      "+-----------+--------+\n",
      "| cusp_s    | 0.000  |\n",
      "+-----------+--------+\n",
      "+-----------+---------+\n",
      "| Parameter |  Value  |\n",
      "+===========+=========+\n",
      "| psi2s_p   | -1.500  |\n",
      "+-----------+---------+\n",
      "| jpsi_s    | 0.020   |\n",
      "+-----------+---------+\n",
      "| sig_R     | -10.000 |\n",
      "+-----------+---------+\n",
      "| cusp_m    | 3550    |\n",
      "+-----------+---------+\n",
      "| psi2s_s   | 0.003   |\n",
      "+-----------+---------+\n",
      "| sig_L     | 200     |\n",
      "+-----------+---------+\n",
      "| jpsi_p    | -1.500  |\n",
      "+-----------+---------+\n",
      "| cusp_s    | 0.000   |\n",
      "+-----------+---------+\n",
      "+-----------+---------+\n",
      "| Parameter |  Value  |\n",
      "+===========+=========+\n",
      "| psi2s_p   | -1.500  |\n",
      "+-----------+---------+\n",
      "| jpsi_s    | 0.020   |\n",
      "+-----------+---------+\n",
      "| sig_R     | 100.000 |\n",
      "+-----------+---------+\n",
      "| cusp_m    | 3550    |\n",
      "+-----------+---------+\n",
      "| psi2s_s   | 0.003   |\n",
      "+-----------+---------+\n",
      "| sig_L     | 200     |\n",
      "+-----------+---------+\n",
      "| jpsi_p    | -1.500  |\n",
      "+-----------+---------+\n",
      "| cusp_s    | 0.000   |\n",
      "+-----------+---------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | -100.000 |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550     |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 1000.000 |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550     |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+-----------+\n",
      "| Parameter |   Value   |\n",
      "+===========+===========+\n",
      "| psi2s_p   | -1.500    |\n",
      "+-----------+-----------+\n",
      "| jpsi_s    | 0.020     |\n",
      "+-----------+-----------+\n",
      "| sig_R     | -1000.000 |\n",
      "+-----------+-----------+\n",
      "| cusp_m    | 3550      |\n",
      "+-----------+-----------+\n",
      "| psi2s_s   | 0.003     |\n",
      "+-----------+-----------+\n",
      "| sig_L     | 200       |\n",
      "+-----------+-----------+\n",
      "| jpsi_p    | -1.500    |\n",
      "+-----------+-----------+\n",
      "| cusp_s    | 0.000     |\n",
      "+-----------+-----------+\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-----------+-----------+\n",
      "| Parameter |   Value   |\n",
      "+===========+===========+\n",
      "| psi2s_p   | -1.500    |\n",
      "+-----------+-----------+\n",
      "| jpsi_s    | 0.020     |\n",
      "+-----------+-----------+\n",
      "| sig_R     | 10000.000 |\n",
      "+-----------+-----------+\n",
      "| cusp_m    | 3550      |\n",
      "+-----------+-----------+\n",
      "| psi2s_s   | 0.003     |\n",
      "+-----------+-----------+\n",
      "| sig_L     | 200       |\n",
      "+-----------+-----------+\n",
      "| jpsi_p    | -1.500    |\n",
      "+-----------+-----------+\n",
      "| cusp_s    | 0.000     |\n",
      "+-----------+-----------+\n",
      "+-----------+------------+\n",
      "| Parameter |   Value    |\n",
      "+===========+============+\n",
      "| psi2s_p   | -1.500     |\n",
      "+-----------+------------+\n",
      "| jpsi_s    | 0.020      |\n",
      "+-----------+------------+\n",
      "| sig_R     | -10000.000 |\n",
      "+-----------+------------+\n",
      "| cusp_m    | 3550       |\n",
      "+-----------+------------+\n",
      "| psi2s_s   | 0.003      |\n",
      "+-----------+------------+\n",
      "| sig_L     | 200        |\n",
      "+-----------+------------+\n",
      "| jpsi_p    | -1.500     |\n",
      "+-----------+------------+\n",
      "| cusp_s    | 0.000      |\n",
      "+-----------+------------+\n",
      "+-----------+------------+\n",
      "| Parameter |   Value    |\n",
      "+===========+============+\n",
      "| psi2s_p   | -1.500     |\n",
      "+-----------+------------+\n",
      "| jpsi_s    | 0.020      |\n",
      "+-----------+------------+\n",
      "| sig_R     | 100000.005 |\n",
      "+-----------+------------+\n",
      "| cusp_m    | 3550       |\n",
      "+-----------+------------+\n",
      "| psi2s_s   | 0.003      |\n",
      "+-----------+------------+\n",
      "| sig_L     | 200        |\n",
      "+-----------+------------+\n",
      "| jpsi_p    | -1.500     |\n",
      "+-----------+------------+\n",
      "| cusp_s    | 0.000      |\n",
      "+-----------+------------+\n",
      "+-----------+-------------+\n",
      "| Parameter |    Value    |\n",
      "+===========+=============+\n",
      "| psi2s_p   | -1.500      |\n",
      "+-----------+-------------+\n",
      "| jpsi_s    | 0.020       |\n",
      "+-----------+-------------+\n",
      "| sig_R     | -100000.005 |\n",
      "+-----------+-------------+\n",
      "| cusp_m    | 3550        |\n",
      "+-----------+-------------+\n",
      "| psi2s_s   | 0.003       |\n",
      "+-----------+-------------+\n",
      "| sig_L     | 200         |\n",
      "+-----------+-------------+\n",
      "| jpsi_p    | -1.500      |\n",
      "+-----------+-------------+\n",
      "| cusp_s    | 0.000       |\n",
      "+-----------+-------------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550.022 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3549.978 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3550.223 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3549.777 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3552.227 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3547.773 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3572.268 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3527.732 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3772.682 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n",
      "+-----------+----------+\n",
      "| Parameter |  Value   |\n",
      "+===========+==========+\n",
      "| psi2s_p   | -1.500   |\n",
      "+-----------+----------+\n",
      "| jpsi_s    | 0.020    |\n",
      "+-----------+----------+\n",
      "| sig_R     | 0.000    |\n",
      "+-----------+----------+\n",
      "| cusp_m    | 3327.318 |\n",
      "+-----------+----------+\n",
      "| psi2s_s   | 0.003    |\n",
      "+-----------+----------+\n",
      "| sig_L     | 200      |\n",
      "+-----------+----------+\n",
      "| jpsi_p    | -1.500   |\n",
      "+-----------+----------+\n",
      "| cusp_s    | 0.000    |\n",
      "+-----------+----------+\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<hr>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "    <tr>\n",
       "        <td title=\"Minimum value of function\">FCN = 3629121.653405886</td>\n",
       "        <td title=\"Total number of call to FCN so far\">TOTAL NCALL = 71</td>\n",
       "        <td title=\"Number of call in last migrad\">NCALLS = 71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td title=\"Estimated distance to minimum\">EDM = 1.716336526500257e-07</td>\n",
       "        <td title=\"Maximum EDM definition of convergence\">GOAL EDM = 5e-06</td>\n",
       "        <td title=\"Error def. Amount of increase in FCN to be defined as 1 standard deviation\">\n",
       "        UP = 0.5</td>\n",
       "    </tr>\n",
       "</table>\n",
       "<table>\n",
       "    <tr>\n",
       "        <td align=\"center\" title=\"Validity of the migrad call\">Valid</td>\n",
       "        <td align=\"center\" title=\"Validity of parameters\">Valid Param</td>\n",
       "        <td align=\"center\" title=\"Is Covariance matrix accurate?\">Accurate Covar</td>\n",
       "        <td align=\"center\" title=\"Positive definiteness of covariance matrix\">PosDef</td>\n",
       "        <td align=\"center\" title=\"Was covariance matrix made posdef by adding diagonal element\">Made PosDef</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">True</td>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td align=\"center\" title=\"Was last hesse call fail?\">Hesse Fail</td>\n",
       "        <td align=\"center\" title=\"Validity of covariance\">HasCov</td>\n",
       "        <td align=\"center\" title=\"Is EDM above goal EDM?\">Above EDM</td>\n",
       "        <td align=\"center\"></td>\n",
       "        <td align=\"center\" title=\"Did last migrad call reach max call limit?\">Reach calllim</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">True</td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">True</td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">False</td>\n",
       "        <td align=\"center\"></td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">False</td>\n",
       "    </tr>\n",
       "</table>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "    <tr>\n",
       "        <td><a href=\"#\" onclick=\"$('#optqXGyAoR').toggle()\">+</a></td>\n",
       "        <td title=\"Variable name\">Name</td>\n",
       "        <td title=\"Value of parameter\">Value</td>\n",
       "        <td title=\"Hesse error\">Hesse Error</td>\n",
       "        <td title=\"Minos lower error\">Minos Error-</td>\n",
       "        <td title=\"Minos upper error\">Minos Error+</td>\n",
       "        <td title=\"Lower limit of the parameter\">Limit-</td>\n",
       "        <td title=\"Upper limit of the parameter\">Limit+</td>\n",
       "        <td title=\"Is the parameter fixed in the fit\">Fixed?</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>0</td>\n",
       "        <td>psi2s_p</td>\n",
       "        <td>-1.50003</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>1</td>\n",
       "        <td>jpsi_s</td>\n",
       "        <td>0.0201815</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>2</td>\n",
       "        <td>sig_R</td>\n",
       "        <td>3e-07</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>3</td>\n",
       "        <td>cusp_m</td>\n",
       "        <td>3550</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>4</td>\n",
       "        <td>psi2s_s</td>\n",
       "        <td>0.00259796</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>5</td>\n",
       "        <td>sig_L</td>\n",
       "        <td>200</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>6</td>\n",
       "        <td>jpsi_p</td>\n",
       "        <td>-1.49997</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>7</td>\n",
       "        <td>cusp_s</td>\n",
       "        <td>7.51955e-10</td>\n",
       "        <td>0</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "</table>\n",
       "<pre id=\"optqXGyAoR\" style=\"display:none;\">\n",
       "<textarea rows=\"22\" cols=\"50\" onclick=\"this.select()\" readonly>\n",
       "\\begin{tabular}{|c|r|r|r|r|r|r|r|c|}\n",
       "\\hline\n",
       " & Name & Value & Hesse Error & Minos Error- & Minos Error+ & Limit- & Limit+ & Fixed?\\\\\n",
       "\\hline\n",
       "0 & $psi2s_{p}$ & -1.50003 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "1 & $jpsi_{s}$ & 0.0201815 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "2 & $sig_{R}$ & 3e-07 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "3 & $cusp_{m}$ & 3550 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "4 & $psi2s_{s}$ & 0.00259796 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "5 & $sig_{L}$ & 200 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "6 & $jpsi_{p}$ & -1.49997 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "7 & $cusp_{s}$ & 7.51955e-10 & 0 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "\\end{tabular}\n",
       "</textarea>\n",
       "</pre>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<hr>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sampler = total_f.create_sampler(n=nevents)\n",
    "nll = zfit.loss.UnbinnedNLL(model=total_f, data=sampler, fit_range = (x_min, x_max))\n",
    "\n",
    "# for param in pdf.get_dependents():\n",
    "#     param.set_value(initial_value)\n",
    "\n",
    "sampler.resample(n=nevents)\n",
    "\n",
    "# Randomise initial values\n",
    "# for param in pdf.get_dependents():\n",
    "#     param.set_value(random value here)\n",
    "\n",
    "# Minimise the NLL\n",
    "minimizer = zfit.minimize.MinuitMinimizer(verbosity = 10)\n",
    "minimum = minimizer.minimize(nll)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fitting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<hr>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "    <tr>\n",
       "        <td title=\"Minimum value of function\">FCN = 2069227.784921124</td>\n",
       "        <td title=\"Total number of call to FCN so far\">TOTAL NCALL = 1700</td>\n",
       "        <td title=\"Number of call in last migrad\">NCALLS = 1689</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td title=\"Estimated distance to minimum\">EDM = 0.29410277187207523</td>\n",
       "        <td title=\"Maximum EDM definition of convergence\">GOAL EDM = 5e-06</td>\n",
       "        <td title=\"Error def. Amount of increase in FCN to be defined as 1 standard deviation\">\n",
       "        UP = 0.5</td>\n",
       "    </tr>\n",
       "</table>\n",
       "<table>\n",
       "    <tr>\n",
       "        <td align=\"center\" title=\"Validity of the migrad call\">Valid</td>\n",
       "        <td align=\"center\" title=\"Validity of parameters\">Valid Param</td>\n",
       "        <td align=\"center\" title=\"Is Covariance matrix accurate?\">Accurate Covar</td>\n",
       "        <td align=\"center\" title=\"Positive definiteness of covariance matrix\">PosDef</td>\n",
       "        <td align=\"center\" title=\"Was covariance matrix made posdef by adding diagonal element\">Made PosDef</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">True</td>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td align=\"center\" title=\"Was last hesse call fail?\">Hesse Fail</td>\n",
       "        <td align=\"center\" title=\"Validity of covariance\">HasCov</td>\n",
       "        <td align=\"center\" title=\"Is EDM above goal EDM?\">Above EDM</td>\n",
       "        <td align=\"center\"></td>\n",
       "        <td align=\"center\" title=\"Did last migrad call reach max call limit?\">Reach calllim</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">False</td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">True</td>\n",
       "        <td align=\"center\" style=\"background-color:#FF7878\">True</td>\n",
       "        <td align=\"center\"></td>\n",
       "        <td align=\"center\" style=\"background-color:#92CCA6\">False</td>\n",
       "    </tr>\n",
       "</table>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "    <tr>\n",
       "        <td><a href=\"#\" onclick=\"$('#VCBNOLYGZE').toggle()\">+</a></td>\n",
       "        <td title=\"Variable name\">Name</td>\n",
       "        <td title=\"Value of parameter\">Value</td>\n",
       "        <td title=\"Hesse error\">Hesse Error</td>\n",
       "        <td title=\"Minos lower error\">Minos Error-</td>\n",
       "        <td title=\"Minos upper error\">Minos Error+</td>\n",
       "        <td title=\"Lower limit of the parameter\">Limit-</td>\n",
       "        <td title=\"Upper limit of the parameter\">Limit+</td>\n",
       "        <td title=\"Is the parameter fixed in the fit\">Fixed?</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>0</td>\n",
       "        <td>psi2s_p</td>\n",
       "        <td>-50.2658</td>\n",
       "        <td>4.8059e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>1</td>\n",
       "        <td>jpsi_s</td>\n",
       "        <td>559850</td>\n",
       "        <td>162.861</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>2</td>\n",
       "        <td>sig_R</td>\n",
       "        <td>488804</td>\n",
       "        <td>4.8059e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>3</td>\n",
       "        <td>cusp_m</td>\n",
       "        <td>-396560</td>\n",
       "        <td>4.8059e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>4</td>\n",
       "        <td>psi2s_s</td>\n",
       "        <td>98059.8</td>\n",
       "        <td>4.73152e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>5</td>\n",
       "        <td>sig_L</td>\n",
       "        <td>0.736243</td>\n",
       "        <td>4.8059e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>6</td>\n",
       "        <td>jpsi_p</td>\n",
       "        <td>-232.478</td>\n",
       "        <td>4.8059e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>7</td>\n",
       "        <td>cusp_s</td>\n",
       "        <td>13254.8</td>\n",
       "        <td>4.80455e+07</td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td></td>\n",
       "        <td>No</td>\n",
       "    </tr>\n",
       "</table>\n",
       "<pre id=\"VCBNOLYGZE\" style=\"display:none;\">\n",
       "<textarea rows=\"22\" cols=\"50\" onclick=\"this.select()\" readonly>\n",
       "\\begin{tabular}{|c|r|r|r|r|r|r|r|c|}\n",
       "\\hline\n",
       " & Name & Value & Hesse Error & Minos Error- & Minos Error+ & Limit- & Limit+ & Fixed?\\\\\n",
       "\\hline\n",
       "0 & $psi2s_{p}$ & -50.2658 & 4.8059e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "1 & $jpsi_{s}$ & 559850 & 162.861 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "2 & $sig_{R}$ & 488804 & 4.8059e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "3 & $cusp_{m}$ & -396560 & 4.8059e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "4 & $psi2s_{s}$ & 98059.8 & 4.73152e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "5 & $sig_{L}$ & 0.736243 & 4.8059e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "6 & $jpsi_{p}$ & -232.478 & 4.8059e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "7 & $cusp_{s}$ & 13254.8 & 4.80455e+07 &  &  &  &  & No\\\\\n",
       "\\hline\n",
       "\\end{tabular}\n",
       "</textarea>\n",
       "</pre>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<hr>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "ename": "RuntimeError",
     "evalue": "Function mimimum is not valid. Make sure migrad converge first",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mRuntimeError\u001b[0m                              Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-6b888d8894a4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mminimizer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mminimize\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnll\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0mparam_errors\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merror\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      8\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mvar\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merrors\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mparam_errors\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\zfit\\minimizers\\fitresult.py\u001b[0m in \u001b[0;36merror\u001b[1;34m(self, params, method, error_name, sigma)\u001b[0m\n\u001b[0;32m    227\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    228\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0muncached_params\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 229\u001b[1;33m             \u001b[0merror_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_error\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mparams\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0muncached_params\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msigma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0msigma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    230\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_cache_errors\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0merror_name\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0merror_name\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0merror_dict\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    231\u001b[0m         \u001b[0mall_errors\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mOrderedDict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mparams\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0merror_name\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\zfit\\minimizers\\fitresult.py\u001b[0m in \u001b[0;36m_error\u001b[1;34m(self, params, method, sigma)\u001b[0m\n\u001b[0;32m    238\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    239\u001b[0m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"The following method is not a valid, implemented method: {}\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 240\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mparams\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msigma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0msigma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    241\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    242\u001b[0m \u001b[1;31m# def set_error_method(self, method):\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\zfit\\minimizers\\fitresult.py\u001b[0m in \u001b[0;36m_minos_minuit\u001b[1;34m(result, params, sigma)\u001b[0m\n\u001b[0;32m     46\u001b[0m                         \"`MinuitMinimizer`.\")\n\u001b[0;32m     47\u001b[0m     result = [minimizer._minuit_minimizer.minos(var=p.name, sigma=sigma)\n\u001b[1;32m---> 48\u001b[1;33m               for p in params][-1]  # returns every var\n\u001b[0m\u001b[0;32m     49\u001b[0m     \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mOrderedDict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     50\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\users\\sa_li\\.conda\\envs\\rmd\\lib\\site-packages\\zfit\\minimizers\\fitresult.py\u001b[0m in \u001b[0;36m<listcomp>\u001b[1;34m(.0)\u001b[0m\n\u001b[0;32m     46\u001b[0m                         \"`MinuitMinimizer`.\")\n\u001b[0;32m     47\u001b[0m     result = [minimizer._minuit_minimizer.minos(var=p.name, sigma=sigma)\n\u001b[1;32m---> 48\u001b[1;33m               for p in params][-1]  # returns every var\n\u001b[0m\u001b[0;32m     49\u001b[0m     \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mOrderedDict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     50\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32miminuit\\_libiminuit.pyx\u001b[0m in \u001b[0;36miminuit._libiminuit.Minuit.minos\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mRuntimeError\u001b[0m: Function mimimum is not valid. Make sure migrad converge first"
     ]
    }
   ],
   "source": [
    "nll = zfit.loss.UnbinnedNLL(model=total_f, data=data, fit_range = (x_min, x_max))\n",
    "\n",
    "minimizer = zfit.minimize.MinuitMinimizer()\n",
    "minimizer._use_tfgrad = False\n",
    "result = minimizer.minimize(nll)\n",
    "\n",
    "param_errors = result.error()\n",
    "\n",
    "for var, errors in param_errors.items():\n",
    "    print('{}: ^{{+{}}}_{{{}}}'.format(var.name, errors['upper'], errors['lower']))\n",
    "\n",
    "print(\"Function minimum:\", result.fmin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}