1#ifndef BMNCONVERTERTOOLS_H
2#define BMNCONVERTERTOOLS_H 1
9#include <nlohmann/json.hpp>
11#include <TClonesArray.h>
13#include <TTimeStamp.h>
16#include <FairLogger.h>
53 template<
typename IntType,
typename LamType>
57 TClonesArray* arr =
nullptr;
61 MStreamHeader* ms =
reinterpret_cast<MStreamHeader*
>(
d + index);
65 UInt_t blockLen = ms->Len;
67 switch (ms->Subtype) {
69 MStream0* ms0 =
reinterpret_cast<MStream0*
>(
d + index);
71 LOGF(debug2,
"MS0 taiFlags %u TAI: %s", ms0->Tai.Flags,
72 TTimeStamp(time_t(ms0->Tai.Sec), ms0->Tai.NSec).AsString());
73 UInt_t nCh =
static_cast<bitset<kNBYTESINWORD * 8>
>(ms0->MaskHi).count()
74 +
static_cast<bitset<kNBYTESINWORD * 8>
>(ms0->MaskLo).count();
75 UInt_t payload = len - (
sizeof(MStreamHeader) +
sizeof(MStream0)) /
kNBYTESINWORD;
76 LOGF(debug2,
"serial %08X payload %6d nCh %u", serial, payload, nCh);
77 if ((nCh == 0) || (payload == 0))
81 if ((payload % nCh != 0)
82 || (payload / nCh <= (
sizeof(MStreamHeader) +
sizeof(MStreamTAI)) /
kNBYTESINWORD))
84 nSmpl = 2 * (payload / nCh - (
sizeof(MStreamHeader) +
sizeof(MStreamTAI)) /
kNBYTESINWORD);
85 LOGF(debug2,
"serial %08X payload %6d nCh %u nSmpl %u", serial, payload, nCh, nSmpl);
86 arr = arr_selector(nSmpl);
87 valI.resize(nSmpl, 0);
91 MStreamTAI* mst =
reinterpret_cast<MStreamTAI*
>(
d + index);
92 LOGF(debug2,
"MS0 taiFlags %u TAI: %s", mst->Flags,
93 TTimeStamp(time_t(mst->Sec), mst->NSec).AsString());
95 uint8_t iCh = ms->CustomBits;
96 TakeDataWords(nSmpl,
d + index, valI);
97 new ((*arr)[arr->GetEntriesFast()])
BmnADCDigit(serial, iCh, nSmpl, valI);
98 index += nSmpl / 2 + nSmpl % 2;
103 LOGF(warning,
"Wrong ADC64:Mstream data type %u !", ms->Subtype);
124 template<
typename ArrType>
125 static void TakeDataWords(UInt_t n, UInt_t*
d, ArrType& valI)
127 for (UInt_t iWord = 0; iWord < n / 2; ++iWord) {
128 valI[2 * iWord + 1] =
131 (
d[iWord] >> 16) & 0xFFFF;
135 static T0Config GetT0Cfg(
string str);
const Float_t d
Z-ccordinate of the first GEM-station.
std::chrono::time_point< SysClock > SysPoint
const uint32_t kNBYTESINWORD
a class to store JSON values
Define enumerations used in tracking.
basic_json<> json
default specialization