ParticleObjectStorer

class ParticleObjectStorer.ParticleObjectStorer(particle_object_list: List[List[Particle]], **kwargs: Dict[str, Tuple[int, int] | None])[source]

Defines a ParticleObjectStorer object, which saves particle object lists.

This is a wrapper for a list of Particle objects. It’s methods allow to directly act on all contained events as applying acceptance filters (e.g. un-/charged particles, spectators/participants) to keep/remove particles by their PDG codes or to apply cuts (e.g. multiplicity, pseudo-/rapidity, pT). Once these filters are applied, the new data set can be accessed as a

  1. nested list containing all quantities

  2. list containing Particle objects from the Particle class

Note

If filters are applied, be aware that not all cuts commute.

Parameters:
None
Other Parameters:
**kwargsproperties, optional

kwargs are used to specify optional properties like a chunk reading and must be used like 'property'='value' where the possible properties are specified below.

Property

Description

events (int)

From the input particle object list load only a single event by
specifying events=i where i is event number i.

events (tuple)

From the input particle object list load only a range of events
given by the tuple (first_event, last_event)
by specifying events=(first_event, last_event)
where last_event is included.

filters (dict)

Apply filters on an event-by-event basis to directly filter the
particles after the read in of one event. This method saves
memory. The names of the filters are the same as the names of
the filter methods. All filters are applied in the order in
which they appear in the dictionary.

Examples

Create a Dummy object and access particle data as a nested list

>>> from sparkx.Particle import Particle
>>> particle1 = Particle()
>>> particle1.t = 1.0
>>> ...
>>> particle2 = Particle()
>>> particle2.t = 1.0
>>> ...
>>> particles = [particle1, particle2]
>>> dummy = DummyStorer(particles)
>>> nested_list = dummy.particle_list()
>>> print(nested_list)
[[[1.0,...],[1.0,...]]]
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 particle object list (updated when filters are applied)

Methods

particle_status:

Keep only particles with a given status flag

print_particle_lists_to_file:

Print current particle data to file with same format

charged_particles() BaseStorer

Keep only charged particles in particle_list.

Returns:
selfBaseStorer object

Containing charged particles in every event only

create_loader(particle_object_list: str | List[List[Particle]]) None[source]

Creates a new ParticleObjectLoader object.

This method creates a new ParticleObjectLoader object with the specified list of particle objects and assigns it to the loader_ attribute.

Parameters:
particle_object_listlist of Particle objects

The list of particle objects to load.

Returns:
None
Raises:
None
keep_baryons() BaseStorer

Keep only baryons in particle_list.

Returns:
selfBaseStorer object

Containing baryons in every event only

keep_bottom() BaseStorer

Keep only hadrons containing bottom quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing bottom quarks in every event only

keep_charm() BaseStorer

Keep only hadrons containing charm quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing charm quarks in every event only

keep_down() BaseStorer

Keep only hadrons containing down quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing down quarks in every event only

keep_hadrons() BaseStorer

Keep only hadrons in particle_list.

Returns:
selfBaseStorer object

Containing hadrons in every event only

keep_leptons() BaseStorer

Keep only leptons in particle_list.

Returns:
selfBaseStorer object

Containing leptons in every event only

keep_mesons() BaseStorer

Keep only mesons in particle_list.

Returns:
selfBaseStorer object

Containing mesons in every event only

keep_quarks() BaseStorer

Keep only quarks in the particle_list.

Returns:
selfBaseStorer object

Containing quarks in every event only

keep_strange() BaseStorer

Keep only hadrons containing strange quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing strange quarks in every event only

keep_top() BaseStorer

Keep only hadrons containing top quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing top quarks in every event only

keep_up() BaseStorer

Keep only hadrons containing up quarks in particle_list.

Returns:
selfBaseStorer object

Containing hadrons containing up quarks in every event only

lower_event_energy_cut(minimum_event_energy: int | float) BaseStorer

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.

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

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

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

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

num_events() int | None

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

num_output_per_event() ndarray | None

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

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

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

participants() BaseStorer

Keep only participants in particle_list.

Returns:
selfBaseStorer object

Containing participants in every event only

particle_list() List

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

particle_objects_list() List | None

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

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

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

particle_status(status_list: int | Tuple[int, ...] | List[int] | ndarray) ParticleObjectStorer[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:
selfParticleObjectStorer object

Containing only hadrons with status specified by status_list for every event

print_particle_lists_to_file(filename: str) None[source]

Prints the current particle data to a file.

Parameters:
filenamestr

The name of the file to write to.

Returns:
None
Raises:
None
pseudorapidity_cut(cut_value: float | Tuple[float, float]) BaseStorer

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

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

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

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

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

remove_photons() BaseStorer

Remove photons from particle_list.

Returns:
selfBaseStorer object

Containing all but photons in every event

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

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

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

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

spectators() BaseStorer

Keep only spectators in particle_list.

Returns:
selfBaseStorer object

Containing spectators in every event only

uncharged_particles() BaseStorer

Keep only uncharged particles in particle_list.

Returns:
selfBaseStorer object

Containing uncharged particles in every event only

ParticleObjectStorer.create_loader(particle_object_list: str | List[List[Particle]]) None[source]

Creates a new ParticleObjectLoader object.

This method creates a new ParticleObjectLoader object with the specified list of particle objects and assigns it to the loader_ attribute.

Parameters:
particle_object_listlist of Particle objects

The list of particle objects to load.

Returns:
None
Raises:
None
ParticleObjectStorer.particle_status(status_list: int | Tuple[int, ...] | List[int] | ndarray) ParticleObjectStorer[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:
selfParticleObjectStorer object

Containing only hadrons with status specified by status_list for every event