Hi I have a ROOT TTree with a bit of a complicated structure. When I use uproot to create an array:
analysis = uproot.open("/b/LJ_data/02Oct2019/FRVZ/FRVZprompt2zd_mH125_mzd01.root")["analysis"]
el_Eratio = analysis.arrays(["el_Eratio"], cache=mycache);
print(el_Eratio)
I get a Jagged Array:
{b'el_Eratio': <JaggedArray [[0.9679527 0.8814101 0.88584787] [0.34557977 0.22699767 0.9040524 0.0] [] ... [0.94681776] [0.91043043 0.621741 0.85297334 0.9364375] [0.83885396]] at 0x7f39cf32dfd0>}
I am trying to create a simple histogram of this data:
n, bins, patches = plt.hist(el_Eratio, 100, density = True)
But I am getting the error:
Traceback (most recent call last):
File "macro.py", line 45, in <module>
n, bins, patches = plt.hist(el_Eratio, 100, density = True)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2636, in hist
**({"data": data} if data is not None else {}), **kwargs)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/matplotlib/__init__.py", line 1589, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 6721, in hist
xmin = min(xmin, np.nanmin(xi))
TypeError: '<' not supported between instances of 'dict' and 'float'
Do I need to reformat the Jagged Array to a list or normal array? If so how do I do this?
Or am I just calling the array wrong? I also tried:
n, bins, patches = plt.hist(el_Eratio.values(), 100, density = True)
But I get a similar error:
Traceback (most recent call last):
File "macro.py", line 45, in <module>
n, bins, patches = plt.hist(el_Eratio.values(), 100, density = True)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2636, in hist
**({"data": data} if data is not None else {}), **kwargs)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/matplotlib/__init__.py", line 1589, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 6721, in hist
xmin = min(xmin, np.nanmin(xi))
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/numpy/lib/nanfunctions.py", line 298, in nanmin
res = np.amin(a, axis=axis, out=out, **kwargs)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 2618, in amin
initial=initial)
File "/opt/ohpc/pub/packages/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: operands could not be broadcast together with shapes (3,) (2,)
Disclamer: Although I have experience with root and C++, I am new to python.
Thanks, Sarah