16#ifndef ALICEO2_SACDECODER_H
17#define ALICEO2_SACDECODER_H
22#include <unordered_map>
75 std::vector<DataPoint>
data;
76 std::vector<std::bitset<NumberFEs>>
fes;
88 while (posGood <
fes.size()) {
89 if (!
fes[posGood].all()) {
122 fes.insert(
fes.begin(), entries, std::bitset<NumberFEs>());
182 mDecodeAdditional.clear();
183 for (
const auto c : additional) {
185 mDecodeAdditional +=
c;
193 mDebugStream = std::make_unique<o2::utils::TreeStreamRedirector>(mDebugOutputName.data(),
"recreate");
216 static void setNThreads(
const int nThreads) { sNThreads = nThreads; }
222 inline static int sNThreads{1};
223 size_t mCollectedDataPackets{};
224 std::array<uint32_t, Instances> mPktCountInstance{};
225 std::array<uint32_t, NumberFEs> mPktCountFEs{};
226 std::array<std::pair<uint32_t, uint32_t>,
NumberFEs> mTSCountFEs;
227 std::array<std::string, NumberFEs> mDataStrings;
228 DecodedData mDecodedData;
229 std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream;
230 std::string mDecodeAdditional;
231 std::string mDebugOutputName{
"SAC_debug.root"};
234 uint32_t mDebugLevel{0};
236 uint32_t decodeTimeStamp(
const char*
data);
239 int decodeChannels(DecodedDataFE& sacs,
size_t& carry,
int feid);
240 void decode(
int feid);
242 void printPacketInfo(
const sac::packet& sac);
246 ClassDefNV(Decoder, 0);
Header to collect LHC related constants.
Sampled Analogue Currents (SACs) data format definitions.
static void setNThreads(const int nThreads)
@ DumpFullStream
Dump the data character streams.
@ StreamSingleFE
Stream debug output for each single FE.
@ ProcessingInfo
Print some processing info.
@ PacketInfo
Print packe information.
@ StreamFinalData
Stream debug output for each single FE.
void setDebugLevel(uint32_t level=(uint32_t) DebugFlags::PacketInfo)
set a debug level, see DebugFlags
double getReferenceTime() const
static constexpr double SampleTimeMS
Internal timer sampling time in milli seconds (downsampled from LHC clock x 2500)
const DecodedData & getDecodedData() const
void setReAlignType(ReAlignType type=ReAlignType::AlignOnly)
void setDecodeAdditional(std::string_view additional)
ReAlignType getReAlignType() const
static constexpr uint32_t SampleDistance
Number of samples between time data stamps.
void streamDecodedData(bool streamAll=false)
static constexpr double SampleDistanceTimeMS
Time distance in MS between samples.
void setReferenceTime(double time)
static constexpr std::string_view AllowedAdditionalStreams
Allowed additional data streams that can be decoded with debug stream enabled.
@ AlignOnly
Try re-alignment.
@ MaxType
Largest type number.
@ None
Print packe information.
@ AlignAndFillMissing
Try re-alignment and fill missing packets with 0s.
GLint GLint GLsizei GLint GLenum GLenum type
constexpr double LHCBunchSpacingMUS
constexpr size_t NumberFEs
Total number of frontends to process.
constexpr uint32_t ChannelsPerFE
Channels per front-end card. One channel is one stack.
constexpr float ADCtoNanoAmp
125000 nA / std::pow(2,23) bits
constexpr size_t Instances
Number of instances to process.
constexpr unsigned short GEMSTACKS
Marks an empty item in the context.
int32_t currents[GEMSTACKS]
Current in signed ADC values, use SACDecoder::ADCtoNanoAmp, to convert to nA.
uint32_t time
Reference time since epoch in ms.
std::array< int32_t, 8 > currents
void insertFront(const size_t entries)
insert entries at the front
double referenceTime
reference time when sampling clock was started
void setData(const size_t pos, uint32_t time, const DecodedDataFE &decdata, const int feid)
copy decoded data from single FE and mark FE as received
size_t getNGoodEntries() const
Number of good entries, for which all FEs were decoded.
std::vector< std::bitset< NumberFEs > > fes
bitmask of decoded FEs
void clearGoodData()
clear entries where all FEs were already decoded
gsl::span< const DataPoint > getGoodData() const
span of good entries for which all FEs were already decoded
ClassDefNV(DecodedData, 1)
void clear()
clear all data
void resize(size_t newSize)
std::vector< DataPoint > data
decoded data