Newer
Older
Rphipi_new / 1_MC_preselection.ipynb
@Davide Lancierini Davide Lancierini on 28 May 2019 37 KB first commit
{
 "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 numpy as np\n",
    "import root_numpy as rn\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "\n",
    "from tools.data_processing import *\n",
    "from tools.kinematics_fix import *\n",
    "from tools.preselector import *\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "l_index = 0\n",
    "mother_index = None\n",
    "data_index = 0\n",
    "n_cats=6\n",
    "apply_phi_mass_cut = True\n",
    "data_type = ['MC','data']\n",
    "mother_ID=['Dplus','Ds']\n",
    "l_flv = ['e','mu']\n",
    "PATH='/disk/lhcb_data/davide/Rphipi_new/'\n",
    "\n",
    "save_path_presel_Dplus= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/presel/'+mother_ID[0]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "save_path_presel_Ds= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/presel/'+mother_ID[1]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "\n",
    "save_path_truthed_Dplus= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/truthed/'+mother_ID[0]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "save_path_ghosts_Dplus= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/ghosts/'+mother_ID[0]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "save_path_truthed_Ds= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/truthed/'+mother_ID[1]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "save_path_ghosts_Ds= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/truthed/'+mother_ID[1]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "\n",
    "save_path_trigged_Dplus = PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/trigged/'+mother_ID[0]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "save_path_trigged_Ds= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/trigged/'+mother_ID[1]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "\n",
    "save_path_trigCats_Dplus= save_path_trigged_Dplus+'trigCats/'\n",
    "save_path_trigCats_Ds= save_path_trigged_Ds+'trigCats/'\n",
    "\n",
    "save_path_BDT_for_Dplus= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/for_BDT_training/'+mother_ID[0]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'\n",
    "save_path_BDT_for_Ds= PATH+data_type[data_index]+'/'+l_flv[l_index]+'_tuples/for_BDT_training/'+mother_ID[1]+'_phipi_'+l_flv[l_index]+l_flv[l_index]+'/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#retrieve files\n",
    "\n",
    "def find_file_path(l_index=l_index, mother_index=mother_index): \n",
    "    return \"/disk/lhcb_data/davide/Rphipi/MC/\"+mother_ID[mother_index]+\"_phipi_\"+l_flv[l_index]+l_flv[l_index]+\"/\"+mother_ID[mother_index]+\"_phipi_\"+l_flv[l_index]+l_flv[l_index]+\".root\"\n",
    "\n",
    "MC_Dplus = r.TFile(find_file_path(l_index=l_index, mother_index=0))\n",
    "MC_Ds = r.TFile(find_file_path(l_index=l_index, mother_index=1))\n",
    "\n",
    "tree_name_Dplus = mother_ID[0]+'_OfflineTree/DecayTree'\n",
    "tree_name_Ds = mother_ID[1]+'_OfflineTree/DecayTree'\n",
    "\n",
    "t_MC_Dplus = MC_Dplus.Get(tree_name_Dplus)\n",
    "t_MC_Ds = MC_Ds.Get(tree_name_Ds)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Converting tuples to dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Switch on only the branches that you need\n",
    "t_MC_Dplus.SetBranchStatus(\"*\",0)\n",
    "\n",
    "for branch in return_branches(data_index=data_index, mother_index=0, l_index=l_index):\n",
    "    if branch!='cos_thetal':\n",
    "        t_MC_Dplus.SetBranchStatus(branch, 1)\n",
    "    \n",
    "MC_Dplus_tuple_dict_presel = {}\n",
    "branches_needed=return_branches(data_index=data_index, mother_index=0, l_index=l_index)\n",
    "\n",
    "for branch in branches_needed:\n",
    "    if branch!='cos_thetal':\n",
    "        MC_Dplus_tuple_dict_presel[branch] = rn.root2array(\n",
    "            \n",
    "            filenames= find_file_path(l_index=l_index, mother_index=0),\n",
    "            treename = tree_name_Dplus,\n",
    "            branches = branch,\n",
    "            start=0,\n",
    "            stop=t_MC_Dplus.GetEntries(),\n",
    "        )\n",
    "    \n",
    "t_MC_Ds.SetBranchStatus(\"*\",0)\n",
    "    \n",
    "for branch in return_branches(data_index=data_index, mother_index=1, l_index=l_index):\n",
    "    if branch!='cos_thetal':\n",
    "        t_MC_Ds.SetBranchStatus(branch, 1)\n",
    "\n",
    "MC_Ds_tuple_dict_presel = {}\n",
    "branches_needed=return_branches(data_index=data_index, mother_index=1, l_index=l_index)\n",
    "for branch in branches_needed:\n",
    "    if branch!='cos_thetal':\n",
    "        MC_Ds_tuple_dict_presel[branch] = rn.root2array(\n",
    "            \n",
    "            filenames=find_file_path(l_index=l_index, mother_index=1),\n",
    "            treename = tree_name_Ds,\n",
    "            branches = branch,\n",
    "            start=0,\n",
    "            stop=t_MC_Ds.GetEntries(),\n",
    "        )    \n",
    "\n",
    "\n",
    "MC_Dplus_tuple_dict_presel= fix_mass_vector(MC_Dplus_tuple_dict_presel, 'Dplus_ConsD_M')\n",
    "MC_Ds_tuple_dict_presel = fix_mass_vector(MC_Ds_tuple_dict_presel, 'Ds_ConsD_M')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Add Cos_thetal branch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "costheta_Dplus=get_costheta_list(MC_Dplus_tuple_dict_presel, l_index=l_index, mother_index=0)\n",
    "costheta_Ds=get_costheta_list(MC_Ds_tuple_dict_presel, l_index=l_index, mother_index=1)\n",
    "\n",
    "MC_Dplus_tuple_dict_presel[\"cos_thetal\"]=costheta_Dplus\n",
    "MC_Ds_tuple_dict_presel[\"cos_thetal\"]=costheta_Ds\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Save the tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "presel\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/presel/Dplus_phipi_ee/Dplus_phipi_ee_presel.pickle\n",
      "presel\n",
      "Saving root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/presel/Ds_phipi_ee/Dplus_phipi_ee_presel.root\n",
      "presel\n",
      "Saving pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/presel/Dplus_phipi_ee/Ds_phipi_ee_presel.pickle\n",
      "presel\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/presel/Ds_phipi_ee/Ds_phipi_ee_presel.root\n"
     ]
    }
   ],
   "source": [
    "save_tuples(locals(), MC_Dplus_tuple_dict_presel, l_index, save_path_presel_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_presel, l_index, save_path_presel_Ds, file_format='root')\n",
    "\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_presel, l_index, save_path_presel_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_presel, l_index, save_path_presel_Ds, file_format='root')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Truthmatching and saving the tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "truthed\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/truthed/Dplus_phipi_ee/Dplus_phipi_ee_truthed.pickle\n",
      "truthed\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/truthed/Dplus_phipi_ee/Dplus_phipi_ee_truthed.root\n",
      "ghosts\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/ghosts/Dplus_phipi_ee/Dplus_phipi_ee_ghosts.pickle\n",
      "ghosts\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/ghosts/Dplus_phipi_ee/Dplus_phipi_ee_ghosts.root\n",
      "truthed\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/truthed/Ds_phipi_ee/Ds_phipi_ee_truthed.pickle\n",
      "truthed\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/truthed/Ds_phipi_ee/Ds_phipi_ee_truthed.root\n",
      "ghosts\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/truthed/Ds_phipi_ee/Ds_phipi_ee_ghosts.pickle\n",
      "ghosts\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/truthed/Ds_phipi_ee/Ds_phipi_ee_ghosts.root\n"
     ]
    }
   ],
   "source": [
    "\n",
    "MC_Dplus_tuple_dict_truthed = filter_tuple_cond(locals(), MC_Dplus_tuple_dict_presel, l_index, 'Dplus_BKGCAT', cmp_eq, 0)\n",
    "MC_Dplus_tuple_dict_ghosts =filter_tuple_cond(locals(), MC_Dplus_tuple_dict_presel, l_index, 'Dplus_BKGCAT', cmp_eq, 60)\n",
    "\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_truthed, l_index, save_path_truthed_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_truthed, l_index, save_path_truthed_Dplus, file_format='root')\n",
    "\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_ghosts, l_index, save_path_ghosts_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_ghosts, l_index, save_path_ghosts_Dplus, file_format='root')\n",
    "\n",
    "\n",
    "MC_Ds_tuple_dict_truthed = filter_tuple_cond(locals(), MC_Ds_tuple_dict_presel, l_index, 'Ds_BKGCAT', cmp_eq, 0)\n",
    "MC_Ds_tuple_dict_ghosts = filter_tuple_cond(locals(), MC_Ds_tuple_dict_presel, l_index, 'Ds_BKGCAT', cmp_eq, 60)\n",
    "\n",
    "\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_truthed, l_index, save_path_truthed_Ds, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_truthed, l_index, save_path_truthed_Ds, file_format='root')\n",
    "\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_ghosts, l_index, save_path_ghosts_Ds, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_ghosts, l_index, save_path_ghosts_Ds, file_format='root')\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Phi Mass Cut "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "if apply_phi_mass_cut:\n",
    "    \n",
    "    if l_flv[l_index]=='mu':\n",
    "        lower_phi_mass = 990\n",
    "        upper_phi_mass = 1050\n",
    "        \n",
    "    if l_flv[l_index]=='e':\n",
    "        lower_phi_mass = 870\n",
    "        upper_phi_mass = 1110\n",
    "        \n",
    "    MC_Dplus_tuple_dict_truthed =filter_tuple_mass_cut(locals(), MC_Dplus_tuple_dict_truthed, l_index, 'phi_M', lower_bound=lower_phi_mass, upper_bound=upper_phi_mass, cut_kind='inside')\n",
    "    MC_Ds_tuple_dict_truthed =filter_tuple_mass_cut(locals(), MC_Ds_tuple_dict_truthed, l_index, 'phi_M', lower_bound=lower_phi_mass, upper_bound=upper_phi_mass, cut_kind='inside')\n",
    "    \n",
    "#for i in range(20):\n",
    "#    \n",
    "#    upper_cut=np.arange(800+5*i,1100-5*i).max()\n",
    "#    lower_cut=np.arange(800+5*i,1100-5*i).min()\n",
    "#    plt.clf()\n",
    "#    MC_Dplus_tuple_dict_truthed_phi_cut=filter_tuple_mass_cut(globals(), MC_Dplus_tuple_dict_truthed, l_index, 'phi_M', lower_bound=lower_cut, upper_bound=upper_cut)\n",
    "#    plt.hist(MC_Dplus_tuple_dict_truthed_phi_cut['Dplus_ConsD_M'],bins=40);\n",
    "#    plt.savefig('plot_{0}.png'.format(i))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Get Hlt cuts "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hlt1\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/Dplus_phipi_ee_Hlt1.pickle\n",
      "Hlt1\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/Dplus_phipi_ee_Hlt1.root\n",
      "Hlt1\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/Ds_phipi_ee_Hlt1.pickle\n",
      "Hlt1\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/Ds_phipi_ee_Hlt1.root\n",
      "Hlt2\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/Dplus_phipi_ee_Hlt2.pickle\n",
      "Hlt2\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/Dplus_phipi_ee_Hlt2.root\n",
      "Hlt2\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/Ds_phipi_ee_Hlt2.pickle\n",
      "Hlt2\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/Ds_phipi_ee_Hlt2.root\n",
      "FullHlt\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/Dplus_phipi_ee_FullHlt.pickle\n",
      "FullHlt\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/Dplus_phipi_ee_FullHlt.root\n",
      "FullHlt\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/Ds_phipi_ee_FullHlt.pickle\n",
      "FullHlt\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/Ds_phipi_ee_FullHlt.root\n"
     ]
    }
   ],
   "source": [
    "#Hlt1\n",
    "MC_Dplus_tuple_dict_Hlt1 = filter_tuple_cond(locals(), MC_Dplus_tuple_dict_truthed, l_index, 'Dplus_Hlt1TrackMVADecision_TOS', cmp_eq, True)\n",
    "\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_Hlt1, l_index, save_path_trigged_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_Hlt1, l_index, save_path_trigged_Dplus, file_format='root')\n",
    "\n",
    "MC_Ds_tuple_dict_Hlt1 = filter_tuple_cond(locals(), MC_Ds_tuple_dict_truthed, l_index, 'Ds_Hlt1TrackMVADecision_TOS', cmp_eq, True)\n",
    "\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_Hlt1, l_index, save_path_trigged_Ds, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_Hlt1, l_index, save_path_trigged_Ds, file_format='root')\n",
    "\n",
    "#Hlt2\n",
    "MC_Dplus_tuple_dict_Hlt2 = filter_tuple_cond(locals(), MC_Dplus_tuple_dict_truthed, l_index, \"Dplus_Hlt2RareCharmD2Pi\"+l_flv[l_index].capitalize()+l_flv[l_index].capitalize()+\"OSDecision_TOS\",cmp_eq, True)\n",
    "\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_Hlt2, l_index, save_path_trigged_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_Hlt2, l_index, save_path_trigged_Dplus, file_format='root')\n",
    "\n",
    "MC_Ds_tuple_dict_Hlt2 = filter_tuple_cond(locals(), MC_Ds_tuple_dict_truthed, l_index, \"Ds_Hlt2RareCharmD2Pi\"+l_flv[l_index].capitalize()+l_flv[l_index].capitalize()+\"OSDecision_TOS\",cmp_eq, True)\n",
    "\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_Hlt2, l_index, save_path_trigged_Ds, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_Hlt2, l_index, save_path_trigged_Ds, file_format='root')\n",
    "\n",
    "#FullHlt\n",
    "MC_Dplus_tuple_dict_FullHlt = filter_tuple_cond(locals(), MC_Dplus_tuple_dict_Hlt1, l_index, \"Dplus_Hlt2RareCharmD2Pi\"+l_flv[l_index].capitalize()+l_flv[l_index].capitalize()+\"OSDecision_TOS\",cmp_eq, True)\n",
    "\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_FullHlt, l_index, save_path_trigged_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_FullHlt, l_index, save_path_trigged_Dplus, file_format='root')\n",
    "\n",
    "MC_Ds_tuple_dict_FullHlt = filter_tuple_cond(locals(), MC_Ds_tuple_dict_Hlt1, l_index, \"Ds_Hlt2RareCharmD2Pi\"+l_flv[l_index].capitalize()+l_flv[l_index].capitalize()+\"OSDecision_TOS\",cmp_eq, True)\n",
    "\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_FullHlt, l_index, save_path_trigged_Ds, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_FullHlt, l_index, save_path_trigged_Ds, file_format='root')\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Split in trigger categories\n",
    "\n",
    "    if trig_cat == 0:\n",
    "        #Exclusive L0_Lepton_TOS \n",
    "        \n",
    "    if trig_cat == 1:\n",
    "        #Exclusive L0_Global_TIS\n",
    "        \n",
    "    if trig_cat == 2:\n",
    "        #L0_Lepton_TOS and L0_Global_TIS\n",
    "        \n",
    "    if trig_cat == 3:\n",
    "        #Either L0_Lepton_TOS or L0_Global_TIS\n",
    "        \n",
    "    if trig_cat == 4:\n",
    "        #TOS and TOSandTIS\n",
    "\n",
    "    if trig_cat == 5:\n",
    "        #TIS and TOSandTIS\n",
    "\n",
    "        \n",
    "      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The counts come back\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/0/Dplus_phipi_ee_trigCat0.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/1/Dplus_phipi_ee_trigCat1.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/2/Dplus_phipi_ee_trigCat2.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/3/Dplus_phipi_ee_trigCat3.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/4/Dplus_phipi_ee_trigCat4.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/5/Dplus_phipi_ee_trigCat5.pickle\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/0/Dplus_phipi_ee_trigCat0.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/1/Dplus_phipi_ee_trigCat1.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/2/Dplus_phipi_ee_trigCat2.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/3/Dplus_phipi_ee_trigCat3.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/4/Dplus_phipi_ee_trigCat4.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Dplus_phipi_ee/trigCats/5/Dplus_phipi_ee_trigCat5.root\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/0/Ds_phipi_ee_trigCat0.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/1/Ds_phipi_ee_trigCat1.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/2/Ds_phipi_ee_trigCat2.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/3/Ds_phipi_ee_trigCat3.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/4/Ds_phipi_ee_trigCat4.pickle\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/5/Ds_phipi_ee_trigCat5.pickle\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/0/Ds_phipi_ee_trigCat0.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/1/Ds_phipi_ee_trigCat1.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/2/Ds_phipi_ee_trigCat2.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/3/Ds_phipi_ee_trigCat3.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/4/Ds_phipi_ee_trigCat4.root\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/trigged/Ds_phipi_ee/trigCats/5/Ds_phipi_ee_trigCat5.root\n"
     ]
    }
   ],
   "source": [
    "MC_Dplus_tuple_dict_trigCats = {}\n",
    "MC_Ds_tuple_dict_trigCats = {}\n",
    "\n",
    "for i in range(n_cats):\n",
    "    \n",
    "    MC_Dplus_tuple_dict_trigCats[i] = filter_tuple_L0TrigCat(locals(), MC_Dplus_tuple_dict_FullHlt, l_index, i)\n",
    "    MC_Ds_tuple_dict_trigCats[i] = filter_tuple_L0TrigCat(locals(), MC_Ds_tuple_dict_FullHlt, l_index, i)\n",
    "    \n",
    "n_0=MC_Dplus_tuple_dict_trigCats[0]['Dplus_ConsD_M'].shape[0]\n",
    "n_1=MC_Dplus_tuple_dict_trigCats[1]['Dplus_ConsD_M'].shape[0]\n",
    "n_2=MC_Dplus_tuple_dict_trigCats[2]['Dplus_ConsD_M'].shape[0]\n",
    "n_3=MC_Dplus_tuple_dict_trigCats[3]['Dplus_ConsD_M'].shape[0]\n",
    "n_4=MC_Dplus_tuple_dict_trigCats[4]['Dplus_ConsD_M'].shape[0]\n",
    "n_5=MC_Dplus_tuple_dict_trigCats[5]['Dplus_ConsD_M'].shape[0]\n",
    "\n",
    "sanity_1=np.array_equal([n_0+n_2+n_1==n_3,n_0+n_5==n_3,n_4+n_1==n_3],[True,True,True])\n",
    "\n",
    "n_0=MC_Ds_tuple_dict_trigCats[0]['Ds_ConsD_M'].shape[0]\n",
    "n_1=MC_Ds_tuple_dict_trigCats[1]['Ds_ConsD_M'].shape[0]\n",
    "n_2=MC_Ds_tuple_dict_trigCats[2]['Ds_ConsD_M'].shape[0]\n",
    "n_3=MC_Ds_tuple_dict_trigCats[3]['Ds_ConsD_M'].shape[0]\n",
    "n_4=MC_Ds_tuple_dict_trigCats[4]['Ds_ConsD_M'].shape[0]\n",
    "n_5=MC_Ds_tuple_dict_trigCats[5]['Ds_ConsD_M'].shape[0]\n",
    "\n",
    "sanity_2=np.array_equal([n_0+n_2+n_1==n_3,n_0+n_5==n_3,n_4+n_1==n_3],[True,True,True])\n",
    "if sanity_1 and sanity_2:\n",
    "    print('The counts come back')\n",
    "    \n",
    "    save_tuples(locals(), MC_Dplus_tuple_dict_trigCats, l_index, save_path_trigCats_Dplus, file_format='pickle')\n",
    "    save_tuples(locals(), MC_Dplus_tuple_dict_trigCats, l_index, save_path_trigCats_Dplus, file_format='root')\n",
    "    \n",
    "    save_tuples(locals(), MC_Ds_tuple_dict_trigCats, l_index, save_path_trigCats_Ds, file_format='pickle')\n",
    "    save_tuples(locals(), MC_Ds_tuple_dict_trigCats, l_index, save_path_trigCats_Ds, file_format='root')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Prepare Sig Sets for BDT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "for_BDT\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/for_BDT/Dplus_phipi_ee/Dplus_phipi_ee_for_BDT.pickle\n",
      "for_BDT\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/for_BDT/Dplus_phipi_ee/Dplus_phipi_ee_for_BDT.root\n",
      "for_BDT\n",
      "Overwriting pickle file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/for_BDT/Ds_phipi_ee/Ds_phipi_ee_for_BDT.pickle\n",
      "for_BDT\n",
      "Overwriting root file at/disk/lhcb_data/davide/Rphipi_new/MC/e_tuples/for_BDT/Ds_phipi_ee/Ds_phipi_ee_for_BDT.root\n"
     ]
    }
   ],
   "source": [
    "if l_flv[l_index]=='mu':\n",
    "    \n",
    "    lower_Dplus_mass_mc=1830\n",
    "    upper_Dplus_mass_mc=1910\n",
    "    \n",
    "    lower_Ds_mass_mc=1930\n",
    "    upper_Ds_mass_mc=2010\n",
    "    \n",
    "    \n",
    "if l_flv[l_index]=='e':\n",
    "    \n",
    "    lower_Dplus_mass_mc=1790\n",
    "    upper_Dplus_mass_mc=1950\n",
    "\n",
    "    lower_Ds_mass_mc=1890\n",
    "    upper_Ds_mass_mc=2050\n",
    "    \n",
    "\n",
    "MC_Dplus_tuple_dict_sig_for_BDT = filter_tuple_mass_cut(locals(), MC_Dplus_tuple_dict_FullHlt, l_index, 'Dplus_ConsD_M', lower_bound=lower_Dplus_mass_mc, upper_bound=upper_Dplus_mass_mc, cut_kind='inside')  \n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_sig_for_BDT, l_index, save_path_BDT_for_Dplus, file_format='pickle')\n",
    "save_tuples(locals(), MC_Dplus_tuple_dict_sig_for_BDT, l_index, save_path_BDT_for_Dplus, file_format='root')\n",
    "\n",
    "\n",
    "MC_Ds_tuple_dict_sig_for_BDT = filter_tuple_mass_cut(locals(), MC_Ds_tuple_dict_FullHlt, l_index, 'Ds_ConsD_M', lower_bound=lower_Ds_mass_mc, upper_bound=upper_Ds_mass_mc, cut_kind='inside')  \n",
    "save_tuples(locals(), MC_Ds_tuple_dict_sig_for_BDT, l_index, save_path_BDT_for_Ds, file_format='pickle')\n",
    "save_tuples(locals(), MC_Ds_tuple_dict_sig_for_BDT, l_index, save_path_BDT_for_Ds, file_format='root')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAD8CAYAAACRkhiPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAADkxJREFUeJzt3V+s5OVdx/H3p+1KUqsG2EOb9Ox6Lpo0Goqke0AbtKWKAdlEE7EQdPWCmhVT/1BvKPUCuSDhQjTBmtBNwCoYspGWNqa7Cr1CkibkgHT/sFj/hMIxhT0V03ChBMvXi/Ngx+Uczp+ZOWdmnvcrmcxvnvnNzPPdJzufeX7/TqoKSVKf3rHbHZAk7R5DQJI6ZghIUscMAUnqmCEgSR0zBCSpY4aAJHXMEJCkjhkCktSxd+12BwD27t1bCwsLu90NSZoqTz311Heqam6Y95iIEFhYWGBpaWm3uyF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uG23q8xvZezWLP2JBcmeUdbXmC19n+ZldqT7G33AT7L92dAMz3m69U9S+PdarsPOFNVdw88dQw41JYP8f06ZmLMt1r3yMd8t/eMb2EP+kOsToNeZzXdPglcAXwDeBZ4BvipgfX/kNXtqKdpR9G09sW27rPA52gnzE3ybSu1A7/Saj4JnAI+Ma21r1P3LcBzrba7BmuYlTHfSt0zNt4/DRSrO0afabdrgQuBr7UavwZcMEtjvtW6Rz3mnjEsSR2b9s1BkqQhGAKS1DFDQJI6ZghIUscMAUnqmCEgSR0zBCSpY4aAJHXsfwE7/xiPvXWzDQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.hist(np.concatenate([MC_Dplus_tuple_dict_sig_for_BDT['Dplus_ConsD_M'],MC_Ds_tuple_dict_sig_for_BDT['Ds_ConsD_M']]), bins=70);\n",
    "                         \n",
    "                         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAESNJREFUeJzt3X2MZXddx/H3h1LAloLd9q4NtMuGxDTGtllhGiSolFBi2wUSgrYQlsQsZsEotTUoVKOl0T8wkYegJmR5iHGX1I0FQWEHuoQ0tRox27J0tw+UYIqFtLvTUgtCRB6+/jFnZdjO7D33zr13Zn77fiWT83DPOfc7Z+5+9nd/95zfTVUhSdr4nrLWBUiSJsNAl6RGGOiS1AgDXZIaYaBLUiMMdElqhIEuSY0w0CWpEQa6JDXiqbN8snPPPbe2bt06y6eUpA3vzjvvfLS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Ac/vnvtLLF5F8mf8+EayNT1nLHYdVFffoe7nqmmcs+VeN8BbgLd082Gxm+fero65k+074df+sNo+BDy+5BwdHPa3nWFt1wJHup+7gMtmcd6G1dUt/wbwdyfsN4tzdjPwMPB9FjPtTbN+rXmnqCQ1YqN0uUiShjDQJakRBrokNcJAl6RGGOiS1AgDXZIaYaBLUiMMdElqxP8BfwCDi9wrm3IAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.hist(np.concatenate([MC_Dplus_tuple_dict_sig_for_BDT['cos_thetal'],MC_Ds_tuple_dict_sig_for_BDT['cos_thetal']]), bins=70);"
   ]
  },
  {
   "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
}