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
16
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, 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 void SetElinkFebMap2022(Bool_t bFlag = kTRUE) { fbElinkFebMap2022 = bFlag; }
107
108 protected:
116 uint32_t getFebIndex(uint32_t dpbidx, uint32_t crobidx, uint16_t elinkidx);
118 virtual void finish()
119 {
120 if (fMonitor) fMonitor->Finish();
121 LOG(info) << "Missed messages: wrong address generated: " << fuSkippMessNoValidAddress;
122 LOG(info) << "Missed messages: wrong FEB Position inPar: " << fuSkippMessNoValidFebPosition;
123 LOG(info) << "Missed messages: wrong Elink generated: " << fuSkippMessNoValidElink;
124 return;
125 }
126
133 uint64_t getFullTimeStamp(const uint16_t usRawTs);
134
140 Bool_t init();
141
144
147
154 Bool_t initParSet(FairParGenericSet* parset);
155
163
165
176 void loopMsMessages(const uint8_t* msContent, const uint32_t uSize, const size_t uMsIdx);
177
179 void printActiveCrobs(CbmMuchUnpackPar* parset, const std::vector<std::vector<bool>>& vbCrobActiveFlag);
180
183 const std::vector<std::vector<std::vector<int32_t>>>& /*viFebModuleIdx*/,
184 const std::vector<std::vector<std::vector<int32_t>>>& /*viFebModuleSide*/);
185
187 void processEpochInfo(const stsxyter::Message& /*mess*/) { return; };
188
190 void processErrorInfo(const stsxyter::Message& mess);
191
193 void processHitInfo(const stsxyter::Message& mess);
194
196 void processStatusInfo(const stsxyter::Message& mess, uint32_t uIdx);
197
199 void processTsMsbInfo(const stsxyter::Message& mess, uint32_t uMessIdx, uint32_t uMsIdx);
200
202 void refreshTsMsbFields(const uint32_t imslice, const size_t mstime);
203 uint32_t CreateMuchAddress(uint32_t dpbidx, int32_t febId, uint32_t usChan);
204
214 bool setDerivedTsParameters(size_t /*itimeslice*/) { return true; }
215
227 bool unpack(const fles::Timeslice* ts, uint16_t icomp, UInt_t imslice);
228
229
230 // Settings
232 uint32_t fdAdcCut = 0;
233
235 std::map<uint32_t, uint32_t> fdAdcCut_perFeb;
236
238 std::vector<double> fvdTimeOffsetNsAsics = {};
239
242
244 bool fbDupliWithoutAdc = true;
245
247 bool fbUseChannelMask = false;
248
250 std::vector<std::vector<bool>> fvvbMaskedChannels = {};
251
252
253 // Parameter members
255 std::map<uint32_t, uint32_t> fDpbIdIndexMap = {};
256
258 uint32_t fuCurrDpbIdx = 0;
259
261 std::vector<bool> fvbMaskedComponents;
262
264 uint32_t fuNbFebs = 0;
265
267 std::vector<uint32_t> fvbFebAdcCut = {};
268
270 uint32_t fNrElinksPerCrob = 0;
271
273 uint32_t fNrAsicsPerCrob = 0;
274
276 uint32_t fNrAsicsPerFeb = 0;
277
279 uint32_t fNrChsPerAsic = 0;
280
282 uint32_t fNrChsPerFeb = 0;
283
285 uint32_t fNrCrobPerDpb = 0;
286
288 uint32_t fNrFebsPerCrob = 0;
289
291 std::vector<int> fElinkIdxToFebIdxVec = {};
292
294 std::vector<std::pair<uint32_t, uint32_t>> fElinkIdxToAsicIdxVec = {};
295
297 std::vector<std::vector<std::vector<int32_t>>> fviFebType = {};
298
300 std::vector<bool> fvbFebPulser;
302 std::vector<int32_t> fviFebAddress;
304 std::vector<int32_t> fviFebSide;
306 std::vector<double> fvdFebAdcGain;
308 std::vector<double> fvdFebAdcOffs;
309
310 // Internal variables
312 std::vector<uint64_t> fvulCurrentTsMsb = {};
314 std::vector<uint32_t> fvuCurrentTsMsbCycle = {};
315
317 uint64_t fulTsStartInTsMsb = 0;
319 std::vector<uint64_t> fulTsMsbIndexInTs = {};
320
322 static const uint32_t kuMaxTsMsbDiffDuplicates = 8;
324 std::vector<std::vector<uint16_t>> fvvusLastTsChan = {};
326 std::vector<std::vector<uint16_t>> fvvusLastAdcChan = {};
328 std::vector<std::vector<uint64_t>> fvvulLastTsMsbChan = {};
329
330 // Monitoring
332 std::shared_ptr<CbmMuchUnpackMonitor> fMonitor = nullptr;
333
335 uint64_t fMsStartTime = 0;
336
337 std::set<uint32_t> fInactiveChannels = {};
338
340
341 private:
347 std::string fParFileName = "mMuchPar.par";
348
351
352 ClassDef(CbmMuchUnpackAlgo, 2)
353};
354
355#endif // CbmMuchUnpackAlgo_H
bool Bool_t
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.
virtual std::vector< std::pair< std::string, std::shared_ptr< FairParGenericSet > > > * GetParContainerRequest(std::string geoTag, uint32_t runId)
Get the requested parameter containers. To be defined in the derived classes! Return the required par...
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 SetElinkFebMap2022(Bool_t bFlag=kTRUE)
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
bool unpack(const fles::Timeslice *ts, uint16_t icomp, UInt_t imslice)
Unpack a given microslice. To be implemented in the derived unpacker algos.
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
std::vector< std::vector< uint16_t > > fvvusLastAdcChan
ADC of last hit message for each channel, [ AsicIdx ][ Chan ].
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.
Bool_t fbElinkFebMap2022
Backward compatibility with 2022 data.
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 micro-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.