DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fdreadoutlibs
include
fdreadoutlibs
CRTGrenobleTypeAdapter.hpp
Go to the documentation of this file.
1
#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_CRTGRENOBLETYPEADAPTER_
2
#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_CRTGRENOBLETYPEADAPTER_
3
4
#include "
daqdataformats/FragmentHeader.hpp
"
5
#include "
daqdataformats/SourceID.hpp
"
6
#include "
fddetdataformats/CRTGrenobleFrame.hpp
"
7
8
#include <cstdint>
// uint_t types
9
#include <memory>
// unique_ptr
10
#include <vector>
11
#include <cstring>
// memcpy
12
#include <tuple>
// tie
13
14
namespace
dunedaq
{
15
namespace
fdreadoutlibs
{
16
namespace
types
{
17
18
const
constexpr
std::size_t
kCRTGrenobleFrameSize
=
sizeof
(
dunedaq::fddetdataformats::CRTGrenobleFrame
);
19
20
struct
CRTGrenobleTypeAdapter
21
{
22
using
FrameType
=
dunedaq::fddetdataformats::CRTGrenobleFrame
;
23
// data
24
char
data
[
kCRTGrenobleFrameSize
];
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
66
FrameType
*
begin
()
67
{
68
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
69
}
70
71
FrameType
*
end
()
72
{
73
return
reinterpret_cast<
FrameType
*
>
(
data
+
kCRTGrenobleFrameSize
);
// NOLINT
74
}
75
76
size_t
get_payload_size
() {
return
get_num_frames
() *
get_frame_size
(); }
77
78
size_t
get_num_frames
() {
return
1; }
79
80
size_t
get_frame_size
() {
return
kCRTGrenobleFrameSize
; }
81
82
static
const
constexpr
size_t
fixed_payload_size
=
kCRTGrenobleFrameSize
;
83
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
84
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kCRTGrenoble
;
85
static
const
constexpr
uint64_t
expected_tick_difference
= 1;
// NOLINT(build/unsigned)
86
};
87
88
static_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_ */
CRTGrenobleFrame.hpp
FragmentHeader.hpp
SourceID.hpp
dunedaq::daqdataformats::FragmentType
FragmentType
All defined Fragment types.
Definition
FragmentHeader.hpp:114
dunedaq::daqdataformats::FragmentType::kCRTGrenoble
@ kCRTGrenoble
Definition
FragmentHeader.hpp:142
dunedaq::fdreadoutlibs::types
Definition
CRTBernTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kCRTGrenobleFrameSize
const constexpr std::size_t kCRTGrenobleFrameSize
Definition
CRTGrenobleTypeAdapter.hpp:18
dunedaq::fdreadoutlibs
Definition
CRTBernFrameProcessor.hpp:16
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::daqdataformats::SourceID::Subsystem
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition
SourceID.hpp:40
dunedaq::daqdataformats::SourceID::Subsystem::kDetectorReadout
@ kDetectorReadout
Definition
SourceID.hpp:42
dunedaq::fddetdataformats::CRTGrenobleFrame
Struct for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD.
Definition
CRTGrenobleFrame.hpp:35
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter
Definition
CRTGrenobleTypeAdapter.hpp:21
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
CRTGrenobleTypeAdapter.hpp:84
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
Definition
CRTGrenobleTypeAdapter.hpp:49
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::data
char data[kCRTGrenobleFrameSize]
Definition
CRTGrenobleTypeAdapter.hpp:24
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::FrameType
dunedaq::fddetdataformats::CRTGrenobleFrame FrameType
Definition
CRTGrenobleTypeAdapter.hpp:22
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_timestamp
uint64_t get_timestamp() const
Definition
CRTGrenobleTypeAdapter.hpp:33
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
CRTGrenobleTypeAdapter.hpp:83
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_payload_size
size_t get_payload_size()
Definition
CRTGrenobleTypeAdapter.hpp:76
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t=expected_tick_difference)
Definition
CRTGrenobleTypeAdapter.hpp:44
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
CRTGrenobleTypeAdapter.hpp:38
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::begin
FrameType * begin()
Definition
CRTGrenobleTypeAdapter.hpp:66
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
CRTGrenobleTypeAdapter.hpp:61
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fixed_payload_size
static const constexpr size_t fixed_payload_size
Definition
CRTGrenobleTypeAdapter.hpp:82
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_frame_size
size_t get_frame_size()
Definition
CRTGrenobleTypeAdapter.hpp:80
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::end
FrameType * end()
Definition
CRTGrenobleTypeAdapter.hpp:71
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_num_frames
size_t get_num_frames()
Definition
CRTGrenobleTypeAdapter.hpp:78
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
CRTGrenobleTypeAdapter.hpp:85
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::operator<
bool operator<(const CRTGrenobleTypeAdapter &other) const
Definition
CRTGrenobleTypeAdapter.hpp:26
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int channel)
Definition
CRTGrenobleTypeAdapter.hpp:56
Generated on
for DUNE-DAQ by
1.17.0