ParticleObjectLoader
- class ParticleObjectLoader.ParticleObjectLoader(particle_list: str | List[List[Particle]])[source]
A loader class for handling particle objects.
The ParticleObjectLoader class is responsible for loading and filtering particle objects from a specified list. It provides methods to initialize the loader, apply filters, and set the particle list based on optional arguments.
- Attributes:
- particle_list_List[List[“Particle”]]
The list of particle objects to load.
- optional_arguments_Dict[str, Any]
A dictionary of optional arguments for loading and filtering particles.
- num_events_int
The number of events in the particle list.
- num_output_per_event_List[int]
The number of output particles per event after filtering.
Methods
load(**kwargs: Any) -> Tuple[List[List[“Particle”]], int, List[int]]
Loads the data from the dummy input based on the specified optional arguments.
set_num_output_per_event() -> List[int]
Sets the number of output particles per event based on the filters applied.
__apply_kwargs_filters(event: List[List[“Particle”]], filters_dict: Dict[str, Any]) -> List[List[“Particle”]]
Applies the specified filters to the event.
set_particle_list(kwargs: Dict[str, Any]) -> List[List[“Particle”]]
Sets the particle list based on the filters applied.
- load(**kwargs: Any) Tuple[List[List[Particle]], int, List[int], List[str]] [source]
Loads the data from the dummy input based on the specified optional arguments.
This method reads the dummy input and applies any filters specified in the ‘filters’ key of the kwargs dictionary. It also adjusts the number of events based on the ‘events’ key in the kwargs dictionary. If any other keys are specified in the kwargs dictionary, it raises a ValueError.
- Parameters:
- kwargsdict
A dictionary of optional arguments. The following keys are recognized:
‘events’: Either a tuple of two integers specifying the range of events to load, or a single integer specifying a single event to load.
‘filters’: A list of filters to apply to the data.
- Returns:
- tuple
A tuple containing the list of Particle objects loaded from the dummy input, the number of events, and the number of output lines per event.
- Raises:
- ValueError
If an unknown keyword argument is used, if the first value of the ‘events’ tuple is larger than the second value, if an event number is negative.
- set_num_output_per_event() List[int] [source]
Set the number of output particles per event based on the filters applied.
- set_particle_list(kwargs: Dict[str, Any]) List[List[Particle]] [source]
Set the particle list based on the filters applied.
- Parameters:
- kwargsdict
Dictionary containing the filters to be applied. The following keys are recognized:
‘events’: Either a tuple of two integers specifying the range of events to load, or a single integer specifying a single event to load.
‘filters’: A list of filters to apply to the data.
- Returns:
- list
List of particle objects.