BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnHgndRaw.h
Go to the documentation of this file.
1
#ifndef BMNHGNDRAW_H
2
#define BMNHGNDRAW_H
3
4
#include <array>
5
#include <cstdint>
6
#include <vector>
7
8
namespace
BmnHgndRaw
9
{
10
11
namespace
Block
12
{
13
14
// Header
15
static
constexpr
uint32_t
HEADER_MASK
= 0xF000;
16
static
constexpr
uint8_t
EVENT_HEADER
= 0xA;
17
18
inline
bool
is_word_event_header
(uint16_t word)
19
{
20
return
((word &
HEADER_MASK
) >> 12) ==
EVENT_HEADER
;
21
}
22
23
// Version
24
enum
EventPacketVersion
25
{
26
ERR
,
27
V1
,
28
V2
29
};
30
31
inline
EventPacketVersion
get_event_packet_version
(uint16_t word)
32
{
33
uint8_t version = uint8_t(word & 0x000F);
34
if
(version == 1)
35
return
EventPacketVersion::V1;
36
if
(version == 2)
37
return
EventPacketVersion::V2;
38
return
EventPacketVersion::ERR;
39
}
40
41
// Length
42
static
constexpr
uint16_t
EVENT_TYPE_1_PACKET_LENGTH
= 8;
43
static
constexpr
uint16_t
EVENT_TYPE_2_PACKET_LENGTH
= 18;
44
45
inline
uint16_t
get_block_size
(
EventPacketVersion
packet_version =
ERR
)
46
{
47
if
(packet_version == Block::EventPacketVersion::V1) {
48
return
Block::EVENT_TYPE_1_PACKET_LENGTH
;
49
}
50
if
(packet_version == Block::EventPacketVersion::V2) {
51
return
Block::EVENT_TYPE_2_PACKET_LENGTH
;
52
}
53
return
0;
54
}
55
56
}
// namespace Block
57
58
struct
FIFO_block
59
{
60
std::vector<uint16_t>
p_words
;
61
FIFO_block
() =
default
;
62
FIFO_block
(std::vector<uint16_t> words)
63
:
p_words
(words)
64
{}
65
virtual
~FIFO_block
() =
default
;
66
67
virtual
bool
validate
() = 0;
68
virtual
void
reset
() = 0;
69
};
70
71
struct
Event
:
public
FIFO_block
72
{
73
uint64_t
timestamp
;
74
uint8_t
channel_number
;
75
uint16_t
channel_number_global
;
76
77
Event
()
78
:
FIFO_block
() {};
79
Event
(std::vector<uint16_t> words)
80
:
FIFO_block
(words)
81
{}
82
~Event
()
override
{}
83
};
84
85
struct
Event_type_1
final :
public
Event
86
{
87
uint8_t
TDC_rise_time
;
88
uint8_t
TDC_falling_time
;
89
uint16_t
pulse_length
;
90
91
bool
validate
()
override
92
{
93
uint16_t trailer =
p_words
[7];
94
if
(trailer != 0xABBA)
95
return
false
;
96
97
if
((
p_words
[5] & 0x80) != 0)
98
return
false
;
99
if
((
p_words
[5] & 0x8000) != 0)
100
return
false
;
101
102
return
true
;
103
}
104
105
Event_type_1
(std::vector<uint16_t> words)
106
:
Event
(words)
107
{
108
channel_number
= (
p_words
[0] & 0x0FF0) >> 4;
109
// Timestamp
110
timestamp
= 0;
111
for
(
size_t
i
= 0;
i
< 4;
i
++)
112
timestamp
+= uint64_t(
p_words
[
i
+ 1]) << 16 *
i
;
113
TDC_rise_time
=
p_words
[5] & 0x007F;
114
TDC_falling_time
= (
p_words
[5] & 0x7F00) >> 8;
115
pulse_length
=
p_words
[6];
116
}
117
118
Event_type_1
()
119
:
Event
()
120
{}
121
~Event_type_1
()
override
{}
122
void
reset
()
override
{ *
this
=
Event_type_1
(); }
123
};
124
125
struct
Event_type_2
final :
public
Event
126
{
127
uint8_t
TDC_rise_time
;
128
uint8_t
TDC_falling_time
;
129
uint8_t
raw_tdc_rise_0
;
130
uint8_t
raw_tdc_rise_1
;
131
uint8_t
raw_tdc_rise_2
;
132
uint8_t
raw_tdc_rise_3
;
133
uint8_t
TDC_time_rise_0
;
134
uint8_t
TDC_time_rise_1
;
135
uint8_t
TDC_time_rise_2
;
136
uint8_t
TDC_time_rise_3
;
137
uint8_t
raw_tdc_fall_0
;
138
uint8_t
raw_tdc_fall_1
;
139
uint8_t
raw_tdc_fall_2
;
140
uint8_t
raw_tdc_fall_3
;
141
uint8_t
TDC_time_fall_0
;
142
uint8_t
TDC_time_fall_1
;
143
uint8_t
TDC_time_fall_2
;
144
uint8_t
TDC_time_fall_3
;
145
uint8_t
post_gen_rise
;
146
uint8_t
post_gen_fall
;
147
uint16_t
pulse_length
;
148
149
bool
validate
()
override
150
{
151
uint16_t trailer = (
p_words
[15] & 0xFF00) >> 8;
152
if
(trailer != 0xB0)
153
return
false
;
154
155
if
((
p_words
[13] & 0x80) != 0)
156
return
false
;
157
if
((
p_words
[13] & 0x8000) != 0)
158
return
false
;
159
160
return
true
;
161
}
162
163
Event_type_2
(std::vector<uint16_t> words)
164
:
Event
(words)
165
{
166
channel_number
= (
p_words
[0] & 0x0FF0) >> 4;
167
// Timestamp
168
timestamp
= 0;
169
for
(
int
i
= 0;
i
< 4;
i
++)
170
timestamp
+= uint64_t(
p_words
[
i
+ 1]) << 16 *
i
;
171
raw_tdc_rise_0
=
p_words
[5] & 0x00FF;
172
raw_tdc_rise_1
= (
p_words
[5] & 0xFF00) >> 8;
173
raw_tdc_rise_2
=
p_words
[6] & 0x00FF;
174
raw_tdc_rise_3
= (
p_words
[6] & 0xFF00) >> 8;
175
TDC_time_rise_0
=
p_words
[7] & 0x00FF;
176
TDC_time_rise_1
= (
p_words
[7] & 0xFF00) >> 8;
177
TDC_time_rise_2
=
p_words
[8] & 0x00FF;
178
TDC_time_rise_3
= (
p_words
[8] & 0xFF00) >> 8;
179
raw_tdc_fall_0
=
p_words
[9] & 0x00FF;
180
raw_tdc_fall_1
= (
p_words
[9] & 0xFF00) >> 8;
181
raw_tdc_fall_2
=
p_words
[10] & 0x00FF;
182
raw_tdc_fall_3
= (
p_words
[10] & 0xFF00) >> 8;
183
TDC_time_fall_0
=
p_words
[11] & 0x00FF;
184
TDC_time_fall_1
= (
p_words
[11] & 0xFF00) >> 8;
185
TDC_time_fall_2
=
p_words
[12] & 0x00FF;
186
TDC_time_fall_3
= (
p_words
[12] & 0xFF00) >> 8;
187
TDC_rise_time
=
p_words
[13] & 0x007F;
188
TDC_falling_time
= (
p_words
[13] & 0x7F00) >> 8;
189
pulse_length
=
p_words
[14];
190
post_gen_rise
=
p_words
[15] & 0x000F;
191
post_gen_rise
= (
p_words
[15] & 0x00F0) >> 4;
192
channel_number_global
=
p_words
[16];
193
}
194
195
Event_type_2
()
196
:
Event
()
197
{}
198
~Event_type_2
()
override
{}
199
void
reset
()
override
{ *
this
=
Event_type_2
(); }
200
};
201
202
}
// namespace BmnHgndRaw
203
204
#endif
i
int i
Definition
P4_F32vec4.h:22
BmnHgndRaw::Block
Definition
BmnHgndRaw.h:12
BmnHgndRaw::Block::HEADER_MASK
static constexpr uint32_t HEADER_MASK
Definition
BmnHgndRaw.h:15
BmnHgndRaw::Block::is_word_event_header
bool is_word_event_header(uint16_t word)
Definition
BmnHgndRaw.h:18
BmnHgndRaw::Block::get_block_size
uint16_t get_block_size(EventPacketVersion packet_version=ERR)
Definition
BmnHgndRaw.h:45
BmnHgndRaw::Block::EVENT_TYPE_2_PACKET_LENGTH
static constexpr uint16_t EVENT_TYPE_2_PACKET_LENGTH
Definition
BmnHgndRaw.h:43
BmnHgndRaw::Block::EventPacketVersion
EventPacketVersion
Definition
BmnHgndRaw.h:25
BmnHgndRaw::Block::V2
@ V2
Definition
BmnHgndRaw.h:28
BmnHgndRaw::Block::V1
@ V1
Definition
BmnHgndRaw.h:27
BmnHgndRaw::Block::ERR
@ ERR
Definition
BmnHgndRaw.h:26
BmnHgndRaw::Block::EVENT_HEADER
static constexpr uint8_t EVENT_HEADER
Definition
BmnHgndRaw.h:16
BmnHgndRaw::Block::EVENT_TYPE_1_PACKET_LENGTH
static constexpr uint16_t EVENT_TYPE_1_PACKET_LENGTH
Definition
BmnHgndRaw.h:42
BmnHgndRaw::Block::get_event_packet_version
EventPacketVersion get_event_packet_version(uint16_t word)
Definition
BmnHgndRaw.h:31
BmnHgndRaw
Definition
BmnHgndRaw.h:9
BmnHgndRaw::Event_type_1::Event_type_1
Event_type_1(std::vector< uint16_t > words)
Definition
BmnHgndRaw.h:105
BmnHgndRaw::Event_type_1::~Event_type_1
~Event_type_1() override
Definition
BmnHgndRaw.h:121
BmnHgndRaw::Event_type_1::TDC_falling_time
uint8_t TDC_falling_time
Definition
BmnHgndRaw.h:88
BmnHgndRaw::Event_type_1::TDC_rise_time
uint8_t TDC_rise_time
Definition
BmnHgndRaw.h:87
BmnHgndRaw::Event_type_1::validate
bool validate() override
Definition
BmnHgndRaw.h:91
BmnHgndRaw::Event_type_1::pulse_length
uint16_t pulse_length
Definition
BmnHgndRaw.h:89
BmnHgndRaw::Event_type_1::Event_type_1
Event_type_1()
Definition
BmnHgndRaw.h:118
BmnHgndRaw::Event_type_1::reset
void reset() override
Definition
BmnHgndRaw.h:122
BmnHgndRaw::Event_type_2::TDC_time_rise_0
uint8_t TDC_time_rise_0
Definition
BmnHgndRaw.h:133
BmnHgndRaw::Event_type_2::post_gen_rise
uint8_t post_gen_rise
Definition
BmnHgndRaw.h:145
BmnHgndRaw::Event_type_2::raw_tdc_rise_1
uint8_t raw_tdc_rise_1
Definition
BmnHgndRaw.h:130
BmnHgndRaw::Event_type_2::Event_type_2
Event_type_2(std::vector< uint16_t > words)
Definition
BmnHgndRaw.h:163
BmnHgndRaw::Event_type_2::TDC_rise_time
uint8_t TDC_rise_time
Definition
BmnHgndRaw.h:127
BmnHgndRaw::Event_type_2::TDC_time_rise_3
uint8_t TDC_time_rise_3
Definition
BmnHgndRaw.h:136
BmnHgndRaw::Event_type_2::validate
bool validate() override
Definition
BmnHgndRaw.h:149
BmnHgndRaw::Event_type_2::raw_tdc_fall_3
uint8_t raw_tdc_fall_3
Definition
BmnHgndRaw.h:140
BmnHgndRaw::Event_type_2::TDC_time_rise_1
uint8_t TDC_time_rise_1
Definition
BmnHgndRaw.h:134
BmnHgndRaw::Event_type_2::TDC_time_fall_2
uint8_t TDC_time_fall_2
Definition
BmnHgndRaw.h:143
BmnHgndRaw::Event_type_2::Event_type_2
Event_type_2()
Definition
BmnHgndRaw.h:195
BmnHgndRaw::Event_type_2::TDC_time_fall_1
uint8_t TDC_time_fall_1
Definition
BmnHgndRaw.h:142
BmnHgndRaw::Event_type_2::raw_tdc_rise_0
uint8_t raw_tdc_rise_0
Definition
BmnHgndRaw.h:129
BmnHgndRaw::Event_type_2::TDC_time_rise_2
uint8_t TDC_time_rise_2
Definition
BmnHgndRaw.h:135
BmnHgndRaw::Event_type_2::reset
void reset() override
Definition
BmnHgndRaw.h:199
BmnHgndRaw::Event_type_2::raw_tdc_fall_2
uint8_t raw_tdc_fall_2
Definition
BmnHgndRaw.h:139
BmnHgndRaw::Event_type_2::~Event_type_2
~Event_type_2() override
Definition
BmnHgndRaw.h:198
BmnHgndRaw::Event_type_2::raw_tdc_rise_2
uint8_t raw_tdc_rise_2
Definition
BmnHgndRaw.h:131
BmnHgndRaw::Event_type_2::TDC_time_fall_3
uint8_t TDC_time_fall_3
Definition
BmnHgndRaw.h:144
BmnHgndRaw::Event_type_2::pulse_length
uint16_t pulse_length
Definition
BmnHgndRaw.h:147
BmnHgndRaw::Event_type_2::post_gen_fall
uint8_t post_gen_fall
Definition
BmnHgndRaw.h:146
BmnHgndRaw::Event_type_2::raw_tdc_rise_3
uint8_t raw_tdc_rise_3
Definition
BmnHgndRaw.h:132
BmnHgndRaw::Event_type_2::raw_tdc_fall_0
uint8_t raw_tdc_fall_0
Definition
BmnHgndRaw.h:137
BmnHgndRaw::Event_type_2::raw_tdc_fall_1
uint8_t raw_tdc_fall_1
Definition
BmnHgndRaw.h:138
BmnHgndRaw::Event_type_2::TDC_time_fall_0
uint8_t TDC_time_fall_0
Definition
BmnHgndRaw.h:141
BmnHgndRaw::Event_type_2::TDC_falling_time
uint8_t TDC_falling_time
Definition
BmnHgndRaw.h:128
BmnHgndRaw::Event::Event
Event(std::vector< uint16_t > words)
Definition
BmnHgndRaw.h:79
BmnHgndRaw::Event::~Event
~Event() override
Definition
BmnHgndRaw.h:82
BmnHgndRaw::Event::timestamp
uint64_t timestamp
Definition
BmnHgndRaw.h:73
BmnHgndRaw::Event::Event
Event()
Definition
BmnHgndRaw.h:77
BmnHgndRaw::Event::channel_number
uint8_t channel_number
Definition
BmnHgndRaw.h:74
BmnHgndRaw::Event::channel_number_global
uint16_t channel_number_global
Definition
BmnHgndRaw.h:75
BmnHgndRaw::FIFO_block::FIFO_block
FIFO_block()=default
BmnHgndRaw::FIFO_block::validate
virtual bool validate()=0
BmnHgndRaw::FIFO_block::FIFO_block
FIFO_block(std::vector< uint16_t > words)
Definition
BmnHgndRaw.h:62
BmnHgndRaw::FIFO_block::p_words
std::vector< uint16_t > p_words
Definition
BmnHgndRaw.h:60
BmnHgndRaw::FIFO_block::reset
virtual void reset()=0
BmnHgndRaw::FIFO_block::~FIFO_block
virtual ~FIFO_block()=default
base
raw
BmnHgndRaw.h
Generated on
for BmnRoot by
1.17.0