Hello,
I tried to run the HZZAnalysis Jupyter notebook, but found that the cell that loads data from a ROOT file throws an error. The cell in question is:
# Accessing the file from the online directory (":mini" opens the tree in a desired manner)
with uproot.open(data_A_path + ":mini") as t:
tree = t
# There are 39 entries in the tree
print(tree.num_entries)
# We can view all the information stored in the tree using the .keys() method.
print(tree.keys())
# We can also view the entire tree using the .arrays() method
# This generates a 39-entry list of dictionaries
print(tree.arrays())
The error is pasted below. Moving the print(tree.arrays()) statement into the with block solves it, so there seems to be an issue with the file needing to be open to access the arrays.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[10], line 13
9 print(tree.keys())
11 # We can also view the entire tree using the .arrays() method
12 # This generates a 39-entry list of dictionaries
---> 13 print(tree.arrays())
File /srv/conda/envs/notebook/lib/python3.11/site-packages/uproot/behaviors/TBranch.py:888, in HasBranches.arrays(self, expressions, cut, filter_name, filter_typename, filter_branch, aliases, language, entry_start, entry_stop, decompression_executor, interpretation_executor, array_cache, library, ak_add_doc, how)
885 ranges_or_baskets.append((branch, basket_num, range_or_basket))
887 interp_options = {"ak_add_doc": ak_add_doc}
--> 888 _ranges_or_baskets_to_arrays(
889 self,
890 ranges_or_baskets,
891 branchid_interpretation,
892 entry_start,
893 entry_stop,
894 decompression_executor,
895 interpretation_executor,
896 library,
897 arrays,
898 False,
899 interp_options,
900 )
902 # no longer needed; save memory
903 del ranges_or_baskets
File /srv/conda/envs/notebook/lib/python3.11/site-packages/uproot/behaviors/TBranch.py:3099, in _ranges_or_baskets_to_arrays(hasbranches, ranges_or_baskets, branchid_interpretation, entry_start, entry_stop, decompression_executor, interpretation_executor, library, arrays, update_ranges_or_baskets, interp_options)
3092 if (
3093 isinstance(library, uproot.interpretation.library.Awkward)
3094 and isinstance(interpretation, uproot.interpretation.objects.AsObjects)
3095 and cache_key in branchid_to_branch
3096 ):
3097 branchid_to_branch[cache_key]._awkward_check(interpretation)
-> 3099 hasbranches._file.source.chunks(ranges, notifications=notifications)
3101 def replace(ranges_or_baskets, original_index, basket):
3102 branch, basket_num, range_or_basket = ranges_or_baskets[original_index]
File /srv/conda/envs/notebook/lib/python3.11/site-packages/uproot/source/fsspec.py:136, in FSSpecSource.chunks(self, ranges, notifications)
108 """
109 Args:
110 ranges (list of tuple[int, int] 2-tuples): Intervals to fetch
(...)
133 chunks to be filled.
134 """
135 if self.closed:
--> 136 raise OSError(f"file {self._file_path!r} is closed")
138 self._num_requests += 1
139 self._num_requested_chunks += len(ranges)
OSError: file 'https://atlas-opendata.web.cern.ch/atlas-opendata/samples/2020/4lep/Data/data_A.4lep.root' is closed