diff --git a/.ipynb_checkpoints/bkg_reduction-checkpoint.ipynb b/.ipynb_checkpoints/bkg_reduction-checkpoint.ipynb index e908b54..20f9c4e 100644 --- a/.ipynb_checkpoints/bkg_reduction-checkpoint.ipynb +++ b/.ipynb_checkpoints/bkg_reduction-checkpoint.ipynb @@ -9,21 +9,23 @@ "import ROOT as r\n", "import ctypes\n", "import numpy as np\n", - "from array import array" + "from array import array\n", + "import root_numpy as rn\n", + "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 2, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -34,26 +36,68 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ - "data_mumu = r.TFile(\"/disk/lhcb_data/davide/Rphipi/small/data/Ds_phipi_mumu/Ds_phipi_mumu_MagDown.root\")\n", - "MC_mumu = r.TFile(\"/disk/lhcb_data/davide/Rphipi/MC/Ds_phipi_mumu/Ds_phipi_mumu_MagDown.root\")" + "l_flv = ['ee','mumu']\n", + "data_type = ['MC','data']\n", + "mag_status =['Up','Down'] \n", + "tree_name = 'Ds_OfflineTree/DecayTree'" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "l_index = 1\n", + "mag_index = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "def find_file_path(l_index, type_index, mag_index): \n", + " return \"../Desktop/Ds_phipi/\"+data_type[i]+\"/Ds_phipi_\"+l_flv[j]+\"/Ds_phipi_\"+l_flv[j]+\"_Mag\"+mag_status[k]+\".root\"" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "#def find_file_path(i,j,k): \n", + "# return \"../Desktop/Ds_phipi/\"+data_type[i]+\"/Ds_phipi_\"+l_flv[j]+\"/Ds_phipi_\"+l_flv[j]+\"_\"+mag_status[k]+\".root\"" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [], + "source": [ + "data_mumu = r.TFile(find_file_path(l_index, 'data', mag_index))\n", + "MC_mumu = r.TFile(find_file_path(l_index, 'MC', mag_index))" + ] + }, + { + "cell_type": "code", + "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 7, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -65,16 +109,16 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 9, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -86,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -100,23 +144,103 @@ "t_data_mumu.SetBranchStatus(\"Ds_DIRA_OWNPV\",1)\n", "t_data_mumu.SetBranchStatus(\"Ds_ConsD_M\",1)\n", "\n", - "t_data_mumu.SetBranchStatus(\"Ds_Hlt1Phys_TOS\",1)\n", - "t_data_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\",1)\n", - "#t_data_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2PiMuMuOSDecision_TOS\",1)\n", + "t_data_mumu.SetBranchStatus(\"mu_plus_MC15TuneV1_ProbNNmu\", 1)\n", + "t_data_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\", 1)\n", + "t_data_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2piMuMuOSDecision_TOS\", 1)\n", + "t_data_mumu.SetBranchStatus(\"Ds_Hlt2Phys_TOS\", 1)\n", + "\n", "\n", "t_MC_mumu.SetBranchStatus(\"*\",0)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_CHI2\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_NDOF\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_CHI2\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_NDOF\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_IP_OWNPV\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_IPCHI2_OWNPV\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_DIRA_OWNPV\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_ConsD_M\",1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_CHI2\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_NDOF\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_CHI2\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_NDOF\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_IP_OWNPV\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_IPCHI2_OWNPV\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_DIRA_OWNPV\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_ConsD_M\", 1)\n", "\n", - "t_MC_mumu.SetBranchStatus(\"Ds_Hlt1Phys_TOS\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\",1)\n", - "#t_MC_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2PiMuMuOSDecision_TOS\",1)" + "t_MC_mumu.SetBranchStatus(\"mu_plus_MC15TuneV1_ProbNNmu\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2piMuMuOSDecision_TOS\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_Hlt2Phys_TOS\", 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "branches_needed = [\"Ds_ENDVERTEX_CHI2\",\n", + " \"Ds_ENDVERTEX_NDOF\"] " + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "MC_mumu_tuple = rn.root2array(\n", + " \n", + " filenames=find_file_path(l_index, 'MC', mag_index),\n", + " treename = tree_name,\n", + " branches = [\"Ds_ConsD_M\",\n", + " \"Ds_ENDVERTEX_CHI2\"],\n", + " \n", + " start=0,\n", + " stop=2,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(array([ 1948.43640137], dtype=float32), 0.59739191)" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a[1]" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "for i, event in enumerate(t_data_mumu):\n", + " if i > 1:\n", + " break\n", + " \n", + " print(t_data_mumu.Ds_ConsD_M.)" ] }, { @@ -256,7 +380,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.6.4" } }, "nbformat": 4, diff --git a/bkg_reduction.ipynb b/bkg_reduction.ipynb index e908b54..20f9c4e 100644 --- a/bkg_reduction.ipynb +++ b/bkg_reduction.ipynb @@ -9,21 +9,23 @@ "import ROOT as r\n", "import ctypes\n", "import numpy as np\n", - "from array import array" + "from array import array\n", + "import root_numpy as rn\n", + "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 2, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -34,26 +36,68 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ - "data_mumu = r.TFile(\"/disk/lhcb_data/davide/Rphipi/small/data/Ds_phipi_mumu/Ds_phipi_mumu_MagDown.root\")\n", - "MC_mumu = r.TFile(\"/disk/lhcb_data/davide/Rphipi/MC/Ds_phipi_mumu/Ds_phipi_mumu_MagDown.root\")" + "l_flv = ['ee','mumu']\n", + "data_type = ['MC','data']\n", + "mag_status =['Up','Down'] \n", + "tree_name = 'Ds_OfflineTree/DecayTree'" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "l_index = 1\n", + "mag_index = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "def find_file_path(l_index, type_index, mag_index): \n", + " return \"../Desktop/Ds_phipi/\"+data_type[i]+\"/Ds_phipi_\"+l_flv[j]+\"/Ds_phipi_\"+l_flv[j]+\"_Mag\"+mag_status[k]+\".root\"" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "#def find_file_path(i,j,k): \n", + "# return \"../Desktop/Ds_phipi/\"+data_type[i]+\"/Ds_phipi_\"+l_flv[j]+\"/Ds_phipi_\"+l_flv[j]+\"_\"+mag_status[k]+\".root\"" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [], + "source": [ + "data_mumu = r.TFile(find_file_path(l_index, 'data', mag_index))\n", + "MC_mumu = r.TFile(find_file_path(l_index, 'MC', mag_index))" + ] + }, + { + "cell_type": "code", + "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 7, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -65,16 +109,16 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 9, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -86,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -100,23 +144,103 @@ "t_data_mumu.SetBranchStatus(\"Ds_DIRA_OWNPV\",1)\n", "t_data_mumu.SetBranchStatus(\"Ds_ConsD_M\",1)\n", "\n", - "t_data_mumu.SetBranchStatus(\"Ds_Hlt1Phys_TOS\",1)\n", - "t_data_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\",1)\n", - "#t_data_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2PiMuMuOSDecision_TOS\",1)\n", + "t_data_mumu.SetBranchStatus(\"mu_plus_MC15TuneV1_ProbNNmu\", 1)\n", + "t_data_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\", 1)\n", + "t_data_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2piMuMuOSDecision_TOS\", 1)\n", + "t_data_mumu.SetBranchStatus(\"Ds_Hlt2Phys_TOS\", 1)\n", + "\n", "\n", "t_MC_mumu.SetBranchStatus(\"*\",0)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_CHI2\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_NDOF\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_CHI2\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_NDOF\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_IP_OWNPV\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_IPCHI2_OWNPV\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_DIRA_OWNPV\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_ConsD_M\",1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_CHI2\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_ENDVERTEX_NDOF\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_CHI2\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_OWNPV_NDOF\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_IP_OWNPV\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_IPCHI2_OWNPV\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_DIRA_OWNPV\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_ConsD_M\", 1)\n", "\n", - "t_MC_mumu.SetBranchStatus(\"Ds_Hlt1Phys_TOS\",1)\n", - "t_MC_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\",1)\n", - "#t_MC_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2PiMuMuOSDecision_TOS\",1)" + "t_MC_mumu.SetBranchStatus(\"mu_plus_MC15TuneV1_ProbNNmu\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_Hlt1TrackMVADecision_TOS\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_Hlt2RareCharmD2piMuMuOSDecision_TOS\", 1)\n", + "t_MC_mumu.SetBranchStatus(\"Ds_Hlt2Phys_TOS\", 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "branches_needed = [\"Ds_ENDVERTEX_CHI2\",\n", + " \"Ds_ENDVERTEX_NDOF\"] " + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "MC_mumu_tuple = rn.root2array(\n", + " \n", + " filenames=find_file_path(l_index, 'MC', mag_index),\n", + " treename = tree_name,\n", + " branches = [\"Ds_ConsD_M\",\n", + " \"Ds_ENDVERTEX_CHI2\"],\n", + " \n", + " start=0,\n", + " stop=2,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(array([ 1948.43640137], dtype=float32), 0.59739191)" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a[1]" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n" + ] + } + ], + "source": [ + "for i, event in enumerate(t_data_mumu):\n", + " if i > 1:\n", + " break\n", + " \n", + " print(t_data_mumu.Ds_ConsD_M.)" ] }, { @@ -256,7 +380,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.6.4" } }, "nbformat": 4,