spine.post.base

Contains base class of all post-processors.

Classes

PostBase([obj_type, run_mode, ...])

Base class of all post-processors.

class spine.post.base.PostBase(obj_type: str | Sequence[str] | None = None, run_mode: str | None = None, truth_point_mode: str | None = None, truth_dep_mode: str | None = None, pid_mode: str | None = None, parent_path: str | None = None)[source]

Base class of all post-processors.

This base class performs the following functions:
  • Ensures that the necessary methods exist

  • Checks that the post-processor is provided the necessary information to do its job

  • Fetches the appropriate coordinate attributes

  • Ensures that the appropriate units are provided

name

Name of the post-processor as defined in the configuration file

Type:

str

aliases

Alternative acceptable names for a post-processor

Type:

tuple[str, …]

Attributes:
dep_modes

Dictionary which maps the name of a true object deposition attribute with the underlying deposition array it points to.

keys

Dictionary of (key, necessity) pairs which determine which data keys are needed/optional for the post-processor to run.

name
point_modes

Dictionary which maps the name of a true object point attribute with the underlying point tensor it points to.

source_modes

Dictionary which maps the name of a true object source attribute with the underlying source tensor it points to.

Methods

__call__(data[, entry])

Calls the post processor on one entry.

check_units(obj)

Check that the point coordinates of an object are as expected.

get_depositions(obj)

Get a certain pre-defined deposition attribute of an object.

get_index(obj)

Get a certain pre-defined index attribute of an object.

get_pid(obj)

Get a certain pre-defined PID prediction of an object.

get_points(obj)

Get a certain pre-defined point attribute of an object.

get_sources(obj)

Get a certain pre-defined sources attribute of an object.

process(data)

Place-holder method to be defined in each post-processor.

update_keys(update_dict)

Update the underlying set of keys and their necessity in place.

update_upstream(key)

Update the underlying set of required upstream modules in place.

name = None
aliases = ()
units = 'cm'
provide_parent_path = False
property keys: dict[str, bool]

Dictionary of (key, necessity) pairs which determine which data keys are needed/optional for the post-processor to run.

Returns:

Dictionary of (key, necessity) pairs to be used

Return type:

dict[str, bool]

property point_modes: dict[str, str]

Dictionary which maps the name of a true object point attribute with the underlying point tensor it points to.

Returns:

Dictionary of (attribute, key) mapping for point coordinates

Return type:

dict[str, str]

property source_modes: dict[str, str]

Dictionary which maps the name of a true object source attribute with the underlying source tensor it points to.

Returns:

Dictionary of (attribute, key) mapping for point sources

Return type:

dict[str, str]

property dep_modes: dict[str, str]

Dictionary which maps the name of a true object deposition attribute with the underlying deposition array it points to.

Returns:

Dictionary of (attribute, key) mapping for point depositions

Return type:

dict[str, str]

update_keys(update_dict: Mapping[str, bool]) None[source]

Update the underlying set of keys and their necessity in place.

Parameters:

update_dict (Mapping[str, bool]) – Dictionary of (key, necessity) pairs to update the keys with

update_upstream(key: str) None[source]

Update the underlying set of required upstream modules in place.

Parameters:

key (str) – Post-processor module name to add to the list

get_index(obj: Any) Any[source]

Get a certain pre-defined index attribute of an object.

The TruthFragment, TruthParticle and TruthInteraction objects index are obtained using the truth_index_mode attribute of the class.

Parameters:
  • obj (FragmentBase, ParticleBase or InteractionBase) – Fragment, Particle or Interaction object

  • Results

  • -------

  • np.ndarray

    1. Object index

get_points(obj: Any) Any[source]

Get a certain pre-defined point attribute of an object.

The TruthFragment, TruthParticle and TruthInteraction objects points are obtained using the truth_point_mode attribute of the class.

Parameters:
  • obj (FragmentBase, ParticleBase or InteractionBase) – Fragment, Particle or Interaction object

  • Results

  • -------

  • np.ndarray – (N, 3) Point coordinates

get_sources(obj: Any) Any[source]

Get a certain pre-defined sources attribute of an object.

The TruthFragment, TruthParticle and TruthInteraction objects sources are obtained using the truth_source_mode attribute of the class.

Parameters:
  • obj (FragmentBase, ParticleBase or InteractionBase) – Fragment, Particle or Interaction object

  • Results

  • -------

  • np.ndarray – (N, 2) Object sources

get_depositions(obj: Any) Any[source]

Get a certain pre-defined deposition attribute of an object.

The TruthFragment, TruthParticle and TruthInteraction objects points are obtained using the truth_dep_mode attribute of the class.

Parameters:
  • obj (FragmentBase, ParticleBase or InteractionBase) – Fragment, Particle or Interaction object

  • Results

  • -------

  • np.ndarray

    1. Depositions

get_pid(obj: Any) Any[source]

Get a certain pre-defined PID prediction of an object.

The TruthParticle PID predictions are obtained using the pid_mode attribute of the class.

Parameters:
  • obj (ParticleBase) – Particle object

  • Results

  • -------

  • int – Particle identification enumerator

check_units(obj: Any) None[source]

Check that the point coordinates of an object are as expected.

Parameters:
  • obj (FragmentBase, ParticleBase or InteractionBase) – Particle or interaction object

  • Results

  • -------

  • np.ndarray – (N, 3) Point coordinates

abstractmethod process(data: MutableMapping[str, Any]) dict[str, Any] | None[source]

Place-holder method to be defined in each post-processor.

Parameters:

data (dict) – Dictionary of processed data products