DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fdreadoutlibs
include
fdreadoutlibs
DAPHNESuperChunkTypeAdapter.hpp
Go to the documentation of this file.
1
#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESUPERCHUNKTYPEADAPTER_
2
#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESUPERCHUNKTYPEADAPTER_
3
4
#include "
daqdataformats/FragmentHeader.hpp
"
5
#include "
daqdataformats/SourceID.hpp
"
6
#include "
fddetdataformats/DAPHNEFrame.hpp
"
7
8
#include <cstdint>
// uint_t types
9
#include <memory>
// unique_ptr
10
#include <vector>
11
#include <cstring>
// memcpy
12
#include <tuple>
// forward_as_tuple
13
14
namespace
dunedaq
{
15
namespace
fdreadoutlibs
{
16
namespace
types
{
17
22
const
constexpr
std::size_t
kDAPHNENumFrames
= 3;
23
const
constexpr
std::size_t
kDAPHNEFrameSize
= 1864;
24
const
constexpr
std::size_t
kDAPHNESuperChunkSize
=
kDAPHNENumFrames
*
kDAPHNEFrameSize
;
// for 12: 22368
25
struct
DAPHNESuperChunkTypeAdapter
26
{
27
using
FrameType
=
dunedaq::fddetdataformats::DAPHNEFrame
;
28
// data
29
char
data
[
kDAPHNESuperChunkSize
];
30
// comparable based on first timestamp and first channel
31
bool
operator<
(
const
DAPHNESuperChunkTypeAdapter
& other)
const
32
{
33
auto
thisptr =
reinterpret_cast<
const
dunedaq::fddetdataformats::DAPHNEFrame
*
>
(&
data
);
// NOLINT
34
auto
otherptr =
reinterpret_cast<
const
dunedaq::fddetdataformats::DAPHNEFrame
*
>
(&other.
data
);
// NOLINT
35
36
return
std::forward_as_tuple(thisptr->get_timestamp(), thisptr->get_channel()) < std::forward_as_tuple(otherptr->get_timestamp(), otherptr->get_channel());
37
}
38
39
uint64_t
get_timestamp
() const
// NOLINT(build/unsigned)
40
{
41
return
reinterpret_cast<
const
dunedaq::fddetdataformats::DAPHNEFrame
*
>
(&
data
)->
get_timestamp
();
// NOLINT
42
}
43
44
void
set_timestamp
(uint64_t ts)
// NOLINT(build/unsigned)
45
{
46
auto
frame =
reinterpret_cast<
dunedaq::fddetdataformats::DAPHNEFrame
*
>
(&
data
);
// NOLINT
47
frame->
set_timestamp
(ts);
48
}
49
50
void
fake_timestamps
(uint64_t first_timestamp, uint64_t
offset
=
expected_tick_difference
)
// NOLINT(build/unsigned)
51
{
52
uint64_t ts_next = first_timestamp;
// NOLINT(build/unsigned)
53
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
54
auto
df =
reinterpret_cast<
dunedaq::fddetdataformats::DAPHNEFrame
*
>
(((uint8_t*)(&
data
)) + i *
get_frame_size
());
// NOLINT
55
df->
set_timestamp
(ts_next);
56
ts_next +=
offset
;
57
}
58
}
59
60
void
fake_geoid
(uint16_t crate_id, uint16_t slot_id, uint16_t link_id) {
61
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
62
auto
df =
reinterpret_cast<
FrameType
*
>
((
reinterpret_cast<
uint8_t*
>
(&
data
)) + i *
get_frame_size
());
63
df->daq_header.slot_id = slot_id;
64
df->daq_header.link_id = link_id;
65
df->daq_header.crate_id = crate_id;
66
}
67
}
68
69
void
fake_adc_pattern
(
int
/*channel*/
) {
70
}
71
72
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
73
{
74
// Set frame 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
+
kDAPHNESuperChunkSize
);
// NOLINT
85
}
86
87
size_t
get_payload_size
()
const
{
return
get_num_frames
() *
get_frame_size
(); }
88
89
size_t
get_num_frames
()
const
{
return
kDAPHNENumFrames
; }
90
91
size_t
get_frame_size
()
const
{
return
kDAPHNEFrameSize
; }
92
93
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
94
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kDAPHNE
;
95
static
const
constexpr
uint64_t
expected_tick_difference
= 1024;
// NOLINT(build/unsigned)
96
};
97
98
static_assert
(
sizeof
(
struct
DAPHNESuperChunkTypeAdapter
) ==
kDAPHNESuperChunkSize
,
99
"Check your assumptions on DAPHNESuperChunkTypeAdapter"
);
100
101
102
}
// namespace types
103
}
// namespace fdreadoutlibs
104
}
// namespace dunedaq
105
106
#endif
/* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESUPERCHUNKTYPEADAPTER_ */
DAPHNEFrame.hpp
FragmentHeader.hpp
SourceID.hpp
offset
double offset
Definition
conversions-impl.hh:28
dunedaq::daqdataformats::FragmentType
FragmentType
All defined Fragment types.
Definition
FragmentHeader.hpp:114
dunedaq::daqdataformats::FragmentType::kDAPHNE
@ kDAPHNE
Definition
FragmentHeader.hpp:118
dunedaq::fdreadoutlibs::types
Definition
CRTBernTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kDAPHNENumFrames
const constexpr std::size_t kDAPHNENumFrames
For DAPHNE the numbers are different. 12[DAPHNE frames] x 454[32-bit words] x 4[Bytes per word] = 217...
Definition
DAPHNESuperChunkTypeAdapter.hpp:22
dunedaq::fdreadoutlibs::types::kDAPHNEFrameSize
const constexpr std::size_t kDAPHNEFrameSize
Definition
DAPHNESuperChunkTypeAdapter.hpp:23
dunedaq::fdreadoutlibs::types::kDAPHNESuperChunkSize
const constexpr std::size_t kDAPHNESuperChunkSize
Definition
DAPHNESuperChunkTypeAdapter.hpp:24
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::DAPHNEFrame
Definition
DAPHNEFrame.hpp:34
dunedaq::fddetdataformats::DAPHNEFrame::set_timestamp
void set_timestamp(uint64_t ts)
Definition
DAPHNEFrame.hpp:264
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter
Definition
DAPHNESuperChunkTypeAdapter.hpp:26
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t link_id)
Definition
DAPHNESuperChunkTypeAdapter.hpp:60
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::get_payload_size
size_t get_payload_size() const
Definition
DAPHNESuperChunkTypeAdapter.hpp:87
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::operator<
bool operator<(const DAPHNESuperChunkTypeAdapter &other) const
Definition
DAPHNESuperChunkTypeAdapter.hpp:31
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::end
FrameType * end()
Definition
DAPHNESuperChunkTypeAdapter.hpp:82
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
DAPHNESuperChunkTypeAdapter.hpp:44
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
DAPHNESuperChunkTypeAdapter.hpp:94
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::begin
FrameType * begin()
Definition
DAPHNESuperChunkTypeAdapter.hpp:77
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::get_num_frames
size_t get_num_frames() const
Definition
DAPHNESuperChunkTypeAdapter.hpp:89
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::FrameType
dunedaq::fddetdataformats::DAPHNEFrame FrameType
Definition
DAPHNESuperChunkTypeAdapter.hpp:27
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
DAPHNESuperChunkTypeAdapter.hpp:72
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
DAPHNESuperChunkTypeAdapter.hpp:93
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int)
Definition
DAPHNESuperChunkTypeAdapter.hpp:69
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::get_frame_size
size_t get_frame_size() const
Definition
DAPHNESuperChunkTypeAdapter.hpp:91
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
DAPHNESuperChunkTypeAdapter.hpp:95
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::get_timestamp
uint64_t get_timestamp() const
Definition
DAPHNESuperChunkTypeAdapter.hpp:39
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t offset=expected_tick_difference)
Definition
DAPHNESuperChunkTypeAdapter.hpp:50
dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter::data
char data[kDAPHNESuperChunkSize]
Definition
DAPHNESuperChunkTypeAdapter.hpp:29
Generated on
for DUNE-DAQ by
1.17.0