DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
datahandlinglibs
include
datahandlinglibs
utils
ErrorBitGenerator.hpp
Go to the documentation of this file.
1
8
#ifndef DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_UTILS_ERRORBITGENERATOR_HPP_
9
#define DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_UTILS_ERRORBITGENERATOR_HPP_
10
11
#include <random>
12
#include <unistd.h>
13
14
namespace
dunedaq
{
15
namespace
datahandlinglibs {
16
25
class
ErrorBitGenerator
26
{
27
public
:
28
explicit
ErrorBitGenerator
(
double
rate = 0)
29
:
m_error_rate
(rate)
30
,
m_error_bits_index
(0)
31
,
m_error_occurrences_index
(0)
32
,
m_no_error_occurrences_index
(0)
33
,
m_current_occurrence
(0)
34
,
m_occurrence_count
(0)
35
,
m_set_error_bits
(true)
36
{}
37
uint16_t
next
()
// NOLINT(build/unsigned)
38
{
39
if
(
m_occurrence_count
>=
m_current_occurrence
) {
40
if
(
m_set_error_bits
) {
41
m_error_bits_index
= (
m_error_bits_index
+ 1) %
m_size
;
42
m_error_occurrences_index
= (
m_error_occurrences_index
+ 1) %
m_size
;
43
m_set_error_bits
=
false
;
44
m_current_occurrence
=
m_no_error_occurrences
[
m_no_error_occurrences_index
];
45
m_occurrence_count
= 0;
46
}
else
{
47
m_no_error_occurrences_index
= (
m_no_error_occurrences_index
+ 1) %
m_size
;
48
m_set_error_bits
=
true
;
49
m_current_occurrence
=
m_error_occurrences
[
m_error_occurrences_index
];
50
m_occurrence_count
= 0;
51
}
52
}
53
m_occurrence_count
++;
54
return
(
m_set_error_bits
&&
m_current_occurrence
) ?
m_error_bits
[
m_error_bits_index
] : 0;
55
}
56
57
void
generate
()
58
{
59
std::random_device rd;
60
std::mt19937 mt(rd());
61
std::uniform_int_distribution<uint16_t> err_bit_dis(0, 65535);
// NOLINT(build/unsigned)
62
std::uniform_int_distribution<int> duration_dis(1, 100000);
63
64
for
(
int
i = 0; i <
m_size
; ++i) {
65
m_error_bits
[i] = err_bit_dis(mt);
66
}
67
for
(
int
i = 0; i <
m_size
; ++i) {
68
m_error_occurrences
[i] = duration_dis(mt) *
m_error_rate
;
69
m_no_error_occurrences
[i] = duration_dis(mt) * (1 -
m_error_rate
);
70
}
71
}
72
73
private
:
74
int
m_size
= 1000;
75
double
m_error_rate
;
76
uint16_t
m_error_bits
[1000];
// NOLINT(build/unsigned)
77
int
m_error_bits_index
;
78
int
m_error_occurrences
[1000];
79
int
m_error_occurrences_index
;
80
int
m_no_error_occurrences
[1000];
81
int
m_no_error_occurrences_index
;
82
int
m_current_occurrence
;
83
int
m_occurrence_count
;
84
bool
m_set_error_bits
;
85
};
86
87
}
// namespace datahandlinglibs
88
}
// namespace dunedaq
89
90
#endif
// DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_UTILS_ERRORBITGENERATOR_HPP_
dunedaq::datahandlinglibs::ErrorBitGenerator
Definition
ErrorBitGenerator.hpp:26
dunedaq::datahandlinglibs::ErrorBitGenerator::m_no_error_occurrences_index
int m_no_error_occurrences_index
Definition
ErrorBitGenerator.hpp:81
dunedaq::datahandlinglibs::ErrorBitGenerator::m_error_occurrences_index
int m_error_occurrences_index
Definition
ErrorBitGenerator.hpp:79
dunedaq::datahandlinglibs::ErrorBitGenerator::m_set_error_bits
bool m_set_error_bits
Definition
ErrorBitGenerator.hpp:84
dunedaq::datahandlinglibs::ErrorBitGenerator::generate
void generate()
Definition
ErrorBitGenerator.hpp:57
dunedaq::datahandlinglibs::ErrorBitGenerator::m_no_error_occurrences
int m_no_error_occurrences[1000]
Definition
ErrorBitGenerator.hpp:80
dunedaq::datahandlinglibs::ErrorBitGenerator::next
uint16_t next()
Definition
ErrorBitGenerator.hpp:37
dunedaq::datahandlinglibs::ErrorBitGenerator::m_error_bits_index
int m_error_bits_index
Definition
ErrorBitGenerator.hpp:77
dunedaq::datahandlinglibs::ErrorBitGenerator::m_occurrence_count
int m_occurrence_count
Definition
ErrorBitGenerator.hpp:83
dunedaq::datahandlinglibs::ErrorBitGenerator::ErrorBitGenerator
ErrorBitGenerator(double rate=0)
Definition
ErrorBitGenerator.hpp:28
dunedaq::datahandlinglibs::ErrorBitGenerator::m_current_occurrence
int m_current_occurrence
Definition
ErrorBitGenerator.hpp:82
dunedaq::datahandlinglibs::ErrorBitGenerator::m_size
int m_size
Definition
ErrorBitGenerator.hpp:74
dunedaq::datahandlinglibs::ErrorBitGenerator::m_error_bits
uint16_t m_error_bits[1000]
Definition
ErrorBitGenerator.hpp:76
dunedaq::datahandlinglibs::ErrorBitGenerator::m_error_rate
double m_error_rate
Definition
ErrorBitGenerator.hpp:75
dunedaq::datahandlinglibs::ErrorBitGenerator::m_error_occurrences
int m_error_occurrences[1000]
Definition
ErrorBitGenerator.hpp:78
dunedaq
Including Qt Headers.
Definition
TimingController.hxx:1
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0