CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MonitorAlgoMuchLite.h
Go to the documentation of this file.
1/* Copyright (C) 2021 Variable Energy Cyclotron Centre, Kolkata
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Vikas Singhal [committer] */
4
5// -----------------------------------------------------------------------------
6// ----- -----
7// ----- CbmMcbm2018MonitorMuchLite -----
8// ----- Created 11/05/18 by P.-A. Loizeau -----
9// ----- Modified 07/12/18 by Ajit Kumar -----
10// ----- Modified 05/03/19 by Vikas Singhal -----
11// ----- -----
12// -----------------------------------------------------------------------------
13
14#ifndef CbmMcbm2018MonitorAlgoMuchLite_H
15#define CbmMcbm2018MonitorAlgoMuchLite_H
16
17#ifndef __CINT__
18#include "Timeslice.hpp"
19#endif
20
21// Data
22#include "StsXyterFinalHit.h"
23#include "StsXyterMessage.h"
24
25// CbmRoot
26#include "CbmHistManager.h"
27#include "CbmMcbmUnpack.h"
28#include "CbmMuchBeamTimeDigi.h"
29#include "CbmStar2019Algo.h"
30
31// C++11
32#include <chrono>
33
34// C/C++
35#include <map>
36#include <set>
37#include <vector>
38
40//class CbmCern2017UnpackParSts;
41
42class CbmMcbm2018MonitorAlgoMuchLite : public CbmStar2019Algo<CbmMuchBeamTimeDigi> {
43public:
48
49
50 virtual Bool_t Init();
51
52 virtual void Reset();
53
54 virtual void Finish();
55
56 Bool_t InitContainers();
57
58 Bool_t ReInitContainers();
59 TList* GetParList();
61 Bool_t InitMuchParameters();
62
63 Bool_t ProcessTs(const fles::Timeslice& ts);
64 Bool_t ProcessTs(const fles::Timeslice& ts, size_t /*component*/) { return ProcessTs(ts); }
65 //Bool_t ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx);
66
67 void AddMsComponentToList(size_t component, UShort_t usDetectorId);
68 Bool_t CreateHistograms();
69 void SaveMuchHistos(TString sFileName = "");
71 inline void SetMonitorMode(Bool_t bFlagIn = kTRUE) { fbMonitorMode = bFlagIn; }
72 inline void SetHistoryHistoSize(UInt_t inHistorySizeSec = 1800) { fuHistoryHistoSize = inHistorySizeSec; }
73 inline void SetSpillThreshold(UInt_t uCntLimit) { fuOffSpillCountLimit = uCntLimit; }
74 //void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb);
75 //void SetMsOverlap(size_t uOverlapMsNb = 1) { fuNbOverMsPerTs = uOverlapMsNb; }
76 //size_t GetMsOverlap() { return fuNbOverMsPerTs; }
77 Bool_t ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx);
78
79 void SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5);
80 void FillHitInfo(stsxyter::Message mess, const UShort_t& usElinkIdx, const UInt_t& uAsicIdx, const UInt_t& uMsIdx);
81
82 /*void
83 FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0);
84 void FillEpochInfo(stsxyter::Message mess);
85
86 void
87 FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0);
88 void FillEpochInfo(stsxyter::Message mess);
89
90
91
92 Bool_t ScanForNoisyChannels(Double_t dNoiseThreshold = 1e3); */
93
94 void ResetAllHistos();
95 void SaveAllHistos(TString sFileName = "");
96 void SaveHistos(TString sFileName = "");
97 void SetHistoFileName(TString sFileName = "data/SetupHistos.root") { fsHistoFileFullname = sFileName; }
98
106 //void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 );
107 //void SetEnableCoincidenceMaps( Bool_t bEnableCoincidenceMapsOn = kTRUE ) { fbEnableCoincidenceMaps = bEnableCoincidenceMapsOn; }
108 //void SetCoincidenceBorder( Double_t dCenterPos, Double_t dBorderVal );
109 //void SetFebChanCoincidenceLimitNs( Double_t dLimitIn ) { fdFebChanCoincidenceLimit = dLimitIn; }
110 //void UseNoiseLimitsSmx2LogicError( Bool_t bUseNoise = kTRUE ) { fbSmx2ErrorUseNoiseLevels = bUseNoise; }
111
112 void SetMuchMode(Bool_t bMuchMode = kTRUE) { fbMuchMode = bMuchMode; }
113
114 // void SetTimeBin( size_t uTimeBin );
115 void UseDaqBuffer(Bool_t) {}; //Virtual function in Mother Class, Need to update accordingly. VS
116
118 void SetBinningFwFlag(Bool_t bEnable = kTRUE) { fbBinningFw = bEnable; }
119 Bool_t ScanForNoisyChannels(Double_t dNoiseThreshold = 1e3);
120
121private:
122 // Parameters
123 // Control flags
124 Bool_t fbMonitorMode = kFALSE;
126 std::vector<Bool_t> fvbMaskedComponents;
128 std::vector<stsxyter::FinalHit>
136 UInt_t fuNrOfDpbs;
137 std::map<UInt_t, UInt_t> fDpbIdIndexMap;
138 std::vector<std::vector<Bool_t>>
140 UInt_t fuNbFebs;
142 std::map<stsxyter::MessType, UInt_t> fmMsgCounter;
144
146 Bool_t fbBinningFw = kTRUE;
147
148 // CbmMcbm2018MuchPar* fUnpackPar = nullptr; //!
149
150 Double_t fdTsStartTime = -1.0;
152 -1.0;
153
154 UInt_t fuMsIndex = 0;
155
157 UInt_t fuHistoryHistoSize = 3600;
159
161 // Unpacking and mapping
162 //std::vector< std::vector< std::vector< Double_t > > > fvdFebAdcGain; //! ADC gain in e-/b, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ]
163 //std::vector< std::vector< std::vector< Double_t > > > fvdFebAdcOffs; //! ADC offset in e-, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ]
164
165 // Constants
166 static const Int_t kiMaxNbFlibLinks = 32;
167 static const UInt_t kuBytesPerMessage = 4;
168
172 //Bool_t fbEnableCoincidenceMaps;
177 UInt_t fuCurrDpbId;
181
183 std::vector<ULong64_t> fvulCurrentTsMsb;
184 std::vector<UInt_t> fvuCurrentTsMsbCycle;
185 std::vector<UInt_t> fvuInitialHeaderDone;
186 std::vector<UInt_t> fvuInitialTsMsbCycleHeader;
187 std::vector<UInt_t> fvuElinkLastTsHit;
189 std::vector<std::vector<ULong64_t>> fvulChanLastHitTime;
190 //std::vector< std::vector< ULong64_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel
191 std::vector<std::vector<Double_t>> fvdChanLastHitTime;
192 std::vector<Double_t> fvdPrevMsTime;
193 std::vector<Double_t> fvdMsTime;
194 std::vector<std::vector<std::vector<Double_t>>>
196 std::vector<std::vector<std::vector<UShort_t>>>
198
199 std::vector<std::vector<stsxyter::FinalHit>>
201 std::vector<std::vector<stsxyter::FinalHit>>
205 std::vector<Int_t> fviFebTimeSecLastRateUpdate;
207 std::vector<std::vector<Double_t>> fvdFebChanCountsSinceLastRateUpdate;
209 //Bool_t fbLongHistoEnable;
210 //UInt_t fuLongHistoNbSeconds;
211 //UInt_t fuLongHistoBinSizeSec;
212 //UInt_t fuLongHistoBinNb;
213 UInt_t Counter;
214 UInt_t Counter1;
216 //Double_t fdCoincCenter; // ns
217 //Double_t fdCoincBorder; // ns, +/-
218 //Double_t fdCoincMin; // ns
219 //Double_t fdCoincMax; // ns
220
231
232 //TH1* fhElinkIdxTsMsb;
233 //TH1* fhElinkIdxEpoch;
234 //TH1* fhElinkIdxStatus;
236 TH1* fhRate;
238 TH1* fhFEBcount = nullptr;
239 // std::vector<TH1 *> fhMuchFebChanRateEvo;
240
242 //UInt_t kuNbAsicPerFeb = 1;
243
244 std::vector<TH2*> fHistPadDistr;
245 std::vector<TH2*> fRealHistPadDistr;
246
247 //Double_t fdFebChanCoincidenceLimit; // ns
248 std::vector<TH1*> fhMuchFebChanCntRaw;
249 std::vector<TH1*> fhMuchFebSpill = {};
250 std::vector<TH2*> fhMuchFebADC = {};
251 //std::vector<TH1 *> fhMuchFebChanCntRawGood;
252 std::vector<TH2*> fhMuchFebChanAdcRaw;
253 std::vector<TProfile*> fhMuchFebChanAdcRawProf;
254 //std::vector<TH2 *> fhMuchFebChanAdcCal;
255 //std::vector<TProfile*> fhMuchFebChanAdcCalProf;
256 std::vector<TH2*> fhMuchFebChanRawTs;
257 std::vector<TH2*> fhMuchChannelTime = {};
258 //std::vector<TH2*> fhMuchFebChanMissEvt;
259 //std::vector<TH2*> fhMuchFebChanMissEvtEvo;
260 //std::vector<TH2*> fhMuchFebAsicMissEvtEvo;
261 //std::vector<TH1*> fhMuchFebMissEvtEvo;
262 std::vector<TH2*> fhMuchFebChanHitRateEvo;
263 std::vector<TProfile*> fhMuchFebChanHitRateProf;
264 //std::vector<TH2*> fhMuchFebAsicHitRateEvo;
265 std::vector<TH1*> fhMuchFebHitRateEvo;
266 std::vector<TH1*> fhMuchFebHitRateEvo_mskch;
269 //std::vector<TH2*> fhMuchFebChanHitRateEvoLong;
270 //std::vector<TH2*> fhMuchFebAsicHitRateEvoLong;
271 //std::vector<TH1*> fhMuchFebHitRateEvoLong;
272 std::vector<std::vector<Double_t>> fdMuchFebChanLastTimeForDist;
273 std::vector<TH2*> fhMuchFebChanDistT;
274 //std::vector< std::vector<TH1*> > fhMuchFebChanDtCoinc;
275 //std::vector< std::vector<TH2*> > fhMuchFebChanCoinc;
276 std::vector<TProfile*> fhMuchFebDuplicateHitProf;
277
279 TH2* fhDpbMsErrors = nullptr;
280
281 TCanvas* fcMsSizeAll;
282
283 // FLES containers
284 std::vector<size_t> fvMsComponentsList;
285
288
291
292 // std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel
294 //Long64_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/
295 Long64_t prevtime_new;
296 Long64_t prevTime;
297 UInt_t prevAsic;
298 UInt_t prevChan;
299 Double_t fdStartTime;
301 std::chrono::steady_clock::time_point
304 std::vector<std::vector<std::vector<UInt_t>>> fvuChanNbHitsInMs;
305
308
309 // Methods later going into Algo
310
311 void FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0);
313
314
316};
317
318#endif // CbmMcbm2018MonitorAlgoMuchLite_H
Histogram manager.
Histogram manager.
Bool_t ProcessTs(const fles::Timeslice &ts)
void FillHitInfo(stsxyter::Message mess, const UShort_t &usElinkIdx, const UInt_t &uAsicIdx, const UInt_t &uMsIdx)
Long64_t prevtime_new
Starting state book-keeping.
std::vector< UInt_t > fvuInitialHeaderDone
Current TS MSB cycle for DPB.
Int_t fiTimeIntervalRateUpdate
Mean Rate per channel plots.
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
UInt_t fuNbFebs
Array to hold the active flag for all CROBs, [ NbDpb ][ NbCrobPerDpb ].
std::map< UInt_t, UInt_t > fDpbIdIndexMap
Total number of STS DPBs in system.
void SaveHistos(TString sFileName="")
void FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
TH1 * fhElinkIdxHit
Number of hits in each MS for each Channel.
UInt_t fuCurrentEquipmentId
Current data properties.
UInt_t fuNbStsXyters
Number of StsXyter ASICs.
std::vector< std::vector< Double_t > > fvdChanLastHitTime
Last hit time in bins for each Channel.
static const Int_t kiMaxNbFlibLinks
/‍** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **‍/
std::vector< Double_t > fvdPrevMsTime
Last hit time in ns for each Channel.
void SaveMuchHistos(TString sFileName="")
CbmMcbm2018MonitorAlgoMuchLite operator=(const CbmMcbm2018MonitorAlgoMuchLite &)
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
std::vector< stsxyter::FinalHit > fvmHitsInMs
Hits time-sorting.
Bool_t fbMuchMode
Switch ON the filling of a minimal set of histograms.
Int_t fiBinSizeDatePlots
Start of run time since "epoch" in s, for the plots with date as X axis.
UInt_t fuHistoryHistoSize
Index of current MS within the TS.
std::vector< std::vector< stsxyter::FinalHit > > fvmAsicHitsInMs
Last hit ADC in bins in each MS for each Channel.
std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs
Last hit time in bins in each MS for each Channel.
std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs
std::vector< ULong64_t > fvulCurrentTsMsb
Bin size in s for the plots with date as X axis.
Int_t fiRunStartDateTimeSec
Index of the DPB from which the MS currently unpacked is coming.
Bool_t ScanForNoisyChannels(Double_t dNoiseThreshold=1e3)
---------------------------------------------------------------—///
std::vector< UInt_t > fvuElinkLastTsHit
TS MSB cycle from MS header in 1st MS for DPB.
UInt_t fuMsIndex
End Time in ns of current TS Core from the index of the first MS first component.
CbmHistManager * fHM
Coincidences in sorted hits.
std::vector< TH2 * > fHistPadDistr
Plots per FEB-8.
void SetHistoFileName(TString sFileName="data/SetupHistos.root")
CbmMcbm2018MonitorAlgoMuchLite(const CbmMcbm2018MonitorAlgoMuchLite &)
std::chrono::steady_clock::time_point ftStartTimeUnix
std::vector< UInt_t > fvuInitialTsMsbCycleHeader
Flag set after seeing MS header in 1st MS for DPB.
std::vector< std::vector< Double_t > > fvdFebChanCountsSinceLastRateUpdate
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
Number of StsXyter ASICs.
Bool_t fbBinningFw
=> Quick and dirty hack for binning FW!!!
Bool_t ProcessTs(const fles::Timeslice &ts, size_t)
std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs
Header time of each MS.
std::vector< std::vector< ULong64_t > > fvulChanLastHitTime
std::vector< Double_t > fvdMsTime
Header time of previous MS per link.
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
void SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize=5)
std::vector< UInt_t > fvuCurrentTsMsbCycle
Current TS MSB for each DPB.
std::vector< std::vector< Double_t > > fdMuchFebChanLastTimeForDist
std::vector< std::vector< stsxyter::FinalHit > > fvmFebHitsInMs
All hits (time in bins, ADC in bins, asic, channel) in last TS, per ASIC, sorted with "<" operator.
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
Bool_t fbPrintMessages
Task configuration values.
void SetPrintMessage(Bool_t bPrintMessOn=kTRUE, stsxyter::MessagePrintMask ctrl=stsxyter::MessagePrintMask::msg_print_Hex|stsxyter::MessagePrintMask::msg_print_Human)
std::vector< std::vector< Bool_t > > fvbCrobActiveFlag
Map of DPB Identifier to DPB index.
void SetHistoryHistoSize(UInt_t inHistorySizeSec=1800)
void SetBinningFwFlag(Bool_t bEnable=kTRUE)
=> Quick and dirty hack for binning FW!!!
std::vector< TProfile * > fhMuchFebDuplicateHitProf
TString fsHistoFilename
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
MessagePrintMask
Printout control.