spine.utils.vertex

Functions

angular_loss(candidates, points, directions)

Computes the angular/cosine distance between vectors that join candidate points to the start points of particles and their respective direction estimates.

get_confluence_points(start_points, ...)

Find the points where multiple particles touch.

get_pseudovertex(start_points, directions[, dim])

Finds the vertex which minimizes the total distance from itself to all the lines defined by the start points of particles and their directions.

get_vertex(start_points, end_points, ...[, ...])

Reconstruct the vertex of an individual interaction.

get_weighted_pseudovertex(start_points, ...)

Finds the vertex which minimizes the total distance from itself to all the lines defined by the start points of particles and their directions.

spine.utils.vertex.get_vertex(start_points, end_points, directions, semantics, anchor_vertex=True, touching_threshold=2.0, return_mode=False)[source]

Reconstruct the vertex of an individual interaction.

Parameters:
  • start_points (np.ndarray) – (P, 3) Particle start points

  • end_points (np.ndarray) – (P, 3) Particle end points

  • directions (np.ndarray) – (P, 3) Particle directions

  • semantics (np.ndarray) –

    1. : particle semantic type

  • anchor_vertex (bool, default True) – If true, anchor the candidate vertex to particle objects, with the expection of interactions only composed of showers.

  • touching_threshold (float, default 2.0) – Maximum distance for two particle points to be considered touching

  • return_mode (bool, default False) – If True, return the method used to find the vertex

spine.utils.vertex.angular_loss(candidates: Array(float32, 2, 'A', False, aligned=True), points: Array(float32, 2, 'A', False, aligned=True), directions: Array(float32, 2, 'A', False, aligned=True), use_cos: bool = True) float32[source]

Computes the angular/cosine distance between vectors that join candidate points to the start points of particles and their respective direction estimates. Values are normalized between 0 (perfect fit) and 1 (complete disagreement).

Parameters:
  • candidates (np.ndarray) – (C, 3) Vertex coordinates

  • points (np.ndarray) – (P, 3) Particle start points

  • directions (np.ndarray) – (P, 3) Particle directions

  • use_cos (bool) – Whether or not to use the cosine as a metric

Returns:

  1. Loss for each of the candidates

Return type:

np.ndarray

spine.utils.vertex.get_confluence_points(start_points: Array(float32, 2, 'A', False, aligned=True), end_points: Array(float32, 2, 'A', False, aligned=True) = None, touching_threshold: float32 = 2.0) -> List(array(float32, 1d, A), False)[source]

Find the points where multiple particles touch.

Parameters:
  • start_points (np.ndarray) – (P, 3) Particle start points

  • end_points (np.ndarray, optional) – (P, 3) Particle end points

  • touching_threshold (float, default 2.0) – Maximum distance for two particle points to be considered touching

Returns:

List of vertices that correspond to the confluence points

Return type:

List[np.ndarray]

spine.utils.vertex.get_pseudovertex(start_points: Array(float32, 2, 'A', False, aligned=True), directions: Array(float32, 2, 'A', False, aligned=True), dim: int = 3)[source]

Finds the vertex which minimizes the total distance from itself to all the lines defined by the start points of particles and their directions.

Parameters:
  • start_points (np.ndarray) – (P, 3) Particle start points

  • directions (np.ndarray) – (P, 3) Particle directions

  • dim (int) – Number of dimensions

spine.utils.vertex.get_weighted_pseudovertex(start_points: Array(float32, 2, 'A', False, aligned=True), directions: Array(float32, 2, 'A', False, aligned=True), weights: Array(float32, 1, 'A', False, aligned=True), dim: int = 3)[source]

Finds the vertex which minimizes the total distance from itself to all the lines defined by the start points of particles and their directions.

Parameters:
  • start_points (np.ndarray) – (P, 3) Particle start points

  • directions (np.ndarray) – (P, 3) Particle directions

  • dim (int) – Number of dimensions