CbmRoot
Loading...
Searching...
No Matches
CbmTofUnpackMonitor.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5#ifndef CbmTofUnpackMonitor_H
6#define CbmTofUnpackMonitor_H
7
8#include "CbmMcbm2018TofPar.h"
9#include "Rtypes.h"
10#include "TH1.h"
11#include "TH2.h"
12#include "TProfile.h"
13#include "TProfile2D.h"
14
15#include <array>
16#include <cstdint>
17#include <vector>
18
19class TCanvas;
20
22 public:
24
25 virtual ~CbmTofUnpackMonitor();
26
28 Bool_t Init(CbmMcbm2018TofPar* digiParSet);
29
30 Bool_t CreateHistograms();
31 Bool_t ResetHistograms();
32 void DrawCanvases();
33
34 Bool_t CreateBmonHistograms();
35 Bool_t ResetBmonHistograms(Bool_t bResetTime);
36 void DrawBmonCanvases();
37
39 Bool_t ResetHistogramsMicroSpills(Bool_t bResetTime);
41
42 Bool_t CreateMsComponentSizeHistos(UInt_t component);
43 Bool_t ResetMsComponentSizeHistos(UInt_t component);
44
46 void Finish();
47
48 void SetHistoFileName(TString nameIn) { fHistoFileName = nameIn; }
49
50 inline void SetPulserTotLimits(UInt_t uMin, UInt_t uMax)
51 {
52 fuMinTotPulser = uMin;
53 fuMaxTotPulser = uMax;
54 }
55 inline void SetSpillThreshold(UInt_t uCntLimit) { fuOffSpillCountLimit = uCntLimit; }
56 inline void SetSpillThresholdNonPulser(UInt_t uCntLimit) { fuOffSpillCountLimitNonPulser = uCntLimit; }
57 inline void SetSpillCheckInterval(Double_t dIntervalSec) { fdSpillCheckInterval = dIntervalSec; }
58 void SetBmonChannelMap(std::vector<uint32_t> vChanMapIn);
59
60 void SetLongDurationLimits(UInt_t uDurationSeconds, UInt_t uBinSize)
61 {
62 //fbLongHistoEnable = kTRUE;
63 fuLongHistoNbSeconds = uDurationSeconds;
64 fuLongHistoBinSizeSec = uBinSize;
65 }
66
67 void AddHistoToVector(TNamed* pointer, std::string sFolder = "")
68 {
69 fvpAllHistoPointers.push_back(std::pair<TNamed*, std::string>(pointer, sFolder));
70 }
71 std::vector<std::pair<TNamed*, std::string>> GetHistoVector() { return fvpAllHistoPointers; }
72
73 void AddCanvasToVector(TCanvas* pointer, std::string sFolder = "")
74 {
75 fvpAllCanvasPointers.push_back(std::pair<TCanvas*, std::string>(pointer, sFolder));
76 }
77 std::vector<std::pair<TCanvas*, std::string>> GetCanvasVector() { return fvpAllCanvasPointers; }
78
80
82 void FillMsSize(UInt_t uMsComp, UInt_t uSize) { fvhMsSize[uMsComp]->Fill(uSize); }
83 void FillMsSizeTime(UInt_t uMsComp, Double_t dTime, UInt_t uSize) { fvhMsSizeTime[uMsComp]->Fill(dTime, uSize); }
84
85
87 // void FillMsCntEvo(ULong64_t MsIdx) { fhMsCntEvo->Fill(MsIdx * 1e-9); }
88 void FillHitMonitoringHistos(const double_t& dMsTime, const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id,
89 const uint32_t& uRawCh, const uint32_t& uRemapCh, const uint32_t& uTot);
90 void FillEpochMonitoringHistos(const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id, const bool& bSyncFlag,
91 const bool& bDataLoss, const bool& bEpochLoss, const bool& bMissmMatch);
92 void FillScmMonitoringHistos(const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id, const uint32_t& uCh,
93 const uint32_t& uEdge, const uint32_t& uType);
94 void FillSysMonitoringHistos(const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id, const uint32_t& uType);
95 void FillErrMonitoringHistos(const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id, const uint32_t& uCh,
96 const uint32_t& uType);
97
99 void CheckBmonSpillLimits(const double_t& dMsTime);
100 void FillHitBmonMonitoringHistos(const double_t& dMsTime, const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id,
101 const uint32_t& uTot);
102
103 void FillErrBmonMonitoringHistos(const double_t& dMsTime, const uint32_t& uCurrCompIdx, const uint32_t& uGet4Id,
104 const bool& bErrEvtLost);
105
107 void SetBmonMode(bool value) { fBmonMode = value; }
108
110 bool GetBmonMode() { return fBmonMode; }
111
113 void FillHitBmonMicroSpillHistos(const double_t& dTime);
116
118 void SetBmonMicroSpillMode(bool value) { fBmonMicroSpillMode = value; }
119
122
124 void SetBmonScvdMode(bool value) { fBmonScvdMode = value; }
125
128
130 void SetInternalHttpMode(bool value) { fbInternalHttp = value; }
131
134
136 void SetHistosStartTime(double_t value) { fdStartTime = value; }
137
139 double_t GetHistosStartTime() { return fdStartTime; }
140
141 private:
142 TString fHistoFileName = "data/mon.tof.root";
143
147 UInt_t fuNbOfComps = 0;
148 UInt_t fuNbOfGet4PerComp = 0;
151 UInt_t fuNbOfGet4InSyst = 0;
152
154 Double_t fdStartTime = -1.0;
155 UInt_t fuHistoryHistoSize = 3600;
156 double_t dFirstTsStartTime = 0;
157 //Bool_t fbLongHistoEnable;
158 UInt_t fuLongHistoNbSeconds = 3600;
161
163 bool fBmonMode = false;
164 bool fBmonScvdMode = false;
166 bool fbInternalHttp = true;
167
169 static const UInt_t kuMaxNbFlibLinks = 32;
170 static const UInt_t kuBytesPerMessage = 8;
171 static const UInt_t kuNbChanBmon = 16;
172 static const UInt_t kuNbChanBmonScvd = 20;
173 static const UInt_t kuNbSpillPlots = 5;
174
176 UInt_t fuMinTotPulser = 185;
177 UInt_t fuMaxTotPulser = 189;
180 Double_t fdSpillCheckInterval = 1.0;
184 static constexpr UInt_t kuBmonChanMap[kuNbChanBmon] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
186 static constexpr UInt_t kuBmonChanMapScvd[kuNbChanBmonScvd] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
187 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
189 UInt_t fuNbChanBmon = 0;
190 std::vector<UInt_t> fuBmonChanMap = {};
191
195
198 TH2* fhGet4MessType = nullptr;
199 TH2* fhGet4EpochFlags = nullptr;
200 TH2* fhGet4ScmType = nullptr;
201 TH2* fhGet4SysMessType = nullptr;
202 TH2* fhGet4ErrorsType = nullptr;
204 std::vector<TH2*> fvhCompGet4MessType = {};
205 std::vector<TH2*> fvhCompGet4ChScm = {};
206 std::vector<TH2*> fvhCompGet4ChErrors = {};
208 std::vector<TH1*> fvhCompRawChCount = {};
209 std::vector<TH2*> fvhCompRawChRate = {};
210 std::vector<TH2*> fvhCompRawChTot = {};
212 std::vector<TH1*> fvhCompRemapChCount = {};
213 std::vector<TH2*> fvhCompRemapChRate = {};
214 std::vector<TH2*> fvhCompRemapChTot = {};
216 TH1* fhPulserChCounts = nullptr;
217 TH2* fhPulserChEvo = nullptr;
218
221 std::vector<UInt_t> fvuBmonHitCntChanMs = {};
222 std::vector<UInt_t> fvuBmonErrorCntChanMs = {};
223 std::vector<UInt_t> fvuBmonEvtLostCntChanMs = {};
224 std::vector<TH1*> fvhBmonMsgCntEvoChan = {};
225 std::vector<TH2*> fvhBmonMsgCntPerMsEvoChan = {};
226 std::vector<TH1*> fvhBmonHitCntEvoChan = {};
227 std::vector<TH2*> fvhBmonHitCntPerMsEvoChan = {};
228 std::vector<TH1*> fvhBmonErrorCntEvoChan = {};
229 std::vector<TH2*> fvhBmonErrorCntPerMsEvoChan = {};
230 std::vector<TH1*> fvhBmonEvtLostCntEvoChan = {};
231 std::vector<TH2*> fvhBmonEvtLostCntPerMsEvoChan = {};
232 std::vector<TProfile*> fvhBmonErrorFractEvoChan = {};
233 std::vector<TH2*> fvhBmonErrorFractPerMsEvoChan = {};
234 std::vector<TProfile*> fvhBmonEvtLostFractEvoChan = {};
235 std::vector<TH2*> fvhBmonEvtLostFractPerMsEvoChan = {};
237 TH1* fhBmonCompMapAll = nullptr;
238 TH2* fhBmonCompGet4 = nullptr;
239 TH1* fhBmonGet4Map = nullptr;
240 TH2* fhBmonGet4MapEvo = nullptr;
241 TH1* fhBmonChannelMapAll = nullptr;
242 TH2* fhBmonChannelTotAll = nullptr;
243 TH2* fhBmonHitMapEvoAll = nullptr;
244 TH2* fhBmonHitTotEvoAll = nullptr;
245 TH1* fhBmonChanHitMapAll = nullptr;
248 TH1* fhBmonCompMap = nullptr;
249 TH1* fhBmonChannelMap = nullptr;
250 TH2* fhBmonHitMapEvo = nullptr;
251 TH2* fhBmonHitTotEvo = nullptr;
252 TH1* fhBmonChanHitMap = nullptr;
253 TH2* fhBmonChanHitMapEvo = nullptr;
255 std::vector<TH1*> fvhBmonCompMapSpill = {};
256 std::vector<TH1*> fvhBmonChannelMapSpill = {};
257 TH1* fhBmonHitsPerSpill = nullptr;
259 TH1* fhBmonMsgCntEvo = nullptr;
260 TH1* fhBmonHitCntEvo = nullptr;
261 TH1* fhBmonErrorCntEvo = nullptr;
262 TH1* fhBmonLostEvtCntEvo = nullptr;
263 TProfile* fhBmonErrorFractEvo = nullptr;
264 TProfile* fhBmonLostEvtFractEvo = nullptr;
266 TH2* fhBmonMsgCntPerMsEvo = nullptr;
267 TH2* fhBmonHitCntPerMsEvo = nullptr;
274 TH2* fhBmonHitMapEvoPulser = nullptr;
275
277 double_t fdBmonMicrospillsTsLengthSec = 0.128; // 128 ms
279 uint32_t fuNbTsMicrospills = 0;
280 std::unique_ptr<double[]> fArrHitCounts;
281 std::unique_ptr<double[]> fArrErrCounts;
282 TH1* fhBmonMicrospillsDistHits = nullptr; // Only internal, not for users
283 TH1* fhBmonMicrospillsDistErrs = nullptr; // Only internal, not for users
294
297 TCanvas* fcSummaryGet4s = nullptr;
298 std::vector<TCanvas*> fvcSumComp = {};
300 TCanvas* fcBmonSummary = nullptr;
301 TCanvas* fcBmonSummaryMap = nullptr;
302 TCanvas* fcBmonHitMaps = nullptr;
303 TCanvas* fcBmonGenCntsPerMs = nullptr;
304 TCanvas* fcBmonSpillCounts = nullptr;
305 TCanvas* fcBmonSpillCountsHori = nullptr;
306 TCanvas* fcBmonSpillCompCountsHori = nullptr;
308 TCanvas* fcBmonMicrospillsBinCnts = nullptr;
309 TCanvas* fcBmonMicrospillsRatios = nullptr;
310 TCanvas* fcBmonMicrospillsFraction = nullptr;
311
313 Bool_t fbSpillOn = kTRUE;
316 Double_t fdStartTimeSpill = -1.0;
317 Double_t fdBmonLastInterTime = -1.0;
320
332 std::vector<std::pair<TNamed*, std::string>>
334 std::vector<std::pair<TCanvas*, std::string>>
336
339
340 ClassDef(CbmTofUnpackMonitor, 1)
341};
342
343#endif
Bool_t fbSpillOn
Spill detection.
void SetHistosStartTime(double_t value)
Set start time for evolution histos.
std::vector< TH1 * > fvhBmonChannelMapSpill
TH1 * fvhMsSize[kuMaxNbFlibLinks]
MS size histograms.
void CheckBmonSpillLimits(const double_t &dMsTime)
Fill BMon histograms.
std::vector< TH1 * > fvhBmonCompMapSpill
---> No Pulser cut + Spill detection
std::vector< std::pair< TNamed *, std::string > > fvpAllHistoPointers
TProfile * fvhMsSizeTime[kuMaxNbFlibLinks]
std::vector< TH1 * > fvhBmonErrorCntEvoChan
std::vector< TH1 * > fvhBmonEvtLostCntEvoChan
Bool_t ResetMsComponentSizeHistos(UInt_t component)
static const UInt_t kuNbChanBmon
void SetBmonMicroSpillMode(bool value)
Activate the BMon mode.
CbmMcbm2018TofPar * fUnpackPar
Settings from parameter file.
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
static const UInt_t kuNbChanBmonScvd
std::vector< std::pair< TCanvas *, std::string > > GetCanvasVector()
static constexpr UInt_t kuBmonChanMap[kuNbChanBmon]
std::vector< TH1 * > fvhBmonHitCntEvoChan
std::vector< TH1 * > fvhCompRemapChCount
---> Per remapped (PADI) channel in Component
void FillSysMonitoringHistos(const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const uint32_t &uType)
void FillHitMonitoringHistos(const double_t &dMsTime, const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const uint32_t &uRawCh, const uint32_t &uRemapCh, const uint32_t &uTot)
Fill general histograms.
void AddCanvasToVector(TCanvas *pointer, std::string sFolder="")
Bool_t ResetHistogramsMicroSpills(Bool_t bResetTime)
bool GetBmonMicroSpillMode()
Read the Bmon mode.
static constexpr UInt_t kuBmonChanMapScvd[kuNbChanBmonScvd]
2024 mapping: +4 channels scvd added
void SetBmonMode(bool value)
Activate the BMon mode.
std::vector< std::pair< TNamed *, std::string > > GetHistoVector()
static const UInt_t kuBytesPerMessage
void FillEpochMonitoringHistos(const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const bool &bSyncFlag, const bool &bDataLoss, const bool &bEpochLoss, const bool &bMissmMatch)
void FillScmMonitoringHistos(const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const uint32_t &uCh, const uint32_t &uEdge, const uint32_t &uType)
std::vector< TH2 * > fvhCompGet4MessType
---> Per GET4 in Component
bool GetBmonScvdMode()
Read the BMon mode.
void FillErrMonitoringHistos(const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const uint32_t &uCh, const uint32_t &uType)
bool GetInternalHttpMode()
Read the Bmon mode.
TH1 * fhBmonCompMapAll
---> Channels maps without cuts
std::vector< TH1 * > fvhBmonMsgCntEvoChan
void FillMsSizeTime(UInt_t uMsComp, Double_t dTime, UInt_t uSize)
void SetSpillCheckInterval(Double_t dIntervalSec)
std::vector< TH2 * > fvhBmonErrorCntPerMsEvoChan
void SetLongDurationLimits(UInt_t uDurationSeconds, UInt_t uBinSize)
Bool_t CreateMsComponentSizeHistos(UInt_t component)
void FillHitBmonMonitoringHistos(const double_t &dMsTime, const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const uint32_t &uTot)
std::vector< UInt_t > fuBmonChanMap
std::unique_ptr< double[]> fArrErrCounts
void FinalizeTsBmonMicroSpillHistos()
Finalize BMon Microspill histograms.
Double_t fdStartTime
Total/maximum number of Get4 in system.
Bool_t ResetBmonHistograms(Bool_t bResetTime)
std::vector< UInt_t > fvuBmonErrorCntChanMs
void FillHitBmonMicroSpillHistos(const double_t &dTime)
Fill BMon Microspill histograms.
std::vector< TH2 * > fvhBmonErrorFractPerMsEvoChan
std::vector< TCanvas * > fvcSumComp
std::vector< TH2 * > fvhBmonMsgCntPerMsEvoChan
std::vector< TH2 * > fvhCompRawChRate
UInt_t fuNbOfComps
Readout chain dimensions and mapping.
double_t GetHistosStartTime()
Set start time for evolution histos.
std::vector< TH2 * > fvhCompRawChTot
TH1 * fhBmonCompMap
---> No Pulser cut
std::vector< UInt_t > fvuBmonEvtLostCntChanMs
TCanvas * fcBmonMicrospillsBinCnts
---> BMon Microspills monitoring
std::vector< TH2 * > fvhCompRemapChRate
void FillErrBmonMonitoringHistos(const double_t &dMsTime, const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const bool &bErrEvtLost)
std::vector< TH2 * > fvhCompGet4ChErrors
UInt_t fuNbChanBmon
Runtime values.
static const UInt_t kuNbSpillPlots
std::unique_ptr< double[]> fArrHitCounts
std::vector< TH2 * > fvhCompGet4ChScm
UInt_t fuNbOfGet4PerComp
Total number of Components in the system.
void SetSpillThresholdNonPulser(UInt_t uCntLimit)
std::vector< TH2 * > fvhCompRemapChTot
TCanvas * fcBmonSummary
---> BMon
TH1 * fhBmonMsgCntEvo
---> Global Rate
bool fBmonMode
Flag if debug mode is active or not.
void SetBmonChannelMap(std::vector< uint32_t > vChanMapIn)
std::vector< TH2 * > fvhBmonEvtLostCntPerMsEvoChan
static const UInt_t kuMaxNbFlibLinks
---> Constants
void FillMsSize(UInt_t uMsComp, UInt_t uSize)
Fill Ms Component Size Histos.
std::vector< TH1 * > fvhCompRawChCount
---> Per raw channel in Component
std::vector< TH2 * > fvhBmonEvtLostFractPerMsEvoChan
void SetHistoFileName(TString nameIn)
CbmTofUnpackMonitor operator=(const CbmTofUnpackMonitor &)
std::vector< TProfile * > fvhBmonErrorFractEvoChan
Bool_t Init(CbmMcbm2018TofPar *digiParSet)
Init all required parameter informations and histograms.
void SetSpillThreshold(UInt_t uCntLimit)
std::vector< std::pair< TCanvas *, std::string > > fvpAllCanvasPointers
Vector of pointers to histograms + optional folder name.
UInt_t fuMinTotPulser
---> User settings: Data correction parameters
std::vector< TH2 * > fvhBmonHitCntPerMsEvoChan
TH2 * fhBmonMsgCntPerMsEvo
---> Global Rate per MS
UInt_t fuNbOfChannelsPerComp
Number of channels per Get4, constant.
void SetBmonScvdMode(bool value)
Activate the BMon sCVD mode.
void SetPulserTotLimits(UInt_t uMin, UInt_t uMax)
std::vector< TProfile * > fvhBmonEvtLostFractEvoChan
TH1 * fhBmonChannelMapPulser
---> Pulser
bool GetBmonMode()
Read the BMon mode.
UInt_t fuNbOfChannelsPerGet4
Max number of Get4 per component.
void Finish()
Write all histograms and canvases to file.
UInt_t fuNbOfGet4InSyst
Number of channels per Component, recalculated.
void SetInternalHttpMode(bool value)
Activate/de-activate the internal histo serve mode.
std::vector< UInt_t > fvuBmonHitCntChanMs
double_t fdBmonMicrospillsTsLengthSec
BMon micro-spills monitoring histograms.
CbmTofUnpackMonitor(const CbmTofUnpackMonitor &)
Vector of pointers to canvases + optional folder name.
TH1 * fhPulserChCounts
---> Pulser