CbmRoot
Loading...
Searching...
No Matches
PsdGbtReader-v1.00.cxx
Go to the documentation of this file.
1
/* Copyright (C) 2019-2021 Institute for Nuclear Research, Moscow
2
SPDX-License-Identifier: GPL-3.0-only
3
Authors: Nikolay Karpushkin [committer]*/
4
5
#include "
PsdGbtReader-v1.00.h
"
6
7
namespace
PsdDataV100
8
{
9
10
PsdGbtReader::~PsdGbtReader
()
11
{
12
MsHdr
.clear();
13
PackHdr
.clear();
14
HitHdr
.clear();
15
HitData
.clear();
16
VectPackHdr
.clear();
17
VectHitHdr
.clear();
18
VectHitData
.clear();
19
}
20
21
void
PsdGbtReader::ReadMsHeader
()
22
{
23
MsHdr
.clear();
24
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl
25
<< std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
+ 1] << std::endl;
26
27
MsHdr
.uMagicWord = (
buffer
[
word_index
] >> 32) & 0xff;
28
MsHdr
.ulMicroSlice = ((
buffer
[
word_index
] & 0xffffff) << 40) | (
buffer
[
word_index
+ 1] & 0xffffffffff);
29
word_index
+= 2;
30
31
if
(
print
)
MsHdr
.printout();
32
}
33
34
void
PsdGbtReader::ReadPackHeader
()
35
{
36
PackHdr
.clear();
37
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl;
38
39
buffer_shift
= 0;
40
PackHdr
.uHitsNumber = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint16_t
>
(1)) <<
PackHdr
.HNs) - 1);
41
buffer_shift
+=
PackHdr
.HNs +
PackHdr
.E0s;
42
PackHdr
.uLinkIndex = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint16_t
>
(1)) <<
PackHdr
.LIs) - 1);
43
buffer_shift
+=
PackHdr
.LIs;
44
PackHdr
.uMagicWord = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint16_t
>
(1)) <<
PackHdr
.MWs) - 1);
45
word_index
++;
46
47
if
(
PackHdr
.uMagicWord != 0xb) {
48
if
(
print
)
PackHdr
.printout();
49
return
;
50
}
51
52
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl;
53
buffer_shift
= 0;
54
PackHdr
.uAdcTime = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint64_t
>
(1)) <<
PackHdr
.TMs) - 1);
55
buffer_shift
+=
PackHdr
.TMs;
56
PackHdr
.uTotalWords = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint32_t
>
(1)) <<
PackHdr
.TWs) - 1);
57
word_index
++;
58
59
if
(
print
)
PackHdr
.printout();
60
}
61
62
void
PsdGbtReader::ReadHitHeader
()
63
{
64
HitHdr
.clear();
65
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl
66
<< std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
+ 1] << std::endl;
67
68
buffer_shift
= 8;
69
HitHdr
.uFeeAccum = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.FAs) - 1);
70
buffer_shift
+=
HitHdr
.FAs;
71
HitHdr
.uWfmWords = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint16_t
>
(1)) <<
HitHdr
.WWs) - 1);
72
buffer_shift
+=
HitHdr
.WWs;
73
HitHdr
.uHitChannel = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.HCs) - 1);
74
word_index
++;
75
76
buffer_shift
= 0;
77
HitHdr
.uZeroLevel = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.ZLs) - 1);
78
buffer_shift
+=
HitHdr
.ZLs;
79
HitHdr
.uSignalCharge = (
buffer
[
word_index
] >>
buffer_shift
) & (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.SCs) - 1);
80
word_index
++;
81
82
if
(
print
)
HitHdr
.printout();
83
}
84
85
void
PsdGbtReader::ReadHitData
()
86
{
87
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl;
88
89
uint16_t wfm_point = 0;
90
wfm_point = ((
buffer
[
word_index
] >> 8) & 0xffff);
91
HitData
.uWfm.push_back(wfm_point);
92
wfm_point = ((
buffer
[
word_index
] & 0xff) << 8) | ((
buffer
[
word_index
+ 1] >> 32) & 0xff);
93
HitData
.uWfm.push_back(wfm_point);
94
word_index
++;
95
96
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl;
97
wfm_point = ((
buffer
[
word_index
] >> 16) & 0xffff);
98
HitData
.uWfm.push_back(wfm_point);
99
wfm_point = (
buffer
[
word_index
] & 0xffff);
100
HitData
.uWfm.push_back(wfm_point);
101
word_index
++;
102
}
103
104
void
PsdGbtReader::ReadMsTrailer
()
105
{
106
save_buffer
<< std::hex << std::setfill(
'0'
) << std::setw(16) <<
buffer
[
word_index
] << std::endl;
107
108
MsTrlr
.uEmpty0 =
buffer
[
word_index
];
109
word_index
++;
110
111
if
(
print
)
MsTrlr
.printout();
112
}
113
114
int
PsdGbtReader::ReadMs
()
115
{
116
save_buffer
.str(
""
);
117
save_buffer
.clear();
118
119
//bool word_is_Ms_header = false;
120
//ReadMsHeader();
121
//word_is_Ms_header = (MsHdr.uMagicWord == 0xa0);
122
123
//if(word_is_Ms_header) { ms_hdrs_read++; }
124
//else { words_missed++; return 4; }
125
126
bool
word_is_Pack_header =
true
;
127
VectPackHdr
.clear();
128
VectHitHdr
.clear();
129
VectHitData
.clear();
130
131
while
(word_is_Pack_header) {
132
ReadPackHeader
();
133
134
if
(
PackHdr
.uMagicWord != 0xb) {
135
word_is_Pack_header =
false
;
136
if
(
print
) printf(
"End of microslice\n"
);
137
word_index
-= 1;
138
break
;
//return 1;
139
}
140
else
{
141
//hit loop
142
for
(
int
hit_iter = 0; hit_iter <
PackHdr
.uHitsNumber; hit_iter++) {
143
ReadHitHeader
();
144
if
(
HitHdr
.uHitChannel > 32)
return
2;
145
146
VectHitHdr
.emplace_back(
HitHdr
);
147
VectPackHdr
.emplace_back(
PackHdr
);
//for convenient use of uAdcTime with each hit
148
149
HitData
.clear();
150
if
(
HitHdr
.uWfmWords > 10)
return
3;
151
for
(
int
wfm_word_iter = 0; wfm_word_iter <
HitHdr
.uWfmWords - 1; wfm_word_iter++)
152
ReadHitData
();
153
154
VectHitData
.emplace_back(
HitData
);
155
if
(
print
)
HitData
.printout();
156
157
}
//hit loop
158
}
159
}
160
161
ReadMsTrailer
();
162
if
(
MsTrlr
.uEmpty0 == 0)
ms_ends_read
++;
163
//else
164
165
return
0;
166
}
167
168
169
void
PsdGbtReader::PrintSaveBuff
() { printf(
"%s\n"
,
save_buffer
.str().c_str()); }
170
171
void
PsdGbtReader::PrintOut
()
172
{
173
MsHdr
.printout();
174
for
(
int
hit_iter = 0; hit_iter < (int)
VectPackHdr
.size(); hit_iter++) {
175
VectPackHdr
.at(hit_iter).printout();
176
VectHitHdr
.at(hit_iter).printout();
177
VectHitData
.at(hit_iter).printout();
178
}
179
PackHdr
.printout();
180
MsTrlr
.printout();
181
}
182
183
184
}
// namespace PsdDataV100
PsdGbtReader-v1.00.h
PsdDataV100::PsdGbtReader::VectPackHdr
std::vector< struct PsdPackHeader > VectPackHdr
Definition
PsdGbtReader-v1.00.h:40
PsdDataV100::PsdGbtReader::ReadMs
int ReadMs()
Definition
PsdGbtReader-v1.00.cxx:114
PsdDataV100::PsdGbtReader::HitData
struct PsdHitData HitData
Definition
PsdGbtReader-v1.00.h:37
PsdDataV100::PsdGbtReader::ReadHitHeader
void ReadHitHeader()
Definition
PsdGbtReader-v1.00.cxx:62
PsdDataV100::PsdGbtReader::buffer
const uint64_t * buffer
Definition
PsdGbtReader-v1.00.h:66
PsdDataV100::PsdGbtReader::PrintOut
void PrintOut()
Definition
PsdGbtReader-v1.00.cxx:171
PsdDataV100::PsdGbtReader::save_buffer
std::stringstream save_buffer
Definition
PsdGbtReader-v1.00.h:32
PsdDataV100::PsdGbtReader::MsTrlr
struct PsdMsTrailer MsTrlr
Definition
PsdGbtReader-v1.00.h:38
PsdDataV100::PsdGbtReader::VectHitData
std::vector< struct PsdHitData > VectHitData
Definition
PsdGbtReader-v1.00.h:42
PsdDataV100::PsdGbtReader::word_index
int word_index
Definition
PsdGbtReader-v1.00.h:60
PsdDataV100::PsdGbtReader::~PsdGbtReader
~PsdGbtReader()
Definition
PsdGbtReader-v1.00.cxx:10
PsdDataV100::PsdGbtReader::ms_ends_read
int ms_ends_read
Definition
PsdGbtReader-v1.00.h:63
PsdDataV100::PsdGbtReader::PrintSaveBuff
void PrintSaveBuff()
Definition
PsdGbtReader-v1.00.cxx:169
PsdDataV100::PsdGbtReader::ReadHitData
void ReadHitData()
Definition
PsdGbtReader-v1.00.cxx:85
PsdDataV100::PsdGbtReader::PackHdr
struct PsdPackHeader PackHdr
Definition
PsdGbtReader-v1.00.h:35
PsdDataV100::PsdGbtReader::print
bool print
Definition
PsdGbtReader-v1.00.h:68
PsdDataV100::PsdGbtReader::VectHitHdr
std::vector< struct PsdHitHeader > VectHitHdr
Definition
PsdGbtReader-v1.00.h:41
PsdDataV100::PsdGbtReader::ReadMsTrailer
void ReadMsTrailer()
Definition
PsdGbtReader-v1.00.cxx:104
PsdDataV100::PsdGbtReader::MsHdr
struct PsdMsHeader MsHdr
Definition
PsdGbtReader-v1.00.h:34
PsdDataV100::PsdGbtReader::HitHdr
struct PsdHitHeader HitHdr
Definition
PsdGbtReader-v1.00.h:36
PsdDataV100::PsdGbtReader::ReadMsHeader
void ReadMsHeader()
Definition
PsdGbtReader-v1.00.cxx:21
PsdDataV100::PsdGbtReader::ReadPackHeader
void ReadPackHeader()
Definition
PsdGbtReader-v1.00.cxx:34
PsdDataV100::PsdGbtReader::buffer_shift
int buffer_shift
Definition
PsdGbtReader-v1.00.h:69
PsdDataV100
Definition
PsdGbtDataFormat-v1.00.h:14
core
data
raw
PsdGbtReader-v1.00.cxx
Generated on Fri Jan 30 2026 23:05:23 for CbmRoot by
1.13.2