{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import uproot\n",
    "import numpy as np\n",
    "import sys\n",
    "import os\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "from mpl_toolkits import mplot3d\n",
    "import itertools\n",
    "import awkward as ak\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n#cut \\ntcut = ((tracked[\"eta\"]<5.0) & (tracked[\"eta\"]>1.9))\\nlcut = ((lost[\"eta\"]<5.0) & (lost[\"eta\"]>1.9))\\n\\ntracked = tracked[tcut]\\nlost = lost[lcut]\\n'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#file = uproot.open(\"tracking_losses_ntuple_Bd2KstEE.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\")\n",
    "file = uproot.open(\"tracking_losses_ntuple_Dst0ToD0EE.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\")\n",
    "\n",
    "\n",
    "\"\"\"\n",
    "#file.keys()\n",
    "#file.show()\n",
    "vertices = file.arrays([\"all_endvtx_x\", \"all_endvtx_y\", \"all_endvtx_z\"])\n",
    "vt_length = file.arrays([\"all_endvtx_x_length\", \"all_endvtx_y_length\", \"all_endvtx_z_length\"])\n",
    "vert_len = vt_length[\"all_endvtx_x_length\"]\n",
    "\n",
    "vtx = vertices[\"all_endvtx_x\"]\n",
    "vty = vertices[\"all_endvtx_y\"]\n",
    "vtz = vertices[\"all_endvtx_z\"]\n",
    "\n",
    "isElectron = file[\"isElectron\"].array()\n",
    "lost = file[\"lost_in_track_fit\"].array()\n",
    "\n",
    "fromPairProd = file[\"fromPairProd\"].array()\n",
    "\n",
    "#vt_length[\"all_endvtx_y_length\"]\n",
    "#vertices\n",
    "\n",
    "#array[array.isElectron]\n",
    "\"\"\"\n",
    "\n",
    "allcolumns = file.arrays()\n",
    "tracked = allcolumns[(allcolumns.isElectron) & (~allcolumns.lost)] #D: 42422\n",
    "lost = allcolumns[(allcolumns.isElectron) & (allcolumns.lost)] #D: 27072\n",
    "\n",
    "#n_cuts = []\n",
    "#n_cuts.append(ak.num(allcolumns, axis=0))\n",
    "\n",
    "\"\"\"\n",
    "#cut \n",
    "tcut = ((tracked[\"eta\"]<5.0) & (tracked[\"eta\"]>1.9))\n",
    "lcut = ((lost[\"eta\"]<5.0) & (lost[\"eta\"]>1.9))\n",
    "\n",
    "tracked = tracked[tcut]\n",
    "lost = lost[lcut]\n",
    "\"\"\"\n",
    "\n",
    "#n_cuts.append(ak.num(tracked, axis=0) + ak.num(lost, axis=0))\n",
    "\n",
    "#~ := logical not \n",
    "#allc_isE= allcolumns[(~allcolumns.isElectron) & (bool 2)]\n",
    "\n",
    "#ak.num(lost, axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#CutFlow\n",
    "decay=\"D\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20676 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "colors = ['blue', 'darkorange']\n",
    "labels = [\"tracked\", \"lost\"]\n",
    "#ak.num(ctracked, axis=0)\n",
    "\n",
    "plt.hist(ak.ravel(tracked[\"eta\"]), bins=100, density=True, alpha=0.4, label=\"tracked\")\n",
    "plt.hist(ak.ravel(lost[\"eta\"]), bins =100, density=True, alpha=0.4, label=\"lost\")\n",
    "plt.legend()\n",
    "plt.xlabel(\"eta\")\n",
    "plt.title(\"$\\eta$ for tracked and lost electrons in the \"+str(decay)+\" decay\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 86184 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#vtx[particle][index of vertex]\n",
    "\n",
    "vtx_x = ak.ravel(allcolumns.all_endvtx_x)\n",
    "vtx_y = ak.ravel(allcolumns.all_endvtx_y)\n",
    "vtx_z = ak.ravel(allcolumns.all_endvtx_z)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(projection='3d')\n",
    "\n",
    "ax.scatter(vtx_x, vtx_y, vtx_z, marker=\".\", s=1)\n",
    "\n",
    "ax.set_xlabel('X')\n",
    "ax.set_ylabel('Y')\n",
    "ax.set_zlabel('Z')\n",
    "ax.view_init(15, 35)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 93204 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#create an array with all electron indices\n",
    "electron = allcolumns[(allcolumns.isElectron)]\n",
    "#electron.show()\n",
    "#electron_ind = electron[electron.]\n",
    "#electron_ind = electron_ind.to_numpy()\n",
    "e_vtx_x = ak.ravel(electron.all_endvtx_x)\n",
    "e_vtx_y = ak.ravel(electron.all_endvtx_y)\n",
    "e_vtx_z = ak.ravel(electron.all_endvtx_z)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(projection='3d')\n",
    "\n",
    "ax.scatter(e_vtx_x, e_vtx_y, e_vtx_z, marker=\".\", s=1)\n",
    "\n",
    "ax.set_xlabel('X')\n",
    "ax.set_ylabel('Y')\n",
    "ax.set_zlabel('Z')\n",
    "ax.view_init(15, 35)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 128144 characters]",
      "text/plain": [
       "<Figure size 4000x2000 with 6 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ((ax0, ax1, ax2), (ax3, ax4, ax5)) = plt.subplots(nrows=2, ncols=3, figsize=(40,20))\n",
    "\n",
    "colors = ['blue', 'darkorange']\n",
    "labels = [\"tracked\", \"lost\"]\n",
    "\n",
    "ax0.hist([ak.ravel(tracked[\"energy\"]),ak.ravel(lost[\"energy\"])], 1000, density=True,alpha=0.5, histtype=\"stepfilled\", color=colors, label=labels)\n",
    "ax0.legend()\n",
    "ax0.set_xlim(0,40000)\n",
    "ax0.set_title('energy '+str(decay)+\" decay\")\n",
    "\n",
    "ax1.hist([ak.ravel(tracked[\"eta\"]), ak.ravel(lost[\"eta\"])], bins=100,alpha=0.5, histtype=\"stepfilled\", density=True, color=colors, label=labels)\n",
    "ax1.legend()\n",
    "ax1.set_title('eta')\n",
    "\n",
    "ax2.hist([ak.ravel(tracked[\"p\"]),ak.ravel(lost[\"p\"])], 500, density=True, alpha=0.5, histtype=\"stepfilled\", color=colors, label=labels)\n",
    "ax2.legend()\n",
    "ax2.set_xlim(0,50000)\n",
    "ax2.set_title('p')\n",
    "\n",
    "ax3.hist([ak.ravel(tracked[\"pt\"]),ak.ravel(lost[\"pt\"])], 500, density=True, alpha=0.5, histtype=\"stepfilled\", color=colors, label=labels)\n",
    "ax3.legend()\n",
    "ax3.set_xlim(0,3000)\n",
    "ax3.set_title('pt')\n",
    "\n",
    "ax4.hist([ak.ravel(tracked[\"tx\"]),ak.ravel(lost[\"tx\"])], 100, density=True, alpha=0.5, histtype=\"stepfilled\", color=colors, label=labels)\n",
    "ax4.legend()\n",
    "ax4.set_title('tx')\n",
    "\n",
    "ax5.hist([ak.ravel(tracked[\"ty\"]),ak.ravel(lost[\"ty\"])], 100, density=True, alpha=0.5, histtype=\"stepfilled\", color=colors, label=labels)\n",
    "ax5.legend()\n",
    "ax5.set_title('ty')\n",
    "\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 186148 characters]",
      "text/plain": [
       "<Figure size 4500x3000 with 9 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ((ax0, ax1, ax2), (ax3, ax4, ax5), (ax6, ax7, ax8)) = plt.subplots(nrows=3, ncols=3, figsize=(45,30))\n",
    "\n",
    "colors = ['blue', 'darkorange']\n",
    "labels = [\"tracked\", \"lost\"]\n",
    "n_bins=75\n",
    "\n",
    "ax0.hist([ak.ravel(tracked[\"velo_hit_pos_x\"]),ak.ravel(lost[\"velo_hit_pos_x\"])], n_bins, density=True, alpha=0.5, histtype=\"stepfilled\", color=colors, label=labels)\n",
    "ax0.legend()\n",
    "ax0.set_title('velo x '+str(decay)+\" decay\")\n",
    "\n",
    "ax1.hist([ak.ravel(tracked[\"velo_hit_pos_y\"]),ak.ravel(lost[\"velo_hit_pos_y\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax1.legend()\n",
    "ax1.set_title('velo y')\n",
    "\n",
    "ax2.hist([ak.ravel(tracked[\"velo_hit_pos_z\"]),ak.ravel(lost[\"velo_hit_pos_z\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax2.legend()\n",
    "ax2.set_title('velo z')\n",
    "\n",
    "ax3.hist([ak.ravel(tracked[\"ut_hit_pos_x\"]),ak.ravel(lost[\"ut_hit_pos_x\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax3.legend()\n",
    "ax3.set_title('ut x')\n",
    "\n",
    "ax4.hist([ak.ravel(tracked[\"ut_hit_pos_y\"]),ak.ravel(lost[\"ut_hit_pos_y\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax4.legend()\n",
    "ax4.set_title('ut y')\n",
    "\n",
    "ax5.hist([ak.ravel(tracked[\"ut_hit_pos_z\"]),ak.ravel(lost[\"ut_hit_pos_z\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax5.legend()\n",
    "ax5.set_title('ut z')\n",
    "\n",
    "ax6.hist([ak.ravel(tracked[\"scifi_hit_pos_x\"]),ak.ravel(lost[\"scifi_hit_pos_x\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax6.legend()\n",
    "ax6.set_title('scifi x')\n",
    "\n",
    "ax7.hist([ak.ravel(tracked[\"scifi_hit_pos_y\"]),ak.ravel(lost[\"scifi_hit_pos_y\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax7.legend()\n",
    "ax7.set_title('scifi y')\n",
    "\n",
    "ax8.hist([ak.ravel(tracked[\"scifi_hit_pos_z\"]),ak.ravel(lost[\"scifi_hit_pos_z\"])], n_bins, density=True, histtype='stepfilled',alpha=0.5, color=colors, label=labels)\n",
    "ax8.legend()\n",
    "ax8.set_title('scifi z')\n",
    "\n",
    "\n",
    "#fig.tight_layout()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 31112 characters]",
      "text/plain": [
       "<Figure size 800x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,6))\n",
    "plt.hist([ak.ravel(tracked[\"brem_photons_pe\"]), ak.ravel(lost[\"brem_photons_pe\"])], 5000, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "plt.xlim(0,8000)\n",
    "plt.xlabel(\"$E_{ph}$\")\n",
    "plt.title(\"brem photons energy \"+str(decay)+\" decay\")\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 127688 characters]",
      "text/plain": [
       "<Figure size 4000x2000 with 6 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ((ax0, ax1, ax2), (ax3, ax4, ax5)) = plt.subplots(nrows=2, ncols=3, figsize=(40,20))\n",
    "\n",
    "colors = ['blue', 'darkorange']\n",
    "labels = [\"tracked\", \"lost\"]\n",
    "n_bins=200\n",
    "\n",
    "ax0.hist([ak.ravel(tracked[\"brem_photons_px\"]),ak.ravel(lost[\"brem_photons_px\"])], 500, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax0.legend()\n",
    "ax0.set_xlim(-1500,1500)\n",
    "ax0.set_title('brem photon px '+str(decay)+\" decay\")\n",
    "\n",
    "ax1.hist([ak.ravel(tracked[\"brem_photons_py\"]),ak.ravel(lost[\"brem_photons_py\"])], 1000, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax1.legend()\n",
    "ax1.set_xlim(-500,500)\n",
    "ax1.set_title('brem photon py')\n",
    "\n",
    "ax2.hist([ak.ravel(tracked[\"brem_photons_pz\"]),ak.ravel(lost[\"brem_photons_pz\"])], 1000, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax2.legend()\n",
    "ax2.set_xlim(0,10000)\n",
    "ax2.set_title('brem photon pz')\n",
    "\n",
    "ax3.hist([ak.ravel(tracked[\"brem_vtx_x\"]),ak.ravel(lost[\"brem_vtx_x\"])], n_bins, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax3.legend()\n",
    "ax3.set_title('brem vtx x')\n",
    "\n",
    "ax4.hist([ak.ravel(tracked[\"brem_vtx_y\"]),ak.ravel(lost[\"brem_vtx_y\"])], n_bins, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax4.legend()\n",
    "ax4.set_title('brem vtx y')\n",
    "\n",
    "ax5.hist([ak.ravel(tracked[\"brem_vtx_z\"]),ak.ravel(lost[\"brem_vtx_z\"])], n_bins, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax5.legend()\n",
    "ax5.set_title('brem vtx z')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38948 characters]",
      "text/plain": [
       "<Figure size 2000x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ((ax0, ax1)) = plt.subplots(nrows=1, ncols=2, figsize=(20,6))\n",
    "\n",
    "ax0.hist([ak.ravel(tracked[\"velo_track_x\"]), ak.ravel(lost[\"velo_track_x\"])], bins=150, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax0.legend()\n",
    "ax0.set_title('velo track x '+str(decay)+\" decay\")\n",
    "\n",
    "ax1.hist([ak.ravel(tracked[\"velo_track_y\"]), ak.ravel(lost[\"velo_track_y\"])],bins=150, density=True, histtype=\"stepfilled\",alpha=0.5, color=colors, label=labels)\n",
    "ax1.legend()\n",
    "ax1.set_title('velo track y')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16840 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"\n",
    "#cut experimentation\n",
    "\n",
    "zcut = (ak.any(tracked[\"velo_hit_pos_z\"]<200, axis=-1) & ak.any(tracked[\"velo_hit_pos_z\"]>-200, axis=-1))\n",
    "zlc = (ak.any(lost[\"velo_hit_pos_z\"]<200, axis=-1) & ak.any(lost[\"velo_hit_pos_z\"]>-200, axis=-1))\n",
    "ztr = tracked[zcut]\n",
    "zlo = lost[zlc]\n",
    "\n",
    "colors = ['blue', 'darkorange']\n",
    "labels = [\"tracked\", \"lost\"]\n",
    "n_bins=200\n",
    "\n",
    "plt.hist([ak.ravel(ztr[\"velo_hit_pos_z\"]),ak.ravel(zlo[\"velo_hit_pos_z\"])], bins=n_bins, density=True, histtype='bar', color=colors, label=labels)\n",
    "plt.legend()\n",
    "plt.title('velo z')\n",
    "plt.show()\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'all_endvtx_types_length': 3,\n",
       " 'all_endvtx_types': [101.0, 104.0, 0.0],\n",
       " 'all_endvtx_x_length': 3,\n",
       " 'all_endvtx_x': [14.989899635314941, 15.055899620056152, 1996.3660888671875],\n",
       " 'all_endvtx_y_length': 3,\n",
       " 'all_endvtx_y': [-30.541900634765625,\n",
       "  -30.669300079345703,\n",
       "  -396.27178955078125],\n",
       " 'all_endvtx_z_length': 3,\n",
       " 'all_endvtx_z': [935.5191040039062, 939.534423828125, 12658.6591796875],\n",
       " 'brem_photons_pe_length': 1,\n",
       " 'brem_photons_pe': [151.66514587402344],\n",
       " 'brem_photons_px_length': 1,\n",
       " 'brem_photons_px': [2.450000047683716],\n",
       " 'brem_photons_py_length': 1,\n",
       " 'brem_photons_py': [-4.78000020980835],\n",
       " 'brem_photons_pz_length': 1,\n",
       " 'brem_photons_pz': [151.57000732421875],\n",
       " 'brem_vtx_x_length': 1,\n",
       " 'brem_vtx_x': [14.989899635314941],\n",
       " 'brem_vtx_y_length': 1,\n",
       " 'brem_vtx_y': [-30.541900634765625],\n",
       " 'brem_vtx_z_length': 1,\n",
       " 'brem_vtx_z': [935.5191040039062],\n",
       " 'endvtx_type': 0,\n",
       " 'endvtx_x': nan,\n",
       " 'endvtx_y': nan,\n",
       " 'endvtx_z': nan,\n",
       " 'energy': 5565.570363846007,\n",
       " 'eta': 4.08326911379515,\n",
       " 'event_count': 0,\n",
       " 'fromB': False,\n",
       " 'fromD': False,\n",
       " 'fromDecay': False,\n",
       " 'fromHadInt': False,\n",
       " 'fromPV': False,\n",
       " 'fromPairProd': True,\n",
       " 'fromSignal': False,\n",
       " 'fromStrange': False,\n",
       " 'isElectron': True,\n",
       " 'isKaon': False,\n",
       " 'isMuon': False,\n",
       " 'isPion': False,\n",
       " 'isProton': False,\n",
       " 'lost': False,\n",
       " 'lost_in_track_fit': False,\n",
       " 'match_fraction': 1.0,\n",
       " 'mcp_idx': 2608,\n",
       " 'mother_id': 22,\n",
       " 'mother_key': 2607,\n",
       " 'originvtx_type': 102,\n",
       " 'originvtx_x': 6.2875000000000005,\n",
       " 'originvtx_y': -13.276200000000001,\n",
       " 'originvtx_z': 385.07070000000004,\n",
       " 'p': 5565.570340387407,\n",
       " 'phi': -1.129423972793533,\n",
       " 'pid': -11,\n",
       " 'pt': 187.531879156585,\n",
       " 'px': 80.11,\n",
       " 'py': -169.56,\n",
       " 'pz': 5562.41,\n",
       " 'scifi_hit_pos_x_length': 12,\n",
       " 'scifi_hit_pos_x': [748.9720458984375,\n",
       "  765.9661254882812,\n",
       "  783.1256103515625,\n",
       "  800.260009765625,\n",
       "  918.012451171875,\n",
       "  935.6343383789062,\n",
       "  953.3908081054688,\n",
       "  971.0899047851562,\n",
       "  1092.497802734375,\n",
       "  1110.47998046875,\n",
       "  1128.590087890625,\n",
       "  1146.6357421875],\n",
       " 'scifi_hit_pos_y_length': 12,\n",
       " 'scifi_hit_pos_y': [-243.1846160888672,\n",
       "  -245.28126525878906,\n",
       "  -247.38218688964844,\n",
       "  -249.4748992919922,\n",
       "  -263.50482177734375,\n",
       "  -265.5829772949219,\n",
       "  -267.6712341308594,\n",
       "  -269.77069091796875,\n",
       "  -284.1728210449219,\n",
       "  -286.2898864746094,\n",
       "  -288.4374694824219,\n",
       "  -290.5879821777344],\n",
       " 'scifi_hit_pos_z_length': 12,\n",
       " 'scifi_hit_pos_z': [7825.2236328125,\n",
       "  7895.0166015625,\n",
       "  7965.20947265625,\n",
       "  8035.00244140625,\n",
       "  8507.150390625,\n",
       "  8576.943359375,\n",
       "  8647.13671875,\n",
       "  8716.9296875,\n",
       "  9192.076171875,\n",
       "  9261.869140625,\n",
       "  9332.0615234375,\n",
       "  9401.8544921875],\n",
       " 'track_p': 5280.022074225443,\n",
       " 'track_pt': 183.50043288509636,\n",
       " 'tx': 0.014402030774430507,\n",
       " 'ty': -0.030483189840374948,\n",
       " 'ut_hit_pos_x_length': 5,\n",
       " 'ut_hit_pos_x': [40.90873718261719,\n",
       "  42.1309814453125,\n",
       "  47.45195007324219,\n",
       "  48.83097457885742,\n",
       "  48.83406066894531],\n",
       " 'ut_hit_pos_y_length': 5,\n",
       " 'ut_hit_pos_y': [-73.33869934082031,\n",
       "  -75.0264892578125,\n",
       "  -81.90847778320312,\n",
       "  -83.59490203857422,\n",
       "  -83.59870147705078],\n",
       " 'ut_hit_pos_z_length': 5,\n",
       " 'ut_hit_pos_z': [2321.846435546875,\n",
       "  2376.846435546875,\n",
       "  2601.846435546875,\n",
       "  2656.765380859375,\n",
       "  2656.888916015625],\n",
       " 'velo_hit_pos_x_length': 7,\n",
       " 'velo_hit_pos_x': [6.313237190246582,\n",
       "  6.5126190185546875,\n",
       "  7.8375444412231445,\n",
       "  9.391555786132812,\n",
       "  10.16195011138916,\n",
       "  10.950575828552246,\n",
       "  11.7467041015625],\n",
       " 'velo_hit_pos_y_length': 7,\n",
       " 'velo_hit_pos_y': [-13.330745697021484,\n",
       "  -13.751118659973145,\n",
       "  -16.4586124420166,\n",
       "  -19.542583465576172,\n",
       "  -21.095014572143555,\n",
       "  -22.661531448364258,\n",
       "  -24.2331485748291],\n",
       " 'velo_hit_pos_z_length': 7,\n",
       " 'velo_hit_pos_z': [386.8590087890625,\n",
       "  400.6409912109375,\n",
       "  486.8590087890625,\n",
       "  586.8590087890625,\n",
       "  636.8590087890625,\n",
       "  686.8590087890625,\n",
       "  736.8590087890625],\n",
       " 'velo_track_idx': 17,\n",
       " 'velo_track_tx': 0.015615668147802353,\n",
       " 'velo_track_ty': -0.03123132698237896,\n",
       " 'velo_track_x': 12.28200912475586,\n",
       " 'velo_track_y': -25.28349494934082,\n",
       " 'velo_track_z': 770.0}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tracked[1].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'lost' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m/work/cetin/Projektpraktikum/wetest.ipynb Cell 16\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2Blhcba1.physi.uni-heidelberg.de/work/cetin/Projektpraktikum/wetest.ipynb#X21sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m lost[\u001b[39m1\u001b[39m]\u001b[39m.\u001b[39mtolist()\n",
      "\u001b[0;31mNameError\u001b[0m: name 'lost' is not defined"
     ]
    }
   ],
   "source": [
    "lost[1].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name                 | typename                 | interpretation                \n",
      "---------------------+--------------------------+-------------------------------\n",
      "all_endvtx_types_... | int32_t                  | AsDtype('>i4')\n",
      "all_endvtx_types     | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "all_endvtx_x_length  | int32_t                  | AsDtype('>i4')\n",
      "all_endvtx_x         | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "all_endvtx_y_length  | int32_t                  | AsDtype('>i4')\n",
      "all_endvtx_y         | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "all_endvtx_z_length  | int32_t                  | AsDtype('>i4')\n",
      "all_endvtx_z         | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_photons_pe_l... | int32_t                  | AsDtype('>i4')\n",
      "brem_photons_pe      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_photons_px_l... | int32_t                  | AsDtype('>i4')\n",
      "brem_photons_px      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_photons_py_l... | int32_t                  | AsDtype('>i4')\n",
      "brem_photons_py      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_photons_pz_l... | int32_t                  | AsDtype('>i4')\n",
      "brem_photons_pz      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_vtx_x_length    | int32_t                  | AsDtype('>i4')\n",
      "brem_vtx_x           | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_vtx_y_length    | int32_t                  | AsDtype('>i4')\n",
      "brem_vtx_y           | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "brem_vtx_z_length    | int32_t                  | AsDtype('>i4')\n",
      "brem_vtx_z           | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "endvtx_type          | int32_t                  | AsDtype('>i4')\n",
      "endvtx_x             | double                   | AsDtype('>f8')\n",
      "endvtx_y             | double                   | AsDtype('>f8')\n",
      "endvtx_z             | double                   | AsDtype('>f8')\n",
      "energy               | double                   | AsDtype('>f8')\n",
      "eta                  | double                   | AsDtype('>f8')\n",
      "event_count          | int32_t                  | AsDtype('>i4')\n",
      "fromB                | bool                     | AsDtype('bool')\n",
      "fromD                | bool                     | AsDtype('bool')\n",
      "fromDecay            | bool                     | AsDtype('bool')\n",
      "fromHadInt           | bool                     | AsDtype('bool')\n",
      "fromPV               | bool                     | AsDtype('bool')\n",
      "fromPairProd         | bool                     | AsDtype('bool')\n",
      "fromSignal           | bool                     | AsDtype('bool')\n",
      "fromStrange          | bool                     | AsDtype('bool')\n",
      "isElectron           | bool                     | AsDtype('bool')\n",
      "isKaon               | bool                     | AsDtype('bool')\n",
      "isMuon               | bool                     | AsDtype('bool')\n",
      "isPion               | bool                     | AsDtype('bool')\n",
      "isProton             | bool                     | AsDtype('bool')\n",
      "lost                 | bool                     | AsDtype('bool')\n",
      "lost_in_track_fit    | bool                     | AsDtype('bool')\n",
      "match_fraction       | float                    | AsDtype('>f4')\n",
      "mcp_idx              | int32_t                  | AsDtype('>i4')\n",
      "mother_id            | int32_t                  | AsDtype('>i4')\n",
      "mother_key           | int32_t                  | AsDtype('>i4')\n",
      "originvtx_type       | int32_t                  | AsDtype('>i4')\n",
      "originvtx_x          | double                   | AsDtype('>f8')\n",
      "originvtx_y          | double                   | AsDtype('>f8')\n",
      "originvtx_z          | double                   | AsDtype('>f8')\n",
      "p                    | double                   | AsDtype('>f8')\n",
      "phi                  | double                   | AsDtype('>f8')\n",
      "pid                  | int32_t                  | AsDtype('>i4')\n",
      "pt                   | double                   | AsDtype('>f8')\n",
      "px                   | double                   | AsDtype('>f8')\n",
      "py                   | double                   | AsDtype('>f8')\n",
      "pz                   | double                   | AsDtype('>f8')\n",
      "scifi_hit_pos_x_l... | int32_t                  | AsDtype('>i4')\n",
      "scifi_hit_pos_x      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "scifi_hit_pos_y_l... | int32_t                  | AsDtype('>i4')\n",
      "scifi_hit_pos_y      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "scifi_hit_pos_z_l... | int32_t                  | AsDtype('>i4')\n",
      "scifi_hit_pos_z      | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "track_p              | double                   | AsDtype('>f8')\n",
      "track_pt             | double                   | AsDtype('>f8')\n",
      "tx                   | double                   | AsDtype('>f8')\n",
      "ty                   | double                   | AsDtype('>f8')\n",
      "ut_hit_pos_x_length  | int32_t                  | AsDtype('>i4')\n",
      "ut_hit_pos_x         | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "ut_hit_pos_y_length  | int32_t                  | AsDtype('>i4')\n",
      "ut_hit_pos_y         | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "ut_hit_pos_z_length  | int32_t                  | AsDtype('>i4')\n",
      "ut_hit_pos_z         | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "velo_hit_pos_x_le... | int32_t                  | AsDtype('>i4')\n",
      "velo_hit_pos_x       | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "velo_hit_pos_y_le... | int32_t                  | AsDtype('>i4')\n",
      "velo_hit_pos_y       | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "velo_hit_pos_z_le... | int32_t                  | AsDtype('>i4')\n",
      "velo_hit_pos_z       | float[]                  | AsJagged(AsDtype('>f4'))\n",
      "velo_track_idx       | int32_t                  | AsDtype('>i4')\n",
      "velo_track_tx        | double                   | AsDtype('>f8')\n",
      "velo_track_ty        | double                   | AsDtype('>f8')\n",
      "velo_track_x         | double                   | AsDtype('>f8')\n",
      "velo_track_y         | double                   | AsDtype('>f8')\n",
      "velo_track_z         | double                   | AsDtype('>f8')\n"
     ]
    }
   ],
   "source": [
    "file.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\nvar=\"energy\"\\n#plt.hist(tracked[var], bins=1000, label=\"tracked\",edgecolor=\"blue\", fill=False, density=True)\\n#plt.hist(lost[var], bins=1000, label=\"lost\",edgecolor=\"darkorange\", fill=False, density=True)\\nplt.hist([tracked[var], lost[var]],bins=1000,label=[\"tracked\", \"lost\"], density=True)\\nplt.title(var)\\nplt.xlim([0,40000])\\nplt.xlabel(var+\" [MeV]\")\\nplt.ylabel(\"scaled\")\\nplt.legend()\\nplt.show()\\n\\nvar=\"eta\"\\nplt.hist(tracked[var], bins=100, label=\"tracked\", edgecolor=\"blue\", fill=False, density=True)\\nplt.hist(lost[var], bins=100, label=\"lost\", edgecolor=\"orange\", fill=False, density=True)\\n#plt.hist([tracked[var], lost[var]],bins=150,label=[\"tracked\", \"lost\"], density=True)\\nplt.title(var)\\nplt.xlabel(var)\\nplt.ylabel(\"scaled\")\\nplt.legend()\\nplt.show()\\n\\nvar=\"p\"\\n#plt.hist(tracked[var], bins=100, label=\"tracked\")\\n#plt.hist(lost[var], bins=100, label=\"lost\")\\nplt.hist([tracked[var], lost[var]],bins=200,label=[\"tracked\", \"lost\"], density=True)\\nplt.title(var)\\nplt.xlabel(var+f\" [MeV/$c^2$]\")\\nplt.ylabel(\"scaled\")\\nplt.xlim([0,150000])\\nplt.legend()\\nplt.show()\\n\\nvar=\"pt\"\\n#plt.hist(tracked[var], bins=200, label=\"tracked\",density=True)\\n#plt.hist(lost[var], bins=200, label=\"lost\", density=True)\\nplt.hist([tracked[var], lost[var]],bins=200,label=[\"tracked\", \"lost\"], density=True)\\nplt.title(var)\\nplt.xlabel(f\"p transversal [MeV/$c^2$]\")\\nplt.ylabel(\"counts\")\\nplt.xlim([0,6000])\\nplt.legend()\\nplt.show()\\n\\nvar=\"tx\"\\n#plt.hist(tracked[var], bins=100, label=\"tracked\")\\n#plt.hist(lost[var], bins=100, label=\"lost\")\\nplt.hist([tracked[var], lost[var]],bins=100,label=[\"tracked\", \"lost\"], density=True)\\nplt.title(var)\\nplt.xlabel(f\"tx [MeV/$c^2$]\")\\nplt.ylabel(\"counts\")\\n#plt.xlim([0,6000])\\nplt.legend()\\nplt.show()\\n\\nvar=\"ty\"\\n#plt.hist(tracked[var], bins=100, label=\"tracked\")\\n#plt.hist(lost[var], bins=100, label=\"lost\")\\nplt.hist([tracked[var], lost[var]],bins=100,label=[\"tracked\", \"lost\"], density=True)\\nplt.title(var)\\nplt.xlabel(f\"ty [MeV/$c^2$]\")\\nplt.ylabel(\"counts\")\\n#plt.xlim([0,6000])\\nplt.legend()\\nplt.show()\\n'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"\n",
    "var=\"energy\"\n",
    "#plt.hist(tracked[var], bins=1000, label=\"tracked\",edgecolor=\"blue\", fill=False, density=True)\n",
    "#plt.hist(lost[var], bins=1000, label=\"lost\",edgecolor=\"darkorange\", fill=False, density=True)\n",
    "plt.hist([tracked[var], lost[var]],bins=1000,label=[\"tracked\", \"lost\"], density=True)\n",
    "plt.title(var)\n",
    "plt.xlim([0,40000])\n",
    "plt.xlabel(var+\" [MeV]\")\n",
    "plt.ylabel(\"scaled\")\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "var=\"eta\"\n",
    "plt.hist(tracked[var], bins=100, label=\"tracked\", edgecolor=\"blue\", fill=False, density=True)\n",
    "plt.hist(lost[var], bins=100, label=\"lost\", edgecolor=\"orange\", fill=False, density=True)\n",
    "#plt.hist([tracked[var], lost[var]],bins=150,label=[\"tracked\", \"lost\"], density=True)\n",
    "plt.title(var)\n",
    "plt.xlabel(var)\n",
    "plt.ylabel(\"scaled\")\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "var=\"p\"\n",
    "#plt.hist(tracked[var], bins=100, label=\"tracked\")\n",
    "#plt.hist(lost[var], bins=100, label=\"lost\")\n",
    "plt.hist([tracked[var], lost[var]],bins=200,label=[\"tracked\", \"lost\"], density=True)\n",
    "plt.title(var)\n",
    "plt.xlabel(var+f\" [MeV/$c^2$]\")\n",
    "plt.ylabel(\"scaled\")\n",
    "plt.xlim([0,150000])\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "var=\"pt\"\n",
    "#plt.hist(tracked[var], bins=200, label=\"tracked\",density=True)\n",
    "#plt.hist(lost[var], bins=200, label=\"lost\", density=True)\n",
    "plt.hist([tracked[var], lost[var]],bins=200,label=[\"tracked\", \"lost\"], density=True)\n",
    "plt.title(var)\n",
    "plt.xlabel(f\"p transversal [MeV/$c^2$]\")\n",
    "plt.ylabel(\"counts\")\n",
    "plt.xlim([0,6000])\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "var=\"tx\"\n",
    "#plt.hist(tracked[var], bins=100, label=\"tracked\")\n",
    "#plt.hist(lost[var], bins=100, label=\"lost\")\n",
    "plt.hist([tracked[var], lost[var]],bins=100,label=[\"tracked\", \"lost\"], density=True)\n",
    "plt.title(var)\n",
    "plt.xlabel(f\"tx [MeV/$c^2$]\")\n",
    "plt.ylabel(\"counts\")\n",
    "#plt.xlim([0,6000])\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\n",
    "var=\"ty\"\n",
    "#plt.hist(tracked[var], bins=100, label=\"tracked\")\n",
    "#plt.hist(lost[var], bins=100, label=\"lost\")\n",
    "plt.hist([tracked[var], lost[var]],bins=100,label=[\"tracked\", \"lost\"], density=True)\n",
    "plt.title(var)\n",
    "plt.xlabel(f\"ty [MeV/$c^2$]\")\n",
    "plt.ylabel(\"counts\")\n",
    "#plt.xlim([0,6000])\n",
    "plt.legend()\n",
    "plt.show()\n",
    "\"\"\""
   ]
  }
 ],
 "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.11.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
