{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import os\n", "import pickle\n", "import sys" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "width_X=8404.0\n", "width_Y=6828.0\n", "#number of events\n", "batch_size=20000\n", "X_pixels=64\n", "Y_pixels=52" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with open('/disk/lhcb_data/davide/HCAL_project_full_event/csv/MCtracker_info.pickle', 'rb') as f:\n", " tracks=pickle.load(f)\n", " \n", "n_batches=len(tracks['xProjections'])\n", "\n", "tracks['pi1_xProjection'][0][0] in tracks['xProjections'][0][0][0]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['xProjections'][j][i][0]/=(width_X/2)\n", " tracks['xProjections'][j][i][0]*=32\n", " tracks['xProjections'][j][i][0]+=32\n", "\n", " \n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['yProjections'][j][i][0]/=(width_Y/2)\n", " tracks['yProjections'][j][i][0]*=26\n", " tracks['yProjections'][j][i][0]+=26\n", "\n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['pi1_xProjection'][j][i]/=(width_X/2)\n", " tracks['pi1_xProjection'][j][i]*=32\n", " tracks['pi1_xProjection'][j][i]+=32\n", "\n", " \n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['pi1_yProjection'][j][i]/=(width_Y/2)\n", " tracks['pi1_yProjection'][j][i]*=26\n", " tracks['pi1_yProjection'][j][i]+=26 \n", " \n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['pi2_xProjection'][j][i]/=(width_X/2)\n", " tracks['pi2_xProjection'][j][i]*=32\n", " tracks['pi2_xProjection'][j][i]+=32\n", "\n", " \n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['pi2_yProjection'][j][i]/=(width_Y/2)\n", " tracks['pi2_yProjection'][j][i]*=26\n", " tracks['pi2_yProjection'][j][i]+=26\n", "\n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['K_xProjection'][j][i]/=(width_X/2)\n", " tracks['K_xProjection'][j][i]*=32\n", " tracks['K_xProjection'][j][i]+=32\n", "\n", " \n", "for j in range(n_batches):\n", " for i in range(batch_size):\n", " tracks['K_yProjection'][j][i]/=(width_Y/2)\n", " tracks['K_yProjection'][j][i]*=26\n", " tracks['K_yProjection'][j][i]+=26 " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([ 26.366026 , 32.283485 , 43.76675 , 40.5049 ,\n", " 26.017092 , 25.059456 , 11.166256 , 32.01572 ,\n", " 46.174244 , 37.074677 , 29.652033 , 42.82162 ,\n", " -4.8200912 , 5.0072193 , 17.069355 , 23.731718 ,\n", " 44.455063 , 55.73885 , 30.468227 , 56.224937 ,\n", " 26.463978 , 12.707497 , 41.476982 , 32.009785 ,\n", " 11.1635895 , 29.462578 , 43.270424 , 40.199158 ,\n", " 37.376354 , 31.979446 , -5.9480743 , 33.48986 ,\n", " -0.35655975, 11.592337 , 46.973446 , 40.964615 ,\n", " 24.896637 , 40.067432 , -4.4417343 , 10.579229 ,\n", " -16.302044 , 30.109873 , 36.19085 , 10.674828 ,\n", " 34.354465 , 51.943687 , 37.02441 , 68.699234 ,\n", " 4.2089787 , 29.306755 , 31.927109 , 17.94367 ,\n", " 46.051395 , 40.864464 , 9.20113 , 30.551847 ,\n", " 59.26765 , 21.558033 , 36.4137 , 43.763763 ,\n", " 31.440235 , 29.761326 , 39.14627 , 21.2994 ,\n", " 13.478554 , 31.528143 , 62.70546 , 18.237343 ,\n", " 35.2656 , 12.071615 , 20.394001 , 28.785568 ,\n", " 35.621407 , 54.64473 , 8.858938 , 72.147156 ,\n", " 47.763863 , 25.496136 , 26.082474 , 26.931595 ,\n", " 27.804598 , 38.213768 , 63.684364 , -12.207516 ,\n", " -1.8446388 , 44.428505 , -7.9377556 , 50.85122 ,\n", " 45.11862 , 35.516087 , 62.596184 , 9.868935 ],\n", " dtype=float32),)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tracks['xProjections'][0][0]" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#for j in range(n_batches):\n", "# for i in range(batch_size):\n", "# tracks[\"xProjections\"][j][i][0]/=(width_X/2)\n", "# tracks[\"yProjections\"][j][i][0]/=(width_Y/2)\n", "# \n", "# tracks[\"xProjections\"][j][i][0]*=32\n", "# tracks[\"yProjections\"][j][i][0]*=26\n", "# \n", "# tracks[\"xProjections\"][j][i][0]+=32\n", "# tracks[\"yProjections\"][j][i][0]+=26\n", "# " ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": true }, "outputs": [], "source": [ "pics_dict_flip = {}\n", "pics_dict = {}\n", "for n in range(n_batches):\n", " \n", " pic = np.zeros(shape=(Y_pixels,X_pixels,1),dtype=np.float32)\n", " batch_size = tracks['pi1_region'][0].shape[0]\n", " pics_dict[n]={}\n", " pics_dict_flip[n]={}\n", " pics_dict[n]['pic']=np.array([pic for i in range(0,batch_size)])\n", " pics_dict_flip[n]['pic']=np.array([pic for i in range(0,batch_size)])\n", " \n", " pics_dict[n]['L0HadronDec_TIS']=np.empty(shape=(batch_size,),dtype='bool')\n", " pics_dict[n]['L0HadronDec_TOS']=np.empty(shape=(batch_size,),dtype='bool')\n", " \n", " for event in range(batch_size):\n", " #if event not in pos_rejected[n]:\n", " pics_dict[n]['L0HadronDec_TIS'][event]=tracks['L0HadronDec_TIS'][n][event]\n", " pics_dict[n]['L0HadronDec_TOS'][event]=tracks['L0HadronDec_TOS'][n][event]\n", " \n", " for ntrack in range(tracks['yProjections'][n][event][0].shape[0]):\n", " \n", " y=int(np.floor(tracks['yProjections'][n][event][0][ntrack]))\n", " x=int(np.floor(tracks['xProjections'][n][event][0][ntrack]))\n", " \n", " if 0<x<X_pixels:\n", " if 0<y<Y_pixels:\n", " \n", " pics_dict_flip[n]['pic'][event][y,x]+=tracks['realETs'][n][event][0][ntrack]\n", " \n", " pics_dict[n]['pic'][event]=np.flip(pics_dict_flip[n]['pic'][event], axis=0)\n", "\n", " " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "#pics_dict_filtered={}\n", "#for n in range(n_batches):\n", "# \n", "# pics_dict_filtered[n]={}\n", "# \n", "#for n in range(n_batches):\n", "# \n", "# pics_dict_filtered[n]['pic']=np.delete(pics_dict[n]['pic'],pos_rejected[n],axis=0)\n", "# pics_dict_filtered[n]['L0HadronDec_TIS']=np.delete(pics_dict[n]['L0HadronDec_TIS'],pos_rejected[n],axis=0)\n", "# pics_dict_filtered[n]['L0HadronDec_TOS']=np.delete(pics_dict[n]['L0HadronDec_TOS'],pos_rejected[n],axis=0)\n", "#" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "<matplotlib.colorbar.Colorbar at 0x7f294be28208>" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWkAAAD6CAYAAABj/rYXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAW2UlEQVR4nO3dfYxc1XnH8e/Pi2MDwQHXgIzXrYnipjE0McExTqlaAqE4JIppVFpoEhyJyhIiKpEiBTuVGuUPS/yFEqqAtEoopiEhFoFi0RDXMdCIljebd2Mcu0BgsWOXlzROKjn27tM/7tkwOzuzc3dndufM3d9Hupq5Z+7LQ3AeH557zr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zcwy5iRtZpYxJ2kzs4w5SZuZZcxJ2swsY/8PuCjq4Z4+iQ8AAAAASUVORK5CYII=\n", "text/plain": [ "<Figure size 432x288 with 2 Axes>" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "i=2\n", "plt.imshow(pics_dict[0]['pic'][i].reshape(52,64));\n", "plt.colorbar()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "for i in range(n_batches):\n", " with open('/disk/lhcb_data/davide/HCAL_project_full_event/true/sample'+str(i)+'.pickle', 'wb') as handle:\n", " pickle.dump(pics_dict[i], handle, protocol=pickle.HIGHEST_PROTOCOL)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.hist(pics_dict[0]['pic'].sum(axis=(1,2))/1000, range=(0,300),bins=70);" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "#def make_pics_dict(X_grid, Y_grid, tracks, n_batches=n_batches):\n", "# X_pixels=64\n", "# Y_pixels=np.int(np.ceil((X_pixels*width_Y)/width_X))\n", "# pic = np.zeros(shape=(Y_pixels,X_pixels,1),dtype=np.float32)\n", "# pics_dict = {}\n", "# \n", "# for n in range(1):\n", "# \n", "# batch_size = tracks['regions'][0].shape[0]\n", "# pics_dict[n]=np.array([pic for i in range(0,batch_size)])\n", "# \n", "# for k in range(batch_size):\n", "# event=k\n", "# if tracks['regions'][n][event][0]>=0: #and particle_1[n][\"region\"][event]>=0 and particle_2[n][\"region\"][event]>=0:\n", "# #event = n*batch_size+k\n", "# \n", "# #print(event)\n", "# for i in range(X_grid.shape[0]-1):\n", "# for j in range(Y_grid.shape[1]-1):\n", "# for ntrack in range(tracks['xProjections'][n][event][0].shape[0]):\n", "# \n", "# xtrack = tracks['xProjections'][n][event][0][ntrack]*X_pixels/2\n", "# ytrack = tracks['yProjections'][n][event][0][ntrack]*Y_pixels/2 \n", "# \n", "# if X_grid[i,j] < xtrack < X_grid[i,j+1]:\n", "# if Y_grid[i,j] < ytrack < Y_grid[i+1,j]:\n", "#\n", "# \n", "# x_primed=int(Y_pixels/2-Y_grid[i,j])\n", "# y_primed=int(X_pixels/2+X_grid[i,j])\n", "#\n", "# #pics_dict[n][k][x_primed,y_primed,0]=1\n", "# \n", "# pics_dict[n][k][x_primed-1,y_primed-1,0]=tracks[\"realETs\"][n][event][0][ntrack]\n", "# #total_pic[x_primed-1,y_primed-1,0]=1\n", "# #total_pic[x_primed-1,y_primed-1,0]=true_events['true_ET'][event]\n", "# \n", "# \n", "# print('Converted '+str(n+1)+'/'+str(n_batches)+' batches of ' +str(batch_size)+' images')\n", "# \n", "# # \n", "# # if N % batch_size != 0:\n", "# # \n", "# # print('Converting last batch of '+str(N%batch_size)+' images') \n", "# # \n", "# # for k in range(batch_size*n_batches,N):\n", "# # #if true_events['region'][k]>=0:\n", "# # \n", "# # for i in range(X_grid.shape[0]):\n", "# # for j in range(Y_grid.shape[1]):\n", "# # if X_grid[i,j-1] < X_norm[n_batches][k]*X_pixels/2 < X_grid[i,j]:\n", "# # if Y_grid[i-1,j] < Y_norm[n_batches][k]*Y_pixels/2 < Y_grid[i,j]:\n", "# # \n", "# # x_primed=int(Y_pixels/2-Y_grid[i,j])\n", "# # y_primed=int(X_pixels/2+X_grid[i,j])\n", "# # \n", "# # pics_dict[n_batches][k-(N-1)][x_primed,y_primed,0]=true_events['true_ET'][event]\n", "# # #total_pic[x_primed,y_primed,0]=true_events['true_ET'][event]\n", "# return pics_dict\n", "#\n", "#\n", "#\n", "#" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }