finding shared tracks in all found events

This commit is contained in:
cetin 2023-09-26 15:12:03 +02:00
parent 7f537d7d3b
commit 2df1468e58

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 60,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -21,9 +21,20 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 61,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"51"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"file = uproot.open(\"tracking_losses_ntuple_Dst0ToD0EE.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\")\n", "file = uproot.open(\"tracking_losses_ntuple_Dst0ToD0EE.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\")\n",
"\n", "\n",
@ -33,12 +44,13 @@
"found = allcolumns[(allcolumns.isElectron) & (~allcolumns.lost) & (allcolumns.fromSignal) & (allcolumns.p < 5e3)] #D: 2591\n", "found = allcolumns[(allcolumns.isElectron) & (~allcolumns.lost) & (allcolumns.fromSignal) & (allcolumns.p < 5e3)] #D: 2591\n",
"lost = allcolumns[(allcolumns.isElectron) & (allcolumns.lost) & (allcolumns.fromSignal) & (allcolumns.p < 5e3)] #D: 1908\n", "lost = allcolumns[(allcolumns.isElectron) & (allcolumns.lost) & (allcolumns.fromSignal) & (allcolumns.p < 5e3)] #D: 1908\n",
"\n", "\n",
"#ak.num(lost, axis=0)" "#ak.num(lost, axis=0)\n",
"ak.num(allcolumns[(allcolumns.fromPairProd) & (allcolumns.isElectron) & (~allcolumns.lost) & (allcolumns.fromSignal)],axis=0)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 62,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -47,7 +59,7 @@
"0.5759057568348522" "0.5759057568348522"
] ]
}, },
"execution_count": 4, "execution_count": 62,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -63,7 +75,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 63,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -72,7 +84,7 @@
"0.7960893854748603" "0.7960893854748603"
] ]
}, },
"execution_count": 5, "execution_count": 63,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -94,7 +106,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 64,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -103,7 +115,7 @@
"0.5568703211784594" "0.5568703211784594"
] ]
}, },
"execution_count": 6, "execution_count": 64,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -126,7 +138,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 65,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -147,7 +159,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 66,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -184,7 +196,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 67,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -213,7 +225,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 68,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -244,7 +256,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 69,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -282,7 +294,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 70,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -340,7 +352,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 71,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -376,7 +388,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 72,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -385,7 +397,7 @@
"-1.5438992626615335e-08" "-1.5438992626615335e-08"
] ]
}, },
"execution_count": 14, "execution_count": 72,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -396,7 +408,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 73,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -444,7 +456,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 74,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -471,7 +483,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 75,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -505,7 +517,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": 76,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -519,9 +531,6 @@
} }
], ],
"source": [ "source": [
"shared = np.array([0,1,0,1,1,2])\n",
"len(shared)\n",
"\n",
"both = ak.concatenate([found,lost],axis=0)\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",
@ -530,42 +539,33 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 81,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#events w/ shared track electrons from found and lost: 1\n",
"event_count: [2822, 2822]\n",
"velo idx: [146, 146]\n",
"mcp_index: [5806, 5829]\n",
"\n",
"velo x: [-75.1, -75.1]\n",
"velo y: [5.88, 5.88]\n",
"\n",
"velo tx: [-0.0908, -0.0908]\n",
"velo ty: [0.00703, 0.00703]\n"
]
}
],
"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" "f_itr = np.unique(a_f_itr)\n",
] "\n",
}, "shared = ak.ArrayBuilder()\n",
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#psb = ak.Array([])\n",
"global psb\n",
"count = 0\n", "count = 0\n",
"\n", "\n",
"for itr in f_itr:\n", "for itr in f_itr:\n",
@ -579,36 +579,51 @@
" for jentry in jitr:\n", " for jentry in jitr:\n",
" jtem = temp[temp[\"velo_track_idx\"]==jentry]\n", " jtem = temp[temp[\"velo_track_idx\"]==jentry]\n",
" if ak.num(jtem,axis=0)>1:\n", " if ak.num(jtem,axis=0)>1:\n",
" if count==0:\n", " shared.append(jtem)\n",
" psb = jtem\n",
" count=1\n",
" else:\n",
" psb = ak.concatenate([psb,jtem],axis=0)\n",
" else:\n", " else:\n",
" continue\n", " continue\n",
" else:\n", " else:\n",
" continue\n", " continue\n",
"shared = ak.Array(shared)\n",
"\n", "\n",
"ak.num(psb, axis=0)" "idx=0\n",
"print(\"#events w/ shared track electrons from found and lost: \",ak.num(shared, axis=0))\n",
"\n",
"print(\"event_count: \", shared[idx,:,\"event_count\"])\n",
"print(\"velo idx: \" ,shared[idx,:,\"velo_track_idx\"])\n",
"print(\"mcp_index: \", shared[idx,:,\"mcp_idx\"])\n",
"\n",
"print(\"\\nvelo x: \" ,shared[idx,:,\"velo_track_x\"])\n",
"print(\"velo y: \" ,shared[idx,:,\"velo_track_y\"])\n",
"\n",
"print(\"\\nvelo tx: \" ,shared[idx,:,\"velo_track_tx\"])\n",
"print(\"velo ty: \" ,shared[idx,:,\"velo_track_ty\"])"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 37, "execution_count": 82,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "name": "stdout",
"text/plain": [ "output_type": "stream",
"217" "text": [
"#velo_track_idx in all events: 217\n",
"velo idx: [0, 0, 0]\n",
"mcp_index: [1066, 1251, 666]\n",
"event_count: [5735, 7049, 7378]\n",
"\n",
"velo x: [-2.21, 9.45, -18.5]\n",
"velo y: [-21.6, -33.4, 17.4]\n",
"\n",
"velo tx: [-0.0022, 0.0153, -0.0224]\n",
"velo ty: [-0.0263, -0.0469, 0.0212]\n"
] ]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"#electrons with same velo_track_idx from all events\n",
"temp_ = found[\"velo_track_idx\"].to_numpy()\n", "temp_ = found[\"velo_track_idx\"].to_numpy()\n",
"temp = np.unique(temp_)\n", "temp = np.unique(temp_)\n",
"count=0\n", "count=0\n",
@ -622,32 +637,10 @@
"\n", "\n",
"psb = ak.Array(psb)\n", "psb = ak.Array(psb)\n",
"\n", "\n",
"ak.num(psb,axis=0)" "print(\"#velo_track_idx in all events: \",ak.num(psb,axis=0))\n",
] "idx = 0\n",
}, "print(\"velo idx: \" ,psb[idx,:,\"velo_track_idx\"])\n",
{ "print(\"mcp_index: \", psb[idx,:,\"mcp_idx\"])\n",
"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(\"event_count: \", psb[idx,:,\"event_count\"])\n",
"print(\"\\nvelo x: \" ,psb[idx,:,\"velo_track_x\"])\n", "print(\"\\nvelo x: \" ,psb[idx,:,\"velo_track_x\"])\n",
"print(\"velo y: \" ,psb[idx,:,\"velo_track_y\"])\n", "print(\"velo y: \" ,psb[idx,:,\"velo_track_y\"])\n",
@ -656,17 +649,6 @@
"print(\"velo ty: \" ,psb[idx,:,\"velo_track_ty\"])" "print(\"velo ty: \" ,psb[idx,:,\"velo_track_ty\"])"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"for epair in range(10):\n",
" print(\"possibles[\", str(epair), \"]= \", psb[epair].tolist())"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@ -676,48 +658,112 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 83,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "name": "stdout",
"text/plain": [ "output_type": "stream",
"[-0.03604912757873535,\n", "text": [
" 0.01677863299846649,\n", "#events w/ shared track electrons from Photon Conversions: 951\n",
" 0.03238071873784065,\n", "shared_idx: 0\n",
" -0.009163273498415947,\n", "event_count: [11, 11]\n",
" -0.022408662363886833,\n", "velo idx: [27, 27]\n",
" -0.004034307319670916,\n", "mcp_index: [1211, 1215]\n",
" -0.01760791800916195,\n", "\n",
" 0.049464158713817596,\n", "velo x: [-20.4, -20.4]\n",
" -0.01695789396762848]" "velo y: [-24.4, -24.4]\n",
"\n",
"velo tx: [-0.0234, -0.0234]\n",
"velo ty: [-0.028, -0.028]\n"
] ]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"mo=found[(found[\"mother_key\"]==3) & (found[\"mother_id\"]==423)]\n", "#generell: wie viele elektronen von photon conversions teilen sich einen track?\n",
"mo\n", "conv = allcolumns[(allcolumns.fromPairProd) & (allcolumns.isElectron) & (~allcolumns.lost)]\n",
"\n", "\n",
"\"\"\"\n", "conv_it = conv[\"event_count\"].to_numpy()\n",
"mother_key : event number\n", "conv_itr = np.unique(conv_it)\n",
"mother_id : specific event type\n", "\n",
"\"\"\"\n", "cshared = ak.ArrayBuilder()\n",
"ak.num(mo[\"energy\"], axis=0)\n", "count = 0\n",
"#mother_key=3 : 9 particles\n", "\n",
"mo[\"velo_track_ty\"].tolist()" "for itr in conv_itr:\n",
" temp = conv[conv[\"event_count\"]==itr]\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",
" #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 = 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",
" cshared.append(jtem)\n",
" else:\n",
" continue\n",
" else:\n",
" continue\n",
"cshared = ak.Array(cshared)\n",
"\n",
"\n",
"print(\"#events w/ shared track electrons from Photon Conversions: \",ak.num(cshared, axis=0))\n",
"idx = 0\n",
"print(\"shared_idx: \", idx)\n",
"print(\"event_count: \", cshared[idx,:,\"event_count\"])\n",
"print(\"velo idx: \" ,cshared[idx,:,\"velo_track_idx\"])\n",
"print(\"mcp_index: \", cshared[idx,:,\"mcp_idx\"])\n",
"\n",
"print(\"\\nvelo x: \" ,cshared[idx,:,\"velo_track_x\"])\n",
"print(\"velo y: \" ,cshared[idx,:,\"velo_track_y\"])\n",
"\n",
"print(\"\\nvelo tx: \" ,cshared[idx,:,\"velo_track_tx\"])\n",
"print(\"velo ty: \" ,cshared[idx,:,\"velo_track_ty\"])"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,