hexsample.digi — Digitization facilities#

This module contains…

Digi event structure#

@dataclass
class DigiEventRectangular(DigiEventBase):

    """Specialized class for a digitized event based on a rectangular ROI.

    This implements the basic legacy machinery of the XPOL-I and XPOL-III readout chips.
    """

    roi: RegionOfInterest

Module documentation#

Digi event structures.

class hexsample.digi.DigiEventBase(trigger_id: int, seconds: int, microseconds: int, livetime: int, pha: ndarray)#

Base class for a digitized event.

This includes alll the timing information that is common to the different digitized event structure, as well as the PHA content of the pixels in the event, but no information about the physical location on the latter within the readout chip. It is responsibility of the derived classes to provide this information, in the way that is more conventient, depending on the particular readout strategy.

Parameters:
  • trigger_id (int) – The trigger identifier.

  • seconds (int) – The integer part of the timestamp.

  • microseconds (int) – The fractional part of the timestamp.

  • pha (np.ndarray) – The pixel content of the event, in the form of a 1-dimensional array.

trigger_id: int#
seconds: int#
microseconds: int#
livetime: int#
pha: ndarray#
timestamp() float#

Return the timestamp of the event, that is, the sum of the second and microseconds parts of the DigiEvent contributions as a floating point number.

classmethod from_digi(*args, **kwargs)#

Build an event object from a row in a digitized file.

ascii(*args, **kwargs)#

Ascii representation of the event.

class hexsample.digi.DigiEventSparse(trigger_id: int, seconds: int, microseconds: int, livetime: int, pha: ndarray, columns: ndarray, rows: ndarray)#

Sparse digitized event.

In this particular incarnation of a digitized event we have no ROI structure, nor any rule as to the shape or morphology of the particular set of pixels being read out. The event represent an arbitrary collection of pixels, and we carry over the arrays of their row and column identifiers, in the form of two arrays whose length must match that of the PHA values.

Parameters:
  • columns (np.ndarray) – The column identifier of the pixels in the event (must have the same length of the pha class member).

  • rows (np.ndarray) – The row identifier of the pixels in the event (must have the same length of the pha class member).

columns: ndarray#
rows: ndarray#
classmethod from_digi(file_row: ndarray, pha: ndarray, columns: ndarray, rows: ndarray)#

Alternative constructor rebuilding an object from a row on a digi file.

This is used internally when we access event data in a digi file, and we need to reassemble a DigiEvent object from a given row of a digi table.

as_dict() dict#

Return the pixel content of the event in the form of a {(col, row): pha} value.

This is useful to address the pixel content at a given coordinate. We refrain, for the moment, from implementing a __call__() hook on top of this, as the semantics would be fundamentally different from that implemented with a rectangular ROI, where the access happen in ROI coordinates, and not in chip coordinates, but we might want to come back to this.

ascii(pha_width: int = 5) str#

Ascii representation.

class hexsample.digi.DigiEventRectangular(trigger_id: int, seconds: int, microseconds: int, livetime: int, pha: ndarray, roi: RegionOfInterest)#

Specialized class for a digitized event based on a rectangular ROI.

This implements the basic legacy machinery of the XPOL-I and XPOL-III readout chips.

roi: RegionOfInterest#
classmethod from_digi(file_row: ndarray, pha: ndarray)#

Alternative constructor rebuilding an object from a row on a digi file.

This is used internally when we access event data in a digi file, and we need to reassemble a DigiEvent object from a given row of a digi table.

highest_pixel(absolute: bool = True) Tuple[int, int]#

Return the coordinates (col, row) of the highest pixel.

Parameters:

absolute (bool) – If true, the absolute coordinates (i.e., those referring to the readout chip) are returned; otherwise the coordinates are intended relative to the readout window (i.e., they can be used to index the pha array).

ascii(pha_width: int = 5)#

Ascii representation.

class hexsample.digi.DigiEventCircular(trigger_id: int, seconds: int, microseconds: int, livetime: int, pha: ndarray, column: int, row: int)#

Circular digitized event.

In this particular incarnation of a digitized event the ROI is built around a central pixel, that is the one corresponding to maximum PHA. The ROI is then always (except in border-pixel cases) composed by 7 pixels: the central one and its 6 neighbours.

Parameters:
  • column (int) – The column identifier of the maximum PHA pixel in the event in pixel coordinates.

  • row (int) – The column identifier of the maximum PHA pixel in the event in pixel coordinates.

column: int#
row: int#
classmethod from_digi(file_row: ndarray)#

Alternative constructor rebuilding an object from a row on a digi file.

This is used internally when we access event data in a digi file, and we need to reassemble a DigiEvent object from a given row of a digi table.

ascii(pha_width: int = 5) str#

Ascii representation. In the specific case of this class, the ascii representation is simply a px (that is the highest PHA pixel), because the neighbor position is not accessible by the DigiEvent.