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 <cstring>
// memcpy
10
#include <memory>
// unique_ptr
11
#include <tuple>
// tie
12
#include <vector>
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
{
56
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
57
auto
df =
reinterpret_cast<
FrameType
*
>
((
reinterpret_cast<
uint8_t*
>
(&
data
)) + i *
get_frame_size
());
58
df->
daq_header
.
crate_id
= crate_id;
59
df->daq_header.slot_id = slot_id;
60
df->daq_header.stream_id = stream_id;
61
}
62
}
63
64
void
fake_adc_pattern
(
int
channel)
65
{
66
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
67
// Set the ADC to the uint16 maximum value
68
// AAA: setting only the first time sample
69
frame->
set_adc
(channel, 0, 16383);
70
}
71
72
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
73
{
74
// Set error bits in header
75
}
76
77
FrameType
*
begin
()
78
{
79
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
80
}
81
82
FrameType
*
end
()
83
{
84
return
reinterpret_cast<
FrameType
*
>
(
data
+
kTDEEthSize
);
// NOLINT
85
}
86
87
size_t
get_payload_size
() {
return
kTDEEthSize
; }
88
89
size_t
get_num_frames
() {
return
1; }
90
91
size_t
get_frame_size
() {
return
kTDEEthSize
; }
92
93
static
const
constexpr
size_t
fixed_payload_size
= 7200;
94
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
95
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
96
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kTDEEth
;
97
// NOTE: the expected_tick_difference is different from WIBs because of the TDE sampling rate
98
static
const
constexpr
uint64_t
expected_tick_difference
= 2000;
// NOLINT(build/unsigned)
99
static
const
constexpr
uint64_t
samples_per_frame
= 64;
// NOLINT(build/unsigned)
100
// NOTE: this is actually 31.25
101
static
const
constexpr
float
samples_tick_difference
= 31.25;
// NOLINT(build/unsigned)
102
};
103
104
static_assert
(
sizeof
(
dunedaq::fddetdataformats::TDEEthFrame
) ==
kTDEEthSize
,
105
"Check your assumptions on TDEEthTypeAdapter"
);
106
107
}
// namespace types
108
}
// namespace fdreadoutlibs
109
}
// namespace dunedaq
110
111
#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
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
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::detdataformats::DAQEthHeader::crate_id
word_t crate_id
Definition
DAQEthHeader.hpp:26
dunedaq::fddetdataformats::TDEEthFrame
Struct for accessing raw TDE eth frames, as used in ProtoDUNE-II.
Definition
TDEEthFrame.hpp:42
dunedaq::fddetdataformats::TDEEthFrame::set_adc
void set_adc(int i_channel, int i_sample, uint16_t val)
Set the i_channel-th ADC value in the i_sample-th time sample to val.
Definition
TDEEthFrame.hxx:20
dunedaq::fddetdataformats::TDEEthFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
Definition
TDEEthFrame.hpp:86
dunedaq::fddetdataformats::TDEEthFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
TDEEthFrame.hpp:96
dunedaq::fddetdataformats::TDEEthFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
TDEEthFrame.hpp:83
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:72
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:93
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:96
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_frame_size
size_t get_frame_size()
Definition
TDEEthTypeAdapter.hpp:91
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_num_frames
size_t get_num_frames()
Definition
TDEEthTypeAdapter.hpp:89
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:82
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:64
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::samples_tick_difference
static const constexpr float samples_tick_difference
Definition
TDEEthTypeAdapter.hpp:101
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::get_payload_size
size_t get_payload_size()
Definition
TDEEthTypeAdapter.hpp:87
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::begin
FrameType * begin()
Definition
TDEEthTypeAdapter.hpp:77
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:94
dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
TDEEthTypeAdapter.hpp:98
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:99
Generated on
for DUNE-DAQ by
1.18.0