CbmRoot
Loading...
Searching...
No Matches
CbmMuchUnpackAlgo.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Fair GmbH, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
17#ifndef CbmMuchUnpackAlgo_H
18#define CbmMuchUnpackAlgo_H
19
20
21#include "CbmErrorMessage.h" // REMARK see remark in CbmMuchUnpackConfig
22#include "CbmMuchDigi.h"
24#include "CbmMuchUnpackPar.h"
25#include "CbmRecoUnpackAlgo.tmpl"
26#include "Timeslice.hpp" // timeslice
27
28#include <FairTask.h> // for InitStatus
29
30#include <Rtypes.h> // for types
31#include <RtypesCore.h>
32
33#include <cstddef>
34#include <cstdint>
35#include <memory>
36#include <set>
37#include <utility>
38
39class CbmMuchUnpackAlgo : public CbmRecoUnpackAlgo<CbmMuchDigi, CbmMuchDigi, CbmErrorMessage> {
40 public:
43
45 CbmMuchUnpackAlgo(std::string name);
46
48 virtual ~CbmMuchUnpackAlgo();
49
52
55
56 // Setters
57
59 void SetMinAdcCut(uint32_t value) { fdAdcCut = value; }
60
61 void SetMinAdcCut(uint32_t febid, uint32_t value) { fdAdcCut_perFeb[febid] = value; }
62
64 void SetAsicTimeOffsetVec(std::vector<double> value) { fvdTimeOffsetNsAsics.swap(value); }
65
67 void SetDuplicatesRejection(bool bIn = true, bool bDiffAdc = true)
68 {
70 fbDupliWithoutAdc = bDiffAdc;
71 }
72
82 virtual std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>*
83 GetParContainerRequest(std::string geoTag, std::uint32_t runId);
84
92 void MaskNoisyChannel(const uint32_t uFeb, const uint32_t uChan, const bool bMasked = true);
93
95 void SetMonitor(std::shared_ptr<CbmMuchUnpackMonitor> monitor) { fMonitor = monitor; }
96
102 void SetParFileName(std::string sNewName) { fParFileName = sNewName; }
103
104 void SetInactiveChannel(uint32_t channel) { fInactiveChannels.insert(channel); }
105
106 protected:
114 uint32_t getFebIndex(uint32_t dpbidx, uint32_t crobidx, uint16_t elinkidx);
116 virtual void finish()
117 {
118 if (fMonitor) fMonitor->Finish();
119 LOG(info) << "Missed messages: wrong address generated: " << fuSkippMessNoValidAddress;
120 LOG(info) << "Missed messages: wrong FEB Position inPar: " << fuSkippMessNoValidFebPosition;
121 LOG(info) << "Missed messages: wrong Elink generated: " << fuSkippMessNoValidElink;
122 return;
123 }
124
131 uint64_t getFullTimeStamp(const uint16_t usRawTs);
132
138 Bool_t init();
139
142
145
152 Bool_t initParSet(FairParGenericSet* parset);
153
160 Bool_t initParSet(CbmMuchUnpackPar* parset);
161
174 void loopMsMessages(const uint8_t* msContent, const uint32_t uSize, const size_t uMsIdx);
175
177 void printActiveCrobs(CbmMuchUnpackPar* parset, const std::vector<std::vector<bool>>& vbCrobActiveFlag);
178
181 const std::vector<std::vector<std::vector<int32_t>>>& /*viFebModuleIdx*/,
182 const std::vector<std::vector<std::vector<int32_t>>>& /*viFebModuleSide*/);
183
185 void processEpochInfo(const stsxyter::Message& /*mess*/) { return; };
186
188 void processErrorInfo(const stsxyter::Message& mess);
189
191 void processHitInfo(const stsxyter::Message& mess);
192
194 void processStatusInfo(const stsxyter::Message& mess, uint32_t uIdx);
195
197 void processTsMsbInfo(const stsxyter::Message& mess, uint32_t uMessIdx, uint32_t uMsIdx);
198
200 void refreshTsMsbFields(const uint32_t imslice, const size_t mstime);
201 uint32_t CreateMuchAddress(uint32_t dpbidx, int32_t febId, uint32_t usChan);
202
212 bool setDerivedTsParameters(size_t /*itimeslice*/) { return true; }
213
225 bool unpack(const fles::Timeslice* ts, std::uint16_t icomp, UInt_t imslice);
226
227
228 // Settings
230 uint32_t fdAdcCut = 0;
231
233 std::map<uint32_t, uint32_t> fdAdcCut_perFeb;
234
236 std::vector<double> fvdTimeOffsetNsAsics = {};
237
240
242 bool fbDupliWithoutAdc = true;
243
245 bool fbUseChannelMask = false;
246
248 std::vector<std::vector<bool>> fvvbMaskedChannels = {};
249
250
251 // Parameter members
253 std::map<uint32_t, uint32_t> fDpbIdIndexMap = {};
254
256 uint32_t fuCurrDpbIdx = 0;
257
259 std::vector<bool> fvbMaskedComponents;
260
262 uint32_t fuNbFebs = 0;
263
265 std::vector<uint32_t> fvbFebAdcCut = {};
266
268 uint32_t fNrElinksPerCrob = 0;
269
271 uint32_t fNrAsicsPerCrob = 0;
272
274 uint32_t fNrAsicsPerFeb = 0;
275
277 uint32_t fNrChsPerAsic = 0;
278
280 uint32_t fNrChsPerFeb = 0;
281
283 uint32_t fNrCrobPerDpb = 0;
284
286 uint32_t fNrFebsPerCrob = 0;
287
289 std::vector<int> fElinkIdxToFebIdxVec = {};
290
292 std::vector<std::pair<uint32_t, uint32_t>> fElinkIdxToAsicIdxVec = {};
293
295 std::vector<std::vector<std::vector<int32_t>>> fviFebType = {};
296
298 std::vector<bool> fvbFebPulser;
300 std::vector<int32_t> fviFebAddress;
302 std::vector<int32_t> fviFebSide;
304 std::vector<double> fvdFebAdcGain;
306 std::vector<double> fvdFebAdcOffs;
307
308 // Internal variables
310 std::vector<uint64_t> fvulCurrentTsMsb = {};
312 std::vector<uint32_t> fvuCurrentTsMsbCycle = {};
313
315 uint64_t fulTsStartInTsMsb = 0;
317 std::vector<uint64_t> fulTsMsbIndexInTs = {};
318
320 static const uint32_t kuMaxTsMsbDiffDuplicates = 8;
322 std::vector<std::vector<uint16_t>> fvvusLastTsChan = {};
324 std::vector<std::vector<uint16_t>> fvvusLastAdcChan = {};
326 std::vector<std::vector<uint64_t>> fvvulLastTsMsbChan = {};
327
328 // Monitoring
330 std::shared_ptr<CbmMuchUnpackMonitor> fMonitor = nullptr;
331
333 uint64_t fMsStartTime = 0;
334
335 std::set<uint32_t> fInactiveChannels = {};
336
338
339 private:
345 std::string fParFileName = "mMuchPar.par";
346 ClassDef(CbmMuchUnpackAlgo, 2)
347};
348
349#endif // CbmMuchUnpackAlgo_H
std::vector< int32_t > fviFebSide
Module side for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::vector< int32_t > fviFebAddress
STS address for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
uint32_t CreateMuchAddress(uint32_t dpbidx, int32_t febId, uint32_t usChan)
void printAddressMaps(CbmMuchUnpackPar *parset, const std::vector< std::vector< std::vector< int32_t > > > &, const std::vector< std::vector< std::vector< int32_t > > > &)
experts please add description
Bool_t initParSet(FairParGenericSet *parset)
Handles the distribution of the hidden derived classes to their explicit functions.
uint32_t fNrAsicsPerFeb
Number of ASICs per FEB.
bool fbDupliWithoutAdc
If rejecting duplicate digis, enables rejection even if ADC differs.
std::vector< uint64_t > fvulCurrentTsMsb
Current TS MSB for each DPB.
uint64_t fuSkippMessNoValidAddress
For static/inline mapping functions.
uint32_t fNrElinksPerCrob
Number of eLinks per CROB.
std::vector< double > fvdFebAdcOffs
ADC offset in e-, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
bool setDerivedTsParameters(size_t)
Set the Derived Ts Parameters.
std::vector< std::vector< uint64_t > > fvvulLastTsMsbChan
TS MSB in TS of last hit message for each channel, [ AsicIdx ][ Chan ].
virtual ~CbmMuchUnpackAlgo()
Destroy the Cbm Much Unpack Algo object.
void processErrorInfo(const stsxyter::Message &mess)
experts please add description
uint32_t fNrFebsPerCrob
Number of FEBs per CROB.
std::vector< std::vector< uint16_t > > fvvusLastTsChan
TS of last hit message for each channel, [ AsicIdx ][ Chan ].
std::map< uint32_t, uint32_t > fdAdcCut_perFeb
Minimum adc cut per Feb to store a hit.
CbmMuchUnpackAlgo()
Create the Cbm Much Unpack Algo object.
std::vector< bool > fvbMaskedComponents
Masked components to print out missing component only once.
virtual void finish()
Finish function for this algorithm base clase.
std::vector< uint32_t > fvuCurrentTsMsbCycle
Current TS MSB cycle for DPB.
bool fbRejectDuplicateDigis
Enables the rejection of duplicate digis.
void SetMinAdcCut(uint32_t value)
Set the minimum adc cut value.
std::map< uint32_t, uint32_t > fDpbIdIndexMap
Map of DPB Identifier to DPB index.
void initInternalStatus(CbmMuchUnpackPar *parset)
experts please add description here
void processTsMsbInfo(const stsxyter::Message &mess, uint32_t uMessIdx, uint32_t uMsIdx)
experts please add description
void processStatusInfo(const stsxyter::Message &mess, uint32_t uIdx)
experts please add description
CbmMuchUnpackPar * fUnpackPar
static const uint32_t kuMaxTsMsbDiffDuplicates
Duplicate hits suppression.
std::vector< std::vector< bool > > fvvbMaskedChannels
Vector of channel masks, [ NbFeb ][ NbCHanInFeb ], used only if fbUseChannelMask is true.
uint32_t fNrCrobPerDpb
Number of CROBs per DPB.
uint64_t fMaskedNoisyHitsFromCbmMuchAddress
virtual std::vector< std::pair< std::string, std::shared_ptr< FairParGenericSet > > > * GetParContainerRequest(std::string geoTag, std::uint32_t runId)
Get the requested parameter containers. To be defined in the derived classes! Return the required par...
std::vector< std::vector< uint16_t > > fvvusLastAdcChan
ADC of last hit message for each channel, [ AsicIdx ][ Chan ].
bool unpack(const fles::Timeslice *ts, std::uint16_t icomp, UInt_t imslice)
Unpack a given microslice. To be implemented in the derived unpacker algos.
std::shared_ptr< CbmMuchUnpackMonitor > fMonitor
Potential (online) monitor for the unpacking process.
void SetMonitor(std::shared_ptr< CbmMuchUnpackMonitor > monitor)
Set a predefined monitor.
void refreshTsMsbFields(const uint32_t imslice, const size_t mstime)
experts please add description here
void SetInactiveChannel(uint32_t channel)
uint32_t fNrChsPerAsic
Number of Channels per Asic.
uint64_t getFullTimeStamp(const uint16_t usRawTs)
Get the Full Time Stamp from raw time stamp.
CbmMuchUnpackAlgo(const CbmMuchUnpackAlgo &)=delete
Copy constructor - not implemented.
uint32_t fuNbFebs
Number of FEBs with StsXyter ASICs.
void processEpochInfo(const stsxyter::Message &)
experts please add description marked as not used currently
std::vector< uint64_t > fulTsMsbIndexInTs
Current TS MSB cycle for DPB relative to TS start.
std::vector< std::pair< uint32_t, uint32_t > > fElinkIdxToAsicIdxVec
Vector used for the translation between eLink index and Asic index first is feb type A second is feb ...
std::vector< int > fElinkIdxToFebIdxVec
Vector used for the translation between eLink index and FEB index.
void SetParFileName(std::string sNewName)
Sets the name of the parameter file to be used.
uint32_t fdAdcCut
Minimum adc cut to store a hit.
Bool_t init()
Intialisation at begin of run. Special inits of the derived algos.
uint32_t fuCurrDpbIdx
Current dpb id.
std::vector< double > fvdFebAdcGain
ADC gain in e-/b, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::vector< uint32_t > fvbFebAdcCut
ADC cuts for FEBs.
void loopMsMessages(const uint8_t *msContent, const uint32_t uSize, const size_t uMsIdx)
Initialize and transfer the informations to the parameters storage vectors.
void printActiveCrobs(CbmMuchUnpackPar *parset, const std::vector< std::vector< bool > > &vbCrobActiveFlag)
experts please add description
void SetDuplicatesRejection(bool bIn=true, bool bDiffAdc=true)
Enable/Disable the duplicate digis rejection, without or with same ADC checks.
bool fbUseChannelMask
flag if channel mask is to be used or not. Set automatically via MaskNoisyChannels
uint32_t fNrAsicsPerCrob
Number of ASICs per CROB.
uint64_t fuSkippMessNoValidFebPosition
std::vector< double > fvdTimeOffsetNsAsics
Time offsets per Asic???
std::vector< bool > fvbFebPulser
Pulser flag for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::string fParFileName
Settings from parameter file.
void SetAsicTimeOffsetVec(std::vector< double > value)
Set the time offset per Asic.
std::vector< std::vector< std::vector< int32_t > > > fviFebType
FEB type, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ], 0 = A, 1 = B, -1 if inactive.
CbmMuchUnpackAlgo & operator=(const CbmMuchUnpackAlgo &)=delete
Assignment operator - not implemented.
uint32_t getFebIndex(uint32_t dpbidx, uint32_t crobidx, uint16_t elinkidx)
Get the Asic Index.
void MaskNoisyChannel(const uint32_t uFeb, const uint32_t uChan, const bool bMasked=true)
Mask a Noisy Channel.
void processHitInfo(const stsxyter::Message &mess)
Process the information of the hit message and create a MuchDigi from it.
void initDpbIdIndexMap(CbmMuchUnpackPar *parset)
Initialize the DpbIdIndexMap with the information from the parset.
void SetMinAdcCut(uint32_t febid, uint32_t value)
uint64_t fMsStartTime
Current µSlice time.
std::set< uint32_t > fInactiveChannels
uint64_t fulTsStartInTsMsb
Start time of the TS expressed in TS_MSB instead of ns.
uint32_t fNrChsPerFeb
Number of Channels per FEB.