Browse Source

finding shared tracks in all found events

master
cetin 1 year ago
parent
commit
7f537d7d3b
  1. 152
      D_tasks.ipynb

152
D_tasks.ipynb

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28,
"execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -21,7 +21,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 29,
"execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -38,7 +38,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 30,
"execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -47,7 +47,7 @@
"0.5759057568348522" "0.5759057568348522"
] ]
}, },
"execution_count": 30,
"execution_count": 4,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -63,7 +63,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 31,
"execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -72,7 +72,7 @@
"0.7960893854748603" "0.7960893854748603"
] ]
}, },
"execution_count": 31,
"execution_count": 5,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -94,7 +94,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 32,
"execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -103,7 +103,7 @@
"0.5568703211784594" "0.5568703211784594"
] ]
}, },
"execution_count": 32,
"execution_count": 6,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -126,7 +126,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 33,
"execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -147,7 +147,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34,
"execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -184,7 +184,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 35,
"execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -213,7 +213,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36,
"execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -244,7 +244,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 37,
"execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -282,7 +282,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38,
"execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -340,7 +340,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39,
"execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -376,7 +376,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 40,
"execution_count": 14,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -385,7 +385,7 @@
"-1.5438992626615335e-08" "-1.5438992626615335e-08"
] ]
}, },
"execution_count": 40,
"execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -396,7 +396,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 41,
"execution_count": 15,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -444,7 +444,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 42,
"execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -471,7 +471,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 43,
"execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -505,7 +505,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 44,
"execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -522,7 +522,7 @@
"shared = np.array([0,1,0,1,1,2])\n", "shared = np.array([0,1,0,1,1,2])\n",
"len(shared)\n", "len(shared)\n",
"\n", "\n",
"both = ak.concatenate([found,lost])\n",
"both = ak.concatenate([found,lost],axis=0)\n",
"print(ak.num(found,axis=0))\n", "print(ak.num(found,axis=0))\n",
"print(ak.num(lost,axis=0))\n", "print(ak.num(lost,axis=0))\n",
"print(ak.num(both,axis=0))" "print(ak.num(both,axis=0))"
@ -530,35 +530,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48,
"execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\ndef shared_track(mc_arr, mc_itr):\\n for itr in mc_itr: #iterate over events\\n potential = mc_arr[mc_arr[\"event_count\"]==itr] #holds all pt of a single event\\n velo_idx = potential[\"velo_track_idx\"].to_numpy()\\n velo_idx_unis, mults = np.unique(velo_idx, return_counts=True)\\n print(velo_idx_unis, mults)\\n if any(x>1 for x in mults):\\n'"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [ "source": [
"#versuche teilchen von denselben events mit shared tracks zu finden. \n", "#versuche teilchen von denselben events mit shared tracks zu finden. \n",
"#idee: alle teilchen eines events sind durch event_count auffindbar. \n", "#idee: alle teilchen eines events sind durch event_count auffindbar. \n",
"a_f_itr = found[\"event_count\"].to_numpy()\n", "a_f_itr = found[\"event_count\"].to_numpy()\n",
"f_itr = np.unique(a_f_itr)\n",
"\n",
"\"\"\"\n",
"def shared_track(mc_arr, mc_itr):\n",
" for itr in mc_itr: #iterate over events\n",
" potential = mc_arr[mc_arr[\"event_count\"]==itr] #holds all pt of a single event\n",
" velo_idx = potential[\"velo_track_idx\"].to_numpy()\n",
" velo_idx_unis, mults = np.unique(velo_idx, return_counts=True)\n",
" print(velo_idx_unis, mults)\n",
" if any(x>1 for x in mults):\n",
"\"\"\" "
"f_itr = np.unique(a_f_itr)\n"
] ]
}, },
{ {
@ -570,7 +549,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 72,
"execution_count": 24,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -579,7 +558,7 @@
"2" "2"
] ]
}, },
"execution_count": 72,
"execution_count": 24,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -593,7 +572,8 @@
" temp = both[both[\"event_count\"]==itr]\n", " temp = both[both[\"event_count\"]==itr]\n",
" if ak.num(temp,axis=0)>1:\n", " if ak.num(temp,axis=0)>1:\n",
" #iterate over cols in temp and append all with duplicate velo_track_idx, such that possibles is array with possible shared tracks particles\n", " #iterate over cols in temp and append all with duplicate velo_track_idx, such that possibles is array with possible shared tracks particles\n",
" #print(temp.tolist())\n",
" #idea: look at one event at a time and at one velo track at a time. if there are at least two e with the same velo_track_idx in the same event,\n",
" #concatenate to the array of other shared track particles\n",
" _jitr = temp[\"velo_track_idx\"].to_numpy()\n", " _jitr = temp[\"velo_track_idx\"].to_numpy()\n",
" jitr = np.unique(_jitr)\n", " jitr = np.unique(_jitr)\n",
" for jentry in jitr:\n", " for jentry in jitr:\n",
@ -603,7 +583,7 @@
" psb = jtem\n", " psb = jtem\n",
" count=1\n", " count=1\n",
" else:\n", " else:\n",
" psb = ak.concatenate([psb,jtem],axis=1)\n",
" psb = ak.concatenate([psb,jtem],axis=0)\n",
" else:\n", " else:\n",
" continue\n", " continue\n",
" else:\n", " else:\n",
@ -614,22 +594,66 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"execution_count": 37,
"metadata": {}, "metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"217"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"_jitr = temp[\"velo_track_idx\"].to_numpy()\n",
" jitr = np.unique(_jitr)\n",
" for jentry in jitr:\n",
" jtem = temp[temp[\"velo_track_idx\"]==jentry]\n",
" if ak.num(jtem,axis=0)>1:\n",
" if count==0:\n",
" psb = jtem\n",
" count=1\n",
" else:\n",
" psb = ak.concatenate([psb,jtem],axis=1)\n",
" else:\n",
" continue"
"temp_ = found[\"velo_track_idx\"].to_numpy()\n",
"temp = np.unique(temp_)\n",
"count=0\n",
"psb=ak.ArrayBuilder()\n",
"for jentry in temp:\n",
" jtem = found[found[\"velo_track_idx\"]==jentry]\n",
" if ak.num(jtem,axis=0)>1:\n",
" psb.append(jtem)\n",
" else:\n",
" continue\n",
"\n",
"psb = ak.Array(psb)\n",
"\n",
"ak.num(psb,axis=0)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"velo idx: 1\n",
"event_count: [3692, 5481, 8364, 8596]\n",
"\n",
"velo x: [9.85, -11.9, 28.6, -5.75]\n",
"velo y: [1.43, 20.1, 8.4, -27.6]\n",
"\n",
"velo tx: [0.0146, -0.0161, 0.0404, -0.00595]\n",
"velo ty: [0.00154, 0.0273, 0.00778, -0.0497]\n"
]
}
],
"source": [
"idx = 1\n",
"print(\"velo idx: \" ,idx)\n",
"print(\"event_count: \", psb[idx,:,\"event_count\"])\n",
"print(\"\\nvelo x: \" ,psb[idx,:,\"velo_track_x\"])\n",
"print(\"velo y: \" ,psb[idx,:,\"velo_track_y\"])\n",
"\n",
"print(\"\\nvelo tx: \" ,psb[idx,:,\"velo_track_tx\"])\n",
"print(\"velo ty: \" ,psb[idx,:,\"velo_track_ty\"])"
] ]
}, },
{ {

Loading…
Cancel
Save