{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/hep/davide/miniconda3/envs/root_env/lib/ROOT.py:301: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility\n", " return _orig_ihook( name, *args, **kwds )\n" ] } ], "source": [ "import ROOT as r\n", "import root_numpy as rn\n", "import pickle\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import array as array" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "l_index=1\n", "l_flv=['e','mu']\n", "\n", "data = np.load('/disk/lhcb_data/davide/Rphipi/selected_data/'+l_flv[l_index]+l_flv[l_index]+'/sel_data_NN_'+l_flv[l_index]+l_flv[l_index]+'.npy')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#cut on mass\n", "cut_indices=[]\n", "\n", "lower_mass_cut=1790\n", "upper_mass_cut=2030\n", "\n", "for i in range(len(data)):\n", " if lower_mass_cut<data[i]<upper_mass_cut:\n", " cut_indices.append(i)\n", " \n", "data_cut=data[cut_indices]/1000. \n", "\n", "lower_mass_cut/=1000.\n", "upper_mass_cut/=1000." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAA68AAAJCCAYAAAAvNfEBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGrtJREFUeJzt3V+Ipfd93/HPNxpZxHYpdnbkQnbloe1FUdZCSCuZYAIWNVjtXLkqFqmVgh0hFOr8ucsqUBwXBFtoKAhKbQXLKlERSy07uVhtZBFfKIYGMY6E/romabfeaZC1rcFNL6yK7q8X84iO1J0/u3PmnO/MvF6wzJzf85yZ37DPPnve8zvnOTXGCAA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9OZpwwAAALQnXgEAAGhPvAIAANCeeAUAAKA98QoAAEB74hUAAID2xCsAAADtiVcAAADa+79Sz9hosrgKgwAAAABJRU5ErkJggg==\n", "text/plain": [ "<Figure size 1152x720 with 1 Axes>" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "data_array=np.array([data_cut[i] for i in range(len(data_cut))], dtype=[('D_sel_M', np.float32)])\n", "\n", "plt.hist(data_cut,range=(lower_mass_cut,upper_mass_cut),bins=100);\n", "fig=plt.gcf();\n", "\n", "fig.set_size_inches(16,10)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "rn.array2root(data_array,\n", " filename='/disk/lhcb_data/davide/Rphipi/selected_data/'+l_flv[l_index]+l_flv[l_index]+'/sel_data_NN_'+l_flv[l_index]+l_flv[l_index]+'.root',\n", " treename='D_M',\n", " mode='recreate',\n", " )\n", "f=r.TFile('/disk/lhcb_data/davide/Rphipi/selected_data/'+l_flv[l_index]+l_flv[l_index]+'/sel_data_NN_'+l_flv[l_index]+l_flv[l_index]+'.root')\n", "tree=f.Get(\"D_M\") " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "mass = np.array([0],dtype=np.float32)\n", "branch = tree.GetBranch(\"D_sel_M\")\n", "branch.SetAddress(mass)\n", "\n", "num_entries=tree.GetEntries()\n", "m = r.RooRealVar(\"m\",\"m\",lower_mass_cut,upper_mass_cut)\n", "l = r.RooArgSet(m)\n", "data_hist = r.RooDataSet(\"data histogram\", \"data\", l)\n", "\n", "\n", "for i in range(num_entries):\n", " tree.GetEvent(i)\n", " r.RooAbsRealLValue.__assign__(m, mass[0])\n", " data_hist.add(l, 1.0)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "#Creating the signal PDF\n", "\n", "\n", "mean_dplus= r.RooRealVar(\"mean_D+\",\"mean_D+\",1.87,1.77,1.97)\n", "sigma_dplus = r.RooRealVar(\"sigma_D+\",\"sigma_D+\",0.020,0.,0.2)\n", "sig_dplus = r.RooGaussian(\"signal_D+\",\"signal_D+\", m, mean_dplus, sigma_dplus)\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "#Creating the signal PDF\n", "\n", "mean_ds= r.RooRealVar(\"mean_Ds\",\"mean_Ds\",1.97,1.87,2.07)\n", "sigma_ds = r.RooRealVar(\"sigma_Ds\",\"sigma_Ds\",0.020,0.,0.2)\n", "sig_ds = r.RooGaussian(\"signal_Ds\",\"signal_Ds\", m, mean_ds, sigma_ds)\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "coef0 = r.RooRealVar(\"c0\",\"coefficient #0\",1.0,-1.,1)\n", "coef1 = r.RooRealVar(\"c1\",\"coefficient #1\",0.1,-1.,1)\n", "coef2 = r.RooRealVar(\"c2\",\"coefficient #2\",-0.1,-1.,1)\n", "bkg = r.RooChebychev(\"bkg\",\"background p.d.f.\",m,r.RooArgList(coef0,coef1,coef2))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "#Add 2 sources of signal\n", "\n", "# first add the sig and the peak together with fraction fpeak\n", "ns = r.RooRealVar(\"# of Ds sig events\",\"# of Ds sig events\",100.,0.,40000.)\n", "nplus = r.RooRealVar(\"# of Dplus sig events\",\"# of Dplus sig events\",100.,0.,40000.)\n", "nbkg = r.RooRealVar(\"# of bkg events\",\"# of bkg events\",100.,0.,40000.)\n", "# sigpeak(x) = fpeak*sig(x) + (1-fpeak)*bkg(x)\n", "model = r.RooAddPdf(\"model\",\"two mass peaks\",r.RooArgList(sig_ds,sig_dplus,bkg),r.RooArgList(ns,nplus,nbkg))\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "model.fitTo(data_hist,r.RooFit.Extended())\n", "\n", "\n", "\n", "xframe = m.frame(r.RooFit.Title(\"Fit to \"+l_flv[l_index]+\" data\"))\n", "\n", "bkg_component = r.RooArgSet(bkg)\n", "data_hist.plotOn(xframe)\n", "model.plotOn(xframe,r.RooFit.Components(bkg_component),r.RooFit.LineStyle(2))\n", "model.plotOn(xframe)\n", "#sigpeaks.plotOn(xframe)\n", "xframe.Draw()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "NB=nbkg.getVal()\n", "NS=ns.getVal()\n", "Nplus=nplus.getVal()\n", "\n", "Nsig_from_MC=5881+9639" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "112.05993156721254" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(Nsig_from_MC)/np.sqrt(NB+Nsig_from_MC)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (<ipython-input-14-c949510cd7b7>, line 1)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"<ipython-input-14-c949510cd7b7>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m NS+\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "source": [ "NS+" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.15" } }, "nbformat": 4, "nbformat_minor": 2 }