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 
15  EvHdrAb.clear();
16  EvHdrAc.clear();
17  HitHdr.clear();
18  HitData.clear();
19  VectHitHdr.clear();
20  VectHitData.clear();
21  }
22 
24  EvHdrAb.clear();
25  buffer_shift = 0;
27  (buffer[gbt_word_index] >> buffer_shift) & 0xffffffffffffffff;
29 
30  buffer_shift = 0;
32  & (((static_cast<uint32_t>(1)) << EvHdrAb.HNs) - 1);
35  & (((static_cast<uint32_t>(1)) << EvHdrAb.MWs) - 1);
37 
38  if (PrintOut) EvHdrAb.printout();
39  }
40 
42  EvHdrAc.clear();
43  buffer_shift = 0;
45  & (((static_cast<uint64_t>(1)) << EvHdrAc.TMs) - 1);
47 
48  buffer_shift = 0;
51  & (((static_cast<uint32_t>(1)) << EvHdrAc.PVs) - 1);
54  & (((static_cast<uint32_t>(1)) << EvHdrAc.MWs) - 1);
56 
57  if (PrintOut) EvHdrAc.printout();
58  }
59 
61  HitHdr.clear();
62  buffer_shift = 0;
64  & (((static_cast<uint32_t>(1)) << HitHdr.ZLs) - 1);
67  & (((static_cast<uint32_t>(1)) << HitHdr.SCs) - 1);
69 
70  buffer_shift = 0;
72  & (((static_cast<uint32_t>(1)) << HitHdr.HCs) - 1);
75  & (((static_cast<uint32_t>(1)) << HitHdr.WPSs) - 1);
77 
78  if (PrintOut) HitHdr.printout();
79  }
80 
82  HitData.clear();
83  buffer_shift = 64;
84  for (int wfm_pt_iter = 0; wfm_pt_iter < HitHdr.uWfmPoints; wfm_pt_iter++) {
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 
99  bool IsAbHeaderInMessage = false;
100  bool IsAcHeaderInMessage = false;
101 
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++) {
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