{"cells":[{"metadata":{"_uuid":"3a4d0944c1cce9812a11d1477d8c32695847af83"},"cell_type":"markdown","source":""},{"metadata":{"_uuid":"829adf419f960ee30d878b78803953ec0d928481"},"cell_type":"markdown","source":"Quick plot for particle trajectories from training data."},{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","collapsed":true,"trusted":true},"cell_type":"code","source":"\n#Filename for event\nfn=\"train_1/event000001000\"\n\n#Row in particle file\nn=100\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfig = plt.figure()\nax = fig.add_subplot(111, projection='3d')\n\nA=np.loadtxt(\"../input/\"+fn+\"-truth.csv\",skiprows=1,delimiter=',')\nB=np.loadtxt(\"../input/\"+fn+\"-particles.csv\",skiprows=1,delimiter=',')\n\n\n#particle id to nth row in particle file.\npart_id = B[n,0]\n\n#Find hits from particle.\nhits_from_part = np.argwhere(A[:,1]==part_id)[:,0]\n\n#Print particle id and number of hits found.\nprint(\"PARTICLE ID:\")\nprint(int(part_id))\nprint(\"Num hits: \" + str(len(hits_from_part)))\nprint(\"\")\n#Get coordinates from hit-data.\ncoords = np.zeros((len(hits_from_part),3))\nfor i in range(0,len(hits_from_part)):\n\tcoords[i,:] = A[hits_from_part[i],2:5]\n\tprint(\"hit id: \"+str(int(A[hits_from_part[i],0]))+ \". Absolute momentum: \" + str(np.sqrt(np.sum(A[hits_from_part[i],5:8]**2))))\n\t\n#Sort coordinates by z-component.\t\nidx = np.argsort(coords[:,2])\ncoords2=coords[idx]\n\n#Plot\nax.plot(coords2[:,0],coords2[:,1],coords2[:,2],'.-')\nax.set_xlabel(\"X\")\nax.set_ylabel(\"Y\")\nax.set_zlabel(\"Z\")\nax.set_title(\"Particle ID: \" +str(int(part_id)))\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.5","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}