Projektpraktikum/trackinglosses_rad_length_beginVelo.ipynb

408 lines
186 KiB
Plaintext
Raw Normal View History

2024-01-22 16:03:16 +01:00
{
"cells": [
{
"cell_type": "code",
2024-01-23 16:00:16 +01:00
"execution_count": 9,
2024-01-22 16:03:16 +01:00
"metadata": {},
"outputs": [],
"source": [
"import uproot\t\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pylab\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",
2024-01-23 16:00:16 +01:00
"execution_count": 10,
2024-01-22 16:03:16 +01:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"40402 10099\n",
"50501\n"
]
}
],
"source": [
"file = uproot.open(\n",
" \"tracking_losses_ntuple_B_default_radlength_beginVelo.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",
2024-01-23 16:00:16 +01:00
"execution_count": 11,
2024-01-22 16:03:16 +01:00
"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",
"phi_found = ak.to_numpy(found[\"phi\"])\n",
"\n",
"rad_length_lost = ak.to_numpy(lost[\"rad_length_frac\"])\n",
"eta_lost = ak.to_numpy(lost[\"eta\"])\n",
"phi_lost = ak.to_numpy(lost[\"phi\"])\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",
2024-01-23 16:00:16 +01:00
"execution_count": 12,
2024-01-22 16:03:16 +01:00
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjYAAAHLCAYAAADbUtJvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAxt0lEQVR4nO3dTWwb653n+59u9xzFieBTkrPJAAHiItCbXoxR1NkEjdiAyc4iS5M2cIHJaeBAJALtDDQJ9cbypgkSvbkLDVI0MnMmAwxgszwvwO1FN3kadjAIcMdmtbO5mHtxVW7AiwzQORJjaOLo5IV34VQdUXwRVWSxisXvBxDOUZFVz5/10FV/PfW8rPX7/b4AAABS4H+LOwAAAIB5IbEBAACpQWIDAABSg8QGAACkBokNAABIDRIbAACQGiQ2AAAgNUhsAABAapDYYGm5rqtmsxl3GCuv1+up2WzK87y4Q0kVz/PUbDbV6/XiDgVYKiQ2WDqe56lYLCqbzcq27YHtm5ubc012ojjmtFzXVbVaVTabVTabXXj502g2m7p+/brK5fLMN2D/8xaLRWUyGTUajfkEGVKcdd9oNJTJZFQul3V0dLSwcmf5zJ1OR5lMRmtra1pbW1M2m5XjOEPvcxxH2Ww2eI/ruhOPuwz/DpAsJDZYOqZpqtVqDW3v9Xrq9Xo6PDwMdVzP84ZuzrMecxaWZenevXsXXvgX6fw5KpVKKpVKMx/XdV3dvn1b9XpdrVZLhUJhoec8aXVfqVRUKBQWXu4snz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jef78eaSJDabz9u1bffjhh/rlL38Z6VBKXIy6SA7qIjmoi+SI8v4duo9NuVz
"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 beginVelo\")\n",
"plt.xlabel(f\"$x/X_0$\")\n",
"plt.ylabel(\"a.u.\")\n",
"\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-01-23 16:00:16 +01:00
"execution_count": 13,
2024-01-22 16:03:16 +01:00
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABiMAAAL7CAYAAACfnvZxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAADuDUlEQVR4nOz9cXQd133Y+/42KZNBq0gHoO/SdfzU0AdsXuh7zeidQ0d5YRU7T0DNu2qtdSkCtkjcrtSpBaSB2MZuCkRNXJpxHBpMWt1bCq0BuXHy7iJhGaC4VuW+0gHcyHXo2jFxqlKvZl4uAdPljVLdSjjHslpYsMD9/oDOEcCzf79zZnBmMAC+n7WwJM5vZu/f3rNnzsyZMzPOe+8FAAAAAAAAAAAgITs2OgEAAAAAAAAAALC1cTECAAAAAAAAAAAkiosRAAAAAAAAAAAgUVyMAAAAAAAAAAAAieJiBAAAAAAAAAAASB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hHR4cMDw/XviCcnZ1tSflZEXfcW/08Pz/f8i9JszA+09g2k9i3JLH9pL2fqq7j6vsM1tOmrG/b/f39a97RMj4+vubl1iLJrNMsbWsAAGDz42IEAACAwXoZaEj1i5vTp09vaB6rxXl0RvUXuKVSSf0Cufql6O1fiKUll8vV+vvRRx9d8+vx1Xp7e9XnwEfV29srk5OTMjY2Vvtvs49w2UyPMIk63qpflp8+fVodLwMDA8EvqDf7+FzPthlFq/ct691+Qustrb6oKpVKksvlao9ZWk+b1rNtp+X2x12tfnG1SDL7xCxtawAAYPPjYgQAAICh+oXb008
"text/plain": [
"<Figure size 2000x800 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nbins = 100\n",
"vmax = 60\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 beginVelo\")\n",
"plt.colorbar(a0[3], ax=ax1)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-01-23 16:00:16 +01:00
"execution_count": 14,
2024-01-22 16:03:16 +01:00
"metadata": {},
2024-01-23 16:00:16 +01:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parameterisation for rad_length_frac:\n",
"intercept= 0.0\n",
"coef= {'1': 0.4397780582886272, 'x': -0.00033503537608265674, 'y': -4.789321464958182e-05, 'tx': 0.29235639572920724, 'ty': 0.04582618208302177, 'qop': -6.415064049320476, 'x^2': -1.7148780985188313e-05, 'x y': 6.213092137729638e-05, 'x tx': 0.0357792373581695, 'x ty': -0.03383507316198001, 'x qop': 5.411983741236269, 'y^2': -0.0001816058133305051, 'y tx': -0.060157737422332554, 'y ty': 0.3005860193729231, 'y qop': -0.5258168180545822, 'tx^2': -20.581151289333324, 'tx ty': 33.044369657406456, 'tx qop': -4029.9409136973454, 'ty^2': -125.62371943789807, 'ty qop': 353.08874965548245, 'qop^2': -3.455196781164501, 'x^3': 1.5371780097645036e-07, 'x^2 y': -1.2426481494632311e-06, 'x^2 tx': -0.0003102207951011151, 'x^2 ty': 0.0008294673378711963, 'x^2 qop': -0.0013130710648701907, 'x y^2': 1.3249247615395102e-07, 'x y tx': 0.0018733641082853674, 'x y ty': 0.0011459295349262105, 'x y qop': 0.0019703515773188207, 'x tx^2': 0.20678893428535178, 'x tx ty': -1.2036256002683805, 'x tx qop': 0.5976253324202965, 'x ty^2': -1.0782570211818505, 'x ty qop': 102.9459912574048, 'x qop^2': -399.16918894718305, 'y^3': 6.233244675968308e-07, 'y^2 tx': -0.0013994133271424403, 'y^2 ty': -0.001494031769823323, 'y^2 qop': 0.000739172959467016, 'y tx^2': -0.7290175680182052, 'y tx ty': 1.243439836769458, 'y tx qop': -105.55527881418587, 'y ty^2': 1.1837378224511292, 'y ty qop': -0.7657500120637686, 'y qop^2': 337.9089334089693, 'tx^3': -46.002810282557306, 'tx^2 ty': 453.57769058127064, 'tx^2 qop': -38.01772137810428, 'tx ty^2': -37.626648454968965, 'tx ty qop': 1.8221207378503694, 'tx qop^2': -0.40208255096589585, 'ty^3': -309.9803925733283, 'ty^2 qop': 15.736234283455065, 'ty qop^2': 0.6119680938280082, 'qop^3': -0.0011848472786331894, 'x^4': 1.4258219493967772e-08, 'x^3 y': -2.866883619390137e-09, 'x^3 tx': -4.622450717306492e-05, 'x^3 ty': -9.82760022623097e-05, 'x^3 qop': -0.0003703064328215433, 'x^2 y^2': -2.5736142106325133e-09, 'x^2 y tx': 0.00010255319807583874, 'x^2 y ty': 4.727919866809316e-05, 'x^2 y qop': -0.0006108544453127251, 'x^2 tx^2': 0.0554175462089006, 'x^2 tx ty': 0.16472559466997527, 'x^2 tx qop': 0.4783758545936343, 'x^2 ty^2': -0.029491297111002623, 'x^2 ty qop': 0.4072459238308874, 'x^2 qop^2': 1.274082272606741, 'x y^3': 1.019856199491187e-08, 'x y^2 tx': -4.0220230914655986e-05, 'x y^2 ty': -7.807169754414645e-05, 'x y^2 qop': 0.0009660222713137046, 'x y tx^2': -0.1655492341343554, 'x y tx ty': -0.026431127204681104, 'x y tx qop': 0.6220634937641649, 'x y ty^2': 0.09539033507193473, 'x y ty qop': -1.5617368820840163, 'x y qop^2': 9.235370076473936, 'x tx^3': -29.04572443637665, 'x tx^2 ty': -68.28508620169197, 'x tx^2 qop': -138.17259913877646, 'x tx ty^2': 35.45859347871301, 'x tx ty qop': -273.5835489656032, 'x tx qop^2': -13.43661305575325, 'x ty^3': -32.63704432223729, 'x ty^2 qop': 266.4268072225656, 'x ty qop^2': -19.06231959583929, 'x qop^3': 1.7675392248918753, 'y^4': -5.9619367220875574e-09, 'y^3 tx': 5.3697276143793715e-05, 'y^3 ty': 1.6576491020714457e-05, 'y^3 qop': -0.00017261869555795784, 'y^2 tx^2': 0.05014539344681879, 'y^2 tx ty': -0.07584181301500559, 'y^2 tx qop': -0.11650839062004614, 'y^2 ty^2': -0.015097852966895253, 'y^2 ty qop': 0.30517451156427916, 'y^2 qop^2': -6.650919392954738, 'y tx^3': 67.30430825382783, 'y tx^2 ty': -34.801544500318485, 'y tx^2 qop': -142.686910608299, 'y tx ty^2': 27.185653317937266, 'y tx ty qop': 439.1032304393983, 'y tx qop^2': -18.23933135674488, 'y ty^3': 4.265555264813383, 'y ty^2 qop': -131.08781810964697, 'y ty qop^2': 34.20534645433437, 'y qop^3': 0.11852127731033578, 'tx^4': 5649.699838454551, 'tx^3 ty': 329.9615549901753, 'tx^3 qop': -5.54031835759426, 'tx^2 ty^2': 584.460443200635, 'tx^2 ty qop': -0.7411483064667538, 'tx^2 qop^2': -0.03588219456135393, 'tx ty^3': 173.96226240131907, 'tx ty^2 qop': 1.0493642752682577, 'tx ty qop^2': -0.052660249222163585, 'tx qop^3': 0.001973073444663188, 'ty^4': 215.62061929608907, 'ty^3 qop': -0.5416245412488983, 'ty^2 qop^2': 0.09234573370962393, 'ty qop^3': 0.0002451739001199065, 'qop^4': 2.303474287996047e-05}\n",
"r2 score= 0.07032743800675567\n",
"RMSE = 0.1530771991719649\n",
"\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAikAAAHLCAYAAAAN9wgKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAABsKUlEQVR4nO3de3xU9Z0//lcIEAKBDAFFFIHMgCIgyhmw9iZqZrzUO0lgt91u261kZOl2v+tqRvYrAloZJrXd77ZN6yR267a7+6tkYsV7nQHFVmslM0YMF4GcAIKIwmQIgVxI5vz+iGfMTOZ+ztxfz8djHnDmzDnnPSeXeefzeX8+nwJJkiQQERERZZhR6Q6AiIiIKBQmKURERJSRmKQQERFRRmKSQkRERBmJSQoRERFlJCYpRERElJGYpBAREVFGYpJCREREGYlJClEGc7vdaGhoyNvrJ4PX60VDQwNEUUx3KEQUBZMUyltutxtmsxnV1dXQ6XSoq6tLd0h+oiiiuroaer0eNpstK64v30+9Xg+9X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x2uNRqO/LkXp52owVZOUlpYWf9FMKBUVFaitrcVDDz2k5mUTJlcbB/eRydt6vT7lMRERUXb79EwvHnluN872D8CyfBHKp07AZwfSHVVyyZ+nan+uqjq6R16+PppkFg3FQ6PRQBCEEdXGcka4YsWKdIRFRERZ6mjnOZjtuzDg88FaOZSgpFohhloglDwK47iew+Hwrxyv9ueqqknKwYMHsXbtWhw+fDjk/kOHDuGJJ57wF9YkQ6SiHFEUodPpAoZLNTY2+peml1mtVlitVi6HTkREMTv4aTc
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
2024-01-22 16:03:16 +01:00
"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",
2024-01-23 16:00:16 +01:00
"})\n",
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
" data,\n",
" \"rad_length_frac\",\n",
" [\"x\", \"y\", \"tx\", \"ty\", \"qop\"],\n",
" 4,\n",
" include_bias=True,\n",
")\n",
"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.2, 1.0], [-0.2, 1.0]],\n",
")\n",
"plt.plot([-0.2, 1], [-0.2, 1], 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()"
2024-01-22 16:03:16 +01:00
]
},
{
"cell_type": "code",
2024-01-23 16:00:16 +01:00
"execution_count": 17,
2024-01-22 16:03:16 +01:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parameterisation for rad_length_frac:\n",
"intercept= 0.0\n",
2024-01-23 16:00:16 +01:00
"coef= {'1': 0.4479234646536249, 'x': -0.0004084072172278079, 'y': -0.0004337281522268355, 'tx': 0.36162738714391346, 'ty': 0.3074416852772706, 'qop': 8.6879246998874, 'x^2': 6.870638463563449e-05, 'x y': -0.00012148333505099224, 'x tx': -0.08753632946361847, 'x ty': -0.008841630356866574, 'x qop': 2.3636302084612413, 'y^2': -0.00010231235440107948, 'y tx': 0.18497450621593262, 'y ty': 0.1675559125761048, 'y qop': -4.153708925054445, 'tx^2': 23.782917176875543, 'tx ty': -66.05577891519296, 'tx qop': -1451.879997584788, 'ty^2': -72.70407315466386, 'ty qop': 2811.440565472475, 'qop^2': 25.48376520289995, 'x^3': 3.312211575601438e-06, 'x^2 y': 4.1376174463449524e-06, 'x^2 tx': -0.007073302591271084, 'x^2 ty': -0.007343778680981201, 'x^2 qop': -0.010800896868279859, 'x y^2': -1.888730589918227e-06, 'x y tx': -0.0015500723141160817, 'x y ty': 0.003351080332733322, 'x y qop': -0.01735357445380728, 'x tx^2': 4.990549905339206, 'x tx ty': 7.558985701868668, 'x tx qop': 4.476707229937508, 'x ty^2': -1.104445169997775, 'x ty qop': -9.151537967253478, 'x qop^2': -910.3882764082207, 'y^3': -1.052533550094381e-06, 'y^2 tx': 0.0005507301794551722, 'y^2 ty': 0.002357501338451584, 'y^2 qop': 0.007420585610647734, 'y tx^2': -1.250712090046683, 'y tx ty': -1.5531355410763075, 'y tx qop': 19.84686939382025, 'y ty^2': -1.7462277992951187, 'y ty qop': -5.356037569819987, 'y qop^2': -279.7638120237527, 'tx^3': -1165.212129591651, 'tx^2 ty': -1478.3661751151212, 'tx^2 qop': 11.51188378893173, 'tx ty^2': 595.4188893174843, 'tx ty qop': 230.63755941369075, 'tx qop^2': -0.10882234534500138, 'ty^3': 429.2917082507941, 'ty^2 qop': -82.0662171571117, 'ty qop^2': -1.9459565902791414, 'qop^3': 0.024415724018080082, 'x^4': -1.475717681387323e-08, 'x^3 y': -8.159629061310625e-08, 'x^3 tx': 1.8736542919839394e-05, 'x^3 ty': 0.00021665972144546686, 'x^3 qop': 0.0006989376250565726, 'x^2 y^2': 2.718623193231906e-08, 'x^2 y tx': -2.4239682488769176e-05, 'x^2 y ty': -8.084108489470054e-05, 'x^2 y qop': -0.003167100608976625, 'x^2 tx^2': 0.008320473005383633, 'x^2 tx ty': -0.31099673106925607, 'x^2 tx qop': -0.9590579633902261, 'x^2 ty^2': -0.06873651193829033, 'x^2 ty qop': 5.972868443095723, 'x^2 qop^2': 8.034990024240143, 'x y^3': 4.6192553782020696e-08, 'x y^2 tx': 1.2378456318629105e-05, 'x y^2 ty': -5.5412774827345856e-05, 'x y^2 qop': -0.0013019927555433242, 'x y tx^2': 0.15448353292862294, 'x y tx ty': 0.2778324639753933, 'x y tx qop': -1.204014224641027, 'x y ty^2': 0.016434784323337226, 'x y ty qop': 2.818541810627377, 'x y qop^2': 8.034350363325663, 'x tx^3': -18.77883071123092, 'x tx^2 ty': 117.5404832475735, 'x tx^2 qop': 350.73626782625695, 'x tx ty^2': -43.39398761296841, 'x tx ty qop': -3601.6230380405145, 'x tx qop^2': -33.190862612375746, 'x ty^3': 0.3797357610145699, 'x ty^2 qop': -1234.3747950404918, 'x ty qop^2': 83.83558397109758, 'x qop^3': -5.702215445849627, 'y^4': -2.336150828341488e-09, 'y^3 tx': -4.0570866303824005e-05, 'y^3 ty': -2.348613449498771e-06, 'y^3 qop': 0.001158537918854563, 'y^2 tx^2': -0.1482288223321575, 'y^2 tx ty': 0.04527719555944287, 'y^2 tx qop': -1.0009453937475368, 'y^2 ty^2': 0.013540534251312408, 'y^2 ty qop': -1.6075747378736662, 'y^2 qop^2': -9.84256818846896, 'y tx^3': -69.10849756704471, 'y tx^2 ty': 21.121054597115727, 'y tx^2 qop': 1848.9215712994694, 'y tx ty^2': -9.234237076693203, 'y tx ty qop': 564.3519892221238, 'y tx qop^2': 68.38095505038116, 'y ty^3': -12.464249025545804, 'y ty^2 qop': 551.51219619504, 'y ty qop^2': 39.825100090236965, 'y qop^3': -1.0176409285192534, 'tx^4': 6221.962679980016, 'tx^3 ty': -3592.5750251228064, 'tx^3 qop': -27.664174751180994, 'tx^2 ty^2': 2731.878418172401, 'tx^2 ty qop': 13.736715296965578, 'tx^2 qop^2': -0.04199811775300766, 'tx ty^3': -2185.0268615440154, 'tx ty^2 qop': -15.049641135727613, 'tx ty qop^2': 0.13949642224427028, 'tx qop^3': -0.008320294336365015, 'ty^4': 3532.7413364811573, 'ty^3 qop': 24.266869324033923, 'ty^2 qop^2': 0.13092733573127732, 'ty qop^3': -0.0016184008383619774, 'qop^4': -0.00044028977350282306}\n",
"r2 score= 0.005485148161997189\n",
"RMSE = 0.27783626532276307\n",
"\n"
2024-01-22 16:03:16 +01:00
]
2024-01-23 16:00:16 +01:00
},
2024-01-22 16:03:16 +01:00
{
"data": {
2024-01-23 16:00:16 +01:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhoAAAHLCAYAAACOMzExAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPY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BPPDAAyk5ZyCRiNZyES/RKC4uBjCQBMVa9Gk4iouLZR+js7MTALB48WKMHz9e8XjUdhxen9h4feLjNYot16/P17/+9YT2efXjz9D8URvuXz4b/6t8Nv78pz8CgKyu9uG6GsBUGfurpTYipXG0tLQEizMjKS8vR01NDdasWZOycwZGl4TXYgTu6/X6lJ2LiIjygyRJcLQcw2/fO4J7vnYVHvimgBEjCpQOKyuldNTJpEmThvW8VBbQaDQa6HS6IaNLAlMcr1y5MmXnIiKi3CdJEn7958P47XtH8D9vnI7VtyiTZIzEQGtAsreRGY84spQmGocOHcLatWtx5MiRiNsPHz6Mp556KljAGU2sAk5RFKHVakPWSmhoaAgumx1gs9lgs9m4XDMREQ2b3y/hX944hN/vOo7Vtwr43g3Tg3WGmTYKwGgZt6ztOnnjjTfw7W9/O+K2Z555BiaTCWVlZSgoKIBGo0FpaWlw9UYAqKysxPPPPx/1+B6PJzgbaGNjI4xGIwwGQzBhCMw0ODgZ0el0cLvdsFgsEAQBoijCYrFwqmMiIhq23j4/nt7+Cd4Tz+Bh4xzcdp2cUkwKSDjRMJlMOHPmTNTtDocD7e3tcLvdaGlpgc/ng1arhSAI0Ol0KCsri3l8nU4Hu90
2024-01-22 16:03:16 +01:00
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-01-23 16:00:16 +01:00
"rad_length_frac = lost[\"rad_length_frac\"]\n",
"# @ z = 9400.mm or 770.mm\n",
"state = 1\n",
"\n",
"if state == 1:\n",
" slopex = lost[\"ideal_state_770_tx\"]\n",
" slopey = lost[\"ideal_state_770_ty\"]\n",
" x = lost[\"ideal_state_770_x\"]\n",
" y = lost[\"ideal_state_770_y\"]\n",
" qop = lost[\"ideal_state_770_qop\"]\n",
"elif state == 2:\n",
" slopex = lost[\"ideal_state_9410_tx\"]\n",
" slopey = lost[\"ideal_state_9410_ty\"]\n",
" x = lost[\"ideal_state_9410_x\"]\n",
" y = lost[\"ideal_state_9410_y\"]\n",
" qop = lost[\"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",
"})\n",
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
" data,\n",
" \"rad_length_frac\",\n",
" [\"x\", \"y\", \"tx\", \"ty\", \"qop\"],\n",
" 4,\n",
" include_bias=True,\n",
")\n",
"\n",
2024-01-22 16:03:16 +01:00
"nbins = 100\n",
2024-01-23 16:00:16 +01:00
"vmax = 50\n",
2024-01-22 16:03:16 +01:00
"\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",
2024-01-23 16:00:16 +01:00
" vmax=vmax * stretch_factor,\n",
" range=[[-0.1, 1.0], [-0.1, 1.0]],\n",
2024-01-22 16:03:16 +01:00
")\n",
2024-01-23 16:00:16 +01:00
"plt.plot([-0.1, 1], [-0.1, 1], marker=\"\", alpha=0.8)\n",
2024-01-22 16:03:16 +01:00
"plt.xlabel(f\"True $x/X_0$\")\n",
"plt.ylabel(f\"Predicted $x/X_0$\")\n",
2024-01-23 16:00:16 +01:00
"plt.title(f\"lost rad_length_frac\")\n",
2024-01-22 16:03:16 +01:00
"# 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": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test = ak.zip({\n",
" \"tx\": slopex,\n",
" \"ty\": slopey,\n",
" \"x\": x,\n",
" \"y\": y,\n",
" \"qop\": qop,\n",
"})\n",
"test = np.column_stack([ak.to_numpy(test[feat]) for feat in features])"
]
}
],
"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
}