CbmRoot
PsdGbtReader.cxx
Go to the documentation of this file.
1
// -----------------------------------------------------------------------------
2
// ----- -----
3
// ----- PsdGbtDataReader -----
4
// ----- Created 14.09.2019 by N.Karpushkin -----
5
// ----- -----
6
// -----------------------------------------------------------------------------
7
8
#include "
PsdGbtReader.h
"
9
10
#include <cstdint>
// for uint16_t, uint64_t, uint32_t
11
12
namespace
PsdData
{
13
14
PsdGbtReader::~PsdGbtReader
() {
15
EvHdrAb
.
clear
();
16
EvHdrAc
.
clear
();
17
HitHdr
.
clear
();
18
HitData
.
clear
();
19
VectHitHdr
.clear();
20
VectHitData
.clear();
21
}
22
23
void
PsdGbtReader::ReadEventHeaderAbFles
() {
24
EvHdrAb
.
clear
();
25
buffer_shift
= 0;
26
EvHdrAb
.
ulMicroSlice
=
27
(
buffer
[
gbt_word_index
] >>
buffer_shift
) & 0xffffffffffffffff;
28
gbt_word_index
++;
29
30
buffer_shift
= 0;
31
EvHdrAb
.
uHitsNumber
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
32
& (((
static_cast<
uint32_t
>
(1)) <<
EvHdrAb
.
HNs
) - 1);
33
buffer_shift
+=
EvHdrAb
.
HNs
;
34
EvHdrAb
.
uMagicWordAB
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
35
& (((
static_cast<
uint32_t
>
(1)) <<
EvHdrAb
.
MWs
) - 1);
36
gbt_word_index
++;
37
38
if
(
PrintOut
)
EvHdrAb
.
printout
();
39
}
40
41
void
PsdGbtReader::ReadEventHeaderAcFles
() {
42
EvHdrAc
.
clear
();
43
buffer_shift
= 0;
44
EvHdrAc
.
uAdcTime
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
45
& (((
static_cast<
uint64_t
>
(1)) <<
EvHdrAc
.
TMs
) - 1);
46
gbt_word_index
++;
47
48
buffer_shift
= 0;
49
EvHdrAc
.
uPacketVersion
=
50
(
buffer
[
gbt_word_index
] >>
buffer_shift
)
51
& (((
static_cast<
uint32_t
>
(1)) <<
EvHdrAc
.
PVs
) - 1);
52
buffer_shift
+=
EvHdrAc
.
PVs
;
53
EvHdrAc
.
uMagicWordAC
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
54
& (((
static_cast<
uint32_t
>
(1)) <<
EvHdrAc
.
MWs
) - 1);
55
gbt_word_index
++;
56
57
if
(
PrintOut
)
EvHdrAc
.
printout
();
58
}
59
60
void
PsdGbtReader::ReadHitHeaderFles
() {
61
HitHdr
.
clear
();
62
buffer_shift
= 0;
63
HitHdr
.
uZeroLevel
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
64
& (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.
ZLs
) - 1);
65
buffer_shift
+=
HitHdr
.
ZLs
;
66
HitHdr
.
uSignalCharge
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
67
& (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.
SCs
) - 1);
68
gbt_word_index
++;
69
70
buffer_shift
= 0;
71
HitHdr
.
uHitChannel
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
72
& (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.
HCs
) - 1);
73
buffer_shift
+=
HitHdr
.
HCs
;
74
HitHdr
.
uWfmPoints
= (
buffer
[
gbt_word_index
] >>
buffer_shift
)
75
& (((
static_cast<
uint32_t
>
(1)) <<
HitHdr
.
WPSs
) - 1);
76
gbt_word_index
++;
77
78
if
(
PrintOut
)
HitHdr
.
printout
();
79
}
80
81
void
PsdGbtReader::ReadHitDataFles
() {
82
HitData
.
clear
();
83
buffer_shift
= 64;
84
for
(
int
wfm_pt_iter = 0; wfm_pt_iter <
HitHdr
.
uWfmPoints
; wfm_pt_iter++) {
85
buffer_shift
-=
HitData
.
WPs
;
86
uint16_t wfm_point = (
buffer
[
gbt_word_index
] >>
buffer_shift
)
87
& (((
static_cast<
uint32_t
>
(1)) <<
HitData
.
WPs
) - 1);
88
HitData
.
uWfm
.push_back(wfm_point);
89
if
(
buffer_shift
== 0) {
90
gbt_word_index
+= 2;
91
buffer_shift
= 64;
92
}
93
}
94
95
if
(
PrintOut
)
HitData
.
printout
();
96
}
97
98
int
PsdGbtReader::ReadEventFles
() {
99
bool
IsAbHeaderInMessage =
false
;
100
bool
IsAcHeaderInMessage =
false
;
101
102
ReadEventHeaderAbFles
();
103
ReadEventHeaderAcFles
();
104
IsAbHeaderInMessage = (
EvHdrAb
.
uMagicWordAB
== 171);
105
IsAcHeaderInMessage = (
EvHdrAc
.
uMagicWordAC
== 172);
106
107
if
(IsAbHeaderInMessage && IsAcHeaderInMessage) {
108
VectHitHdr
.clear();
109
VectHitData
.clear();
110
111
//hit loop
112
for
(
int
hit_iter = 0; hit_iter <
EvHdrAb
.
uHitsNumber
; hit_iter++) {
113
ReadHitHeaderFles
();
114
VectHitHdr
.push_back(
HitHdr
);
115
ReadHitDataFles
();
116
VectHitData
.push_back(
HitData
);
117
118
if
(
VectHitHdr
.at(hit_iter).uWfmPoints != 8) {
return
2; }
119
}
//hit loop
120
121
if
(
EvHdrAb
.
uHitsNumber
!=
VectHitHdr
.size()) {
return
3; }
122
}
else
{
123
return
1;
124
}
125
126
return
0;
127
}
128
}
// namespace PsdData
PsdData::PsdEventHeaderAC::uMagicWordAC
uint8_t uMagicWordAC
Definition:
PsdGbtDataFormat.h:54
PsdGbtReader.h
PsdData::PsdGbtReader::buffer
const uint64_t * buffer
Definition:
PsdGbtReader.h:51
PsdData::PsdHitHeader::uSignalCharge
uint16_t uSignalCharge
Empty bits.
Definition:
PsdGbtDataFormat.h:91
PsdData::PsdGbtReader::VectHitData
std::vector< PsdHitData > VectHitData
Definition:
PsdGbtReader.h:34
PsdData::PsdGbtReader::ReadEventHeaderAcFles
void ReadEventHeaderAcFles()
Definition:
PsdGbtReader.cxx:41
PsdData::PsdHitHeader::uHitChannel
uint8_t uHitChannel
Total waveform points per hit.
Definition:
PsdGbtDataFormat.h:89
PsdData::PsdGbtReader::gbt_word_index
uint32_t gbt_word_index
Definition:
PsdGbtReader.h:54
PsdData::PsdGbtReader::EvHdrAc
PsdEventHeaderAC EvHdrAc
Definition:
PsdGbtReader.h:29
PsdData::PsdGbtReader::PrintOut
bool PrintOut
Definition:
PsdGbtReader.h:53
PsdData::PsdGbtReader::ReadEventHeaderAbFles
void ReadEventHeaderAbFles()
Definition:
PsdGbtReader.cxx:23
PsdData::PsdGbtReader::~PsdGbtReader
~PsdGbtReader()
Definition:
PsdGbtReader.cxx:14
PsdData::PsdGbtReader::ReadHitHeaderFles
void ReadHitHeaderFles()
Definition:
PsdGbtReader.cxx:60
PsdData::PsdGbtReader::ReadEventFles
int ReadEventFles()
Definition:
PsdGbtReader.cxx:98
PsdData::PsdEventHeaderAB::HNs
@ HNs
MagicWord size in bits.
Definition:
PsdGbtDataFormat.h:21
PsdData::PsdGbtReader::buffer_shift
int buffer_shift
Definition:
PsdGbtReader.h:55
PsdData::PsdEventHeaderAC::clear
void clear()
Definition:
PsdGbtDataFormat.h:68
PsdData::PsdEventHeaderAC::printout
void printout()
ADC Time of threshold cross from the begining of TS.
Definition:
PsdGbtDataFormat.h:60
PsdData::PsdHitData::WPs
@ WPs
Empty bits size in bits.
Definition:
PsdGbtDataFormat.h:118
PsdData::PsdHitHeader::ZLs
@ ZLs
Signal charge size in bits.
Definition:
PsdGbtDataFormat.h:85
PsdData::PsdEventHeaderAB::MWs
@ MWs
Definition:
PsdGbtDataFormat.h:20
PsdData::PsdHitData::uWfm
std::vector< uint16_t > uWfm
Empty bits.
Definition:
PsdGbtDataFormat.h:122
PsdData
Definition:
PsdGbtDataFormat.h:16
PsdData::PsdEventHeaderAC::uAdcTime
uint32_t uAdcTime
Empty bits.
Definition:
PsdGbtDataFormat.h:58
PsdData::PsdGbtReader::EvHdrAb
PsdEventHeaderAB EvHdrAb
Definition:
PsdGbtReader.h:28
PsdData::PsdEventHeaderAC::uPacketVersion
uint8_t uPacketVersion
Should be AC.
Definition:
PsdGbtDataFormat.h:55
PsdData::PsdGbtReader::HitData
PsdHitData HitData
Definition:
PsdGbtReader.h:31
PsdData::PsdHitHeader::uZeroLevel
uint16_t uZeroLevel
Waveform integral above ZeroLevel.
Definition:
PsdGbtDataFormat.h:92
PsdData::PsdHitHeader::SCs
@ SCs
Empty bits size in bits.
Definition:
PsdGbtDataFormat.h:84
PsdData::PsdHitData::printout
void printout()
Waveform vector.
Definition:
PsdGbtDataFormat.h:124
PsdData::PsdEventHeaderAC::PVs
@ PVs
MagicWord size in bits.
Definition:
PsdGbtDataFormat.h:49
PsdData::PsdHitHeader::clear
void clear()
Definition:
PsdGbtDataFormat.h:103
PsdData::PsdEventHeaderAB::printout
void printout()
Epoch.
Definition:
PsdGbtDataFormat.h:29
PsdData::PsdHitData::clear
void clear()
Definition:
PsdGbtDataFormat.h:131
PsdData::PsdHitHeader::uWfmPoints
uint8_t uWfmPoints
Definition:
PsdGbtDataFormat.h:88
PsdData::PsdEventHeaderAB::uHitsNumber
uint8_t uHitsNumber
Should be AB.
Definition:
PsdGbtDataFormat.h:26
PsdData::PsdEventHeaderAC::MWs
@ MWs
Definition:
PsdGbtDataFormat.h:48
PsdData::PsdGbtReader::ReadHitDataFles
void ReadHitDataFles()
Definition:
PsdGbtReader.cxx:81
PsdData::PsdEventHeaderAC::TMs
@ TMs
Empty bits size in bits.
Definition:
PsdGbtDataFormat.h:51
PsdData::PsdGbtReader::HitHdr
PsdHitHeader HitHdr
Definition:
PsdGbtReader.h:30
PsdData::PsdEventHeaderAB::uMagicWordAB
uint8_t uMagicWordAB
Definition:
PsdGbtDataFormat.h:25
PsdData::PsdHitHeader::WPSs
@ WPSs
Definition:
PsdGbtDataFormat.h:81
PsdData::PsdHitHeader::HCs
@ HCs
Waveform points size in bits.
Definition:
PsdGbtDataFormat.h:82
PsdData::PsdEventHeaderAB::clear
void clear()
Definition:
PsdGbtDataFormat.h:36
PsdData::PsdHitHeader::printout
void printout()
Waveform ZeroLevel.
Definition:
PsdGbtDataFormat.h:94
PsdData::PsdEventHeaderAB::ulMicroSlice
uint64_t ulMicroSlice
Total number of hits.
Definition:
PsdGbtDataFormat.h:27
PsdData::PsdGbtReader::VectHitHdr
std::vector< PsdHitHeader > VectHitHdr
Definition:
PsdGbtReader.h:33
core
data
raw
PsdGbtReader.cxx
Generated on Wed Oct 28 2020 15:11:51 for CbmRoot by
1.8.18