CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018UnpackerAlgoRich2020.h
Go to the documentation of this file.
1/* Copyright (C) 2021 Justus-Liebig-Universitaet Giessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer] */
4
11#ifndef CbmMcbm2018UnpackerAlgoRich2020_H
12#define CbmMcbm2018UnpackerAlgoRich2020_H
13
14#include "CbmStar2019Algo.h" // mother class
15
16// STD
17#include <array>
18#include <map>
19#include <vector>
20
21// ROOT
22#include <TArrayD.h>
23#include <TH2D.h>
24
25// CbmRoot
27#include "CbmRichDigi.h"
28
31
32#define RISINGEDGEID 1
33#define FALLINGEDGEID 0
34
35#define TOTMIN -20.
36#define TOTMAX 100.
37
38enum class TrbNetState
39{
40 IDLE,
41 HEADER,
42 EPOCH,
43 TDC,
44 TRAILER,
45 CTS,
46 DEBUG
47};
48
49enum class RichErrorType
50{
57};
58
60public:
62
64
65 virtual Bool_t Init();
66
67 virtual void Reset();
68
69 virtual void Finish();
70
71 virtual Bool_t InitContainers();
72
73 virtual Bool_t ReInitContainers();
74
75 virtual TList* GetParList();
76
77 Bool_t InitParameters();
78
82 void AddMsComponentToList(size_t component, UShort_t usDetectorId);
83
84 virtual Bool_t ProcessTs(const fles::Timeslice& ts);
85
86 virtual Bool_t ProcessTs(const fles::Timeslice& ts, size_t component);
87
88 virtual Bool_t ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx);
89
90 Bool_t DebugMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx);
91
92 void SetMonitorMode(Bool_t bFlagIn = kTRUE) { fbMonitorMode = bFlagIn; }
93
94 inline void SetTimeOffsetNs(Double_t dOffsetIn = 0.0) { fdTimeOffsetNs = dOffsetIn; }
95
96 inline void DoTotCorr(Bool_t bDoToTCorr = kTRUE) { fbDoToTCorr = bDoToTCorr; }
97
98 void SetRawDataMode(Bool_t bDebug = kFALSE) { fRawDataMode = bDebug; }
99
100 Int_t Debug(const uint8_t* ptr, const size_t size);
101
102private:
108 void InitStorage();
109
110 void ProcessMicroslice(size_t const size, uint8_t const* const ptr);
111
115 Int_t ProcessTRBevent(size_t const size, uint8_t const* const ptr);
116
120 Int_t ProcessTRBeventHeader(size_t const size, uint8_t const* const ptr);
121
126 Int_t ProcessSKIPsubevent(size_t const size, uint8_t const* const ptr);
127
128 Int_t ProcessCTSsubevent(size_t const size, uint8_t const* const ptr);
129
130 Int_t ProcessTRBsubevent(size_t const size, uint8_t const* const ptr);
131
136 Int_t ProcessTRBsubsubevent(size_t const size, uint8_t const* const ptr, Int_t const hubOffset, size_t const hubSize);
137
141 Int_t ProcessTDCword(uint8_t const* const ptr, Int_t const word, size_t const size);
142
146 void ProcessTimestampWord(Int_t tdcData);
147
151 void WriteOutputDigi(Int_t fpgaID, Int_t channel, Double_t time, Double_t tot, uint64_t MSidx);
152
156 void FinalizeTs();
157
161 void ErrorMsg(uint16_t errbits, RichErrorType type, uint16_t tdcAddr = 0);
162
163 Int_t GetPixelUID(Int_t fpgaID, Int_t ch) const
164 {
165 // First 16 bits are used for the FPGA ID, then
166 // 8 bits unused and then 8 bits are used for the channel
167 return ((fpgaID << 16) | (ch & 0x00FF));
168 }
169
170 void findTDCAlignmentError(uint8_t const* const ptr, size_t const size);
171
172private: // data members
175
177
179
180 Bool_t fError;
181
182 TrbNetState fTrbState; // State of TrbNet (HEADER,TRAILER,...)
183
184 uint32_t fErrorCorr; // Offset to correct a error in datastream
185
188
189 Bool_t fSkipMs;
192
193 size_t fDataSize = 0;
194
195
201
206
210 uint64_t fTScounter;
211
215 Int_t fCurMSid;
216
221 uint64_t fCurMSidx;
222
226 Int_t fGwordCnt;
227
232
237
242
246 Bool_t fLastFeeOnHub = false;
247
248 std::vector<Int_t> fTDCAlignmentErrorPositions;
249
251
253
254 Int_t fSkipCnt = 0;
255
256private: // Stored timestamps
261
266
271
276
281
286
291
296
297private: // digi building
298 void ProcessRisingEdge(Int_t subSubEvId, Int_t channel, Double_t time);
299
300 void ProcessFallingEdge(Int_t subSubEvId, Int_t channel, Double_t time);
301
308 std::vector<CbmMcbmRichEdge> fRisingEdgesBuf;
309
313 std::vector<CbmMcbmRichEdge> fFallingEdgesBuf;
314
315public: // histograms
319 Bool_t CreateHistograms();
320
324 // Bool_t FillHistograms();
325
329 Bool_t ResetHistograms();
330
331 TH1D* GetTotH1(Int_t fpgaID, Int_t channel);
332 TH2D* GetTotH2(Int_t fpgaID);
333 /*
334 TH2D* fhTDCch0re_minusCTSch0re; //!
335 TH2D* fhTDCch0re_minusCTSch2re; //!
336 TH2D* fhTDCch0re_minusCTSch2fe; //!
337 TH2D* fhTDCch0re_minusPrevCTSch0re; //!
338 TH2D* fhTDCch0re_minusPrevCTSch2re; //!
339 TH2D* fhTDCch0re_minusPrevCTSch2fe; //!
340
341 std::vector<TH2D*> fhTDCre_minusTDCch0re; //!
342
343 std::vector<TH2D*> fhTDCre_minusPrevTDCch0re; //!
344*/
345 std::vector<TH2D*> fhTDCre_corrected1;
346
347 std::vector<TH2D*> fhTDCre_corrected2;
348
349 std::vector<TCanvas*> fcTot2d;
350
351 TH1* fhVectorSize = nullptr;
352 TH1* fhVectorCapacity = nullptr;
353
354 //TH2* fhDigisInChnl = nullptr;
355 //TH2* fhDigisInDiRICH = nullptr;
356
357 TH2D* fhTdcErrors = nullptr;
358 TH2D* fhEventErrors = nullptr;
359
360 TH2D* fhDiRICHWords = nullptr;
361 TH2D* fhChnlWords = nullptr;
362
363 TH1* fhEventSize = nullptr;
364 TH2* fhSubEventSize = nullptr;
365 TH2* fhSubSubEventSize = nullptr;
366 TH2* fhChnlSize = nullptr;
367
368 std::array<unsigned int, 33> fChnlMsgCnt;
369
370 bool fDebugPrint = 0;
371 std::map<uint16_t, uint16_t> fMapFEE;
372
373 std::map<Int_t, std::map<Int_t, TH1D*>> fhTotMap;
374
375 std::map<Int_t, TH2D*> fhTot2dMap;
376
378 Double_t fdCapacityIncFactor = 1.1;
379
380 inline void SetVectCapInc(Double_t dIncFact) { fdCapacityIncFactor = dIncFact; }
381
383};
384
385#endif // CbmMcbm2018UnpackerAlgoRich2020_H
static constexpr size_t size()
Definition KfSimdPseudo.h:2
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
TH1D * GetTotH1(Int_t fpgaID, Int_t channel)
Int_t ProcessCTSsubevent(size_t const size, uint8_t const *const ptr)
TrbNetState fTrbState
flag for an error in the datastream
Bool_t fbDoToTCorr
User setting: kTRUE activates ToT correction from Parameterfile.
void ProcessFallingEdge(Int_t subSubEvId, Int_t channel, Double_t time)
std::vector< CbmMcbmRichEdge > fFallingEdgesBuf
Exclude from ROOT dictionnary due to missing empty constructor!!
Int_t ProcessTRBevent(size_t const size, uint8_t const *const ptr)
Int_t ProcessTRBsubsubevent(size_t const size, uint8_t const *const ptr, Int_t const hubOffset, size_t const hubSize)
Bool_t fRawDataMode
Switch ON the filling of a additional set of histograms.
Bool_t DebugMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
void ProcessMicroslice(size_t const size, uint8_t const *const ptr)
Double_t fdTimeOffsetNs
User settings: Data correction parameters.
std::vector< CbmMcbmRichEdge > fRisingEdgesBuf
Int_t ProcessTRBeventHeader(size_t const size, uint8_t const *const ptr)
void ErrorMsg(uint16_t errbits, RichErrorType type, uint16_t tdcAddr=0)
Int_t ProcessTRBsubevent(size_t const size, uint8_t const *const ptr)
void findTDCAlignmentError(uint8_t const *const ptr, size_t const size)
void ProcessRisingEdge(Int_t subSubEvId, Int_t channel, Double_t time)
virtual Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
Int_t GetPixelUID(Int_t fpgaID, Int_t ch) const
Int_t ProcessSKIPsubevent(size_t const size, uint8_t const *const ptr)
Int_t ProcessTDCword(uint8_t const *const ptr, Int_t const word, size_t const size)
Bool_t fbDebugMonitorMode
Switch ON the filling of a minimal set of histograms.
std::map< Int_t, std::map< Int_t, TH1D * > > fhTotMap
virtual Bool_t ProcessTs(const fles::Timeslice &ts)
ClassDef(CbmMcbm2018UnpackerAlgoRich2020, 1)
void WriteOutputDigi(Int_t fpgaID, Int_t channel, Double_t time, Double_t tot, uint64_t MSidx)
Bool_t CreateHistograms()
Exclude from ROOT dictionnary due to missing empty constructor!!