daq2lh5.fc package

This subpackage overloads decoding utilities defined in pygama.raw to read files produced by the FlashCam acquisition system.

Submodules

daq2lh5.fc.fc_config_decoder module

class daq2lh5.fc.fc_config_decoder.FCConfigDecoder(*args, **kwargs)

Bases: DataDecoder

Decode FlashCam config data.

Note

Derives from DataDecoder in anticipation of possible future functionality. Currently the base class interface is not used.

Example

>>> from fcio import fcio_open
>>> from daq2lh5.fc.config_decoder import FCConfigDecoder
>>> fc = fcio_open('file.fcio')
>>> decoder = FCConfigDecoder()
>>> config = decoder.decode_config(fc)
>>> type(config)
lgdo.types.struct.Struct
decode_config(fcio)
Return type:

Struct

decode_packet(fcio, config_rb, packet_id)
Return type:

bool

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

daq2lh5.fc.fc_event_decoder module

class daq2lh5.fc.fc_event_decoder.FCEventDecoder(*args, **kwargs)

Bases: DataDecoder

Decode FlashCam digitizer event data.

decode_packet(fcio, evt_rbkd, packet_id)

Access FCIOEvent members for each event in the DAQ file.

Parameters:
  • fcio (FCIO) – The interface to the fcio data. Enters this function after a call to fcio.get_record() so that data for packet_id ready to be read out.

  • evt_rbkd (Table | dict[int, Table]) – A single table for reading out all data, or a dictionary of tables keyed by rawid.

  • packet_id (int) – The index of the packet in the fcio stream. Incremented by FCStreamer.

Returns:

any_full – TODO

Return type:

bool

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

get_max_rows_in_packet()

Returns the maximum number of rows that could be read out in a packet.

1 by default, overload as necessary to avoid writing past the ends of buffers.

Return type:

int

set_fcio_stream(fcio_stream)

Access FCIOConfig members once when each file is opened.

Parameters:

fc_config – extracted via decode_config().

daq2lh5.fc.fc_eventheader_decoder module

class daq2lh5.fc.fc_eventheader_decoder.FCEventHeaderDecoder(*args, **kwargs)

Bases: DataDecoder

decode_packet(fcio, evt_hdr_rbkd, packet_id)
Return type:

bool

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

get_max_rows_in_packet()

Returns the maximum number of rows that could be read out in a packet.

1 by default, overload as necessary to avoid writing past the ends of buffers.

Return type:

int

set_fcio_stream(fcio_stream)

Access FCIOConfig members once when each file is opened.

Parameters:

fc_config – extracted via decode_config().

daq2lh5.fc.fc_eventheader_decoder.get_card_address(key)
Return type:

int

daq2lh5.fc.fc_eventheader_decoder.get_card_input(key)
Return type:

int

daq2lh5.fc.fc_eventheader_decoder.get_fcid(key)
Return type:

int

daq2lh5.fc.fc_eventheader_decoder.get_key(streamid, card_address, card_input, iwf=-1)
Return type:

int

daq2lh5.fc.fc_fsp_decoder module

class daq2lh5.fc.fc_fsp_decoder.FSPConfigDecoder(*args, **kwargs)

Bases: DataDecoder

decode_config(fcio)
Return type:

Struct

decode_packet(fcio, fsp_config_rb, packet_id)
Return type:

bool

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

make_lgdo(key=None, size=None)

Make an LGDO for this DataDecoder to fill.

This default version of this function allocates a Table using the decoded_values for key. If a different type of LGDO object is required for this decoder, overload this function.

Parameters:
  • key (int | str | None) – used to initialize the LGDO for a particular key (e.g. to have different trace lengths for different channels of a piece of hardware). Leave as None if such specialization is not necessary.

  • size (int | None) – the size to be allocated for the LGDO, if applicable.

Returns:

data_obj – the newly allocated LGDO.

Return type:

Struct

set_fcio_stream(fcio_stream)
class daq2lh5.fc.fc_fsp_decoder.FSPEventDecoder(*args, **kwargs)

Bases: DataDecoder

decode_packet(fcio, fsp_evt_rbkd, packet_id, is_header=False)
Return type:

bool

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

set_fcio_stream(fcio_stream)
class daq2lh5.fc.fc_fsp_decoder.FSPStatusDecoder(*args, **kwargs)

Bases: DataDecoder

decode_packet(fcio, fsp_status_rbkd, packet_id)
Return type:

bool

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

set_fcio_stream(fcio_stream)

daq2lh5.fc.fc_status_decoder module

class daq2lh5.fc.fc_status_decoder.FCStatusDecoder(*args, **kwargs)

Bases: DataDecoder

Decode FlashCam digitizer status data.

decode_packet(fcio, status_rbkd, packet_id)

Access FCIOStatus members for each status packet in the DAQ file.

Parameters:
  • fcio (FCIO) – The interface to the fcio data. Enters this function after a call to fcio.get_record() so that data for packet_id ready to be read out.

  • status_rbkd (Table | dict[int, Table]) – A single table for reading out all data, or a dictionary of tables keyed by card number.

  • packet_id (int) – The index of the packet in the fcio stream. Incremented by FCStreamer.

Returns:

any_full – TODO

Return type:

bool

decoded_values

Default FlashCam status decoded values.

Warning

This configuration can be dynamically modified by the decoder at runtime.

get_decoded_values(key=None)

Get decoded values (optionally for a given key, typically a channel).

Notes

Must overload for your decoder if it has key-specific decoded values. Must also implement key = None returns a “default” decoded_values. Otherwise, just returns self.decoded_values, which should be defined in the constructor.

Return type:

dict[str, dict[str, Any]]

get_key_lists()

Return a list of lists of keys available for this decoder. Each list must contain keys that can share a buffer, i.e. decoded_values is exactly the same (including e.g. waveform length) for all keys in the list. Overload with lists of keys for this decoder, e.g. return [range(n_channels)]. The default version works for decoders with single / no keys.

Return type:

list[list[int | str]]

get_max_rows_in_packet()

Returns the maximum number of rows that could be read out in a packet.

1 by default, overload as necessary to avoid writing past the ends of buffers.

Return type:

int

set_fcio_stream(fcio_stream)

Access FCIOConfig members once when each file is opened.

Parameters:

fcio_stream (FCIO) – extracted via decode_config().

daq2lh5.fc.fc_status_decoder.get_fcid(key)
Return type:

int

daq2lh5.fc.fc_status_decoder.get_key(streamid, reqid)
daq2lh5.fc.fc_status_decoder.get_reqid(key)
Return type:

int

daq2lh5.fc.fc_streamer module

class daq2lh5.fc.fc_streamer.FCStreamer

Bases: DataStreamer

Decode FlashCam data, using the fcio package to handle file access, and the FlashCam data decoders to save the results and write to output.

_abc_impl = <_abc._abc_data object>
close_stream()

Close this data stream.

Note

Needs to be overloaded.

get_decoder_list()

Returns a list of decoder objects for this data stream.

Notes

Needs to be overloaded. Gets called during open_stream().

Return type:

list[DataDecoder]

open_stream(fcio_peer, rb_lib=None, buffer_size=8192, chunk_mode='any_full', out_stream='')

Initialize the FlashCam data stream.

Refer to the documentation for data_streamer.DataStreamer.open_stream() for a description of the parameters.

Returns:

header_data – a list of length 2 containing the raw buffer holding the FCConfig table and optionally the FSPConfig table.

Return type:

list[RawBuffer]

read_packet()

Reads a single packet’s worth of data in to the RawBufferLibrary.

Needs to be overloaded. Gets called by read_chunk() Needs to update self.any_full if any buffers would possibly over-fill on the next read. Needs to update self.n_bytes_read too.

Returns:

still_has_data – returns True while there is still data to read.

Return type:

bool