{"cells":[{"metadata":{"_uuid":"596f35eb3eaacd7d64b36a3b3349c4c737e30dcf","_cell_guid":"80494b6e-3bcc-4cdd-9be4-d35332f3c66e"},"cell_type":"markdown","source":"An algorithm that quickly reconstructs particle tracks from 3D points left in the silicon detectors.\n**GROUP THE RECORDED MEASUREMENTS/HITS FOR EACH EVENT INTO TRACKS (SETS OF HITS THAT BELONG TO THE SAME INTITIAL PARTICLE)**"},{"metadata":{"_uuid":"9421b774f535a83cde73d37f06dbce8785366dad","_cell_guid":"80afc574-79c5-4247-a921-483fb6bdbc34","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport pandas as pd\nimport os\nimport tensorflow as tf\nprint(os.listdir(\"../input\"))","execution_count":13,"outputs":[]},{"metadata":{"_uuid":"39179bd81c5c520507ed957aa9c937606d3a98a6","_cell_guid":"92b8267d-963a-4ab3-a590-b2d418586edd","collapsed":true,"trusted":true},"cell_type":"code","source":"from trackml.dataset import load_event, load_dataset\nfrom trackml.randomize import shuffle_hits\nfrom trackml.score import score_event","execution_count":14,"outputs":[]},{"metadata":{"_uuid":"a8ddb943f3d81d460f42676110c56e8dd340ce5b","_cell_guid":"d0813ac0-edae-485e-a902-e8f2ff2e40af","trusted":true},"cell_type":"code","source":"for i in os.listdir('../input/'):\n    print(i)","execution_count":15,"outputs":[]},{"metadata":{"_uuid":"6783e28705155c5eb40e24dba330ed0bfcfd3882","_cell_guid":"20a83341-a332-485e-8937-0009e5f69da2","trusted":true},"cell_type":"code","source":"def parse_event_id(filename):\n    return int(filename[5:].split('-')[0])\n\nsample_filename = os.listdir('../input/train_1')[0]\nparse_event_id(sample_filename)","execution_count":16,"outputs":[]},{"metadata":{"_uuid":"bb7737931e97f936cfa0c34573844b8ee65e4b5f","_cell_guid":"b9896cc8-ec2a-4b96-9bf5-54f73673004c","trusted":true},"cell_type":"code","source":"train_filenames = os.listdir('../input/train_1')\ntrain_event_ids = np.unique(sorted([parse_event_id(i) for i in train_filenames]))\nprint('train event ids:', train_event_ids[:10],'...', train_event_ids[-10:])","execution_count":17,"outputs":[]},{"metadata":{"_uuid":"a201996e9202759a434031e853a6964307b2ec8e","_cell_guid":"0f29309a-a50c-4f6d-9178-8a7913f764da","trusted":true},"cell_type":"code","source":"def get_by_event_id_train(id_):\n    if id_ in train_event_ids:\n        return sorted(np.array(train_filenames)[[id_ == parse_event_id(i) for i in train_filenames]])\n    else:\n        return None\n\n# Test:\nevent_id = 1000\nprint(get_by_event_id_train(event_id))\nprint(get_by_event_id_train(10))","execution_count":18,"outputs":[]},{"metadata":{"_uuid":"f8f7e045db6d773efaa5687d93bd97b88a4953ef","_cell_guid":"a55150a2-e712-4153-ba9e-b0d5b557dd3a","collapsed":true,"trusted":true},"cell_type":"code","source":"\ncells_df = pd.read_csv('../input/train_1/'+get_by_event_id_train(event_id)[0]) \nhits_df = pd.read_csv('../input/train_1/'+get_by_event_id_train(event_id)[1])\nparticles_df = pd.read_csv('../input/train_1/'+get_by_event_id_train(event_id)[2])\ntruth_df = pd.read_csv('../input/train_1/'+get_by_event_id_train(event_id)[3])","execution_count":19,"outputs":[]},{"metadata":{"_uuid":"9475c57da64d898a44f2b06d6bc4b31b65823b23","_cell_guid":"1b41eaf2-b394-44da-aa60-1815d5e1dec6","trusted":true},"cell_type":"code","source":"cells_df.head()","execution_count":20,"outputs":[]},{"metadata":{"_uuid":"5ca5544aae4ae0419b52a2dd85da90ce266a991a","_cell_guid":"cd8dca37-13a5-47ca-bd1b-20516576c232","trusted":true},"cell_type":"code","source":"hits_df.tail()","execution_count":21,"outputs":[]},{"metadata":{"_uuid":"93f4267a5f116c1e71a7905773812fdbef869510","_cell_guid":"5fe86767-c74b-459b-87cd-dae840068047","trusted":true},"cell_type":"code","source":"particles_df.tail()","execution_count":22,"outputs":[]},{"metadata":{"_uuid":"5436e64588077290af47607f9b90678ab0b363de","_cell_guid":"995b36a5-9c8c-42b9-a90b-8251d2115c0f","trusted":true},"cell_type":"code","source":"truth_df.tail()","execution_count":23,"outputs":[]},{"metadata":{"_uuid":"b2d26900c6d2c2031645666daf3295dbb06906b3","_cell_guid":"2fbf34d8-6d84-4da6-9f1d-a3d0a99d7625","trusted":true},"cell_type":"code","source":"sample_particle_id = 0\nwhile sample_particle_id == 0:\n    sample_particle_id = int(truth_df.sample()['particle_id'])\nprint(sample_particle_id)\n\ndata = np.array(truth_df[truth_df['particle_id']==sample_particle_id][['tx', 'ty', 'tz']])\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfig = plt.figure()\nax = fig.add_subplot(111, projection='3d')\nax.scatter(data[:,0], data[:,1], data[:,2] , c='red', marker='o', edgecolor='k')\nax.plot(data[:,0], data[:,1], data[:,2] , '-', lw=3, alpha=0.4)\nax.set_xlabel('X Label')\nax.set_ylabel('Y Label')\nax.set_zlabel('Z Label')\nfig.tight_layout()\nplt.show()","execution_count":24,"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}