{ "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\n", "from xgboost import XGBClassifier\n", "from tools.data_processing import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "l_flv=['e','mu']\n", "mother_ID=[\"Dplus\",\"Ds\",\"both\"]\n", "PATH='/disk/lhcb_data/davide/Rphipi_new/'\n", "data_type=['MC','data']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "test=1\n", "l_index=1\n", "trigCat=0\n", "data_index=0\n", "\n", "mother_index=0\n", "mis_id_bkg=False\n", "\n", "PATH_BDTs=PATH+'BDT/'+l_flv[l_index]+'/test_'+str(test)+'/'\n", "FIT_PATH=l_flv[l_index]+'_fits/'\n", "MC_PATH = PATH+'MC/'+l_flv[l_index]+'_tuples/trigged/'+mother_ID[mother_index]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/trigCats/'+str(trigCat)+'/'\n", "\n", "workspace_filename='fitAndsPlot_D_phipi_'+l_flv[l_index]+l_flv[l_index]+'_2016_trigCat'+str(trigCat)+'.root'\n", "workspace_path='/home/hep/davide/Rphipi_new/workspaces/'\n", "\n", "names={}\n", "names['m_name']=data_type[data_index]+\"_\"+mother_ID[mother_index]+\"_m\"\n", "\n", "names['mean_D_name']=data_type[data_index]+\"_mean_\"+mother_ID[mother_index]\n", "names['sigma_D_name']=data_type[data_index]+\"_sigma_\"+mother_ID[mother_index]\n", "\n", "names['alpha_left_name']=data_type[data_index]+\"_alpha_\"+mother_ID[mother_index]+\"_left\"\n", "names['n_left_name' ]=data_type[data_index]+\"_n_\"+mother_ID[mother_index]+\"_left\"\n", "names['sig_pdf_left_name' ]=data_type[data_index]+\"_pdf_\"+mother_ID[mother_index]+\"_left\"\n", "\n", "names['alpha_right_name']=data_type[data_index]+\"_alpha_\"+mother_ID[mother_index]+\"_right\"\n", "names['n_right_name'] =data_type[data_index]+\"_n_\"+mother_ID[mother_index]+\"_right\"\n", "names['sig_pdf_right_name'] =data_type[data_index]+\"_pdf_\"+mother_ID[mother_index]+\"_right\"\n", "\n", "names['frac_lr_name']=data_type[data_index]+'_'+mother_ID[mother_index]+\"_lr_fraction\"\n", "names['model_name']=data_type[data_index]+'_'+mother_ID[mother_index]+\"_model\"\n", "names['data_set_name']=data_type[data_index]+'_'+mother_ID[mother_index]+'_ConsD_M'\n", " \n", "if mis_id_bkg:\n", " for key in names:\n", " names[key]=names[key]+'_misID'" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "f = r.TFile(workspace_path+workspace_filename)\n", "w2 = (f.Get(workspace_filename))\n", "\n", "model=w2.pdf(names['model_name'])\n", "data_set=w2.data(names['data_set_name'])\n", "alpha_D_l=w2.var(names['alpha_left_name'])\n", "alpha_D_r=w2.var(names['alpha_right_name'])\n", "n_D_l=w2.var(names['n_left_name'])\n", "n_D_r=w2.var(names['n_right_name'])\n", "frac_D=w2.var(names['frac_lr_name'])\n", "m = w2.var(names['m_name'])\n", "\n", "frame_title=\"Fit to \"+mother_ID[mother_index]+\"_phipi_\"+l_flv[l_index]+l_flv[l_index]+\" MC trigCat\"+str(trigCat)\n", "\n", "if mis_id_bkg: frame_title=frame_title+\" misID\"\n", "xframe = m.frame(r.RooFit.Title(frame_title))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "data_set.plotOn(xframe)\n", "argset=r.RooArgSet(alpha_D_l, alpha_D_r, n_D_l, n_D_r)\n", "model.plotOn(xframe)\n", "model.paramOn(xframe, r.RooFit.Layout(0.6,0.99,0.92), r.RooFit.Parameters(argset),r.RooFit.Format(\"NEU\", r.RooFit.AutoPrecision(1)))\n", "xframe.getAttText().SetTextSize(0.03)\n", "xframe.Draw()" ] }, { "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 }