DDAS Format
1.1.1
A self-contained, lightweight format library and unpacker for DDAS data
|
Unpacker for DDAS data recorded by NSCLDAQ. More...
#include <DDASHitUnpacker.h>
Public Member Functions | |
std::tuple< DDASHit, const uint32_t * > | unpack (const uint32_t *beg, const uint32_t *sentinel) |
Unpack data into a DDASHit. More... | |
const uint32_t * | unpack (const uint32_t *beg, const uint32_t *sentinel, DDASHit &hit) |
Unpack data into a DDASHit. More... | |
Protected Member Functions | |
const uint32_t * | parseBodySize (const uint32_t *beg, const uint32_t *sentinel) |
Ensure there is enough data to parse. More... | |
const uint32_t * | parseModuleInfo (DDASHit &hit, const uint32_t *beg) |
Parse the module identifying information encoded in the hit. More... | |
const uint32_t * | parseHeaderWord0 (DDASHit &hit, const uint32_t *beg) |
Parse the word 0 of the Pixie-16 data header. More... | |
const uint32_t * | parseHeaderWords1And2 (DDASHit &hit, const uint32_t *beg) |
Parse words 1 and 2 of the Pixie-16 data header. More... | |
const uint32_t * | parseHeaderWord3 (DDASHit &hit, const uint32_t *beg) |
Parse word 3 of the Pixie-16 data header. More... | |
const uint32_t * | parseTraceData (DDASHit &hit, const uint32_t *beg) |
Unpack the trace data. More... | |
std::tuple< double, uint32_t, uint32_t, uint32_t > | parseAndComputeCFD (uint32_t ModMSPS, uint32_t data) |
Determine the CFD correction to the leading-edge time in nanoseconds from the CFD word. More... | |
double | parseAndComputeCFD (DDASHit &hit, uint32_t data) |
Determine the CFD correction to the leading-edge time in nanoseconds from the CFD word. More... | |
uint64_t | computeCoarseTime (uint32_t adcFrequency, uint32_t timeLow, uint32_t timeHigh) |
Compute time in nanoseconds from raw data (no CFD correction). More... | |
const uint32_t * | extractEnergySums (const uint32_t *data, DDASHit &hit) |
Unpack energy sums. More... | |
const uint32_t * | extractQDC (const uint32_t *data, DDASHit &hit) |
Unpack QDC values. More... | |
const uint32_t * | extractExternalTimestamp (const uint32_t *data, DDASHit &hit) |
Unpack the external timestamp data. More... | |
Unpacker for DDAS data recorded by NSCLDAQ.
This class unpacks NSCLDAQ-formatted Pixie-16 data recorded by a DDAS readout program into DDASHits which encapsulate the information recorded by a single Pixie channel. This is a generic unpacker which can accomodate information from all Pixie-16 digitizer types at FRIB. In general, all of the digitizer outputs contain the same information but importantly the meaning of the CFD data depends on the digitizer type. The unpacker class abstracts this difference away from the user.
This class does not provide any parsing capabilities like the ddasdumper. You must create a DDASHit object and unpack data into it. Here is how you do that:
where pData
is a pointer to the first 32-bit word of the hit body and sizeOfData
is the size of the hit in 32-bit words.
|
protected |
Compute time in nanoseconds from raw data (no CFD correction).
adcFrequency | Module ADC frequency in MSPS. |
timeLow | Data word containing the lower 32 bits of the 48-bit timestamp. |
timeHigh | Data word containing the upper 16 bits of the 48-bit timestamp. |
Form the timestamp from the low and high bits and convert it to a time in nanoseconds.
The calculations for the various modules are as follows:
For the 100 MSPS module:
\[\text{time} = 10\times((\text{timeHigh} << 32) + \text{timeLow})\]
For the 250 MSPS module...
\[\text{time} = 8\times((\text{timeHigh} << 32) + \text{timeLow})\]
For the 500 MSPS module,
\[\text{time} = 10\times((\text{timeHigh} << 32) + \text{timeLow})\]
|
protected |
Unpack energy sums.
data | Pointer to the first 32-bit word containing the energy sum data. |
hit | References the DDASHit we are unpacking. |
Energy sums consist of SIZE_OF_ENE_SUMS (=4) 32-bit words, which are, in order: 0. The trailing (pre-gap ) sum.
If the hit is not reset between calls to this function, the energy sum data will be appended to the end of the exisiting energy sums.
|
protected |
Unpack the external timestamp data.
data | Pointer to the 32-bit word containing the lower 16 bits of the 48-bit external timestamp. |
hit | References the DDASHit we are unpacking. |
Unpack and set the 48-bit external timestamp. Unlike the internal timestamp where the conversion from clock tics to nanoseconds is known, for the external timestamp no unit conversion is applied. Converting the timestamp to proper units is left to the user.
|
protected |
Unpack QDC values.
data | Pointer to the first 32-bit word containing the QDC sum data. |
hit | References the DDASHit we are unpacking. |
QDC sums consist of SIZE_OF_QDC_SUMS (=8) 32-bit words. If the hit is not reset between calls to this function, the QDC sum data will be appended to the end of the exisiting QDC sums.
|
protected |
Determine the CFD correction to the leading-edge time in nanoseconds from the CFD word.
hit | References the DDASHit we are unpacking. |
data | The 32-bit data word encoding the CFD information. |
The value of the CFD correction depends on the module. Because the module information is encoded in the data, this function should be called after parseModuleInfo()
.
|
protected |
Determine the CFD correction to the leading-edge time in nanoseconds from the CFD word.
ModMSPS | The module ADC frequency in MSPS. |
data | The 32-bit data word encoding the CFD information. |
The value of the CFD correction depends on the module. Because the module information is encoded in the data, this function should be called after parseModuleInfo()
.
|
protected |
Ensure there is enough data to parse.
data | Pointer to the hit body. |
sentinel | Pointer to the first word after the body. |
std::runtime_error | If there are an incorrect number of 16-bit data words in the event (words exceed sentinal boundry) and the pointer to the last data word is not a nullptr. |
The first word of the body passed to this function is the self-inclusive event size in 16-bit words.
|
protected |
Parse the word 0 of the Pixie-16 data header.
hit | References the DDASHit we are unpacking. |
data | The 32-bit data word to parse. |
Word 0 contains:
|
protected |
Parse word 3 of the Pixie-16 data header.
hit | References the DDASHit we are unpacking. |
data | Pointer to word 3. |
Word 3 contains:
parseHeaderWord0()
for more info.
|
protected |
Parse words 1 and 2 of the Pixie-16 data header.
hit | References the DDASHit we are unpacking. |
data | Pointer to word 1. |
Words 1 and 2 contain the timestamp and CFD information. The meaning of the CFD word depends on the module type. The unpacker abstracts this meaning away from the user. Note that we know the module type if the module identifier word was unpacked before calling this function.
Word 1 contains:
|
protected |
Parse the module identifying information encoded in the hit.
hit | References the DDASHit we are unpacking. |
data | The 32-bit data word containing the module identifying information. |
The lower 16 bits encode the ADC frequency, the upper 16 bits encode the hardware revision and ADC resolution.
|
protected |
Unpack the trace data.
hit | References the hit we are unpacking. |
data | Pointer to the 32-bit trace word to unpack. The 32-bit trace word contains two 16-bit trace ADC values. |
The 16-bit trace data is stored two samples to one 32-bit word in little-endian. The data for sample i is stored in the lower 16 bits while the data for sample i + 1 is stored in the upper 16 bits. For ADCs with less than 16-bit resolution, those bits are set to 0.
std::tuple< ddasfmt::DDASHit, const uint32_t * > ddasfmt::DDASHitUnpacker::unpack | ( | const uint32_t * | beg, |
const uint32_t * | sentinel | ||
) |
Unpack data into a DDASHit.
beg | Pointer to the first word of the hit body. |
sentinel | Pointer to the first word after the end of the body. |
This expects data from a DDAS readout program. It will parse the entire body of the event in a manner that is consistent with the data present. In other words, it uses the sizes of the event encoded in the data to determine when the parsing is complete.
While it parses, it stores the results into the data members of the object hit. Prior to parsing, all data members are reset to 0 using the Reset() method.
const uint32_t * ddasfmt::DDASHitUnpacker::unpack | ( | const uint32_t * | beg, |
const uint32_t * | sentinel, | ||
DDASHit & | hit | ||
) |
Unpack data into a DDASHit.
[in] | beg | Pointer to the first 32-bit word of the hit body. |
[in] | sentinel | Pointer to the first word after the end of the body. |
[in,out] | hit | Reference to the DDASHit object filled during unpacking. |
std::runtime_error | If the hit data buffer is empty. |
std::runtime_error | If the hit's length is not the value specified in the header. |
This expects data from a DDAS readout program. It will parse the entire body of the event in a manner that is consistent with the data present. In other words, it uses the sizes of the event encoded in the data to determine when the parsing is complete.
While it parses, it stores the results into the data members of the object hit. Prior to parsing, all data members are reset to 0 using the Reset() method.