Projektpraktikum/trackinglosses_endVelo_momEff.ipynb

157 lines
28 KiB
Plaintext
Raw Normal View History

2024-01-23 16:00:16 +01:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"import uproot\t\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from mpl_toolkits import mplot3d\n",
"import awkward as ak\n",
"from scipy.optimize import curve_fit\n",
"from methods.fit_linear_regression_model import fit_linear_regression_model\n",
"import sklearn\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"298 72\n",
"370\n"
]
}
],
"source": [
"file = uproot.open(\n",
" \"tracking_losses_ntuple_test_endVelo_momEff.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\"\n",
")\n",
"\n",
"# selektiere nur elektronen von B->K*ee\n",
"allcolumns = file.arrays()\n",
"found = allcolumns[\n",
" (allcolumns.isElectron) & (~allcolumns.lost) & (allcolumns.fromB)\n",
"] # B: 9056\n",
"lost = allcolumns[\n",
" (allcolumns.isElectron) & (allcolumns.lost) & (allcolumns.fromB)\n",
"] # B: 1466\n",
"\n",
"electrons = allcolumns[(allcolumns.isElectron) & (allcolumns.fromB)]\n",
"\n",
"print(ak.num(found, axis=0), ak.num(lost, axis=0))\n",
"print(ak.num(electrons, axis=0))\n",
"# ak.count(found, axis=None)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"stretch factor: 0.24161073825503357\n"
]
}
],
"source": [
"rad_length_found = ak.to_numpy(found[\"rad_length_frac\"])\n",
"eta_found = ak.to_numpy(found[\"eta\"])\n",
"rad_length_lost = ak.to_numpy(lost[\"rad_length_frac\"])\n",
"eta_lost = ak.to_numpy(lost[\"eta\"])\n",
"\n",
"stretch_factor = ak.num(eta_lost, axis=0) / ak.num(eta_found, axis=0)\n",
"print(\"stretch factor: \", stretch_factor)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjQAAAHJCAYAAACSb6NZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAABHK0lEQVR4nO3df4wj553f+Q81ksbyDjScnr0LdLnzeqp3c4H/sVTs2b3LBR54xfJe4AsO9pAzQZB4c2c1uU5vcIjg7fLsXjQzCtYUG8LlkEPDJtvGCc4liEQqQLLnu0OK2j0pweEu0yyPkVtvcGvWyM4Pb3Zldnl21qOWpof3R6vKzW7+KJJFdrH5fgEFDfk8VXxYolTfeZ7n+zypTqfTEQAAwBx75LgbAAAAMCkCGgAAMPcIaAAAwNwjoAEAAHOPgAYAAMw9AhoAADD3CGgAAMDcI6ABAABzj4AGQGK5rqtqtXrczQAwBwhogAXluq5s21Y+n9fy8rI2NjaOu0khz/OUz+eVyWRUqVQG1m00GrIsS6lUSqlUSufOndPy8rKWl5dlWZZs25bneTNqOYDjkmLrA2DxuK6rZ599Vjs7O5Ik27bl+/7Q4GHWUqmUTNNUs9mMVFeSms2mTNOUJNXrda2ursr3fTmOo2w2O9X2Ajg+jx53AwDMXqlU0tLSUvi6XC4fY2vilU6nwz/ncjlJUj6fVz6fDwM4ACcPQ07AAnJd97ibELuDgcxBQa+M7/sMPQEnGAENsECq1ary+bw8zwvnqeTzeTUajbCO7/sqFouybVuWZcmyrK7yer2uc+fOKZVKhYFRo9FQPp9XKpVSPp8Pr1OtVpXJZFSv19VoNJTJZLrqHBR8bnDENaen3W7Hch0ACdcBsHAMw+gYhnHk/Waz2Umn051msxm+V6lUOpI65XI5fK9QKHQkddVrtVodSZ1cLhe+zuVyHUmdbDbbWV9f7zSbzfDcg9drtVqddDrdcRwnfK9cLnckdUzTjPSd0ul0R1Kn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HPs2fP6oc//GHkD+wnnU7L932trq6Gs6MNwzgStQV7Qti2LcMw5HmebNvuWh55lnUAAFh0hmFoaWlJpVJJjuPINE1ZltXVISHtd1602+2uOTNxPWtHGg4LcsyDxluWpWw227VnwySiLqBjmmbfFLDjqAMAWGwv6DckSX+kPwz/fNDf6vQ+73tvPdA3Lk2zZT8RDDlNeo1e0ul0pGe4aZra2dnp+f6kz9rI3y2dTuvKlStqtVp644031Gq11Gq1wgDn53/+53XlyhVls1k9/fTTkqSvfe1reu655yZq4CJZW1tL7DmTnDeLz+E+jH/OrD9rVp+T9N/RrD7npN2HcT9rVuesrCU3YeS4JgXPSqrT6fSJG7ttbW1pdXU1fP2tb31Lr776qhqNRphjHmwZnk6ntbKyou3t7ViGo+bNW2+9Fa6vMGoa9kly9+5dnT17Vj/60Y9GTss8SbgP+7gP+7gP+07afejVKxPF9976vr5x6X+Z6vMimN/y30uKsmrc76h/kvn72l+L5uDO2EkROdg6GMxI0jPPPKNnnnlG0v6ie41GQ47jhBN7HMcJAxwAAHC8og45WR8cvbwt6WZcDYpZLL1HZ8+e1eXLl3X58mVJ0p07d+Q4jr70pS/FcXkAADChkz7kNJW2XbhwQYVCYeF7aD73uc/pwx/+cM+ytbW1mY45AwCOx63NbW1vNnuWvf/juHZYwlSDrcPDVIvmG9/4xkLPoQEASBfXVnRxrfdqucEcmlkIFseb9BpJleS2AQCQCKnU4Jkjnc5vjnn+7B7DJ33IKfJKwQAAAEmV5GALAADE5KT30CS5bXPr8ccf7/rnojp9+rSuX7+u06dH3XD+ZOE
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"endVeloP_found = ak.to_numpy(found[\"ideal_state_770_p\"])\n",
"trueP_found = ak.to_numpy(found[\"p\"])\n",
"nbins = 50\n",
"vmax = 5\n",
"\n",
"a0 = plt.hist2d(\n",
" trueP_found,\n",
" endVeloP_found,\n",
" density=False,\n",
" bins=nbins,\n",
" cmap=plt.cm.jet,\n",
" cmin=1,\n",
" vmax=vmax,\n",
" range=[[0, 30000], [0, 30000]],\n",
")\n",
"# plt.plot([-0.1, 1.0], [-0.1, 1.0], marker=\"\", alpha=0.8)\n",
"plt.xlabel(f\"True $P$\")\n",
"plt.ylabel(f\"endVelo $P$\")\n",
"plt.title(f\"found P\")\n",
"# ax1.set(xlim=(0,4000), ylim=(-1000,1000))\n",
"\n",
"plt.colorbar(a0[3])\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "tuner",
"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.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}