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": [
"# test samples directory - aanet test file\n",
"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": [
{
"data": {
"text/plain": [
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"Number of events: 10\n",
"Events keys are:\n",
"\tid\n",
"\tdet_id\n",
"\tmc_id\n",
"\trun_id\n",
"\tmc_run_id\n",
"\tframe_index\n",
"\ttrigger_mask\n",
"\ttrigger_counter\n",
"\toverlays\n",
"\thits\n",
"\ttrks\n",
"\tw\n",
"\tw2list\n",
"\tw3list\n",
"\tmc_t\n",
"\tmc_hits\n",
"\tmc_trks\n",
"\tcomment\n",
"\tindex\n",
"\tflags\n",
"\tt.fSec\n",
"\tt.fNanoSec\n",
"Hits keys are:\n",
"\thits.id\n",
"\thits.dom_id\n",
"\thits.channel_id\n",
"\thits.tdc\n",
"\thits.tot\n",
"\thits.trig\n",
"\thits.pmt_id\n",
"\thits.t\n",
"\thits.a\n",
"\thits.pos.x\n",
"\thits.pos.y\n",
"\thits.pos.z\n",
"\thits.dir.x\n",
"\thits.dir.y\n",
"\thits.dir.z\n",
"\thits.pure_t\n",
"\thits.pure_a\n",
"\thits.type\n",
"\thits.origin\n",
"\thits.pattern_flags\n",
"Tracks keys are:\n",
"\ttrks.fUniqueID\n",
"\ttrks.fBits\n",
"\ttrks.usr_data\n",
"\ttrks.usr_names\n",
"\ttrks.id\n",
"\ttrks.pos.x\n",
"\ttrks.pos.y\n",
"\ttrks.pos.z\n",
"\ttrks.dir.x\n",
"\ttrks.dir.y\n",
"\ttrks.dir.z\n",
"\ttrks.t\n",
"\ttrks.E\n",
"\ttrks.len\n",
"\ttrks.lik\n",
"\ttrks.type\n",
"\ttrks.rec_type\n",
"\ttrks.rec_stages\n",
"\ttrks.status\n",
"\ttrks.mother_id\n",
"\ttrks.fitinf\n",
"\ttrks.hit_ids\n",
"\ttrks.error_matrix\n",
"\ttrks.comment"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"reader = AanetReader(aanet_file)\n",
"reader"
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Table [<Row 0> <Row 1> <Row 2> ... <Row 7> <Row 8> <Row 9>] at 0x7f9011f02b50>"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# big lazyarray with ALL file data!\n",
"lazy_data = reader.lazy_data\n",
"lazy_data"
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# getting the run_id for a specific event (event 5 for example)\n",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can check how many hits are in event 5\n",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"56"
]
},
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can also check how many tracks are in event 5\n",
"reader[5]['trks']"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\"'whatever' is not a valid key or is a fake branch.\"\n"
]
}
],
"source": [
"# the user is reminded to always specify the \"correct\" event/hits/tracks \n",
"# key in the Aanet event file\n",
"try:\n",
" reader['whatever']\n",
"except KeyError as e:\n",
" print(e)"
"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 0x7f9011eb3b10>"
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# reading all data from a specific branch in hits data: for example \n",
"# 'hits.dom_id'\n",
"reader['hits.dom_id']"
"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",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We previsouly checked (using reader[5]['hits']) that event\n",
"# 5 has 60 hits, now we can see that reader['hits.dom_id'][5]\n",
"# has exaclty 60 dom ids as well! \n",
"len(reader['hits.dom_id'][5])"
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can access a dom id of the first hit \n",
"# Now let's explore in more details the tracks:"
"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 0x7f9011ebdf10>"
"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",
"outputs": [
{
"data": {
"text/plain": [
"56"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"# We previsouly checked (using reader[5]['trks']) that event\n",
"# 5 has 56 tracks, now we can see that reader['trks.dir.z'][5]\n",
"# has exaclty 56 values of trks.dir.z as well! \n",
"outputs": [
{
"data": {
"text/plain": [
"-0.6024604933159441"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# one can access the first trks.dir.z from event 5 using \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
}