BaseStorer

class BaseStorer.BaseStorer(path: str | List[List[Particle]], **kwargs: Any)[source]

Defines a generic BaseStorer object.

Attributes:
num_output_per_event_numpy.array

Array containing the event number and the number of particles in this event as num_output_per_event_[event i][num_output in event i] (updated when filters are applied)

num_events_int

Number of events contained in the Oscar object (updated when filters are applied)

loader_: Loader object

Loader object that loads the data

Methods

load:

Load data

particle_list:

Returns current events data as nested list

particle_objects_list:

Returns current events data as nested list of Particle objects

num_events:

Get number of events

num_output_per_event:

Get number of particles in each event

particle_species:

Keep only particles with given PDG ids

remove_particle_species:

Remove particles with given PDG ids

participants:

Keep participants only

spectators:

Keep spectators only

lower_event_energy_cut:

Filters out events with total energy lower than a threshold

charged_particles:

Keep charged particles only

uncharged_particles:

Keep uncharged particles only

strange_particles:

Keep strange particles only

pT_cut:

Apply pT cut to all particles

mT_cut:

Apply mT cut to all particles

rapidity_cut:

Apply rapidity cut to all particles

pseudorapidity_cut:

Apply pseudorapidity cut to all particles

spacetime_rapidity_cut:

Apply spacetime rapidity cut to all particles

multiplicity_cut:

Apply multiplicity cut to all particles

spacetime_cut:

Apply spacetime cut to all particles

BaseStorer.num_output_per_event() ndarray | None[source]

Returns a numpy array containing the event number (starting with 1) and the corresponding number of particles created in this event as

num_output_per_event[event_n, number_of_particles_in_event_n]

num_output_per_event is updated with every manipulation e.g. after applying cuts.

Returns:
num_output_per_event_numpy.ndarray

Array containing the event number and the corresponding number of particles

BaseStorer.num_events() int | None[source]

Returns the number of events in particle_list.

num_events is updated with every manipulation e.g. after applying cuts.

Returns:
num_events_int

Number of events in particle_list

BaseStorer.particle_list() List[source]

Returns a nested python list containing all quantities from the current data as numerical values with the following shape:

Single Event: [[output_line][particle_quantity]]
Multiple Events: [event][output_line][particle_quantity]
Returns:
list

Nested list containing the current data

abstract BaseStorer._particle_as_list(particle: Particle) List[source]
BaseStorer.particle_objects_list() List | None[source]

Returns a nested python list containing all particles from the data as particle objects from Particle:

Single Event: [particle_object]
Multiple Events: [event][particle_object]
Returns:
particle_list_list

List of particle objects from Particle

BaseStorer.charged_particles() BaseStorer[source]

Keep only charged particles in particle_list.

Returns:
selfBaseStorer object

Containing charged particles in every event only

BaseStorer.uncharged_particles() BaseStorer[source]

Keep only uncharged particles in particle_list.

Returns:
selfBaseStorer object

Containing uncharged particles in every event only

BaseStorer.particle_species(pdg_list: int | Tuple[int] | List[int] | ndarray) BaseStorer[source]

Keep only particle species given by their PDG ID in every event.

Parameters:
pdg_listint

To keep a single particle species only, pass a single PDG ID

pdg_listtuple/list/array

To keep multiple particle species, pass a tuple or list or array of PDG IDs

Returns:
selfBaseStorer object

Containing only particle species specified by pdg_list for every event

BaseStorer.remove_particle_species(pdg_list: int | Tuple[int] | List[int] | ndarray) BaseStorer[source]

Remove particle species from particle_list by their PDG ID in every event.

Parameters:
pdg_listint

To remove a single particle species only, pass a single PDG ID

pdg_listtuple/list/array

To remove multiple particle species, pass a tuple or list or array of PDG IDs

Returns:
selfBaseStorer object

Containing all but the specified particle species in every event

BaseStorer.participants() BaseStorer[source]

Keep only participants in particle_list.

Returns:
selfBaseStorer object

Containing participants in every event only

BaseStorer.spectators() BaseStorer[source]

Keep only spectators in particle_list.

Returns:
selfBaseStorer object

Containing spectators in every event only

BaseStorer.lower_event_energy_cut(minimum_event_energy: int | float) BaseStorer[source]

Filters out events with total energy lower than a threshold.

Parameters:
minimum_event_energyint or float

The minimum event energy threshold. Should be a positive integer or float.

Returns:
self: BaseStorer object

The updated instance of the class contains only events above the energy threshold.

Raises:
TypeError

If the minimum_event_energy parameter is not an integer or float.

ValueError

If the minimum_event_energy parameter is less than or equal to 0.

BaseStorer.pT_cut(cut_value_tuple: Tuple[float | None, float | None]) BaseStorer[source]

Apply transverse momentum cut to all events by passing an acceptance range by cut_value_tuple. All particles outside this range will be removed.

Parameters:
cut_value_tupletuple

Tuple with the upper and lower limits of the pT acceptance range (cut_min, cut_max). If one of the limits is not required, set it to None, i.e. (None, cut_max) or (cut_min, None).

Returns:
selfBaseStorer object

Containing only particles complying with the transverse momentum cut for all events

BaseStorer.mT_cut(cut_value_tuple: Tuple[float | None, float | None]) BaseStorer[source]

Apply transverse mass cut to all events by passing an acceptance range by cut_value_tuple. All particles outside this range will be removed.

Parameters:
cut_value_tupletuple

Tuple with the upper and lower limits of the mT acceptance range (cut_min, cut_max). If one of the limits is not required, set it to None, i.e. (None, cut_max) or (cut_min, None).

Returns:
selfBaseStorer object

Containing only particles complying with the transverse mass cut for all events

BaseStorer.rapidity_cut(cut_value: float | Tuple[float, float]) BaseStorer[source]

Apply rapidity cut to all events and remove all particles with rapidity not complying with cut_value.

Parameters:
cut_valuefloat

If a single value is passed, the cut is applied symmetrically around 0. For example, if cut_value = 1, only particles with rapidity in [-1.0, 1.0] are kept.

cut_valuetuple

To specify an asymmetric acceptance range for the rapidity of particles, pass a tuple (cut_min, cut_max)

Returns:
selfBaseStorer object

Containing only particles complying with the rapidity cut for all events

BaseStorer.pseudorapidity_cut(cut_value: float | Tuple[float, float]) BaseStorer[source]

Apply pseudo-rapidity cut to all events and remove all particles with pseudo-rapidity not complying with cut_value.

Parameters:
cut_valuefloat

If a single value is passed, the cut is applied symmetrically around 0. For example, if cut_value = 1, only particles with rapidity in [-1.0, 1.0] are kept.

cut_valuetuple

To specify an asymmetric acceptance range for the pseudo-rapidity of particles, pass a tuple (cut_min, cut_max)

Returns:
selfBaseStorer object

Containing only particles complying with the pseudo-rapidity cut for all events

BaseStorer.spacetime_rapidity_cut(cut_value: float | Tuple[float, float]) BaseStorer[source]

Apply spacetime rapidity (space-time rapidity) cut to all events and remove all particles with spacetime rapidity not complying with cut_value.

Parameters:
cut_valuefloat

If a single value is passed, the cut is applied symmetrically around 0. For example, if cut_value = 1, only particles with spacetime rapidity in [-1.0, 1.0] are kept.

cut_valuetuple

To specify an asymmetric acceptance range for the spacetime rapidity of particles, pass a tuple (cut_min, cut_max)

Returns:
selfBaseStorer object

Containing only particles complying with the spacetime rapidity cut for all events

BaseStorer.multiplicity_cut(cut_value_tuple: Tuple[float | None, float | None]) BaseStorer[source]

Apply multiplicity cut. Remove all events with a multiplicity not complying with cut_value.

Parameters:
cut_value_tupletuple

Upper and lower bound for multiplicity. If the multiplicity of an event is not in this range, the event is discarded. The range is inclusive on the lower bound and exclusive on the upper bound.

Returns:
selfBaseStorer object

Containing only events with a multiplicity >= min_multiplicity

BaseStorer.spacetime_cut(dim: str, cut_value_tuple: Tuple[float, float]) BaseStorer[source]

Apply spacetime cut to all events by passing an acceptance range by cut_value_tuple. All particles outside this range will be removed.

Parameters:
dimstring

String naming the dimension on which to apply the cut. Options: t,:code:x,:code:y,:code:z

cut_value_tupletuple

Tuple with the upper and lower limits of the coordinate space acceptance range (cut_min, cut_max). If one of the limits is not required, set it to None, i.e. (None, cut_max) or (cut_min, None).

Returns:
selfBaseStorer object

Containing only particles complying with the spacetime cut for all events

BaseStorer.particle_status(status_list: int | Tuple[int, ...] | List[int] | ndarray) BaseStorer[source]

Keep only particles with a given particle status.

Parameters:
status_listint

To keep a particles with a single status only, pass a single status

status_listtuple/list/array

To keep hadrons with different hadron status, pass a tuple or list or array

Returns:
selfBaseStorer object

Containing only hadrons with status specified by status_list for every event

BaseStorer.keep_hadrons() BaseStorer[source]

Keep only hadrons in particle_list.

Returns:
selfBaseStorer object

Containing hadrons in every event only

BaseStorer.keep_leptons() BaseStorer[source]

Keep only leptons in particle_list.

Returns:
selfBaseStorer object

Containing leptons in every event only

BaseStorer.keep_quarks() BaseStorer[source]

Keep only quarks in the particle_list.

Returns:
selfBaseStorer object

Containing quarks in every event only

BaseStorer.keep_mesons() BaseStorer[source]

Keep only mesons in particle_list.

Returns:
selfBaseStorer object

Containing mesons in every event only

BaseStorer.keep_baryons() BaseStorer[source]

Keep only baryons in particle_list.

Returns:
selfBaseStorer object

Containing baryons in every event only

BaseStorer.keep_up() BaseStorer[source]

Keep only hadrons containing up quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing up quarks in every event only

BaseStorer.keep_down() BaseStorer[source]

Keep only hadrons containing down quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing down quarks in every event only

BaseStorer.keep_strange() BaseStorer[source]

Keep only hadrons containing strange quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing strange quarks in every event only

BaseStorer.keep_charm() BaseStorer[source]

Keep only hadrons containing charm quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing charm quarks in every event only

BaseStorer.keep_bottom() BaseStorer[source]

Keep only hadrons containing bottom quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing bottom quarks in every event only

BaseStorer.keep_top() BaseStorer[source]

Keep only hadrons containing top quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing top quarks in every event only

BaseStorer.remove_photons() BaseStorer[source]

Remove photons from particle_list.

Returns:
selfBaseStorer object

Containing all but photons in every event

abstract BaseStorer.print_particle_lists_to_file(output_file: str) None[source]

Prints the particle lists to a specified file.

This method should be implemented by subclasses to print the particle lists to the specified output file. The method raises a NotImplementedError if it is not overridden by a subclass.

Parameters:
output_filestr

The path to the file where the particle lists will be printed.

Returns:
None
Raises:
NotImplementedError

If the method is not implemented by a subclass.