DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fdreadoutlibs
include
fdreadoutlibs
TDEEthTypeAdapter.hpp
Go to the documentation of this file.
1
#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHTYPEADAPTER_HPP_
2
#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHTYPEADAPTER_HPP_
3
4
#include "
daqdataformats/FragmentHeader.hpp
"
5
#include "
daqdataformats/SourceID.hpp
"
6
#include "
fddetdataformats/TDEEthFrame.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
22
const
constexpr
std::size_t
kTDEEthSize
= 7200;
23
struct
TDEEthTypeAdapter
24
{
25
using
FrameType
=
dunedaq::fddetdataformats::TDEEthFrame
;
26
27
// data
28
char
data
[
kTDEEthSize
];
29
// comparable based on first timestamp
30
bool
operator<
(
const
TDEEthTypeAdapter
& other)
const
31
{
32
auto
thisptr =
reinterpret_cast<
const
FrameType
*
>
(&
data
);
// NOLINT
33
auto
otherptr =
reinterpret_cast<
const
FrameType
*
>
(&other.
data
);
// NOLINT
34
return
thisptr->get_timestamp() < otherptr->get_timestamp() ? true :
false
;
35
}
36
37
uint64_t
get_timestamp
() const
// NOLINT(build/unsigned)
38
{
39
return
reinterpret_cast<
const
FrameType
*
>
(&
data
)->
get_timestamp
();
// NOLINT
40
}
41
42
void
set_timestamp
(uint64_t ts)
// NOLINT(build/unsigned)
43
{
44
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
45
frame->set_timestamp(ts);
46
}
47
48
void
fake_timestamps
(uint64_t first_timestamp, uint64_t
/*offset*/
= 2048 )
// NOLINT(build/unsigned)
49
{
50
auto
wef =
reinterpret_cast<
FrameType
*
>
(((uint8_t*)(&
data
)));
// NOLINT
51
wef->set_timestamp(first_timestamp);
52
}
53
54
void
fake_geoid
(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id) {
55
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
56
auto
df =
reinterpret_cast<
FrameType
*
>
((
reinterpret_cast<
uint8_t*
>
(&
data
)) + i *
get_frame_size
());
57
df->daq_header.crate_id = crate_id;
58
df->daq_header.slot_id = slot_id;
59
df->daq_header.stream_id = stream_id;
60
}
61
}
62
63
void
fake_adc_pattern
(
int
channel) {
64
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
65
// Set the ADC to the uint16 maximum value
66
// AAA: setting only the first time sample
67
frame->set_adc(channel, 0, 16383);
68
}
69
70
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
71
{
72
// Set error bits in header
73
}
74
75
FrameType
*
begin
()
76
{
77
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
78
}
79
80
FrameType
*
end
()
81
{
82
return
reinterpret_cast<
FrameType
*
>
(
data
+
kTDEEthSize
);
// NOLINT
83
}
84
85
size_t
get_payload_size
() {
return
kTDEEthSize
; }
86
87
size_t
get_num_frames
() {
return
1; }
88
89
size_t
get_frame_size
() {
return
kTDEEthSize
; }
90
91
static
const
constexpr
size_t
fixed_payload_size
= 7200;
92
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
93
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kTDEEth
;
94
// NOTE: the expected_tick_difference is different from WIBs because of the TDE sampling rate
95
static
const
constexpr
uint64_t
expected_tick_difference
= 2000;
// NOLINT(build/unsigned)
96
static
const
constexpr
uint64_t
samples_per_frame
= 64;
// NOLINT(build/unsigned)
97
// NOTE: this is actually 31.25
98
static
const
constexpr
float
samples_tick_difference
= 31.25;
// NOLINT(build/unsigned)
99
};
100
101
static_assert
(
sizeof
(
dunedaq::fddetdataformats::TDEEthFrame
) ==
kTDEEthSize
,
102
"Check your assumptions on TDEEthTypeAdapter"
);
103
104
105
}
// namespace types
106
}
// namespace fdreadoutlibs
107
}
// namespace dunedaq
108
109
#endif
/* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHTYPEADAPTER_HPP_ */
FragmentHeader.hpp
SourceID.hpp
TDEEthFrame.hpp
dunedaq::daqdataformats::FragmentType
FragmentType
All defined Fragment types.
Definition
FragmentHeader.hpp:114
dunedaq::daqdataformats::FragmentType::kTDEEth
@ kTDEEth
Definition
FragmentHeader.hpp:140
dunedaq::fdreadoutlibs::types
Definition
CRTBernTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kTDEEthSize
const constexpr std::size_t kTDEEthSize
For TDEEth the numbers are different. Header + (64 channels * 64 time slices) = 7200[Bytes].
Definition
TDEEthTypeAdapter.hpp:22
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::TDEEthFrame
Struct for accessing raw TDE eth frames, as used in ProtoDUNE-II.
Definition
TDEEthFrame.hpp:42
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter
Definition
TDEEthTypeAdapter.hpp:24
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
TDEEthTypeAdapter.hpp:70
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
Definition
TDEEthTypeAdapter.hpp:54
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::data
char data[kTDEEthSize]
Definition
TDEEthTypeAdapter.hpp:28
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::fixed_payload_size
static const constexpr size_t fixed_payload_size
Definition
TDEEthTypeAdapter.hpp:91
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t=2048)
Definition
TDEEthTypeAdapter.hpp:48
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
TDEEthTypeAdapter.hpp:93
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_frame_size
size_t get_frame_size()
Definition
TDEEthTypeAdapter.hpp:89
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_num_frames
size_t get_num_frames()
Definition
TDEEthTypeAdapter.hpp:87
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
TDEEthTypeAdapter.hpp:42
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::end
FrameType * end()
Definition
TDEEthTypeAdapter.hpp:80
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::FrameType
dunedaq::fddetdataformats::TDEEthFrame FrameType
Definition
TDEEthTypeAdapter.hpp:25
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int channel)
Definition
TDEEthTypeAdapter.hpp:63
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::samples_tick_difference
static const constexpr float samples_tick_difference
Definition
TDEEthTypeAdapter.hpp:98
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_payload_size
size_t get_payload_size()
Definition
TDEEthTypeAdapter.hpp:85
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::begin
FrameType * begin()
Definition
TDEEthTypeAdapter.hpp:75
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_timestamp
uint64_t get_timestamp() const
Definition
TDEEthTypeAdapter.hpp:37
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
TDEEthTypeAdapter.hpp:92
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
TDEEthTypeAdapter.hpp:95
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::operator<
bool operator<(const TDEEthTypeAdapter &other) const
Definition
TDEEthTypeAdapter.hpp:30
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::samples_per_frame
static const constexpr uint64_t samples_per_frame
Definition
TDEEthTypeAdapter.hpp:96
Generated on
for DUNE-DAQ by
1.17.0