DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CRTGrenobleTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_CRTGRENOBLETYPEADAPTER_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_CRTGRENOBLETYPEADAPTER_
3
7
8#include <cstdint> // uint_t types
9#include <cstring> // memcpy
10#include <memory> // unique_ptr
11#include <tuple> // tie
12#include <vector>
13
14namespace dunedaq {
15namespace fdreadoutlibs {
16namespace types {
17
19
21{
23 // data
25 // comparable based on first timestamp
26 bool operator<(const CRTGrenobleTypeAdapter& other) const
27 {
28 auto thisptr = reinterpret_cast<const FrameType*>(&data); // NOLINT
29 auto otherptr = reinterpret_cast<const FrameType*>(&other.data); // NOLINT
30 return thisptr->get_timestamp() < otherptr->get_timestamp() ? true : false;
31 }
32
33 uint64_t get_timestamp() const // NOLINT(build/unsigned)
34 {
35 return reinterpret_cast<const FrameType*>(&data)->get_timestamp(); // NOLINT
36 }
37
38 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
39 {
40 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
41 frame->set_timestamp(ts);
42 }
43
44 void fake_timestamps(uint64_t first_timestamp,
45 uint64_t /*offset*/ = expected_tick_difference) // NOLINT(build/unsigned)
46 {
47 set_timestamp(first_timestamp);
48 }
49
50 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
51 {
52 auto df = reinterpret_cast<FrameType*>(reinterpret_cast<uint8_t*>(&data));
53 df->daq_header.slot_id = slot_id;
54 df->daq_header.stream_id = stream_id;
55 df->daq_header.crate_id = crate_id;
56 }
57
58 void fake_adc_pattern(int channel)
59 {
60 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
61 frame->set_adc(channel, 0xbeef);
62 }
63
64 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
65 {
66 // Set frame error bits in header
67 }
68
70 {
71 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
72 }
73
75 {
76 return reinterpret_cast<FrameType*>(data + kCRTGrenobleFrameSize); // NOLINT
77 }
78
80
81 size_t get_num_frames() { return 1; }
82
84
85 static const constexpr size_t fixed_payload_size = kCRTGrenobleFrameSize;
89 static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned)
90};
91
92static_assert(sizeof(struct CRTGrenobleTypeAdapter) == kCRTGrenobleFrameSize,
93 "Check your assumptions on CRTGrenobleTypeAdapter");
94
95} // namespace types
96} // namespace fdreadoutlibs
97} // namespace dunedaq
98
99#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_CRTGRENOBLETYPEADAPTER_ */
FragmentType
All defined Fragment types.
const constexpr std::size_t kCRTGrenobleFrameSize
The DUNE-DAQ namespace.
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:40
Struct for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
void set_adc(const int i_ch, const int val)
Set the adc value for channel i_ch to val.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
static const constexpr daqdataformats::FragmentType fragment_type
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
dunedaq::fddetdataformats::CRTGrenobleFrame FrameType
static const constexpr daqdataformats::SourceID::Subsystem subsystem
void fake_timestamps(uint64_t first_timestamp, uint64_t=expected_tick_difference)
bool operator<(const CRTGrenobleTypeAdapter &other) const