CbmRoot
Loading...
Searching...
No Matches
trd2d/UnpackMS.h
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pascal Raisig, Alexandru Bercuci, Dominik Smith [committer] */
4#pragma once
5
6#include "CbmTrdDigi.h"
8#include "MicrosliceDescriptor.hpp"
9#include "UnpackMSBase.h"
10
11#include <array>
12#include <memory>
13#include <sstream>
14
15#define NFASPMOD 180
16#define NCROBMOD 5
17#define NFASPCROB NFASPMOD / NCROBMOD
18#define NFASPCH 16
19
20#define FASP_EPOCH_LENGTH 128
21
22namespace cbm::algo::trd2d
23{
24
26 {
27 kEpoch = 0,
28 kData
29 };
30
32 struct FaspMessage {
33 FaspMessage(uint8_t c, uint8_t typ, uint8_t t, uint16_t d, uint8_t rob, uint8_t asic);
34 uint8_t ch = 0;
35 uint8_t type = 0;
36 uint8_t tlab = 0;
37 uint16_t data = 0;
38 uint32_t epoch = 0;
39 uint32_t mod = 0;
40 uint8_t crob = 0;
41 uint8_t fasp = 0;
42 };
43
50 int32_t fPadAddress;
51 bool fMask;
52 uint64_t fDaqOffset = 0;
53 };
54
61 std::vector<UnpackChannelPar> fChanParams;
62 };
63
69 struct UnpackPar {
70 int32_t fSystemTimeOffset = 0;
71 uint16_t fModId = 0;
72 uint8_t fCrobId = 0;
73 std::vector<UnpackAsicPar> fAsicParams = {};
74 };
75
76
83 uint32_t fNumSelfTriggeredData = 0;
84 uint32_t fNumIncompleteDigis = 0;
85 uint32_t fNumErrEndBitSet = 0;
86
87 bool HasErrors()
88 {
89 uint32_t numErrors = fNumErrEndBitSet;
90 return (numErrors > 0 ? true : false);
91 }
92 std::string print()
93 {
94 std::stringstream ss;
95 ss << "stats " << fNumSelfTriggeredData << " | " << fNumIncompleteDigis << " | errors " << fNumErrEndBitSet
96 << " | ";
97 return ss.str();
98 }
99 };
100
108 };
109
115 class UnpackMS : public UnpackMSBase<CbmTrdDigi, UnpackMonitorData, UnpackAuxData> {
116
117 public:
119 UnpackMS(const UnpackPar& pars);
120
121
123 ~UnpackMS() override;
124
125
132 Result_t operator()(const uint8_t* msContent, const fles::MicrosliceDescriptor& msDescr,
133 const uint64_t tTimeslice) const override;
134
138 void SetParams(std::unique_ptr<UnpackPar> params) { fParams = *(std::move(params)); }
139
140 private: // Types
141 struct MsContext {
143
144 std::array<std::vector<CbmTrdDigi>, NFASPMOD* NFASPCH> fDigiBuffer = {
145 {}};
146 };
147
148 private: // members
150
151 bool pushDigis(std::vector<FaspMessage> messages, const uint64_t time, MsContext& ctx) const;
152
154 std::vector<CbmTrdDigi> FinalizeComponent(MsContext& ctx) const;
155
156 // Constants
172 static const std::uint8_t fBytesPerWord = 4;
173 };
174
175
176} // namespace cbm::algo::trd2d
std::tuple< std::vector< Digi_t >, Monitor_t, Aux_t > Result_t
Unpack algorithm for TRD.
static const std::uint8_t fBytesPerWord
Bytes per FASP frame stored in the microslices (32 bits words)
Result_t operator()(const uint8_t *msContent, const fles::MicrosliceDescriptor &msDescr, const uint64_t tTimeslice) const override
Algorithm execution.
UnpackMS(const UnpackPar &pars)
Construct from parameters.
std::vector< CbmTrdDigi > FinalizeComponent(MsContext &ctx) const
Finalize component (e.g. copy from temp buffers)
void SetParams(std::unique_ptr< UnpackPar > params)
Set the parameter container.
bool pushDigis(std::vector< FaspMessage > messages, const uint64_t time, MsContext &ctx) const
~UnpackMS() override
Destructor.
UnpackPar fParams
Parameter container.
Data structure for unpacking the FASP word.
uint8_t tlab
time of the digi inside the epoch
uint8_t type
message type 0 = epoch, 1 = data (not used for the moment)
FaspMessage(uint8_t c, uint8_t typ, uint8_t t, uint16_t d, uint8_t rob, uint8_t asic)
uint32_t epoch
epoch id (not used for the moment)
uint8_t ch
ch id in the FASP
uint32_t mod
full module address according to CbmTrdAddress
uint8_t fasp
FASP id in the module.
uint8_t crob
CROB id in the module.
TRD Unpacking parameters for one Asic.
std::vector< UnpackChannelPar > fChanParams
Parameters for different channels.
TRD Unpacking parameters for one Asic channel.
int32_t fPadAddress
Pad address for channel.
bool fMask
Flag for channel masking.
uint64_t fDaqOffset
Time calibration parameter.
UnpackMonitorData fMonitor
Container for monitoring data.
std::array< std::vector< CbmTrdDigi >, NFASPMOD *NFASPCH > fDigiBuffer
uint32_t fNumSelfTriggeredData
word fulfills data & 0x2000
uint32_t fNumIncompleteDigis
incomplete digis left in pads after finalization
uint32_t fNumErrEndBitSet
Corrupted data with end bit set.
Parameters required for the TRD unpacking (specific to one component)
uint16_t fModId
Module ID of component.
int32_t fSystemTimeOffset
Time calibration parameter.
uint8_t fCrobId
CROB ID of component.
std::vector< UnpackAsicPar > fAsicParams
Parameters for each ASIC.
#define NFASPCH
#define NFASPMOD