artdaq_core
v3_01_05
|
A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is the main data storage class in artdaq. Each Fragment represents the data from one piece of the readout, for one artdaq event. BoardReaders create Fragments and send them to the EventBuilders, where they are assembled into artdaq::RawEvent objects. More...
#include <artdaq-core/Data/Fragment.hh>
Public Member Functions | |
Fragment () | |
Create a Fragment with all header values zeroed. | |
Fragment (const Fragment &)=default | |
Default copy constructor. More... | |
Fragment (Fragment &&) noexcept | |
Move Constructor. More... | |
Fragment & | operator= (const Fragment &)=default |
Default copy-assignment operator. More... | |
Fragment & | operator= (Fragment &&) noexcept |
Move-assignment operator. More... | |
Fragment (std::size_t n) | |
Create a Fragment ready to hold n words (RawDataTypes) of payload, and with all values zeroed. More... | |
template<class T > | |
Fragment (std::size_t payload_size, sequence_id_t sequence_id, fragment_id_t fragment_id, type_t type, const T &metadata, timestamp_t timestamp=Fragment::InvalidTimestamp) | |
Create a Fragment with the given header values. More... | |
Fragment (sequence_id_t sequenceID, fragment_id_t fragID, type_t type=Fragment::DataFragmentType, timestamp_t timestamp=Fragment::InvalidTimestamp) | |
Create a fragment with the given event id and fragment id, and with no data payload. More... | |
void | print (std::ostream &os) const |
Print out summary information for this Fragment to the given stream. More... | |
std::size_t | size () const |
Gets the size of the Fragment, from the Fragment header. More... | |
version_t | version () const |
Version of the Fragment, from the Fragment header. More... | |
type_t | type () const |
Type of the Fragment, from the Fragment header. More... | |
std::string | typeString () const |
Print the type of the Fragment. More... | |
sequence_id_t | sequenceID () const |
Sequence ID of the Fragment, from the Fragment header. More... | |
fragment_id_t | fragmentID () const |
Fragment ID of the Fragment, from the Fragment header. More... | |
timestamp_t | timestamp () const |
Timestamp of the Fragment, from the Fragment header. More... | |
void | setUserType (type_t utype) |
Sets the type of the Fragment, checking that it is a valid user type. More... | |
void | setSystemType (type_t stype) |
Sets the type of the Fragment, checking that it is a valid system type. More... | |
void | setSequenceID (sequence_id_t sequence_id) |
Sets the Sequence ID of the Fragment. More... | |
void | setFragmentID (fragment_id_t fragment_id) |
Sets the Fragment ID of the Fragment. More... | |
void | setTimestamp (timestamp_t timestamp) |
Sets the Timestamp of the Fragment. More... | |
std::size_t | sizeBytes () const |
Size of vals_ vector ( header + (optional) metadata + payload) in bytes. More... | |
std::size_t | dataSize () const |
Return the number of RawDataType words in the data payload. This does not include the number of words in the header or the metadata. More... | |
std::size_t | dataSizeBytes () const |
Return the number of bytes in the data payload. This does not include the number of bytes in the header or the metadata. More... | |
bool | hasMetadata () const |
Test whether this Fragment has metadata. More... | |
template<class T > | |
T * | metadata () |
Return a pointer to the metadata. This throws an exception if the Fragment contains no metadata. More... | |
template<class T > | |
T const * | metadata () const |
Return a const pointer to the metadata. This throws an exception if the Fragment contains no metadata. More... | |
template<class T > | |
void | setMetadata (const T &md) |
Set the metadata in the Fragment to the contents of the specified structure. This throws an exception if the Fragment already contains metadata. More... | |
template<class T > | |
void | updateMetadata (const T &md) |
Updates existing metadata with a new metadata object. More... | |
void | resize (std::size_t sz) |
Resize the data payload to hold sz RawDataType words. More... | |
void | resize (std::size_t sz, RawDataType val) |
Resize the data payload to hold sz RawDataType words. Initialize new elements (if any) with val. More... | |
void | resizeBytes (std::size_t szbytes) |
Resize the data payload to hold szbytes bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16) More... | |
void | resizeBytes (std::size_t szbytes, byte_t val) |
Resize the data payload to hold sz bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16). Initialize new elements (if any) with val. More... | |
void | autoResize () |
Resize the fragment to hold the number of words indicated by the header. | |
iterator | dataBegin () |
Return an iterator to the beginning of the data payload (after header and metadata) More... | |
iterator | dataEnd () |
Return an iterator to the end of the data payload. More... | |
template<typename T > | |
T | reinterpret_cast_checked (const RawDataType *in) const |
Wrapper around reinterpret_cast. More... | |
template<typename T > | |
T | reinterpret_cast_checked (RawDataType *in) |
Wrapper around reinterpret_cast. More... | |
byte_t * | dataBeginBytes () |
Return Fragment::byte_t* pointing at the beginning of the payload. More... | |
byte_t * | dataEndBytes () |
Return Fragment::byte_t* pointing at the end of the payload. More... | |
iterator | headerBegin () |
Return an iterator to the beginning of the header (should be used for serialization only: use setters for preference). More... | |
byte_t * | headerBeginBytes () |
Return a Fragment::byte_t pointer pointing to the beginning of the header. More... | |
const_iterator | dataBegin () const |
Returns a const_iterator to the beginning of the data payload. More... | |
const_iterator | dataEnd () const |
Returns a const_iterator to the end of the data payload. More... | |
const byte_t * | dataBeginBytes () const |
Return const Fragment::byte_t* pointing at the beginning of the payload. More... | |
const byte_t * | dataEndBytes () const |
Return const Fragment::byte_t* pointing at the end of the payload. More... | |
const_iterator | headerBegin () const |
Return an const_iterator to the beginning of the header (should be used for serialization only: use setters for preference). More... | |
const byte_t * | headerBeginBytes () const |
Return a const Fragment::byte_t pointer pointing to the beginning of the header. More... | |
void | clear () |
Removes all elements from the payload section of the Fragment. | |
bool | empty () |
Determines if the Fragment contains no data. More... | |
void | reserve (std::size_t cap) |
Reserves enough memory to hold cap RawDataType words in the Fragment payload. More... | |
void | swap (Fragment &other) noexcept |
Swaps two Fragment objects. More... | |
void | swap (QuickVec< RawDataType > &other) noexcept |
Swaps two Fragment data vectors. More... | |
RawDataType * | dataAddress () |
Returns a RawDataType pointer to the beginning of the payload. More... | |
RawDataType * | metadataAddress () |
Get the address of the metadata. For internal use only, use metadata() instead. More... | |
RawDataType * | headerAddress () |
Gets the address of the header. More... | |
Static Public Member Functions | |
static constexpr bool | isUserFragmentType (type_t fragmentType) |
Returns whether the given type is in the range of user types. More... | |
static constexpr bool | isSystemFragmentType (type_t fragmentType) |
Returns whether the given type is in the range of system types. More... | |
static std::map< type_t, std::string > | MakeSystemTypeMap () |
Returns a map of the most commonly-used system types. More... | |
static FragmentPtr | FragmentBytes (std::size_t nbytes) |
Create a Fragment using a static factory function rather than a constructor to allow for the function name "FragmentBytes". More... | |
template<class T > | |
static FragmentPtr | FragmentBytes (std::size_t payload_size_in_bytes, sequence_id_t sequence_id, fragment_id_t fragment_id, type_t type, const T &metadata, timestamp_t timestamp=Fragment::InvalidTimestamp) |
Create a Fragment with the given header values. Uses static factory function instead of constructor to allow for the function name "FragmentBytes". More... | |
static FragmentPtr | eodFrag (size_t nFragsToExpect) |
Creates an EndOfData Fragment. More... | |
template<class InputIterator > | |
static FragmentPtr | dataFrag (sequence_id_t sequenceID, fragment_id_t fragID, InputIterator i, InputIterator e) |
Creates a Fragment, copying data from given location. 12-Apr-2013, KAB - this method is deprecated, please do not use (internal use only) More... | |
static FragmentPtr | dataFrag (sequence_id_t sequenceID, fragment_id_t fragID, RawDataType const *dataPtr, size_t dataSize, timestamp_t timestamp=Fragment::InvalidTimestamp) |
Crates a Fragment, copying data from given location. More... | |
Static Public Attributes | |
static constexpr version_t | InvalidVersion = detail::RawFragmentHeader::InvalidVersion |
Copy InvalidVersion from RawFragmentHeader. | |
static constexpr sequence_id_t | InvalidSequenceID = detail::RawFragmentHeader::InvalidSequenceID |
Copy InvalidSequenceID from RawFragmentHeader. | |
static constexpr fragment_id_t | InvalidFragmentID = detail::RawFragmentHeader::InvalidFragmentID |
Copy InvalidFragmentID from RawFragmentHeader. | |
static constexpr timestamp_t | InvalidTimestamp = detail::RawFragmentHeader::InvalidTimestamp |
Copy InvalidTimestamp from RawFragmentHeader. | |
static constexpr type_t | InvalidFragmentType = detail::RawFragmentHeader::InvalidFragmentType |
Copy InvalidFragmentType from RawFragmentHeader. | |
static constexpr type_t | EndOfDataFragmentType = detail::RawFragmentHeader::EndOfDataFragmentType |
Copy EndOfDataFragmentType from RawFragmentHeader. | |
static constexpr type_t | DataFragmentType = detail::RawFragmentHeader::DataFragmentType |
Copy DataFragmentType from RawFragmentHeader. | |
static constexpr type_t | InitFragmentType = detail::RawFragmentHeader::InitFragmentType |
Copy InitFragmentType from RawFragmentHeader. | |
static constexpr type_t | EndOfRunFragmentType = detail::RawFragmentHeader::EndOfRunFragmentType |
Copy EndOfRunFragmentType from RawFragmentHeader. | |
static constexpr type_t | EndOfSubrunFragmentType = detail::RawFragmentHeader::EndOfSubrunFragmentType |
Copy EndOfSubrunFragmentType from RawFragmentHeader. | |
static constexpr type_t | ShutdownFragmentType = detail::RawFragmentHeader::ShutdownFragmentType |
Copy ShutdownFragmentType from RawFragmentHeader. | |
static constexpr type_t | FirstUserFragmentType = detail::RawFragmentHeader::FIRST_USER_TYPE |
Copy FIRST_USER_TYPE from RawFragmentHeader. | |
static constexpr type_t | EmptyFragmentType = detail::RawFragmentHeader::EmptyFragmentType |
Copy EmptyFragmentType from RawFragmentHeader. | |
static constexpr type_t | ContainerFragmentType = detail::RawFragmentHeader::ContainerFragmentType |
Copy ContainerFragmentType from RawFragmentHeader. | |
A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is the main data storage class in artdaq. Each Fragment represents the data from one piece of the readout, for one artdaq event. BoardReaders create Fragments and send them to the EventBuilders, where they are assembled into artdaq::RawEvent objects.
Definition at line 84 of file Fragment.hh.
typedef uint8_t artdaq::Fragment::byte_t |
For byte representation.
JCF, 3/25/14 Add interface functions which allow users to work with the underlying data (a vector of RawDataTypes) in byte representation
Definition at line 99 of file Fragment.hh.
|
default |
Default copy constructor.
|
inlinedefaultnoexcept |
Move Constructor.
Separate declaration and definition of Move Constructor: http://stackoverflow.com/questions/33939687 This should generate an exception if artdaq::Fragment is not move-constructible
|
explicit |
Create a Fragment ready to hold n words (RawDataTypes) of payload, and with all values zeroed.
n | The initial size of the Fragment, in RawDataType words |
Definition at line 22 of file Fragment.cc.
artdaq::Fragment::Fragment | ( | std::size_t | payload_size, |
sequence_id_t | sequence_id, | ||
fragment_id_t | fragment_id, | ||
type_t | type, | ||
const T & | metadata, | ||
timestamp_t | timestamp = Fragment::InvalidTimestamp |
||
) |
Create a Fragment with the given header values.
T | Metadata type |
payload_size | Size of the payload in RawDataType words (Fragment size is header + metadata + payload) |
sequence_id | Sequence ID of Fragment |
fragment_id | Fragment ID of Fragment |
type | Type of Fragment |
metadata | Metadata object |
timestamp | Timestamp of Fragment |
Definition at line 767 of file Fragment.hh.
artdaq::Fragment::Fragment | ( | sequence_id_t | sequenceID, |
fragment_id_t | fragID, | ||
type_t | type = Fragment::DataFragmentType , |
||
timestamp_t | timestamp = Fragment::InvalidTimestamp |
||
) |
|
inline |
Returns a RawDataType pointer to the beginning of the payload.
Definition at line 1101 of file Fragment.hh.
|
inline |
Return an iterator to the beginning of the data payload (after header and metadata)
Definition at line 1025 of file Fragment.hh.
|
inline |
Returns a const_iterator to the beginning of the data payload.
Definition at line 1047 of file Fragment.hh.
|
inline |
Return Fragment::byte_t* pointing at the beginning of the payload.
JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataBegin() ) to get ahold of the memory
Definition at line 522 of file Fragment.hh.
|
inline |
Return const Fragment::byte_t* pointing at the beginning of the payload.
JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataEnd() ) to get ahold of the memory
Definition at line 567 of file Fragment.hh.
|
inline |
Return an iterator to the end of the data payload.
Definition at line 1033 of file Fragment.hh.
|
inline |
Returns a const_iterator to the end of the data payload.
Definition at line 1055 of file Fragment.hh.
|
inline |
Return Fragment::byte_t* pointing at the end of the payload.
JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataEnd() ) to get ahold of the memory
Definition at line 532 of file Fragment.hh.
|
inline |
Return const Fragment::byte_t* pointing at the end of the payload.
JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataEnd() ) to get ahold of the memory
Definition at line 580 of file Fragment.hh.
|
inlinestatic |
Creates a Fragment, copying data from given location. 12-Apr-2013, KAB - this method is deprecated, please do not use (internal use only)
InputIterator | Type of input iterator |
sequenceID | Sequence ID of new Fragment |
fragID | Fragment ID of new Fragment |
i | Beginning of input range |
e | End of input range |
Definition at line 669 of file Fragment.hh.
|
static |
Crates a Fragment, copying data from given location.
sequenceID | Sequence ID of new Fragment |
fragID | Fragment ID of new Fragment |
dataPtr | Pointer to data to store in Fragment |
dataSize | Size of data to store in Fragment |
timestamp | Timestamp of created Fragment |
Definition at line 85 of file Fragment.cc.
|
inline |
Return the number of RawDataType words in the data payload. This does not include the number of words in the header or the metadata.
Definition at line 894 of file Fragment.hh.
|
inline |
Return the number of bytes in the data payload. This does not include the number of bytes in the header or the metadata.
Definition at line 355 of file Fragment.hh.
|
inline |
Determines if the Fragment contains no data.
Definition at line 1078 of file Fragment.hh.
|
static |
Creates an EndOfData Fragment.
nFragsToExpect | The number of Fragments the receiver should have at the end of data-taking |
Definition at line 74 of file Fragment.cc.
|
inlinestatic |
Create a Fragment using a static factory function rather than a constructor to allow for the function name "FragmentBytes".
nbytes | The initial size of the Fragment, in bytes |
Definition at line 200 of file Fragment.hh.
|
inlinestatic |
Create a Fragment with the given header values. Uses static factory function instead of constructor to allow for the function name "FragmentBytes".
T | Metadata type |
payload_size_in_bytes | Size of the payload in bytes (Fragment size is header + metadata + payload). Bytes will be rounded to the next factor of RawDataType / sizeof(char) |
sequence_id | Sequence ID of Fragment |
fragment_id | Fragment ID of Fragment |
type | Type of Fragment |
metadata | Metadata object |
timestamp | Timestamp of Fragment |
Definition at line 235 of file Fragment.hh.
|
inline |
|
inline |
Test whether this Fragment has metadata.
Definition at line 902 of file Fragment.hh.
|
inline |
Gets the address of the header.
Definition at line 1121 of file Fragment.hh.
|
inline |
Return an iterator to the beginning of the header (should be used for serialization only: use setters for preference).
Definition at line 1040 of file Fragment.hh.
|
inline |
Return an const_iterator to the beginning of the header (should be used for serialization only: use setters for preference).
Definition at line 1062 of file Fragment.hh.
|
inline |
Return a Fragment::byte_t pointer pointing to the beginning of the header.
Definition at line 545 of file Fragment.hh.
|
inline |
Return a const Fragment::byte_t pointer pointing to the beginning of the header.
Definition at line 596 of file Fragment.hh.
|
inlinestatic |
Returns whether the given type is in the range of system types.
fragmentType | The type to test |
Definition at line 734 of file Fragment.hh.
|
inlinestatic |
Returns whether the given type is in the range of user types.
fragmentType | The type to test |
Definition at line 724 of file Fragment.hh.
|
inlinestatic |
Returns a map of the most commonly-used system types.
Definition at line 175 of file Fragment.hh.
T * artdaq::Fragment::metadata | ( | ) |
Return a pointer to the metadata. This throws an exception if the Fragment contains no metadata.
T | Type of the metadata |
cet::exception | if no metadata is present |
Definition at line 909 of file Fragment.hh.
T const * artdaq::Fragment::metadata | ( | ) | const |
Return a const pointer to the metadata. This throws an exception if the Fragment contains no metadata.
T | Type of the metadata |
cet::exception | if no metadata is present |
Definition at line 923 of file Fragment.hh.
|
inline |
Get the address of the metadata. For internal use only, use metadata() instead.
cet::exception | if no metadata in Fragment |
Definition at line 1109 of file Fragment.hh.
|
inlinedefaultnoexcept |
Move-assignment operator.
Separate declaration and definition of Move Constructor: http://stackoverflow.com/questions/33939687 This should generate an exception if artdaq::Fragment is not move-constructible
void artdaq::Fragment::print | ( | std::ostream & | os | ) | const |
Print out summary information for this Fragment to the given stream.
os | Stream to print to |
Definition at line 65 of file Fragment.cc.
|
inline |
Wrapper around reinterpret_cast.
T | Type of output pointer |
in | input pointer |
cet::exception | if new pointer does not point to same address as old pointer |
JCF, 1/21/15 There's actually not an ironclad guarantee in the C++ standard that the pointer reinterpret_cast<> returns has the same address as the pointer that was casted. It IS tested in the artdaq-core test suite, but since any uncaught, unexpected behavior from reinterpret_cast could be disastrous, I've wrapped it in this function and added a check just to be completely safe.
Please note that for this const-version, you'll need the const- qualifier to the pointer you pass as a parameter (i.e., reinterpret_cast_checked<const PtrType*>, not reinterpret_cast_checked<PtrType*>)
Definition at line 474 of file Fragment.hh.
|
inline |
Wrapper around reinterpret_cast.
T | Type of output pointer |
in | input pointer |
cet::exception | if new pointer does not point to same address as old pointer |
JCF, 1/21/15 There's actually not an ironclad guarantee in the C++ standard that the pointer reinterpret_cast<> returns has the same address as the pointer that was casted. It IS tested in the artdaq-core test suite, but since any uncaught, unexpected behavior from reinterpret_cast could be disastrous, I've wrapped it in this function and added a check just to be completely safe.
Definition at line 502 of file Fragment.hh.
|
inline |
Reserves enough memory to hold cap RawDataType words in the Fragment payload.
cap | The new capacity of the Fragment payload, in RawDataType words. |
Definition at line 1086 of file Fragment.hh.
|
inline |
Resize the data payload to hold sz RawDataType words.
sz | The new size of the payload portion of the Fragment, in RawDataType words |
Definition at line 973 of file Fragment.hh.
|
inline |
Resize the data payload to hold sz RawDataType words. Initialize new elements (if any) with val.
sz | The new size of the payload portion of the Fragment, in RawDataType words |
val | Value with which to initialize any new elements |
Definition at line 982 of file Fragment.hh.
|
inline |
Resize the data payload to hold szbytes bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16)
szbytes | The new size of the payload portion of the Fragment, in bytes |
Definition at line 990 of file Fragment.hh.
|
inline |
Resize the data payload to hold sz bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16). Initialize new elements (if any) with val.
szbytes | The new size of the payload portion of the Fragment, in bytes |
val | Value with which to initialize any new elements |
Definition at line 998 of file Fragment.hh.
|
inline |
Sequence ID of the Fragment, from the Fragment header.
Definition at line 826 of file Fragment.hh.
|
inline |
Sets the Fragment ID of the Fragment.
fragment_id | The Fragment ID to set |
Definition at line 869 of file Fragment.hh.
void artdaq::Fragment::setMetadata | ( | const T & | md | ) |
Set the metadata in the Fragment to the contents of the specified structure. This throws an exception if the Fragment already contains metadata.
T | Type of the metadata |
md | Metadata to store in Fragment |
cet::exception | if metadata already present in Fragment |
Definition at line 936 of file Fragment.hh.
|
inline |
Sets the Sequence ID of the Fragment.
sequence_id | The sequence ID to set |
Definition at line 861 of file Fragment.hh.
|
inline |
Sets the type of the Fragment, checking that it is a valid system type.
stype | The System type to set |
Definition at line 854 of file Fragment.hh.
|
inline |
Sets the Timestamp of the Fragment.
timestamp | The Timestamp to set |
Definition at line 876 of file Fragment.hh.
|
inline |
Sets the type of the Fragment, checking that it is a valid user type.
utype | The User type to set |
Definition at line 847 of file Fragment.hh.
|
inline |
Gets the size of the Fragment, from the Fragment header.
Definition at line 798 of file Fragment.hh.
|
inline |
Size of vals_ vector ( header + (optional) metadata + payload) in bytes.
Definition at line 340 of file Fragment.hh.
|
inlinenoexcept |
Swaps two Fragment objects.
other | Fragment to swap with |
Definition at line 1094 of file Fragment.hh.
|
inlinenoexcept |
Swaps two Fragment data vectors.
other | The data vector to swap with |
Since all Fragment header information is stored in the data vector, this is equivalent to swapping two Fragment objects
Definition at line 630 of file Fragment.hh.
|
inline |
Timestamp of the Fragment, from the Fragment header.
Definition at line 840 of file Fragment.hh.
|
inline |
Type of the Fragment, from the Fragment header.
Definition at line 812 of file Fragment.hh.
|
inline |
Print the type of the Fragment.
Definition at line 819 of file Fragment.hh.
void artdaq::Fragment::updateMetadata | ( | const T & | md | ) |
Updates existing metadata with a new metadata object.
T | Type of the metadata |
md | Metadata to set |
cet::exception | if no metadata stored in Fragment |
cet::exception | if new metadata has different size than existing metadata |
Definition at line 953 of file Fragment.hh.
|
inline |
Version of the Fragment, from the Fragment header.
Definition at line 805 of file Fragment.hh.