Skip to content

Instantly share code, notes, and snippets.

@ErikHogenbirk
Created March 8, 2016 16:36
Show Gist options
  • Save ErikHogenbirk/5da9801d81b253ef7717 to your computer and use it in GitHub Desktop.
Save ErikHogenbirk/5da9801d81b253ef7717 to your computer and use it in GitHub Desktop.
data = []
def loop_body(event):
global data
data_this_event = root_to_numpy(event,"all_hits",hit_fields_to_import)
data.append(data_this_event)
return None
hax.paxroot.loop_over_datasets([dataset],
# Must contain a function with event as argument
loop_body,
branch_selection=["all_hits*"])
Don't know a dataset named r26_XENON1T_LED_full, trying to find it anyway...
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/home/erik/hax/hax/paxroot.py in loop_over_datasets(datasets_names, event_function, branch_selection)
55 try:
---> 56 dataset = runs.datasets.loc[runs.datasets['name'] == dataset_name].iloc[0]
57 filename = dataset.location
/home/erik/anaconda3/envs/pax/lib/python3.4/site-packages/pandas/core/indexing.py in __getitem__(self, key)
1226 else:
-> 1227 return self._getitem_axis(key, axis=0)
1228
/home/erik/anaconda3/envs/pax/lib/python3.4/site-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis)
1516 # validate the location
-> 1517 self._is_valid_integer(key, axis)
1518
/home/erik/anaconda3/envs/pax/lib/python3.4/site-packages/pandas/core/indexing.py in _is_valid_integer(self, key, axis)
1430 if key >= l or key < -l:
-> 1431 raise IndexError("single positional indexer is out-of-bounds")
1432 return True
IndexError: single positional indexer is out-of-bounds
During handling of the above exception, another exception occurred:
NameError Traceback (most recent call last)
<ipython-input-10-1261cc0fba97> in <module>()
17 # Must contain a function with event as argument
18 loop_body,
---> 19 branch_selection=["all_hits*"])
20
21 data = np.concatenate(data)
/home/erik/hax/hax/paxroot.py in loop_over_datasets(datasets_names, event_function, branch_selection)
58 except IndexError:
59 print("Don't know a dataset named %s, trying to find it anyway..." % dataset_name)
---> 60 filename = find_file_in_folders(dataset_name + '.root', CONFIG['main_data_paths'])
61 if not filename:
62 raise ValueError("Cannot loop over dataset %s, we don't know where it is." % dataset_name)
NameError: name 'CONFIG' is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment