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 <memory> // unique_ptr
10#include <vector>
11#include <cstring> // memcpy
12#include <tuple> // tie
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, uint64_t /*offset*/= expected_tick_difference) // NOLINT(build/unsigned)
45 {
46 set_timestamp(first_timestamp);
47 }
48
49 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id) {
50 auto df = reinterpret_cast<FrameType*>(reinterpret_cast<uint8_t*>(&data));
51 df->daq_header.slot_id = slot_id;
52 df->daq_header.stream_id = stream_id;
53 df->daq_header.crate_id = crate_id;
54 }
55
56 void fake_adc_pattern(int channel) {
57 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
58 frame->set_adc(channel,0xbeef);
59 }
60
61 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
62 {
63 // Set frame error bits in header
64 }
65
67 {
68 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
69 }
70
72 {
73 return reinterpret_cast<FrameType*>(data + kCRTGrenobleFrameSize); // NOLINT
74 }
75
77
78 size_t get_num_frames() { return 1; }
79
81
82 static const constexpr size_t fixed_payload_size = kCRTGrenobleFrameSize;
85 static const constexpr uint64_t expected_tick_difference = 64; // NOLINT(build/unsigned)
86};
87
88static_assert(sizeof(struct CRTGrenobleTypeAdapter) == kCRTGrenobleFrameSize,
89 "Check your assumptions on CRTGrenobleTypeAdapter");
90
91
92} // namespace types
93} // namespace fdreadoutlibs
94} // namespace dunedaq
95
96#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_CRTGRENOBLETYPEADAPTER_ */
Class 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(int i_ch, 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.
FragmentType
This enumeration should list all defined Fragment types.
const constexpr std::size_t kCRTGrenobleFrameSize
Including Qt Headers.
PDS Frame with unphysical timestamp detected with ts
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:43
static const constexpr daqdataformats::FragmentType fragment_type
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
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