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 <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
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,
45
uint64_t
/*offset*/
=
expected_tick_difference
)
// NOLINT(build/unsigned)
46
{
47
set_timestamp
(first_timestamp);
48
}
49
50
void
fake_geoid
(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
51
{
52
auto
df =
reinterpret_cast<
FrameType
*
>
(
reinterpret_cast<
uint8_t*
>
(&
data
));
53
df->
daq_header
.
slot_id
= slot_id;
54
df->daq_header.stream_id = stream_id;
55
df->daq_header.crate_id = crate_id;
56
}
57
58
void
fake_adc_pattern
(
int
channel)
59
{
60
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
61
frame->
set_adc
(channel, 0xbeef);
62
}
63
64
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
65
{
66
// Set frame error bits in header
67
}
68
69
FrameType
*
begin
()
70
{
71
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
72
}
73
74
FrameType
*
end
()
75
{
76
return
reinterpret_cast<
FrameType
*
>
(
data
+
kCRTGrenobleFrameSize
);
// NOLINT
77
}
78
79
size_t
get_payload_size
() {
return
get_num_frames
() *
get_frame_size
(); }
80
81
size_t
get_num_frames
() {
return
1; }
82
83
size_t
get_frame_size
() {
return
kCRTGrenobleFrameSize
; }
84
85
static
const
constexpr
size_t
fixed_payload_size
=
kCRTGrenobleFrameSize
;
86
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
87
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
88
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kCRTGrenoble
;
89
static
const
constexpr
uint64_t
expected_tick_difference
= 1;
// NOLINT(build/unsigned)
90
};
91
92
static_assert
(
sizeof
(
struct
CRTGrenobleTypeAdapter
) ==
kCRTGrenobleFrameSize
,
93
"Check your assumptions on CRTGrenobleTypeAdapter"
);
94
95
}
// namespace types
96
}
// namespace fdreadoutlibs
97
}
// namespace dunedaq
98
99
#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
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::slot_id
word_t slot_id
Definition
DAQEthHeader.hpp:26
dunedaq::fddetdataformats::CRTGrenobleFrame
Struct for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD.
Definition
CRTGrenobleFrame.hpp:35
dunedaq::fddetdataformats::CRTGrenobleFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
CRTGrenobleFrame.hpp:114
dunedaq::fddetdataformats::CRTGrenobleFrame::set_adc
void set_adc(const int i_ch, const int val)
Set the adc value for channel i_ch to val.
Definition
CRTGrenobleFrame.hpp:105
dunedaq::fddetdataformats::CRTGrenobleFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
CRTGrenobleFrame.hpp:119
dunedaq::fddetdataformats::CRTGrenobleFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
Definition
CRTGrenobleFrame.hpp:117
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter
Definition
CRTGrenobleTypeAdapter.hpp:21
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
CRTGrenobleTypeAdapter.hpp:88
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
Definition
CRTGrenobleTypeAdapter.hpp:50
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:86
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_payload_size
size_t get_payload_size()
Definition
CRTGrenobleTypeAdapter.hpp:79
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:69
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
CRTGrenobleTypeAdapter.hpp:64
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::fixed_payload_size
static const constexpr size_t fixed_payload_size
Definition
CRTGrenobleTypeAdapter.hpp:85
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_frame_size
size_t get_frame_size()
Definition
CRTGrenobleTypeAdapter.hpp:83
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::end
FrameType * end()
Definition
CRTGrenobleTypeAdapter.hpp:74
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::get_num_frames
size_t get_num_frames()
Definition
CRTGrenobleTypeAdapter.hpp:81
dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
CRTGrenobleTypeAdapter.hpp:89
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:58
Generated on
for DUNE-DAQ by
1.18.0