Newer
Older
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['/home/zineb/km3net/km3net/km3io/notebooks', '/home/zineb/miniconda3/envs/km3pipe/lib/python37.zip', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7/lib-dynload', '', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7/site-packages', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7/site-packages/IPython/extensions', '/home/zineb/.ipython', '/home/zineb/km3net/km3net/km3io']\n"
]
}
],
"source": [
"# Add file to current python path\n",
"from pathlib import Path\n",
"import sys\n",
"sys.path.append(str(Path.cwd().parent))\n",
"Path.cwd()\n",
"print(sys.path)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"files_path = Path.cwd().parent / 'tests/samples' \n",
"aanet_file = files_path / 'aanet_v2.0.0.root'"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Table [<Row 0> <Row 1> <Row 2> ... <Row 7> <Row 8> <Row 9>] at 0x7f315b3f9fd0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# big lazyarray with ALL file data!\n",
"lazy_data = reader.lazy_data\n",
"lazy_data"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<ChunkedArray [5971 5971 5971 ... 5971 5971 5971] at 0x7f315b3a50d0>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# reading all data from a specific branch from events data (data is \n",
"# ordered in the same order as in Aanet event file)\n",
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# getting the run_id for a specific event (event 5 for example)\n",
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\"'whatever' could not be found or is a fake branch.\"\n"
]
}
],
"source": [
"# the user is reminded to always specify the \"correct\" event key in the\n",
"# Aanet event file\n",
"try:\n",
" reader.read_event('whatever')\n",
"except KeyError as e:\n",
" print(e)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can check how many hits are in event 5\n",
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"56"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can also check how many tracks are in event 5\n",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<ChunkedArray [[806451572 806451572 806451572 ... 809544061 809544061 809544061] [806451572 806451572 806451572 ... 809524432 809526097 809544061] [806451572 806451572 806451572 ... 809544061 809544061 809544061] ... [806451572 806455814 806465101 ... 809526097 809544058 809544061] [806455814 806455814 806455814 ... 809544061 809544061 809544061] [806455814 806455814 806455814 ... 809544058 809544058 809544061]] at 0x7f315b3a5b10>"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# reading all data from a specific branch in hits data:\n",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([806455814, 806487219, 806487219, 806487219, 806487226, 808432835,\n",
" 808432835, 808432835, 808432835, 808432835, 808432835, 808432835,\n",
" 808451904, 808451904, 808451907, 808451907, 808469129, 808469129,\n",
" 808469129, 808493910, 808949744, 808949744, 808951460, 808951460,\n",
" 808956908, 808961655, 808964908, 808969848, 808969857, 808972593,\n",
" 808972593, 808972598, 808972598, 808972698, 808972698, 808974758,\n",
" 808974811, 808976377, 808981510, 808981523, 808981812, 808982005,\n",
" 808982005, 808982018, 808982077, 808982077, 808982547, 809007627,\n",
" 809521500, 809521500, 809521500, 809524432, 809526097, 809526097,\n",
" 809526097, 809526097, 809526097, 809526097, 809526097, 809544058],\n",
" dtype=int32)"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# the user can access hits.dom_id data for a specific event (for example \n",
"# event 5)\n",
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We previsouly checked (using reader.event_reader('hits')[5]) that event\n",
"# 5 has 218 hits, now we can see that reader.hits_reader('hits.dom_id')[5]\n",
"# has exaclty 218 dom ids as well! \n",
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can access a dom id of the first hit \n",
"name": "stdout",
"output_type": "stream",
"text": [
"\"'whatever' is not a valid hits key.\"\n"
]
}
],
"source": [
"# once again, the user is reminded to always use the hits keys stored i Aanet event\n",
"# file\n",
"try:\n",
" reader.read_hits('whatever')\n",
"except KeyError as e:\n",
" print(e)"
"# Now let's explore in more details the tracks:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<ChunkedArray [[-0.872885221293917 -0.872885221293917 -0.872885221293917 ... -0.6631226836266504 -0.5680647731737454 -0.5680647731737454] [-0.8351996698137462 -0.8351996698137462 -0.8351996698137462 ... -0.7485107718446855 -0.8229838871876581 -0.239315690284641] [-0.989148723802379 -0.989148723802379 -0.989148723802379 ... -0.9350162572437829 -0.88545604390297 -0.88545604390297] ... [-0.5704611045902105 -0.5704611045902105 -0.5704611045902105 ... -0.9350162572437829 -0.4647231989130516 -0.4647231989130516] [-0.9779941383490359 -0.9779941383490359 -0.9779941383490359 ... -0.88545604390297 -0.88545604390297 -0.8229838871876581] [-0.7396916780974963 -0.7396916780974963 -0.7396916780974963 ... -0.6631226836266504 -0.7485107718446855 -0.7485107718446855]] at 0x7f315b3b0f10>"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# reading all data from a specific branch in tracks data:\n",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-0.60246049, -0.60246049, -0.60246049, -0.51420541, -0.5475772 ,\n",
" -0.5772408 , -0.56068238, -0.64907684, -0.67781799, -0.66565114,\n",
" -0.63014839, -0.64566464, -0.62691012, -0.58465493, -0.59287533,\n",
" -0.63655091, -0.63771247, -0.73446841, -0.7456636 , -0.70941246,\n",
" -0.66312268, -0.66312268, -0.56806477, -0.56806477, -0.66312268,\n",
" -0.66312268, -0.74851077, -0.74851077, -0.66312268, -0.74851077,\n",
" -0.56806477, -0.74851077, -0.66312268, -0.74851077, -0.56806477,\n",
" -0.66312268, -0.56806477, -0.66312268, -0.56806477, -0.56806477,\n",
" -0.66312268, -0.74851077, -0.66312268, -0.93501626, -0.56806477,\n",
" -0.74851077, -0.66312268, -0.56806477, -0.82298389, -0.74851077,\n",
" -0.66312268, -0.56806477, -0.82298389, -0.56806477, -0.66312268,\n",
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# the user can access trks.dir.z data for a specific event (for example \n",
"# event 5)\n",
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"56"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We previsouly checked (using reader.event_reader('trks')[5]) that event\n",
"# 5 has 56 tracks, now we can see that reader.hits_reader('hits.dom_id')[5]\n",
"# has exaclty 56 values of trks.dir.z as well! \n",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can access the first trks.dir.z from event 5 using \n",
"name": "stdout",
"output_type": "stream",
"text": [
"\"'whatever' is not a valid tracks key.\"\n"
]
}
],
"source": [
"# once again, the user is reminded to always use the tracks keys stored in Aanet\n",
"# event file\n",
"try:\n",
" reader.read_tracks('whatever')\n",
"except KeyError as e:\n",
" print(e)"
"outputs": [
{
"ename": "TypeError",
"evalue": "can only concatenate str (not \"int\") to str",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-24-713f816108bc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;34m'test'\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
]
}
],
"source": [
"'test' + 1\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.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}