CbmRoot
Loading...
Searching...
No Matches
sts/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 "CbmStsDigi.h"
7#include "Definitions.h"
8#include "MicrosliceDescriptor.hpp"
9#include "StsXyterMessage.h"
10#include "UnpackMSBase.h"
11
12#include <cassert>
13#include <cstddef>
14#include <cstdint>
15#include <memory>
16#include <vector>
17
18namespace cbm::algo::sts
19{
20
27 int32_t fAddress = 0;
28 uint32_t fAsicNr = 0;
29 uint64_t fTimeOffset = 0.;
30 double fAdcOffset = 0.;
31 double fAdcGain = 0.;
32 uint32_t fAdcMinCut = 0.;
33 std::vector<double> fWalk;
34 std::vector<bool> fChanMask;
35 };
36
37
43 struct UnpackPar {
44 uint32_t fNumChansPerAsic = 0;
45 uint32_t fNumAsicsPerModule = 0;
46 std::vector<UnpackElinkPar> fElinkParams = {};
47 bool fWriteAux = false;
48 };
49
50
60 uint32_t fNumErrInvalidMsSize = 0;
62 bool HasErrors()
63 {
66 return (numErrors > 0 ? true : false);
67 }
68 std::string print()
69 {
70 std::stringstream ss;
71 ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
73 return ss.str();
74 }
75 };
76
82 struct QaDigi {
83
84 QaDigi(bool missed, int32_t addr, int32_t chan, uint32_t t, uint16_t c, uint16_t e)
85 : missedEvent(missed)
86 , address(addr)
87 , channel(chan)
88 , time(t)
89 , charge(c)
90 , elink(e)
91 {
92 }
93
95 int32_t address;
96 int32_t channel;
97 uint32_t time;
98 uint16_t charge;
99 uint16_t elink;
100 };
101
108 std::vector<QaDigi> fQaDigis;
109 };
110
117 class UnpackMS : public UnpackMSBase<CbmStsDigi, UnpackMonitorData, UnpackAuxData> {
118
119 public:
121 UnpackMS(const UnpackPar& pars);
122
123
125 ~UnpackMS() override;
126
127
134 Result_t operator()(const uint8_t* msContent, const fles::MicrosliceDescriptor& msDescr,
135 const uint64_t tTimeslice) const override;
136
140 void SetParams(std::unique_ptr<UnpackPar> params) { fParams = *(std::move(params)); }
141
142 private: // types
152
153 private: // methods
160 void ProcessHitMessage(const stsxyter::Message& message, const TimeSpec& time, std::vector<CbmStsDigi>& digiVec,
161 UnpackMonitorData& monitor, UnpackAuxData& aux) const;
162
166 void ProcessTsmsbMessage(const stsxyter::Message& message, TimeSpec& time) const;
167
168
169 private: // members
171
174
177
179 static constexpr uint32_t fkClockCycleNom = stsxyter::kulClockCycleNom;
180 static constexpr uint32_t fkClockCycleDen = stsxyter::kulClockCycleDen;
181
184 };
185
186} /* namespace cbm::algo::sts */
std::tuple< std::vector< Digi_t >, Monitor_t, Aux_t > Result_t
Unpack algorithm for STS.
void ProcessTsmsbMessage(const stsxyter::Message &message, TimeSpec &time) const
Process an epoch message (TS_MSB)
static constexpr uint32_t fkClockCycleNom
UnpackPar fParams
Parameter container.
void ProcessHitMessage(const stsxyter::Message &message, const TimeSpec &time, std::vector< CbmStsDigi > &digiVec, UnpackMonitorData &monitor, UnpackAuxData &aux) const
Process a hit message.
static constexpr uint32_t fkClockCycleDen
Result_t operator()(const uint8_t *msContent, const fles::MicrosliceDescriptor &msDescr, const uint64_t tTimeslice) const override
Algorithm execution.
void SetParams(std::unique_ptr< UnpackPar > params)
Set the parameter container.
static constexpr uint64_t fkEpochsPerCycle
static constexpr uint64_t fkCycleLength
~UnpackMS() override
Destructor.
UnpackMS(const UnpackPar &pars)
Default constructor.
static constexpr uint64_t fkEpochLength
std::uint32_t u32
Definition Definitions.h:21
std::uint64_t u64
Definition Definitions.h:23
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
Extended digi which contains auxiliary QA information.
QaDigi(bool missed, int32_t addr, int32_t chan, uint32_t t, uint16_t c, uint16_t e)
std::vector< QaDigi > fQaDigis
uint64_t fTimeOffset
Time calibration parameter.
double fAdcGain
Charge calibration parameter.
int32_t fAddress
CbmStsAddress for the connected module.
double fAdcOffset
Charge calibration parameter.
uint32_t fAdcMinCut
Minimum Acd cut.
std::vector< bool > fChanMask
Channel masking flags.
std::vector< double > fWalk
Walk correction coefficients.
uint32_t fAsicNr
Number of connected ASIC within the module.
Structure to hold the current time information for the current microslice.
u64 currentEpochTime
Current epoch time relative to timeslice in clock cycles.
u64 currentTsTime
Unix time of timeslice in units of epoch length.
u64 currentCycle
Current epoch cycle.
u32 currentEpoch
Current epoch number within epoch cycle.
uint32_t fNumErrInvalidMsSize
Microslice size is not multiple of message size.
uint32_t fNumErrElinkOutOfRange
Elink not contained in parameters.
uint32_t fNumErrTimestampOverflow
Overflow in 64 bit time stamp.
uint32_t fNumErrInvalidFirstMessage
First message is not TS_MSB or second is not EPOCH.
bool fWriteAux
Write auxiliary data for module.
uint32_t fNumAsicsPerModule
Number of ASICS per module.
uint32_t fNumChansPerAsic
Number of channels per ASIC.
std::vector< UnpackElinkPar > fElinkParams
Parameters for each eLink.