CbmRoot
Loading...
Searching...
No Matches
much/UnpackMS.h
Go to the documentation of this file.
1/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Volker Friese [committer] */
4#pragma once
5
6#include "CbmMuchDigi.h"
7#include "MicrosliceDescriptor.hpp"
8#include "StsXyterMessage.h"
9#include "Timeslice.hpp"
10#include "UnpackMSBase.h"
11
12#include <cassert>
13#include <cstddef>
14#include <cstdint>
15#include <memory>
16#include <sstream>
17#include <vector>
18
19namespace cbm::algo::much
20{
21
22
29 std::vector<uint32_t> fAddress;
30 std::vector<bool> fChanMask;
31 uint64_t fTimeOffset = 0.;
32 };
33
34
40 struct UnpackPar {
41 std::vector<UnpackElinkPar> fElinkParams = {};
42 };
43
44
54 uint32_t fNumErrInvalidMsSize = 0;
56 bool HasErrors()
57 {
60 return (numErrors > 0 ? true : false);
61 }
62 std::string print()
63 {
64 std::stringstream ss;
65 ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
67 return ss.str();
68 }
69 };
70
78 };
79
86 class UnpackMS : public UnpackMSBase<CbmMuchDigi, UnpackMonitorData, UnpackAuxData> {
87
88 public:
90 UnpackMS(const UnpackPar& pars);
91
93 ~UnpackMS() override;
94
95
102 Result_t operator()(const uint8_t* msContent, const fles::MicrosliceDescriptor& msDescr,
103 const uint64_t tTimeslice) const override;
104
105 private: // datatypes
106 struct TimeSpec {
107 uint64_t currentTsTime = 0;
108 uint64_t currentCycle = 0;
109 uint32_t currentEpoch = 0;
110 uint64_t currentEpochTime = 0;
111 };
112
113
114 private: // methods
120 void ProcessHitMessage(const stsxyter::Message& message, const TimeSpec& time, std::vector<CbmMuchDigi>& digiVec,
121 UnpackMonitorData& monitor) const;
122
126 void ProcessTsmsbMessage(const stsxyter::Message& message, TimeSpec& time) const;
127
128
129 private: // members
131
134
137
139 static constexpr uint32_t fkClockCycleNom = stsxyter::kulClockCycleNom;
140 static constexpr uint32_t fkClockCycleDen = stsxyter::kulClockCycleDen;
141
144 };
145
146
147} // namespace cbm::algo::much
std::tuple< std::vector< Digi_t >, Monitor_t, Aux_t > Result_t
Unpack algorithm for STS.
static constexpr uint32_t fkClockCycleDen
void ProcessTsmsbMessage(const stsxyter::Message &message, TimeSpec &time) const
Process an epoch message (TS_MSB)
UnpackMS(const UnpackPar &pars)
Construct with parameters.
void ProcessHitMessage(const stsxyter::Message &message, const TimeSpec &time, std::vector< CbmMuchDigi > &digiVec, UnpackMonitorData &monitor) const
Process a hit message.
static constexpr uint64_t fkEpochLength
~UnpackMS() override
Destructor.
static constexpr uint64_t fkEpochsPerCycle
Result_t operator()(const uint8_t *msContent, const fles::MicrosliceDescriptor &msDescr, const uint64_t tTimeslice) const override
Algorithm execution.
static constexpr uint32_t fkClockCycleNom
UnpackPar fParams
Parameter container.
static constexpr uint64_t fkCycleLength
static constexpr uint32_t kulClockCycleDen
Clock cycle denominator, equivalent to 2*160 MHz clock.
static constexpr uint32_t kuHitNbTsBinsBinning
static constexpr uint32_t kulClockCycleNom
Clock cycle nominator [ns], equivalent to 2*160 MHz clock.
static constexpr uint32_t kuTsMsbNbTsBinsBinning
STS Unpacking parameters for one eLink / ASIC.
uint64_t fTimeOffset
Time calibration parameter.
std::vector< bool > fChanMask
Channel masking flags.
std::vector< uint32_t > fAddress
CbmMuchAddress for different channels.
uint64_t currentCycle
Current epoch cycle.
uint64_t currentEpochTime
Current epoch time relative to timeslice in clock cycles.
uint32_t currentEpoch
Current epoch number within epoch cycle.
uint64_t currentTsTime
Unix time of timeslice in units of epoch length.
uint32_t fNumErrElinkOutOfRange
Elink not contained in parameters.
uint32_t fNumErrInvalidMsSize
Microslice size is not multiple of message size.
uint32_t fNumErrInvalidFirstMessage
First message is not TS_MSB or second is not EPOCH.
uint32_t fNumErrTimestampOverflow
Overflow in 64 bit time stamp.
Parameters required for the STS unpacking (specific to one component)
std::vector< UnpackElinkPar > fElinkParams
Parameters for each eLink.