daq2lh5.orca package¶
This subpackage overloads decoding utilities defined in pygama.raw to
read files produced by the ORCA
acquisition system.
Submodules¶
daq2lh5.orca.orca_base module¶
- class daq2lh5.orca.orca_base.OrcaDecoder(header=None, **kwargs)¶
Bases:
DataDecoderBase class for ORCA decoders.
Mostly here to provide a standard interface for setting the header during initialization.
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
- daq2lh5.orca.orca_base.get_card(ccc)¶
Get card number back from hash value.
See also
- Return type:
- daq2lh5.orca.orca_base.get_ccc(crate, card, channel)¶
Define a standard hash for (crate, card, channel) to integer.
- Return type:
- daq2lh5.orca.orca_base.get_channel(ccc)¶
Get channel number back from hash value.
See also
- Return type:
daq2lh5.orca.orca_digitizers module¶
- class daq2lh5.orca.orca_digitizers.ORSIS3302DecoderForEnergy(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for Struck SIS3302 digitizer data written by ORCA.
- decoded_values_template¶
Default Struck SIS3302 (read out by ORCA) waveform 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
- class daq2lh5.orca.orca_digitizers.ORSIS3316WaveformDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for Struck SIS3316 digitizer data written by ORCA.
- decode_packet(packet, packet_id, rbl)¶
Decode the ORCA SIS3316 ADC packet.
The packet is formatted as:
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx ^^^^ ^^^^ ^^^^ ^^----------------------- Data ID (from header) -----------------^^ ^^^^ ^^^^ ^^^^ ^^^^- length xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx --------^-^^^--------------------------- Crate number -------------^-^^^^--------------------- Card number --------------------^^^^ ^^^^----------- Chan number xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Num Events in this packet xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Num longs in each record xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Num of Records that were in the FIFO xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Num of longs in data header -- can get from the raw data also xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Spare xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Spare xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Spare xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Spare
Then, data events follow with format described in below (note the format bits):
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx -----------------------------------^^^^- Format bits (from header) --------------------^^^^ ^^^^ ^^^^------ Channel ID ^^^^ ^^^^ ^^^^ ^^^^--------------------- Timestamp[47:32] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Timestamp[31:0] if Format bit 0 = 1 add xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx --------------------^^^^ ^^^^ ^^^^ ^^^^- Peakhigh value ^^^^ ^^^^ ^^^^ ^^^^--------------------- Index of Peakhigh value xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx ----------^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^- Accumulator sum of Gate 1 [23:0] ^^^^ ^^^^------------------------------- Information byte xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 2 [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 3 [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 4 [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 5 [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 6 [27:0] If Format bit 1 = 1 add xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 7 [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Accumulator sum of Gate 8 [27:0] If Format bit 2 = 1 add xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx MAW Maximum value [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx MAW Value before Trigger [27:0] xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx MAW Value after/with Trigger [27:0] If Format bit 3 = 1 add xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Start Energy Value (in Trigger Gate) xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Max Energy Value (in Trigger Gate) Regardless of format bit xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx -------^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^- number of raw samples divided by 2 ------^--------------------------------- status Flag -----^---------------------------------- MAW Test Flag Followed by N ADC Raw Samples (2 Samples per 32 bit word) Followed by MAW Test data
- Return type:
- decoded_values_template¶
Default Struck SIS3316 (read out by ORCA) waveform 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
daq2lh5.orca.orca_fcio module¶
- class daq2lh5.orca.orca_fcio.ORFCIOConfigDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoder- 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
- class daq2lh5.orca.orca_fcio.ORFCIOEventDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for FlashCam FCIO stream data written by ORCA.
- 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- 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:
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
- class daq2lh5.orca.orca_fcio.ORFCIOEventHeaderDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoder- 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
- class daq2lh5.orca.orca_fcio.ORFCIOStatusDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoder- 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- 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:
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
- daq2lh5.orca.orca_fcio.extract_header_information(header)¶
- daq2lh5.orca.orca_fcio.get_fcio_stream(streamid)¶
daq2lh5.orca.orca_flashcam module¶
- class daq2lh5.orca.orca_flashcam.ORFlashCamADCWaveformDecoder(header=None, **kwargs)¶
Bases:
ORFlashCamWaveformDecoder
- class daq2lh5.orca.orca_flashcam.ORFlashCamListenerConfigDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for FlashCam listener config written by ORCA.
- decoded_values¶
Default FlashCam (read out by ORCA) config 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- class daq2lh5.orca.orca_flashcam.ORFlashCamListenerStatusDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for FlashCam status packets written by ORCA
Some of the card level status data contains an array of values (temperatures for instance) for each card. Since lh5 currently only supports a 1d vector of 1d vectors, this (card,value) data has to be flattened before populating the lh5 table.
- decoded_values¶
Default FlashCam (read out by ORCA) 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- class daq2lh5.orca.orca_flashcam.ORFlashCamWaveformDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for FlashCam ADC data written by ORCA.
- assert_nsamples(nsamples, fcid)¶
- decoded_values_template¶
A custom copy of
fc.fc_event_decoder.fc_event_decoded_values.
- 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
- 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.
- set_header(header)¶
Setter for headers. Overload to set card parameters, etc.
daq2lh5.orca.orca_header module¶
- class daq2lh5.orca.orca_header.OrcaHeader(jsons=None, lgdo_scalar=None)¶
Bases:
dictORCA file header object.
- get_auxhw_info(orca_class_name, unique_id=-1)¶
Returns a list with all the info from the
AuxHwtable of the header with name orca_class_name.Optionally, if unique_id is greater or equal to zero, only return the object for that ORCA unique ID number.
- Return type:
- get_object_info(orca_class_name)¶
Returns a
dict[crate][card]with all info from the header for each card with name orca_class_name.
- get_readout_info(orca_class_name, unique_id=-1)¶
Returns a list with all the readout list info from the header with name orca_class_name.
Optionally, if unique_id is greater or equal than zero, only return the readout info for that ORCA unique ID number.
- Return type:
- set_from_lgdo(lgdo_scalar)¶
daq2lh5.orca.orca_header_decoder module¶
- class daq2lh5.orca.orca_header_decoder.OrcaHeaderDecoder(header=None, **kwargs)¶
Bases:
OrcaDecoderDecodes ORCA headers.
- make_lgdo(key=None, size=None)¶
Make an LGDO for this
DataDecoderto fill.This default version of this function allocates a
Tableusing the decoded_values for key. If a different type of LGDO object is required for this decoder, overload this function.- Parameters:
- Returns:
data_obj – the newly allocated LGDO.
- Return type:
daq2lh5.orca.orca_packet module¶
Provides convenience functions for working with ORCA packets.
An ORCA packet is represented by a one-dimensional numpy.ndarray of
type numpy.uint32.
- daq2lh5.orca.orca_packet.get_data_id(packet, shift=True)¶
- Return type:
uint32
- daq2lh5.orca.orca_packet.hex_dump(packet, shift_data_id=True, print_n_words=False, max_words=inf, as_int=False, as_short=False, id_dict=None, use_logging=True, return_output=False)¶
daq2lh5.orca.orca_run_decoder module¶
- class daq2lh5.orca.orca_run_decoder.ORRunDecoderForRun(header=None, **kwargs)¶
Bases:
OrcaDecoderDecoder for Run Control data written by ORCA.
- decode_packet(packet, packet_id, rbl)¶
Decode the ORCA Run packet.
Format is taken from the ORCA website: Run Control
- Return type:
- 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 = Nonereturns a “default” decoded_values. Otherwise, just returnsself.decoded_values, which should be defined in the constructor.
daq2lh5.orca.orca_streamer module¶
- class daq2lh5.orca.orca_streamer.OrcaStreamer¶
Bases:
DataStreamerData streamer for ORCA data.
- _abc_impl = <_abc._abc_data object>¶
- build_packet_locs(saveloc=True)¶
- close_in_stream()¶
- 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:
- hex_dump(stream_name, n_packets=inf, skip_header=False, shift_data_id=True, print_n_words=False, max_words=inf, as_int=False, as_short=False)¶
- load_packet(index=None, whence=0, skip_unknown_ids=False)¶
Loads the next packet into the internal buffer.
Returns packet as a
numpy.uint32view of the buffer (a slice), returnsNoneat EOF.- Parameters:
index (int | None) – Optionally give an index of packet to skip to, relative to the “whence” location. Can be positive or negative. If out-of-range for the file, None will be returned.
whence (int) – used when an index is supplied. Follows the file.seek() convention: whence = 0 (default) means index is relative to the beginning of the file; whence = 1 means index is relative to the current position in the file; whence = 2 means relative to the end of the file.
- Returns:
packet – a view of the internal buffer spanning the packet data (uint32 ndarray). If you want to hold on to the packet data while you load more packets, you can call copy() on the view to make a copy.
- Return type:
ndarray | None
- load_packet_header()¶
Loads the packet header at the current read location into the buffer
and updates internal variables.
- Return type:
ndarray | None
- open_stream(stream_name, rb_lib=None, buffer_size=8192, chunk_mode='any_full', out_stream='')¶
Initialize the ORCA data stream.
- Parameters:
stream_name (str) – The ORCA filename. Only file streams are currently supported. Socket stream reading can be added later.
rb_lib (RawBufferLibrary | None) – library of buffers for this stream.
buffer_size (int) – length of tables to be read out in
read_chunk().chunk_mode ('any_full', 'only_full', or 'single_packet') – sets the mode use for
read_chunk().out_stream (str) – optional name of output stream for default rb_lib generation.
- Returns:
header_data – a list of length 1 containing the raw buffer holding the ORCA header.
- Return type:
- set_in_stream(stream_name)¶
daq2lh5.orca.skim_orca_file module¶
- daq2lh5.orca.skim_orca_file.skim_orca_file()¶