Projektpraktikum/trackinglosses_rad_length_endVelo.ipynb

318 lines
131 KiB
Plaintext
Raw Normal View History

2024-01-22 16:03:16 +01:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 55,
"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": 56,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"40402 10099\n",
"50501\n"
]
}
],
"source": [
"file = uproot.open(\n",
" \"tracking_losses_ntuple_B_default_radlength_endVelo.root:PrDebugTrackingLosses.PrDebugTrackingTool/Tuple;1\"\n",
")\n",
"\n",
"# selektiere nur elektronen von B->K*ee\n",
"allcolumns = file.arrays()\n",
"found = allcolumns[(allcolumns.isElectron) & (~allcolumns.lost) &\n",
" (allcolumns.fromB)] # B: 9056\n",
"lost = allcolumns[(allcolumns.isElectron) & (allcolumns.lost) &\n",
" (allcolumns.fromB)] # 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": 57,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"stretch factor: 0.24996287312509283\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": 58,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAj8AAAHLCAYAAAAnR/mlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAyUUlEQVR4nO3dUYgb+4Hv+Z8nuafjTONT3c4+ZOFCXIJ5GC5cU+pc2HCJD1gisHnZpSUb9iGZ5dAqQr95GQnPi+2XEdXMa0NKZpizeVg4rTK7CzsPM6ozHIdlYNdWjQPLstzdLgfykAub010xfeP0mUx0H5wqt1rqbnVJJam6vh9oznGVqv5/ValVv/7//1X/a4PBYCAAAICC+KNFVwAAAGCeCD8AAKBQCD8AAKBQCD8AAKBQCD8AAKBQCD8AAKBQCD8AAKBQCD8AAKBQCD8otCAI1Ol0Fl2NwouiSJ1OR2EYLroquCR+h5BHhB8UUhiGqtfrKpfLcl13aPna2tpMv8yz2OekgiBQq9VSuVxWuVyee/mT6HQ6unXrlmzbVhRFU+0rfr/1el2lUkk7OzuzqWRKizz3WRv3O+T7vkqlkq5du6Zr166pXC7L87yRbT3PU7lcTl4TBMG5ZeXhc4x8IfygkEzTVLfbHVkeRZGiKNL+/n6q/YZhOHIBn3af07AsS/fv37/w4jJPp49Ro9FQo9GYer9BEOju3btyHEfdble1Wm2ux3zZzn3Wxv0OVSoV9fv95N+2batWq41sW6vVZNu2DMNQv9+XZVnnlrWMn2PkG+EHOMGyLA0GAzmOk2r7er2ug4ODme5zWhddWOZt3DG6efPm1Pttt9taX19P/u04zlCrXtaW8dwvgmEYajabkjT2D4xYv9/Xw4cPJ97vsn2OkW+EH2BG6vU6f5leIMtjtMhjz7kfFoca3/fPPC57e3szafED0iD8IBc8z1O1WpXv++p0OlpbW5Nt28n6nZ0d2badjAsYN8YiiiLZtp38jBsP4nme6vW66vX6y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IPwAAoFAY8wMAAAqlEHd7/epXv9Lf/d3f6Vvf+pauX7++6OoAAIAJvH37Vj//+c/1ve99T9/4xjdmtt9ChJ+//du/1Z/92Z8tuhoAACCFTz75RD/84Q9ntr9ChJ9vfvObkqSnT5+eO9/QNDY3N/Xs2bNM9n2Vyjg6OtKdO3f0/Plzra6uZlZO1u+DczG5q3CsOBfFKYNzsVxlBEGgra2t5Do+K5mFnx/96Efa2NjQxx9/nFURE/va174mSfqTP/mTzMLP9evXM9v3VSrjzZs3kqTbt2/rxo0bmZWT9fvgXEzuKhwrzkVxyuBcLFcZR0dHkt5fx2clkwHPr1+/luu6PM4eAAAsnUxafm7duiXXdXnWBwAAWDqZdXttbW1ltWsAAIDUMgs/3/ve9+Q4jm7fvp1VEZf2gx/8QF//+tfHrtve3tb29vacawQAQLHt7u5qd3d37Lrf/OY3mZSZOvzcv3//zHVRFMn3fe3t7S1V+PnJT36i7373u4uuBgAA+IPzGh9++tOf6s6dOzMvM3X46Xa7E73mL//yL9MWkSvzaDW6KmXMQ9bvg3MxuatwrDgXxSsja1flOOX1XKSe2+vevXtyHEfr6+sj6/b399XpdPTjH/946grOQpwcnz9/TsvPgr1580Yffvihfv3rX2d6GykuxrlYHpyL5cG5WC5ZXb9T3+pu27Zu3bqlDz/8cOTHsiyVy2X9xV/8xcwqCgAAMAupw8/du3fPXW+aplzXTbt7AACATKQe8/Pq1asz14VhqFarlXbXAAAAmUkdfizL0rVr185cPxgMtLOzk3b3AAAAmUgdfgzD0L1792QYxsi6mzdvyrKsC7vGAAAA5i11+Hn69Kk2NzdnWRcAAIDMpR7wTPABAAB5lNn0Fj/60Y+0sbGhjz/
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.hist(\n",
" rad_length_lost,\n",
" bins=100,\n",
" density=True,\n",
" alpha=0.5,\n",
" color=\"darkorange\",\n",
" histtype=\"bar\",\n",
" label=\"lost\",\n",
" range=[0, 1],\n",
")\n",
"plt.hist(\n",
" rad_length_found,\n",
" bins=100,\n",
" density=True,\n",
" alpha=0.5,\n",
" color=\"blue\",\n",
" histtype=\"bar\",\n",
" label=\"found\",\n",
" range=[0, 1],\n",
")\n",
"plt.xlim(0, 1)\n",
"# plt.yscale(\"log\")\n",
"plt.title(\"radiation length fraction endVelo\")\n",
"plt.xlabel(f\"$x/X_0$\")\n",
"plt.ylabel(\"a.u.\")\n",
"\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABiMAAAL7CAYAAACfnvZxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC5AUlEQVR4nOz9f5hb1X3o+3+2h+BOsI08pN9CnPZgTXsvpvnBlUwI+BxcQLopTdIfsWRyn5O0+Z6ClHbSQk0zKt+ee4bp87QTTYoLaaeNZN+Wc5KeE1tye9vclOZIQMx5jEsyUmlIMKftyGmLA+2lM/KPMDFhvL9/TCRmZq+1RtqjvbUlvV/Powe8PuvX/qVZey/tvS3btm0BAAAAAAAAAADwyKZudwAAAAAAAAAAAPQ3JiMAAAAAAAAAAICnmIwAAAAAAAAAAACeYjICAAAAAAAAAAB4iskIAAAAAAAAAADgKSYjAAAAAAAAAACAp5iMAAAAAAAAAAAAnmIyAgAAAAAAAAAAeIrJCAAAAAAAAAAA4CkmIwAAAAKmWq3K9PS0RKNRicfj3e5Oz6jVapLP5/tynZXLZUmn07J9+3YpFovd7g56FN8t3gjieu3n70MAANC7mIwAAAAIkGq1KkeOHJFMJiPValWZp1gsyvbt22V6etqXPvndXruq1arE43EZHR2VdDot5XK5213qqGKxKLlcTvL5vNTrdU/amJ6elmQyKdu3b5ft27dLOp32rK1OC/r+GRStfLegfab1WiwWJRqN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Figure size 2000x800 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nbins = 100\n",
"vmax = 80\n",
"\n",
"fig, ((ax0, ax1)) = plt.subplots(nrows=1, ncols=2, figsize=(20, 8))\n",
"\n",
"a0 = ax0.hist2d(\n",
" rad_length_found,\n",
" eta_found,\n",
" density=False,\n",
" bins=nbins,\n",
" cmap=plt.cm.jet,\n",
" cmin=1,\n",
" vmax=vmax,\n",
" range=[[0, 0.6], [2, 5]],\n",
")\n",
"ax0.set_xlabel(f\"$x/X_0$\")\n",
"ax0.set_ylabel(f\"$\\eta$\")\n",
"ax0.set_title(f\"found $\\eta$ rad_length_frac\")\n",
"\n",
"a1 = ax1.hist2d(\n",
" rad_length_lost,\n",
" eta_lost,\n",
" density=False,\n",
" bins=nbins,\n",
" cmap=plt.cm.jet,\n",
" cmin=1,\n",
" vmax=vmax * stretch_factor,\n",
" range=[[0, 0.6], [2, 5]],\n",
")\n",
"ax1.set_xlabel(f\"$x/X_0$\")\n",
"ax1.set_ylabel(f\"$\\eta$\")\n",
"ax1.set_title(f\"lost $\\eta$ rad_length_frac\")\n",
"# ax1.set(xlim=(0,4000), ylim=(-1000,1000))\n",
"\n",
"plt.suptitle(\"radiation length fraction and eta endVelo\")\n",
"plt.colorbar(a0[3], ax=ax1)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
"rad_length_frac = found[\"rad_length_frac\"]\n",
"# @ z = 9400.mm or 770.mm\n",
"state = 1\n",
"\n",
"if state == 1:\n",
" slopex = found[\"ideal_state_770_tx\"]\n",
" slopey = found[\"ideal_state_770_ty\"]\n",
" x = found[\"ideal_state_770_x\"]\n",
" y = found[\"ideal_state_770_y\"]\n",
" qop = found[\"ideal_state_770_qop\"]\n",
"elif state == 2:\n",
" slopex = found[\"ideal_state_9410_tx\"]\n",
" slopey = found[\"ideal_state_9410_ty\"]\n",
" x = found[\"ideal_state_9410_x\"]\n",
" y = found[\"ideal_state_9410_y\"]\n",
" qop = found[\"ideal_state_9410_qop\"]\n",
"\n",
"data = ak.zip({\n",
" \"rad_length_frac\": rad_length_frac,\n",
" \"x\": x,\n",
" \"y\": y,\n",
" \"tx\": slopex,\n",
" \"ty\": slopey,\n",
" \"qop\": qop,\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parameterisation for rad_length_frac:\n",
"intercept= 0.0\n",
"coef= {'1': 0.19432666451166924, 'x': -0.00010136532791187516, 'y': -0.00022209404990607013, 'tx': 0.058480207541052064, 'ty': 0.18599542917589618, 'qop': -17.657405901936546, 'x^2': 1.2271024867047469e-05, 'x y': 5.376824972059055e-08, 'x tx': -0.025941371835257743, 'x ty': 0.014328015524776564, 'x qop': -0.38410998543244235, 'y^2': -1.8261507968709735e-05, 'y tx': -0.014951077113227147, 'y ty': 0.02154311538810164, 'y qop': -0.008987663050567057, 'tx^2': 9.180854607357592, 'tx ty': 0.1873064867954838, 'tx qop': -0.47120712928737807, 'ty^2': -6.787398610853974, 'ty qop': -0.05031041352613623, 'qop^2': 0.24778641944197533, 'x^3': -5.992321693190818e-09, 'x^2 y': -2.649404482539432e-07, 'x^2 tx': 5.42176741002125e-06, 'x^2 ty': 0.0020253771536145383, 'x^2 qop': 0.003955288970107154, 'x y^2': 2.8906882704270233e-09, 'x y tx': -0.0016493773782229844, 'x y ty': 0.0005067592007986898, 'x y qop': -0.0031813438496783404, 'x tx^2': 0.0022653308811514867, 'x tx ty': -1.5366360302916284, 'x tx qop': -0.47946313010450653, 'x ty^2': -0.16776305178984158, 'x ty qop': 2.1889500302073115, 'x qop^2': 0.008745243979922932, 'y^3': 1.4363120470761714e-08, 'y^2 tx': -0.0005062978553841023, 'y^2 ty': 1.4165440283044409e-05, 'y^2 qop': -0.005787147937546765, 'y tx^2': 1.404047645962725, 'y tx ty': 0.1643910546131908, 'y tx qop': 2.0452379823825813, 'y ty^2': -0.02140660574730952, 'y ty qop': 4.596387657867597, 'y qop^2': -0.00994088354226498, 'tx^3': -0.1303976515212055, 'tx^2 ty': -0.01339610187978276, 'tx^2 qop': -0.0009383144690666937, 'tx ty^2': 0.010330807276347866, 'tx ty qop': 0.00564141621903312, 'tx qop^2': 1.1663926820802422e-05, 'ty^3': 0.00629773549670367, 'ty^2 qop': 0.012052455601588194, 'ty qop^2': -1.60166284721317e-05, 'qop^3': -1.5639205966369518e-06, 'x^4': 1.4244960766518489e-09, 'x^3 y': -3.1096076824610464e-09, 'x^3 tx': -3.587531603760352e-06, 'x^3 ty': 2.4713133050052738e-05, 'x^3 qop': 2.5845963699160437e-05, 'x^2 y^2': -2.0323240867980985e-09, 'x^2 y tx': -1.781414931473213e-05, 'x^2 y ty': -1.0125741814137612e-05, 'x^2 y qop': 0.00010504795400130865, 'x^2 tx^2': 0.00318540624554603, 'x^2 tx ty': -0.019979832566411563, 'x^2 tx qop': 0.006687084675785277, 'x^2 ty^2': 0.01525871952521068, 'x^2 ty qop': 0.5999059816243137, 'x^2 qop^2': 8.117293800523118, 'x y^3': 7.45386197209541e-10, 'x y^2 tx': 1.539536253053475e-05, 'x y^2 ty': -1.089334137566178e-05, 'x y^2 qop': -1.95550966909791e-05, 'x y tx^2': 0.015033712066153922, 'x y tx ty': -0.02448056876178019, 'x y tx qop': -0.6716914089728931, 'x y ty^2': 0.007182752502229531, 'x y ty qop': -0.18936713869537714, 'x y qop^2': 3.611377836849899, 'x tx^3': -0.9115227647899486, 'x tx^2 ty': 0.8829467327098821, 'x tx^2 qop': 0.2695607767961495, 'x tx ty^2': 0.6012451073716732, 'x tx ty qop': -0.00930712726835479, 'x tx qop^2': 0.009680202136377838, 'x ty^3': -0.06079594416933904, 'x ty^2 qop': 0.04029084967629493, 'x ty qop^2': 0.004774793771381167, 'x qop^3': -4.554461348017879e-05, 'y^4': 4.04032363121587e-12, 'y^3 tx': 8.925743423537913e-06, 'y^3 ty': -1.0182095510069544e-06, 'y^3 qop': -2.928516988854517e-05, 'y^2 tx^2': 0.004743417924369025, 'y^2 tx ty': -0.0055290127765494496, 'y^2 tx qop': 0.2133121554871387, 'y^2 ty^2': 0.0017685009285896116, 'y^2 ty qop': 0.020383665461783013, 'y^2 qop^2': -0.90657292007639, 'y tx^3': 0.27175992018246475, 'y tx^2 ty': 0.6761073293647273, 'y tx^2 qop': -0.01248506771745212, 'y tx ty^2': -0.39076013367696105, 'y tx ty qop': 0.04349449144257623, 'y tx qop^2': 0.004752914013263597, 'y ty^3': -0.729116504589348, 'y ty^2 qop': -0.015043560943011547, 'y ty qop^2': -0.001547809754472937, 'y qop^3': -1.316621299355546e-05, 'tx^4': -0.003228436324482351, 'tx^3 ty': 0.0044775047770867545, 'tx^3 qop': 0.001098230908109032, 'tx^2 ty^2': 0.0029303145639830285, 'tx^2 ty qop': -4.337425914757845e-05, 'tx^2 qop^2': 1.134299372765626e-05, 'tx ty^3': -0.0014086661449565522, 'tx ty^2 qop': 0.0001660768862220596, 'tx ty qop^2': 6.3521706353330705e-06, 'tx qop^3': -5.1281203369915226e-08, 'ty^4': -0.0071021220988862245, 'ty^3 qop': -6.7134108016768
"r2 score= 0.04993524171391073\n",
"RMSE = 0.12351226258714283\n",
"Type <class 'numpy.ndarray'>\n"
]
}
],
"source": [
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
" data,\n",
" \"rad_length_frac\",\n",
" [\"x\", \"y\", \"tx\", \"ty\", \"qop\"],\n",
" 5,\n",
" include_bias=True,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAikAAAHLCAYAAAAN9wgKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAABq00lEQVR4nO3de3xTdZ4//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MMNSp8WwOdlsBOVtk70RETK7Gw2W2QbqW+KxWKBw+GI2ww0ZcoUAMDPfvYzXH311YPG981vfhO//vWv+70f70lKRUUFtmzZMugx09k+2W3b29uxfPly7NixAyUlJarFkeq2qWyf6jVq4XNJddtMXqMWfh78nmYvjkxuq/XvaaInE4l+rwNA54UwfvX2MRwLdeCakhDqHn4gct/IhFOnTuECgEoApQB65RwLwLYLF3Dq1ClMnTo14XaVlZWorKyMTEuR7n04EUWTlC1btsDhcGD16tX9JsEKBoPw+/144IEH8N3vfhf33HOPkqcG8PnFJ5oQLdEPJ9FjKWk4Y6LHU1ITz9VXX43rrrtu0PjGjBmT1HYAMGrUqAEnTZOzfbLbtrW1AQCWLFmCcePGqRZHqtumsn2q16iFzyXVbTN5jVr4efB7mr04Mrltrn5PE/1eP3P+AtY9uxs9E4vxi79dgJMHd6EOkNU1IFmXA7hC5jHGpLCtxWKJ9EtJ9z6ciKJJSlNTU6TTTDzl5eWoqanBgw8+qORpI6Tew7FJhbRsMpkG3K+5uTnues44SkREyfr0bCce3roH57p74Fi5GDMmjcHJg2pHlVnSfTTd+3Aiio7ukaavH0ymOg3pdDoYjcZ+vYelDG/VqlUJ9zObzf3KaUuZYKo
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nbins = 100\n",
"vmax = 50\n",
"\n",
"a0 = plt.hist2d(\n",
" xx0_test,\n",
" xx0_predicted,\n",
" density=False,\n",
" bins=nbins,\n",
" cmap=plt.cm.jet,\n",
" cmin=1,\n",
" vmax=vmax,\n",
" range=[[-0.1, 0.6], [-0.1, 0.6]],\n",
")\n",
"plt.plot([-0.1, 0.6], [-0.1, 0.6], marker=\"\", alpha=0.8)\n",
"plt.xlabel(f\"True $x/X_0$\")\n",
"plt.ylabel(f\"Predicted $x/X_0$\")\n",
"plt.title(f\"found rad_length_frac\")\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
}