NSCL DDAS
12.1-001
Support for XIA DDAS at FRIB
|
A struct containing a pointer to a hit and its properties. More...
#include <RawChannel.h>
Public Member Functions | |
RawChannel () | |
Default constructor. More... | |
RawChannel (size_t nWords) | |
Construct a channel for copy-in data. More... | |
RawChannel (size_t nWords, void *pZcopyData) | |
Constructor initialized with zero-copy hit data. More... | |
virtual | ~RawChannel () |
Destructor. More... | |
int | SetTime () |
Set the 48-bit timestamp data from the hit infomration. More... | |
int | SetTime (double nsPerTick, bool useExt=false) |
Set time time in ns. More... | |
int | SetLength () |
Set the event length from the data. More... | |
int | SetChannel () |
Set the channel value from the data. More... | |
int | Validate (int expecting) |
Determine if a channel has the correct amount of data. More... | |
void | setData (size_t nWords, void *pZCopyData) |
Set new data. More... | |
void | copyInData (size_t nWords, const void *pData) |
Copy in data. More... | |
RawChannel (const RawChannel &rhs) | |
Copy constructor. More... | |
RawChannel & | operator= (const RawChannel &rhs) |
Assignment operator. More... | |
Static Public Member Functions | |
static uint32_t | channelLength (void *pData) |
Extract the number of words in a hit. More... | |
static double | moduleCalibration (uint32_t moduleType) |
Returns the multiplier used to convert the module raw timestamp into nanoseconds. More... | |
Public Attributes | |
uint32_t | s_moduleType |
Type of module this comes from. More... | |
double | s_time |
Extracted time, possibly calibrated. More... | |
int | s_chanid |
Channel within module. More... | |
bool | s_ownData |
True if we own s_data. More... | |
int | s_ownDataSize |
If we own data, how many uint32_t's. More... | |
int | s_channelLength |
Number of uint32_t in s_data. More... | |
uint32_t * | s_data |
Pointer to the hit data. More... | |
A struct containing a pointer to a hit and its properties.
The struct can be used in either zero copy or copy mode. In zero-copy mode, a channel's data pointer points to some buffer that may have raw data from more than one hit. In copy mode, the data are dynamically allocated to hold the raw hit.
DDASReadout::RawChannel::RawChannel | ( | ) |
Default constructor.
Constructs a new raw channel that could be used in either zerocopy or copy mode. The size and data are not yet set and the ownData flag is set false since we don't need to delete.
DDASReadout::RawChannel::RawChannel | ( | size_t | nWords | ) |
Construct a channel for copy-in data.
nWords | Number of data words to pre-allocate. |
std::bad_alloc | If malloc of pre-allocated storage fails. |
Construts a channel for copy in data. Data are pre-allocated as demanded but not initialized. We use malloc rather than new because new will construct (initialize) ints to zero and we don't want to take that time.
Data must eventually be provided by calling copyInData.
DDASReadout::RawChannel::RawChannel | ( | size_t | nWords, |
void * | pZCopyData | ||
) |
Constructor initialized with zero-copy hit data.
nWords | Number of data words to pre-allocate. |
pZCopyData | Pointer to the data of the hit. |
|
virtual |
Destructor.
If we own the data, this will free it.
DDASReadout::RawChannel::RawChannel | ( | const RawChannel & | rhs | ) |
Copy constructor.
rhs | The object we're copying into this. |
This is just assignment to *this once we're appropriately initialized.
|
static |
Extract the number of words in a hit.
pData | Pointer to the hit data. |
void DDASReadout::RawChannel::copyInData | ( | size_t | nWords, |
const void * | pData | ||
) |
Copy in data.
nWords | The new channel length (32-bit words). |
pData | Pointer to the data to copy in. |
|
static |
Returns the multiplier used to convert the module raw timestamp into nanoseconds.
moduleType | The module type/speed etc. word that's normally prepended to hit data. |
RawChannel & DDASReadout::RawChannel::operator= | ( | const RawChannel & | rhs | ) |
Assignment operator.
rhs | The object we'er assigning to this. |
Only works if this != &rhs. There are piles of cases to consider:
These two cases and their subcases are handled by setData and copyInData respectively.
int DDASReadout::RawChannel::SetChannel | ( | ) |
Set the channel value from the data.
0 | Success. |
1 | Insufficent data in the hit or the hit has not been set. |
void DDASReadout::RawChannel::setData | ( | size_t | nWords, |
void * | pZCopyData | ||
) |
Set new data.
nWords | The new channel length (32-bit words). |
pZCopyData | Pointer to the data to set. |
Perform at most two tasks:
int DDASReadout::RawChannel::SetLength | ( | ) |
Set the event length from the data.
int DDASReadout::RawChannel::SetTime | ( | ) |
Set the 48-bit timestamp data from the hit infomration.
0 | Success. |
1 | If the number of data words is insufficient (< 4). |
Assumes that the data are set using the setData()
or copyInData()
methods of this class. Determine the raw timestamp from the 48-bit timestamp data in the hit and set it in s_time. The timestamp is extracted from data words 1 and 2 of the Pixie-16 list mode event header structure in the hit.
int DDASReadout::RawChannel::SetTime | ( | double | nsPerTick, |
bool | useExt = false |
||
) |
Set time time in ns.
nsPerTick | Clock calibration in nanoseconds per clock tick. |
useExt | True if using an external timestamp (default=false). |
0 | Success. |
1 | Failure, which can happen in the following ways:
|
This function assumes that the data are set using either the setData()
or copyInData()
methods of this class. Note that setData()
is used for zero-copy. Determine the calibrated timestamp from the 48-bit timestamp data in the hit and set it in s_time. The timestamp is extracted from data words 1 and 2 of the Pixie-16 list mode event header structure in the hit. The clock calibration passed to this function is used to convert the time to nanoseconds from clock ticks.
int DDASReadout::RawChannel::Validate | ( | int | expecting | ) |
Determine if a channel has the correct amount of data.
expecting | The expected channel length in 32-bit words. |
0 | Correct length. |
1 | Incorrect channel length. A message is output to std::cerr. |
Retains rough compatibility with the old channel class.
int DDASReadout::RawChannel::s_chanid |
Channel within module.
int DDASReadout::RawChannel::s_channelLength |
Number of uint32_t in s_data.
uint32_t* DDASReadout::RawChannel::s_data |
Pointer to the hit data.
uint32_t DDASReadout::RawChannel::s_moduleType |
Type of module this comes from.
bool DDASReadout::RawChannel::s_ownData |
True if we own s_data.
int DDASReadout::RawChannel::s_ownDataSize |
If we own data, how many uint32_t's.
double DDASReadout::RawChannel::s_time |
Extracted time, possibly calibrated.