DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fdreadoutlibs
include
fdreadoutlibs
DUNEWIBEthTypeAdapter.hpp
Go to the documentation of this file.
1
#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_HPP_
2
#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_HPP_
3
4
#include "
daqdataformats/FragmentHeader.hpp
"
5
#include "
daqdataformats/SourceID.hpp
"
6
#include "
fddetdataformats/WIBEthFrame.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
kDUNEWIBEthSize
= 7200;
23
24
struct
DUNEWIBEthTypeAdapter
25
{
26
using
FrameType
=
dunedaq::fddetdataformats::WIBEthFrame
;
27
// data
28
char
data
[
kDUNEWIBEthSize
];
29
// comparable based on first timestamp
30
bool
operator<
(
const
DUNEWIBEthTypeAdapter
& 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
+
kDUNEWIBEthSize
);
// NOLINT
85
}
86
87
size_t
get_payload_size
() {
return
kDUNEWIBEthSize
; }
88
89
size_t
get_num_frames
() {
return
1; }
90
91
size_t
get_frame_size
() {
return
kDUNEWIBEthSize
; }
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::kWIBEth
;
97
static
const
constexpr
uint64_t
expected_tick_difference
= 2048;
// NOLINT(build/unsigned)
98
static
const
constexpr
uint64_t
samples_per_frame
= 64;
// NOLINT(build/unsigned)
99
static
const
constexpr
float
samples_tick_difference
= 32;
// NOLINT(build/unsigned)
100
};
101
102
static_assert
(
sizeof
(
dunedaq::fddetdataformats::WIBEthFrame
) ==
kDUNEWIBEthSize
,
103
"Check your assumptions on DUNEWIBEthTypeAdapter"
);
104
105
}
// namespace types
106
}
// namespace fdreadoutlibs
107
}
// namespace dunedaq
108
109
#endif
/* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_HPP_ */
FragmentHeader.hpp
SourceID.hpp
WIBEthFrame.hpp
dunedaq::daqdataformats::FragmentType
FragmentType
All defined Fragment types.
Definition
FragmentHeader.hpp:114
dunedaq::daqdataformats::FragmentType::kWIBEth
@ kWIBEth
Definition
FragmentHeader.hpp:137
dunedaq::fdreadoutlibs::types
Definition
CRTBernTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kDUNEWIBEthSize
const constexpr std::size_t kDUNEWIBEthSize
For WIBEth the numbers are different. Header + (64 channels * 64 time slices) = 7200[Bytes].
Definition
DUNEWIBEthTypeAdapter.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::WIBEthFrame
struct for accessing raw WIB eth frames, as used in ProtoDUNE-II
Definition
WIBEthFrame.hpp:40
dunedaq::fddetdataformats::WIBEthFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
WIBEthFrame.hpp:93
dunedaq::fddetdataformats::WIBEthFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
WIBEthFrame.hpp:106
dunedaq::fddetdataformats::WIBEthFrame::set_adc
void set_adc(int i_channel, int i_sample, uint16_t adc_val)
Set the i_channel-th ADC value in the i_sample-th time sample to adc_val.
Definition
WIBEthFrame.hxx:15
dunedaq::fddetdataformats::WIBEthFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
Definition
WIBEthFrame.hpp:96
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter
Definition
DUNEWIBEthTypeAdapter.hpp:25
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::begin
FrameType * begin()
Definition
DUNEWIBEthTypeAdapter.hpp:77
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::get_frame_size
size_t get_frame_size()
Definition
DUNEWIBEthTypeAdapter.hpp:91
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int channel)
Definition
DUNEWIBEthTypeAdapter.hpp:64
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
DUNEWIBEthTypeAdapter.hpp:72
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::fixed_payload_size
static const constexpr size_t fixed_payload_size
Definition
DUNEWIBEthTypeAdapter.hpp:93
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::operator<
bool operator<(const DUNEWIBEthTypeAdapter &other) const
Definition
DUNEWIBEthTypeAdapter.hpp:30
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
DUNEWIBEthTypeAdapter.hpp:96
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
DUNEWIBEthTypeAdapter.hpp:94
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::samples_per_frame
static const constexpr uint64_t samples_per_frame
Definition
DUNEWIBEthTypeAdapter.hpp:98
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::end
FrameType * end()
Definition
DUNEWIBEthTypeAdapter.hpp:82
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::data
char data[kDUNEWIBEthSize]
Definition
DUNEWIBEthTypeAdapter.hpp:28
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::samples_tick_difference
static const constexpr float samples_tick_difference
Definition
DUNEWIBEthTypeAdapter.hpp:99
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::get_timestamp
uint64_t get_timestamp() const
Definition
DUNEWIBEthTypeAdapter.hpp:37
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
DUNEWIBEthTypeAdapter.hpp:97
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::FrameType
dunedaq::fddetdataformats::WIBEthFrame FrameType
Definition
DUNEWIBEthTypeAdapter.hpp:26
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::get_payload_size
size_t get_payload_size()
Definition
DUNEWIBEthTypeAdapter.hpp:87
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t=2048)
Definition
DUNEWIBEthTypeAdapter.hpp:48
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
DUNEWIBEthTypeAdapter.hpp:42
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
Definition
DUNEWIBEthTypeAdapter.hpp:54
dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter::get_num_frames
size_t get_num_frames()
Definition
DUNEWIBEthTypeAdapter.hpp:89
Generated on
for DUNE-DAQ by
1.18.0