QA plots for the TPC detector
# imports to write dynamic markdown contents
import os
from IPython.display import display, Markdown, Latex
from IPython.display import HTML
# turn off/on code for the result HTML page
display(Markdown('*For the result HTML page:* '))
HTML('''<script>
code_show=false;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
For the result HTML page:
import uproot
import matplotlib.pyplot as plt
plt.style.use('seaborn-white')
import numpy as np
MapFile2D = '/cvmfs/eic.opensciencegrid.org/ecce/gcc-8.3/release/release_prop/prop.7/share/calibrations//Field/Map/sPHENIX.2d.root'
# 2D field map scaling on its working point
# https://github.com/ECCE-EIC/macros/blob/prop.7.0/detectors/EICDetector/Fun4All_G4_EICDetector.C#L460
magfield_2D_rescale = -1.4 / 1.5;
file = uproot.open(MapFile2D)
file.keys()
['fieldmap;1', 'h1;1']
file['fieldmap'].keys()
['r', 'z', 'br', 'bz']
df_fieldmap = file['fieldmap'].arrays(library="pd")
df_fieldmap['br'] = df_fieldmap['br'].apply(lambda x: x * magfield_2D_rescale)
df_fieldmap['bz'] = df_fieldmap['bz'].apply(lambda x: x * magfield_2D_rescale)
df_fieldmap
r | z | br | bz | |
---|---|---|---|---|
0 | 300.0 | 400.0 | 0.004610 | -0.002614 |
1 | 298.0 | 400.0 | 0.004837 | -0.002521 |
2 | 296.0 | 400.0 | 0.005066 | -0.002391 |
3 | 294.0 | 400.0 | 0.005322 | -0.002253 |
4 | 292.0 | 400.0 | 0.005585 | -0.002108 |
... | ... | ... | ... | ... |
60546 | 8.0 | -400.0 | -0.002663 | 0.007943 |
60547 | 6.0 | -400.0 | -0.002007 | 0.008361 |
60548 | 4.0 | -400.0 | -0.001348 | 0.008561 |
60549 | 2.0 | -400.0 | -0.000696 | 0.008769 |
60550 | 0.0 | -400.0 | -0.000000 | 0.008848 |
60551 rows × 4 columns
X=df_fieldmap['z'].values
Y=df_fieldmap['r'].values
Z=df_fieldmap.apply(lambda x: np.sqrt(x['br']*x['br'] + x['bz']*x['bz']), axis=1).values
limits = np.arange(0,2.5,.1);
fig, ax = plt.subplots(figsize=(16,6))
ax.set_aspect('equal')
ax.tricontourf(X,Y,Z,limits, cmap='Spectral_r')
contours = ax.tricontour(X,Y,Z, limits)
ax.clabel(contours, inline=True, fontsize=8)
ax.set_xlabel('z [cm]')
ax.set_ylabel('R [cm]')
ax.set_title("Total B strengh [T] : " + MapFile2D)
fig.show()
df_fieldmap.to_csv('sPHENIX.2d.csv');
MapFile3D = '/cvmfs/eic.opensciencegrid.org/ecce/gcc-8.3/release/release_prop/prop.7/share/calibrations//Field/Map/sphenix3dbigmapxyz.root'
file = uproot.open(MapFile3D)
file.keys()
['fieldmap;13', 'fieldmap;12']
file['fieldmap'].keys()
['x', 'y', 'z', 'bx', 'by', 'bz', 'hz']
df_fieldmap = file['fieldmap'].arrays(library="pd")
df_fieldmap
x | y | z | bx | by | bz | hz | |
---|---|---|---|---|---|---|---|
0 | -270.0 | -270.0 | -330.0 | 0.001434 | 0.001430 | -0.002762 | -0.002762 |
1 | -270.0 | -270.0 | -328.0 | 0.001390 | 0.001386 | -0.002795 | -0.002795 |
2 | -270.0 | -270.0 | -326.0 | 0.001345 | 0.001341 | -0.002826 | -0.002826 |
3 | -270.0 | -270.0 | -324.0 | 0.001299 | 0.001295 | -0.002855 | -0.002855 |
4 | -270.0 | -270.0 | -322.0 | 0.001252 | 0.001248 | -0.002881 | -0.002881 |
... | ... | ... | ... | ... | ... | ... | ... |
24308966 | 270.0 | 270.0 | 322.0 | 0.001292 | 0.001240 | -0.003005 | -0.003005 |
24308967 | 270.0 | 270.0 | 324.0 | 0.001341 | 0.001289 | -0.002977 | -0.002977 |
24308968 | 270.0 | 270.0 | 326.0 | 0.001389 | 0.001338 | -0.002947 | -0.002947 |
24308969 | 270.0 | 270.0 | 328.0 | 0.001436 | 0.001385 | -0.002915 | -0.002915 |
24308970 | 270.0 | 270.0 | 330.0 | 0.001482 | 0.001432 | -0.002881 | -0.002881 |
24308971 rows × 7 columns
df_fieldmap_yz = df_fieldmap[df_fieldmap['x'] == 0]
df_fieldmap_yz
x | y | z | bx | by | bz | hz | |
---|---|---|---|---|---|---|---|
12109635 | 0.0 | -270.0 | -330.0 | 0.000137 | 0.009904 | -0.092114 | -0.092114 |
12109636 | 0.0 | -270.0 | -328.0 | 0.000332 | 0.005110 | -0.095648 | -0.095648 |
12109637 | 0.0 | -270.0 | -326.0 | 0.000301 | 0.000888 | -0.091804 | -0.091804 |
12109638 | 0.0 | -270.0 | -324.0 | 0.000270 | -0.004503 | -0.089257 | -0.089257 |
12109639 | 0.0 | -270.0 | -322.0 | 0.000258 | -0.010979 | -0.088455 | -0.088455 |
... | ... | ... | ... | ... | ... | ... | ... |
12199331 | 0.0 | 270.0 | 322.0 | 0.000173 | -0.010986 | -0.090137 | -0.090137 |
12199332 | 0.0 | 270.0 | 324.0 | 0.000142 | -0.004388 | -0.090975 | -0.090975 |
12199333 | 0.0 | 270.0 | 326.0 | 0.000133 | 0.001115 | -0.093587 | -0.093587 |
12199334 | 0.0 | 270.0 | 328.0 | 0.000149 | 0.005438 | -0.097469 | -0.097469 |
12199335 | 0.0 | 270.0 | 330.0 | 0.000049 | 0.010424 | -0.093614 | -0.093614 |
89701 rows × 7 columns
X=df_fieldmap_yz['z'].values
Y=df_fieldmap_yz['y'].values
Z=df_fieldmap_yz.apply(lambda x: np.sqrt(x['bx']*x['bx'] + x['by']*x['by'] + x['bz']*x['bz']), axis=1).values
limits = np.arange(0,2.5,.1);
fig, ax = plt.subplots(figsize=(16,16))
ax.set_aspect('equal')
ax.tricontourf(X,Y,Z,limits, cmap='Spectral_r')
contours = ax.tricontour(X,Y,Z, limits)
ax.clabel(contours, inline=True, fontsize=8)
ax.set_xlabel('z [cm]')
ax.set_ylabel('y [cm]')
ax.set_title("Total B strengh [T] @ x=0 : " + MapFile3D)
fig.show()
df_fieldmap.to_csv('sphenix3dbigmapxyz.csv');