Newer
Older
HCAL_project / create_reco_images.ipynb
@Davide Lancierini Davide Lancierini on 8 Feb 2019 45 KB Extended to full event conversion
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "\n",
    "import pickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ones_to_zeros(ET_inner_dict, ET_outer_dict):\n",
    "    \n",
    "    for k in range(0,len(ET_inner_dict)):\n",
    "        for i in range(ET_inner_dict[k].shape[0]):\n",
    "            equal_inner = np.array_equal(ET_inner_dict[k][i],np.ones_like(ET_inner_dict[k][i]))\n",
    "            equal_outer = np.array_equal(ET_outer_dict[k][i],np.ones_like(ET_outer_dict[k][i]))\n",
    "            if equal_inner or equal_outer:\n",
    "                ET_inner_dict[k][i]=np.zeros_like(ET_inner_dict[k][i])\n",
    "                ET_outer_dict[k][i]=np.zeros_like(ET_outer_dict[k][i])\n",
    "                \n",
    "    return ET_inner_dict, ET_outer_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def double_size(X_in):\n",
    "\n",
    "    X_out = np.zeros(\n",
    "        shape=(2*X_in.shape[0],2*X_in.shape[1],1),\n",
    "        dtype=np.float32\n",
    "    )\n",
    "    \n",
    "    for i in range(X_in.shape[0]):\n",
    "        for j in range(X_in.shape[1]):\n",
    "            \n",
    "            if X_in[i,j]!=0:\n",
    "                value = X_in[i,j]/4\n",
    "                X_out[2*i,2*j]=value\n",
    "                X_out[2*i+1,2*j]=value\n",
    "                X_out[2*i,2*j+1]=value\n",
    "                X_out[2*i+1,2*j+1]=value\n",
    "    return X_out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def insert(X_inner, X_outer):\n",
    "    X=X_outer\n",
    "    \n",
    "    for i in range(12,40):\n",
    "        for j in range(16,48):\n",
    "            X[i,j]=X_inner[i-12,j-16]\n",
    "    \n",
    "    return X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def generate_HCAL_images(ET_inner_dict, ET_outer_dict):\n",
    "    \n",
    "    output_pics = {}\n",
    "    \n",
    "    pic = np.array(np.zeros(shape=(52,64,1), dtype=np.float32))\n",
    "    \n",
    "    for j in range(len(ET_inner_dict)):\n",
    "        \n",
    "        \n",
    "        output_pics[j]=np.array([pic for i in range(len(ET_inner_dict[j]))])    \n",
    "        \n",
    "    \n",
    "    for j in range(len(ET_inner_dict)):\n",
    "        \n",
    "        for k in range(len(ET_inner_dict[j])):\n",
    "            \n",
    "            ET_image = insert(ET_inner_dict[j][k], double_size(ET_outer_dict[j][k]))\n",
    "            ET_image = np.flip(ET_image, axis = 0)\n",
    "            \n",
    "            output_pics[j][k]= ET_image\n",
    "            \n",
    "        print('Done batch {0}'.format(j+1))\n",
    "                \n",
    "    return output_pics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "ET_inner_dict={}\n",
    "ET_outer_dict={}\n",
    "\n",
    "i=0\n",
    "while os.path.exists('/disk/lhcb_data/davide/HCAL_project_full_event/npy/B2Dmunu_full/ET_inner/batch_'+str(i)+'.npy'):\n",
    "#while i < 2:\n",
    "    ET_inner_dict[i]=np.load('/disk/lhcb_data/davide/HCAL_project_full_event/npy/B2Dmunu_full/ET_inner/batch_'+str(i)+'.npy')\n",
    "    ET_outer_dict[i]=np.load('/disk/lhcb_data/davide/HCAL_project_full_event/npy/B2Dmunu_full/ET_outer/batch_'+str(i)+'.npy')\n",
    "\n",
    "    i+=1\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAzIAAAFZCAYAAABDmRqd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DxO822/VMtxtiZpB3ufrz9+s6vSHqPpH8l6fPufo+Z/aGkb7r7x+eZKwAAszbPV2RukPSEu3/P3UeS7pF0yxzzwWm0F0g7dsrdt0i6u719t9ZPIIu0yfYtBHc/7O7faG+/oPWvRbxKCzB+p9m2heDrjre/Dtp/Luk3JP1xe3+RYwcAwFbNs5C5StIPT/r9kBboBKTlkr5kZl83sz3zTqYDV7j7YWn9hFLS5XPOpwu3m9m32reeFffWq1OZ2TWSXivpES3Y+J2ybdKCjJ2Z9dqv7Dwq6UFJ35X0bHuRMWkx104AAM5onoWMbXDfon2F2o3u/o8kvUnSu9u3L6EcH5d0raRdkg5L+sh809kaM7tA61cWfq+7Pz/vfKZpg21bmLFz99rdd2n9ysg3SHrNRmGzzQoAgPmbZyFzSNLVJ/3+SklPzymXTrj70+3Po5Lu1fpJyCI58uKVadufR+ecz1S5+5H2JLKR9AkVPH7t5ys+J+lT7v759u6FGL+Ntm2Rxu5F7v6spD+T9DpJl5jZixc0Xri1EwCAiHkWMl+TdF377TtDSW+XdP8c85kqM9vRfvhYZrZD0hslHTj9XxXnfkm3tbdvk3TfHHOZuhdP8ltvVaHj135g/E5JB939oyf9V/Hjt9m2LdDYvdzMLmlvb5P0m1r/HNDDkn67DSty7AAA2Kq5XhCz/UrU/yipJ+kud//3c0tmyszs72r9VRhJ6kv6dMnbZ2afkXSTpMskHZH0AUn/TdJnJf0dST+Q9DZ3L/ID85ts301af2uSS3pS0rte/ExJSczsVyX9uaRHJTXt3e/X+mdJih6/02zbrVqMsfuHWv8wf0/rTzx91t3/bbu+3CPpUkl/Kel33H1tfpkCADB7cy1kAAAAAOBszPWCmAAAAABwNihkAAAAABSHQgYAAABAcShkAAAAABSHQgYAAABAcShkAAAAABSHQgYAAABAcShkAAAAABTn/wHUNkKHGljLDAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1008x432 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "mean_inner_ET=np.mean(ET_inner_dict[0], axis=0, keepdims=True).reshape(32,32)\n",
    "plt.subplot(1,2,1)\n",
    "plt.imshow(mean_inner_ET[2:mean_inner_ET.shape[0]-2,0:mean_inner_ET.shape[0]])\n",
    "plt.subplot(1,2,2)\n",
    "mean_outer_ET=np.mean(ET_outer_dict[0], axis=0, keepdims=True).reshape(32,32)\n",
    "plt.imshow(mean_outer_ET[3:mean_outer_ET.shape[0]-3,0:mean_outer_ET.shape[0]])\n",
    "fig = plt.gcf()\n",
    "fig.set_size_inches(14,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "ET_inner_dict, ET_outer_dict = ones_to_zeros(ET_inner_dict, ET_outer_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "#cutting out useless pixels\n",
    "for i in range(len(ET_inner_dict)):\n",
    "    ET_inner_dict[i]=ET_inner_dict[i][:,2:ET_inner_dict[i].shape[1]-2,:]\n",
    "    ET_outer_dict[i]=ET_outer_dict[i][:,3:ET_outer_dict[i].shape[1]-3,:]\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "((20000, 28, 32), (20000, 26, 32))\n"
     ]
    }
   ],
   "source": [
    "#Check cut dict dimensions\n",
    "print(ET_inner_dict[0].shape, ET_outer_dict[0].shape)\n",
    "#is\n",
    "#(?, 28, 32), (?,26, 32)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "def delete_undetected_events(X_inner, X_outer):\n",
    "\n",
    "    pos_rejected={}\n",
    "    \n",
    "    for i in range(len(X_inner)):\n",
    "        pos_rejected[i]=[]\n",
    "        \n",
    "        for j in range(X_inner[i].shape[0]):\n",
    "            \n",
    "            equal_inner = np.array_equal(X_inner[i][j],np.zeros_like(X_inner[i][j]))\n",
    "            equal_outer = np.array_equal(X_outer[i][j],np.zeros_like(X_outer[i][j]))\n",
    "            \n",
    "                \n",
    "    X_inner_filtered={}\n",
    "    X_outer_filtered={}\n",
    "    for i in range(len(X_inner)):\n",
    "    \n",
    "        X_inner_filtered[i]=np.delete(X_inner[i],pos_rejected[i],axis=0)\n",
    "        X_outer_filtered[i]=np.delete(X_outer[i],pos_rejected[i],axis=0)\n",
    "        \n",
    "    return X_inner_filtered, X_outer_filtered"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "ET_inner_filtered, ET_outer_filtered = delete_undetected_events(ET_inner_dict,ET_outer_dict)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f55a0625810>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAACoCAYAAADw6BWzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAE39JREFUeJzt3WuMXdV5xvH/OzZDcSkOrgGNbGgCRRFWRVyBwBVRZZm6cpHAVEqqUNFQCeR8iKWmikhMKjUUqQKaBPqhJSqRERS1BGibABUqtaxYtBIkGS51CJgYLOqMsXwJDhdZYjzM2w9nTzWzz5o56+z73uf5SaOZs7wv75k5Xj5ez6y1zN0REZH2G6u7ABERKYY6dBGRjlCHLiLSEerQRUQ6Qh26iEhHqEMXEekIdegiIh2hDl1EpCNydehmtsXMXjezN8xsR1FFiYjI8CzrTFEzWwb8DNgMTAE/Bm5w91eLK09ERGItz3HuFcAb7n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Vy98Pu/mLy9fvA3KJqbanf3f2D5OFpyYcDm4B/Sdoz1V9Lh+7uTfxLGa3N9be5dmhs/WuAn897PEU7V208b26GbPL53JrrGSi1qFpr6jezZclktqPALuBN4JfuPpMckuk1pCEXkfxCk5Nas/Z/WwUWVWuNZK2g9cBaev/DuyR02LDXrbxDV3hUnTaHR2UGRyWYAs6f93gt8HZNteRxJNn0Y27zj6M117Oo0KJqtKj+Oe7+S2APvSzgY2Y2N3s/02uo0g5d4VHl2hwelRYcleDHwMXJPzbjwOeAJ2uuKYsngZuSr28CnqixlkUli6rtBF5z93vm/VFb6j/HzD6WfH0G8Hv0coAfAJ9JDstWv7tX9gH8DvDMvMe3AbdVWUPGuj8OvDLv8ev0ti4DmABer7vGyOfxBLC5bfUDK4AXgSvpTSpaHno91VzjNcDP6I2F/kXd9UTU+wi9td5P0fsfxs3Ar9P7B35/8nlV3XUuUvun6Q1H7AVeTj6uaVH9lwIvJfW/Avxl0n4h8CPgDeBx4PRhr1314lyh8OjKimsowoLwxcwaG77MWSo8amr9yf/oXgB+k97/7AoJjsrg7k/TokW93P2GRf7o6koLycAXX1QN2lH/Xnp/F9PtB1hk7f1YVY+hKzyqQVvDIy8pOBLpqqo7dIVHFetCeOQFB0ciXVV1h67wqEJtDo9KDY5EOqryxbnM7Brgb4FlwAPu/teVFjAkM3sE2Ehvlb8jwNeB7wOPARcAB4HPunt61l3tzOzTwH8BPwFmk+av0RtHb3T9ZnYpvdlyy+i98XjM3e8wswvpzcRcRS9YutHdm7kfnkjFalltUUREiqeZoiIiHaEOXUSkI9Shi4h0hDp0EZGOUIcuItIR6tBFRDpCHbqISEeoQxcR6Yj/A05Mv1efuboCAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.subplot(1,2,1)\n",
    "plt.imshow(ET_inner_filtered[0][2].reshape(28,32),cmap='gray')\n",
    "plt.subplot(1,2,2)\n",
    "plt.imshow(ET_outer_filtered[0][2].reshape(26,32),cmap='gray')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f55a0522d90>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAATEAAAD8CAYAAAAfZJO2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEzFJREFUeJzt3X+MHPV5x/HPx+ezjTEUzA/X2BY/VIuA2mLIiR+ijagJkUOiUFUQQaLKf1iyKlGJqJECtFKVSG0V/migf0RIVqHxH2mAJBAQjUJcB4tWrQxHMGBjHDv8CI4dTAOuCaHmbD/9Y8dws7d3M7s7Ozvf8/slWXff2dmZZ3/c49lnn/mOI0IAkKo5ww4AAPpBEgOQNJIYgKSRxAAkjSQGIGkkMQBJI4kBSBpJDEDS+kpittfY3mV7j+07qgoKAMpyrx37tkck/UzSdZL2SnpG0i0R8dJ095nn+bFAJ/e0PwAnjv/Te/ogDrvMunP72M/lkvZExCuSZPsBSTdImjaJLdDJusLXTr/FOSPFez12tMswh6TosaTyOOrAczX79Pm3vDU2l99V6TWnWibpjUnjvdmyHNvrbY/bHp/Q4T52BwBT9ZPEOh3qTflsGhEbImIsIsZGNb+P3QHAVP0ksb2SVkwaL5e0r79wAKA7/SSxZySttH2+7XmSbpb0WDVhAUA5PRf2I+KI7b+U9ISkEUn3R8SOyiIDgBL6+XZSEfFDST+sKBYA6FpfSaxyTfkqvYqv/Pt9LLOp3aTIbHkcJ9JrVqTGx8lpRwCSRhIDkDSSGICkkcQAJI0kBiBpJDEASSOJAUgaS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TBXEmXSbo3Ii6V9J5q+ohbZxLbK2nFpPFySftq3H8vSk38WCfbo2olsG9HxMPZ4sbFeVxEHFTr+gtXSjrN9vGZU4b9+l8t6XPZlbweUOsj5T1qVoyS+puUtEZ7Je2NiK3Z+HtqJbWBx1lnEntG0srs2595km5Wa2LFJmvUxI9uTep2n6SdEfGNSTc1Lc6zbJ+W/X6SpE+qVeR9UtKN2WpDjTMi7oyI5RFxnlrvxZ9ExBfVoBildCYljYhfSXrD9oXZomslvaQ64qy5+He9pJ+pVR/5m2EWIjvE9h1J+yVNqPW/yjq1aiSbJe3Ofi4ecox/pNbHmxckbcv+Xd/AOP9Q0nNZnNsl/W22/AJJT0vaI+m7kuYP+3XP4rpG0uNNjDGL5/ns347jfzdNe82zmFZJGs9e9x9IOr2OOOnYB5A0OvYBJI0kBiBpJDEASSOJAUgaSQxA0khiAJJGEgOQNJIYgKT9Py4V/2I3Fu4qAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "i=11\n",
    "plt.imshow(np.flip(insert(ET_inner_filtered[0][i],double_size(ET_outer_filtered[0][i])).reshape(52,64),axis=0))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Done batch 1\n",
      "Done batch 2\n",
      "Done batch 3\n",
      "Done batch 4\n",
      "Done batch 5\n",
      "Done batch 6\n",
      "Done batch 7\n",
      "Done batch 8\n",
      "Done batch 9\n",
      "Done batch 10\n",
      "Done batch 11\n",
      "Done batch 12\n"
     ]
    }
   ],
   "source": [
    "output_pics = generate_HCAL_images(ET_inner_filtered,ET_outer_filtered)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(20000, 52, 64, 1)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output_pics[0].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(len(output_pics)):\n",
    "    with open('/disk/lhcb_data/davide/HCAL_project_full_event/reco/sample'+str(i)+'.pickle', 'wb') as handle:\n",
    "        pickle.dump(output_pics[i], handle, protocol=pickle.HIGHEST_PROTOCOL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=np.array([output_pics[0][i].sum() for i in range(len(output_pics[0]))])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEelJREFUeJzt3W+s5FV9x/H3p6D4r7ogC6G7Sxfjxj81VeiNYm2MBdsKGpcHEjFGN3aTfYItVhOF+qAx6QNMG/+QWMxG1KWxIkUtG4tWsmKMD0AXpQgulhUpe92VXRXwD/EP9dsHc2693Z3lzr137s6ds+9XMpnf7/zOzJyT393PnD2/P5OqQpLUr9+ZdAMkSSvLoJekzhn0ktQ5g16SOmfQS1LnDHpJ6pxBL0mdM+glqXMGvSR17sRJNwDg1FNPrY0bN066GZI0VW6//fYfVtXaheqtiqDfuHEju3fvnnQzJGmqJPnvUeo5dSNJnTPoJalzBr0kdc6gl6TOGfSS1DmDXpI6Z9BLUucMeknqnEEvSZ1bFVfGauVtvPzfjyi7/8pXT6Alko41R/SS1DmDXpI6Z9BLUueco9f/OXwe3zl8qQ+O6CWpcwa9JHXOqZtODTudUt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Zuv8xztP2wE3hzO/vmXOCRuSme1SqDH2Z6F/Daqnp03qadwCVJTkpyFoMDzF8by4dW1VQ+gAsZHLH+LvDuSbdnEe3+Ewb/HbsTuKM9LmQwt70LuLc9nzLpti6yX68APteWn9X+QPcC/wqcNOn2jdiHFwG72775N+Dkad0vwHuAe4C7gH8GTpqW/QJ8ksGxhV8zGOVuPdp+YDDd8aGWA99icKbRxPuwQF/2MpiLn/v3/+F59d/d+vId4IJxtcMrYyWpc9M6dSNJGpFBL0mdM+glqXMGvSR1zqCXpM4Z9JLUOYNekjpn0EtS5/4XVxaw+G+yct4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.hist(a/1000,range=(0.5,120),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
}