spine.io.read.LArCVReader
- class spine.io.read.LArCVReader(file_keys: str | list[str] | None = None, file_list: str | None = None, tree_keys: list[str] | None = None, limit_num_files: int | None = None, max_print_files: int = 10, n_entry: int | None = None, n_skip: int | None = None, entry_list: list[int] | None = None, skip_entry_list: list[int] | None = None, run_event_list: list[list[int]] | None = None, skip_run_event_list: list[list[int]] | None = None, create_run_map: bool = False, run_info_key: str | None = None, allow_missing: bool = False)[source]
Class which reads information stored in LArCV files.
This class inherits from the
ReaderBaseclass. It provides methods to load LArCV2 files and extract their data products:EventSparseTensor: voxel IDs and their values
EventClusterSparseTensor: list of sparse tensors
EventParticle: list of Geant4 particle information
EventNeutrino: list of generstor neutrino information
EventFlash: list of optical flashes information
EventCRTHit: list of cosmic-ray tagger hits
EventTrigger: trigger information
It builds a TChain from the list of files provided with the appropriate trees corresponding to each of the requested data products.
- Attributes:
- run_info
- run_map
Methods
get(idx)Returns a specific entry in the file.
get_file_entry_index(idx)Returns the index of an entry within the file it lives in, provided a global index over the list of files.
get_file_index(idx)Returns the index of the file corresponding to a specific entry.
get_file_path(idx)Returns the path to the file corresponding to a specific entry.
get_run_event(run, subrun, event)Returns an entry corresponding to a specific (run, subrun, event) triplet.
get_run_event_index(run, subrun, event)Returns an entry index corresponding to a specific (run, subrun, event) triplet.
get_source_provenance(file_idx, file_entry_idx)Return lightweight source-file provenance for one entry.
is_remote_path(path)Checks whether a path points to a remote resource.
list_data(file_path)Dumps top-level information about the contents of a LArCV root file.
parse_entry_list(list_source)Parses a list into an np.ndarray.
parse_run_event_list(list_source)Parses a list of (run, subrun, event) triplets into an np.ndarray.
process_entry_list([n_entry, n_skip, ...])Create a list of entries that can be accessed by
__getitem__().process_file_paths([file_keys, file_list, ...])Process list of files.
process_run_info()Process the run information.
- __init__(file_keys: str | list[str] | None = None, file_list: str | None = None, tree_keys: list[str] | None = None, limit_num_files: int | None = None, max_print_files: int = 10, n_entry: int | None = None, n_skip: int | None = None, entry_list: list[int] | None = None, skip_entry_list: list[int] | None = None, run_event_list: list[list[int]] | None = None, skip_run_event_list: list[list[int]] | None = None, create_run_map: bool = False, run_info_key: str | None = None, allow_missing: bool = False) None[source]
Initialize the LArCV file reader.
- Parameters:
file_keys (Union[str, List[str]], optional) – Path or list of paths to the LArCV files to be read
file_list (str, optional) – Path to a text file containing a list of file paths to be read
tree_keys (List[str]) – List of data keys to load from the LArCV files
limit_num_files (Optional[int], optional) – Integer limiting number of files to be taken per data directory
max_print_files (int, default 10) – Maximum number of loaded file names to be printed
n_entry (Optional[int], optional) – Maximum number of entries to load
n_skip (Optional[int], optional) – Number of entries to skip at the beginning
entry_list (Optional[List[int]]) – List of integer entry IDs to add to the index
skip_entry_list (Optional[List[int]]) – List of integer entry IDs to skip from the index
run_event_list (Optional[List[List[int]]], optional) – List of (run, subrun, event) triplets to add to the index
skip_run_event_list (Optional[List[List[int]]], optional) – List of (run, subrun, event) triplets to skip from the index
create_run_map (bool, default False) – Initialize a map between (run, subrun, event) triplets and entries. For large files, this can be quite expensive (must load every entry).
run_info_key (Optional[str], optional) – Key of the tree in the file to get the run information from
allow_missing (bool, default False) – If True, allows missing entries in the entry or event list
Methods
__init__([file_keys, file_list, tree_keys, ...])Initialize the LArCV file reader.
get(idx)Returns a specific entry in the file.
get_file_entry_index(idx)Returns the index of an entry within the file it lives in, provided a global index over the list of files.
get_file_index(idx)Returns the index of the file corresponding to a specific entry.
get_file_path(idx)Returns the path to the file corresponding to a specific entry.
get_run_event(run, subrun, event)Returns an entry corresponding to a specific (run, subrun, event) triplet.
get_run_event_index(run, subrun, event)Returns an entry index corresponding to a specific (run, subrun, event) triplet.
get_source_provenance(file_idx, file_entry_idx)Return lightweight source-file provenance for one entry.
is_remote_path(path)Checks whether a path points to a remote resource.
list_data(file_path)Dumps top-level information about the contents of a LArCV root file.
parse_entry_list(list_source)Parses a list into an np.ndarray.
parse_run_event_list(list_source)Parses a list of (run, subrun, event) triplets into an np.ndarray.
process_entry_list([n_entry, n_skip, ...])Create a list of entries that can be accessed by
__getitem__().process_file_paths([file_keys, file_list, ...])Process list of files.
process_run_info()Process the run information.
Attributes
run_inforun_mapsource_keysfile_pathsfile_indexfile_offsetsentry_indexnum_entries- name: str = 'larcv'