CbmRoot
Loading...
Searching...
No Matches
CbmCheckDataFormatGdpb2018.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2021 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// -----------------------------------------------------------------------------
6// ----- -----
7// ----- CbmCheckDataFormatGdpb2018 -----
8// ----- Created 10.07.2018 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
13
15#include "CbmHistManager.h"
16#include "CbmMcbm2018TofPar.h"
17
18#include "FairRootManager.h"
19#include "FairRun.h"
20#include "FairRunOnline.h"
21#include "FairRuntimeDb.h"
22#include <Logger.h>
23
24#include "Rtypes.h"
25#include "TCanvas.h"
26#include "TClonesArray.h"
27#include "TF1.h"
28#include "TH1.h"
29#include "TH2.h"
30#include "THStack.h"
31#include "THttpServer.h"
32#include "TMath.h"
33#include "TPaveStats.h"
34#include "TProfile.h"
35#include "TProfile2D.h"
36#include "TROOT.h"
37#include "TString.h"
38#include "TStyle.h"
39#include <TFile.h>
40
41#include <algorithm>
42#include <ctime>
43#include <iomanip>
44#include <iostream>
45
46#include <stdint.h>
47
50
53 , fvMsComponentsList()
54 , fuNbCoreMsPerTs(0)
55 , fuNbOverMsPerTs(0)
56 , fbIgnoreOverlapMs(kFALSE)
57 , fuMsAcceptsPercent(100)
58 , fuTotalMsNb(0)
59 , fuOverlapMsNb(0)
60 , fuCoreMs(0)
61 , fdMsSizeInNs(0.0)
62 , fdTsCoreSizeInNs(0.0)
63 , fuMinNbGdpb(0)
64 , fuCurrNbGdpb(0)
65 , fUnpackPar()
66 , fuNrOfGdpbs(0)
67 , fuNrOfFeePerGdpb(0)
68 , fuNrOfGet4PerFee(0)
69 , fuNrOfChannelsPerGet4(0)
70 , fuNrOfChannelsPerFee(0)
71 , fuNrOfGet4(0)
72 , fuNrOfGet4PerGdpb(0)
73 , fuNrOfChannelsPerGdpb(0)
74 , fuDiamondDpbIdx(10000)
75 , // Crazy default value => should never make troubles given the price
76 fsHistoFilename("data/HistosCheckGdpb.root")
77 , fulCurrentTsIndex(0)
78 , fuCurrentMs(0)
79 , fuCurrentMsSysId(0)
80 , fdMsIndex(0)
81 , fuGdpbId(0)
82 , fuGdpbNr(0)
83 , fuGet4Id(0)
84 , fuGet4Nr(0)
85 , fiEquipmentId(0)
86 , fvulCurrentEpoch()
87 ,
88 /*
89 fvbFirstEpochSeen(),
90 fvulCurrentEpochCycle(),
91 fvulCurrentEpochFull(),
92*/
93 fulCurrentEpochTime(0)
94 , fGdpbIdIndexMap()
95 , fcMsSizeAll(NULL)
96 , fdStartTimeMsSz(-1.)
97 , fvhMsSzPerLink(12, NULL)
98 , fvhMsSzTimePerLink(12, NULL)
99 , fhMessType(NULL)
100 , fhSysMessType(NULL)
101 , fhGet4MessType(NULL)
102 , fhGet4ChanScm(NULL)
103 , fhGet4ChanErrors(NULL)
104 , fhGet4EpochFlags(NULL)
105 , fhGdpbMessType(NULL)
106 , fhGdpbSysMessType(NULL)
107 , fhGdpbSysMessPattType(NULL)
108 , fhGdpbEpochFlags(NULL)
109 , fhGdpbEpochSyncEvo(NULL)
110 , fhGdpbEpochMissEvo(NULL)
111 , fvhGdpbGet4MessType()
112 , fhPatternMissmatch(NULL)
113 , fhPatternEnable(NULL)
114 , fhPatternResync(NULL)
115 , fvuGdpbNbEpochPerMs()
116 , fvvuChanNbHitsPerMs()
117 , fhEpochsPerMs_gDPB()
118 , fhEpochsPerMsPerTs_gDPB()
119 , fhEpochsDiff_gDPB()
120 , fhEpochsDiffPerTs_gDPB()
121 , fhEpochsJumpBitsPre_gDPB()
122 , fhEpochsJumpBitsNew_gDPB()
123 , fhEpochsJumpDigitsPre_gDPB()
124 , fhEpochsJumpDigitsNew_gDPB()
125 , fhStartEpochPerMs_gDPB()
126 , fhCloseEpochPerMs_gDPB()
127 , fhHitsPerMsFirstChan_gDPB()
128 , fvhChannelRatePerMs_gDPB()
129 , fcFormatGdpb()
130 , fTimeLastHistoSaving()
131{
132}
133
135
137{
138 LOG(info) << "Initializing Get4 monitor";
139
140 FairRootManager* ioman = FairRootManager::Instance();
141 if (ioman == NULL) { LOG(fatal) << "No FairRootManager instance"; } // if( ioman == NULL )
142
143 return kTRUE;
144}
145
147{
148 LOG(info) << "Setting parameter containers for " << GetName();
149 fUnpackPar = (CbmMcbm2018TofPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMcbm2018TofPar"));
150}
151
153{
154 LOG(info) << "Init parameter containers for " << GetName();
155 Bool_t initOK = ReInitContainers();
156
158
160 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
161 fvulCurrentEpoch[uGdpb] = 0;
162 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
163
164 return initOK;
165}
166
168{
169 LOG(info) << "ReInit parameter containers for " << GetName();
170
172 LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs;
174
176 LOG(info) << "Nr. of FEEs per Tof GDPB: " << fuNrOfFeePerGdpb;
177
179 LOG(info) << "Nr. of GET4 per Tof FEE: " << fuNrOfGet4PerFee;
180
182 LOG(info) << "Nr. of channels per GET4: " << fuNrOfChannelsPerGet4;
183
185 LOG(info) << "Nr. of channels per FEE: " << fuNrOfChannelsPerFee;
186
188 LOG(info) << "Nr. of GET4s: " << fuNrOfGet4;
189
191 LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb;
192
194 LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb;
195
196 fGdpbIdIndexMap.clear();
197 for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
199 LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetGdpbId(i) << std::dec;
200 } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
201
203 LOG(info) << "Nr. of GBTx: " << fuNrOfGbtx;
204
210 LOG(info) << "Timeslice parameters: " << fuTotalMsNb << " MS per link, of which " << fuOverlapMsNb
211 << " overlap MS, each MS is " << fdMsSizeInNs << " ns";
212
213 return kTRUE;
214}
215
216
217void CbmCheckDataFormatGdpb2018::AddMsComponentToList(size_t component, UShort_t /*usDetectorId*/)
218{
220 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
221 if (component == fvMsComponentsList[uCompIdx]) return;
222
224 fvMsComponentsList.push_back(component);
225
227 if (NULL == fvhMsSzPerLink[component]) {
228 TString sMsSzName = Form("MsSz_link_%02lu", component);
229 TString sMsSzTitle = Form("Size of MS from link %02lu; Ms Size [bytes]", component);
230 fvhMsSzPerLink[component] = new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.);
231
232 sMsSzName = Form("MsSzTime_link_%02lu", component);
233 sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component);
234 fvhMsSzTimePerLink[component] = new TProfile(sMsSzName.Data(), sMsSzTitle.Data(), 100 * 1800, 0., 2 * 1800);
235 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
236 if (server) {
237 server->Register("/FlibRaw", fvhMsSzPerLink[component]);
238 server->Register("/FlibRaw", fvhMsSzTimePerLink[component]);
239 } // if( server )
240 if (NULL != fcMsSizeAll) {
241 fcMsSizeAll->cd(1 + component);
242 gPad->SetLogy();
243 fvhMsSzTimePerLink[component]->Draw("hist le0");
244 } // if( NULL != fcMsSizeAll )
245 LOG(info) << "Added MS size histo for component (link): " << component;
246 } // if( NULL == fvhMsSzPerLink[ component ] )
247}
248void CbmCheckDataFormatGdpb2018::SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
249{
250 fuNbCoreMsPerTs = uCoreMsNb;
251 fuNbOverMsPerTs = uOverlapMsNb;
252
253 // UInt_t uNbMsTotal = fuNbCoreMsPerTs + fuNbOverMsPerTs;
254}
255
257{
258 LOG(info) << "create Histos for " << fuNrOfGdpbs << " gDPBs ";
259
260 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
261
262 TString name {""};
263 TString title {""};
264 UInt_t uHistoryHistoSize = 1800;
265
266 /*******************************************************************/
267 name = "hMessageType";
268 title = "Nb of message for each type; Type";
269 // Test Big Data readout with plotting
270 fhMessType = new TH1I(name, title, 1 + gdpbv100::MSG_STAR_TRI_D, 0., 1 + gdpbv100::MSG_STAR_TRI_D);
271 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_HIT, "HIT");
272 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_EPOCH, "EPOCH");
273 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SLOWC, "SLOWC");
274 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SYST, "SYST");
275 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_A, "TRI_A");
276 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_B, "TRI_B");
277 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_C, "TRI_C");
278 fhMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_D, "TRI_D");
279
280 /*******************************************************************/
281 name = "hSysMessType";
282 title = "Nb of system message for each type; System Type";
283 fhSysMessType = new TH1I(name, title, 1 + gdpbv100::SYS_PATTERN, 0., 1 + gdpbv100::SYS_PATTERN);
284 fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_GET4_ERROR, "GET4 ERROR");
285 fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_GDPB_UNKWN, "UNKW GET4 MSG");
286 fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_GET4_SYNC_MISS, "SYS_GET4_SYNC_MISS");
287 fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_PATTERN, "SYS_PATTERN");
288
289 /*******************************************************************/
290 name = "hGet4MessType";
291 title = "Nb of message for each type per GET4; GET4 chip # ; Type";
292 fhGet4MessType = new TH2I(name, title, fuNrOfGet4, 0., fuNrOfGet4, 4, 0., 4.);
293 fhGet4MessType->GetYaxis()->SetBinLabel(1, "DATA 32b");
294 fhGet4MessType->GetYaxis()->SetBinLabel(2, "EPOCH");
295 fhGet4MessType->GetYaxis()->SetBinLabel(3, "S.C. M");
296 fhGet4MessType->GetYaxis()->SetBinLabel(4, "ERROR");
297
298 /*******************************************************************/
299 name = "hGet4ChanScm";
300 title = "SC messages per GET4 channel; GET4 channel # ; SC type";
302 new TH2I(name, title, 2 * fuNrOfGet4 * fuNrOfChannelsPerGet4, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, 5, 0., 5.);
303 fhGet4ChanScm->GetYaxis()->SetBinLabel(1, "Hit Scal");
304 fhGet4ChanScm->GetYaxis()->SetBinLabel(2, "Deadtime");
305 fhGet4ChanScm->GetYaxis()->SetBinLabel(3, "SPI");
306 fhGet4ChanScm->GetYaxis()->SetBinLabel(4, "SEU Scal");
307 fhGet4ChanScm->GetYaxis()->SetBinLabel(5, "START");
308
309 /*******************************************************************/
310 name = "hGet4ChanErrors";
311 title = "Error messages per GET4 channel; GET4 channel # ; Error";
313 new TH2I(name, title, fuNrOfGet4 * fuNrOfChannelsPerGet4, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, 21, 0., 21.);
314 fhGet4ChanErrors->GetYaxis()->SetBinLabel(1, "0x00: Readout Init ");
315 fhGet4ChanErrors->GetYaxis()->SetBinLabel(2, "0x01: Sync ");
316 fhGet4ChanErrors->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync");
317 fhGet4ChanErrors->GetYaxis()->SetBinLabel(4, "0x03: Epoch ");
318 fhGet4ChanErrors->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write ");
319 fhGet4ChanErrors->GetYaxis()->SetBinLabel(6, "0x05: Lost event ");
320 fhGet4ChanErrors->GetYaxis()->SetBinLabel(7, "0x06: Channel state ");
321 fhGet4ChanErrors->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state");
322 fhGet4ChanErrors->GetYaxis()->SetBinLabel(9, "0x08: Token ");
323 fhGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout ");
324 fhGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI ");
325 fhGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2
326 fhGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2
327 fhGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite ");
328 fhGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range");
329 fhGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded ");
330 fhGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x14: Add. Rising edge"); // <- From GET4 v1.3
331 fhGet4ChanErrors->GetYaxis()->SetBinLabel(18, "0x15: Unpaired Falling"); // <- From GET4 v1.3
332 fhGet4ChanErrors->GetYaxis()->SetBinLabel(19, "0x16: Sequence error "); // <- From GET4 v1.3
333 fhGet4ChanErrors->GetYaxis()->SetBinLabel(20, "0x7f: Unknown ");
334 fhGet4ChanErrors->GetYaxis()->SetBinLabel(21, "Corrupt/unsuprtd error");
335
336 /*******************************************************************/
337 name = "hGet4EpochFlags";
338 title = "Epoch flags per GET4; GET4 chip # ; Type";
339 fhGet4EpochFlags = new TH2I(name, title, fuNrOfGet4, 0., fuNrOfGet4, 4, 0., 4.);
340 fhGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC");
341 fhGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS");
342 fhGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS");
343 fhGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT");
344
345 /*******************************************************************/
346 name = "hGdpbMessageType";
347 title = "Nb of message for each type per Gdpb; Type; Gdpb Idx []";
348 // Test Big Data readout with plotting
350 -0.5, fuNrOfGdpbs - 0.5);
351 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_HIT, "HIT");
352 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_EPOCH, "EPOCH");
353 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SLOWC, "SLOWC");
354 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SYST, "SYST");
355 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_A, "TRI_A");
356 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_B, "TRI_B");
357 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_C, "TRI_C");
358 fhGdpbMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_D, "TRI_D");
359
360 /*******************************************************************/
361 name = "hGdpbSysMessType";
362 title = "Nb of system message for each type per Gdpb; System Type; Gdpb Idx []";
363 fhGdpbSysMessType = new TH2I(name, title, 1 + gdpbv100::SYS_PATTERN, 0., 1 + gdpbv100::SYS_PATTERN, fuNrOfGdpbs, -0.5,
364 fuNrOfGdpbs - 0.5);
365 fhGdpbSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_GET4_ERROR, "GET4 ERROR");
366 fhGdpbSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_GDPB_UNKWN, "UNKW GET4 MSG");
367 fhGdpbSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_GET4_SYNC_MISS, "SYS_GET4_SYNC_MISS");
368 fhGdpbSysMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::SYS_PATTERN, "SYS_PATTERN");
369
370 /*******************************************************************/
371 name = "hGdpbSysMessPattType";
372 title = "Nb of pattern message for each type per Gdpb; Pattern Type; Gdpb Idx []";
374 -0.5, fuNrOfGdpbs - 0.5);
375 fhGdpbSysMessPattType->GetXaxis()->SetBinLabel(1 + gdpbv100::PATT_MISSMATCH, "PATT_MISSMATCH");
376 fhGdpbSysMessPattType->GetXaxis()->SetBinLabel(1 + gdpbv100::PATT_ENABLE, "PATT_ENABLE");
377 fhGdpbSysMessPattType->GetXaxis()->SetBinLabel(1 + gdpbv100::PATT_RESYNC, "PATT_RESYNC");
378
379 /*******************************************************************/
380 name = "hGdpbEpochFlags";
381 title = "Epoch flags per gDPB; gDPB # ; Type";
382 fhGdpbEpochFlags = new TH2I(name, title, fuNrOfGdpbs, 0., fuNrOfGdpbs, 4, 0., 4.);
383 fhGdpbEpochFlags->GetYaxis()->SetBinLabel(1, "SYNC");
384 fhGdpbEpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS");
385 fhGdpbEpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS");
386 fhGdpbEpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT");
387
388 /*******************************************************************/
389 name = Form("hGdpbEpochSyncEvo");
390 title = Form("Epoch SYNC per second and gDPB; Time[s]; gDPB #; SYNC Nb");
392 new TH2D(name.Data(), title.Data(), uHistoryHistoSize, 0, uHistoryHistoSize, fuNrOfGdpbs, 0., fuNrOfGdpbs);
393
394 /*******************************************************************/
395 name = Form("hGdpbEpochMissEvo");
396 title = Form("Epoch Missmatch per second and gDPB; Time[s]; gDPB #; Missmatch Nb");
398 new TH2D(name.Data(), title.Data(), uHistoryHistoSize, 0, uHistoryHistoSize, fuNrOfGdpbs, 0., fuNrOfGdpbs);
399
400
401 /*******************************************************************/
402 name = "hPatternMissmatch";
403 title = "Missmatch pattern integral per Gdpb; ASIC Pattern []; Gdpb Idx []";
405 new TH2I(name, title, fuNrOfGet4PerGdpb, 0., fuNrOfGet4PerGdpb, fuNrOfGdpbs, -0.5, fuNrOfGdpbs - 0.5);
406 name = "hPatternEnable";
407 title = "Enable pattern integral per Gdpb; ASIC Pattern []; Gdpb Idx []";
409 new TH2I(name, title, fuNrOfGet4PerGdpb, 0., fuNrOfGet4PerGdpb, fuNrOfGdpbs, -0.5, fuNrOfGdpbs - 0.5);
410 name = "hPatternResync";
411 title = "Resync pattern integral per Gdpb; ASIC Pattern []; Gdpb Idx []";
413 new TH2I(name, title, fuNrOfGet4PerGdpb, 0., fuNrOfGet4PerGdpb, fuNrOfGdpbs, -0.5, fuNrOfGdpbs - 0.5);
414
415
416 /*******************************************************************/
419 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
420 /*******************************************************************/
421 name = Form("hGdpbGet4MessType_%02u", uGdpb);
422 title = Form("Nb of message for each type per GET4 in gDPB %02u; GET4 chip # ; Type", uGdpb);
423 fvhGdpbGet4MessType.push_back(new TH2I(name, title, fuNrOfGet4PerGdpb, 0., fuNrOfGet4PerGdpb, 4, 0., 4.));
424 fvhGdpbGet4MessType[uGdpb]->GetYaxis()->SetBinLabel(1, "DATA 32b");
425 fvhGdpbGet4MessType[uGdpb]->GetYaxis()->SetBinLabel(2, "EPOCH");
426 fvhGdpbGet4MessType[uGdpb]->GetYaxis()->SetBinLabel(3, "S.C. M");
427 fvhGdpbGet4MessType[uGdpb]->GetYaxis()->SetBinLabel(4, "ERROR");
428
429 /*******************************************************************/
430 name = Form("hGdpbGet4ChanErrors_%02u", uGdpb);
431 title = Form("Error messages per GET4 channel in gDPB %02u; GET4 channel # ; Error", uGdpb);
432 fvhGdpbGet4ChanErrors.push_back(
433 new TH2I(name, title, fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, 22, 0., 22.));
434 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(1, "0x00: Readout Init ");
435 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(2, "0x01: Sync ");
436 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync");
437 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(4, "0x03: Epoch ");
438 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write ");
439 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(6, "0x05: Lost event ");
440 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(7, "0x06: Channel state ");
441 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state");
442 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(9, "0x08: Token ");
443 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(10, "0x09: Error Readout ");
444 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(11, "0x0a: SPI ");
445 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2
446 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2
447 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); // <- From GET4 v1.0 to 1.3
448 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range");
449 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded ");
450 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(17, "0x14: Add. Rising edge"); // <- From GET4 v1.3
451 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(18, "0x15: Unpaired Falling"); // <- From GET4 v1.3
452 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(19, "0x16: Sequence error "); // <- From GET4 v1.3
453 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(20, "0x17: Epoch Overflow "); // <- From GET4 v2.0
454 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(21, "0x7f: Unknown ");
455 fvhGdpbGet4ChanErrors[uGdpb]->GetYaxis()->SetBinLabel(22, "Corrupt/unsuprtd error");
456
459 fhEpochsPerMs_gDPB.push_back(new TH1D(Form("hEpochsPerMs_gDPB%02u", uGdpb),
460 Form("Epoch Counts per MS in gDPB %02u; Epochs/MS []; MS nb[]", uGdpb), 1000,
461 -0.5, 999.5));
462 fhEpochsPerMsPerTs_gDPB.push_back(new TH2D(
463 Form("hEpochsPerMsPerTs_gDPB%02u", uGdpb),
464 Form("Epoch Counts per MS in gDPB %02u; TS []; Epochs/MS []; MS nb[]", uGdpb), 10000, 0, 10000, 100, -0.5, 99.5));
465 fhEpochsDiff_gDPB.push_back(new TH1D(Form("hEpochsDiff_gDPB%02u", uGdpb),
466 Form("Epoch index difference per MS in gDPB %02u; Ep(N) - Ep(N "
467 "- 1) []; MS nb[]",
468 uGdpb),
469 1001, -500.5, 500.5));
470 fhEpochsDiffPerTs_gDPB.push_back(new TH2D(Form("hEpochsDiffPerTs_gDPB%02u", uGdpb),
471 Form("Epoch index difference per MS in gDPB %02u; TS []; Ep(N) "
472 "- Ep(N - 1) []; MS nb[]",
473 uGdpb),
474 10000, 0, 10000, 101, -50.5, 50.5));
475 fhEpochsJumpBitsPre_gDPB.push_back(new TH2D(Form("hEpochsJumpBitsPre_gDPB%02u", uGdpb),
476 Form("Bits value in previous epoch when diff not 1 in gDPB "
477 "%02u; TS []; Bit []; Value[]",
478 uGdpb),
479 32, -0.5, 31.5, 2, -0.5, 1.5));
480 fhEpochsJumpBitsNew_gDPB.push_back(new TH2D(Form("hEpochsJumpBitsNew_gDPB%02u", uGdpb),
481 Form("Bits value in new epoch when diff not 1 in gDPB %02u; TS "
482 "[]; Bit []; Value[]",
483 uGdpb),
484 32, -0.5, 31.5, 2, -0.5, 1.5));
485 fhEpochsJumpDigitsPre_gDPB.push_back(new TH2D(Form("hEpochsJumpDigitsPre_gDPB%02u", uGdpb),
486 Form("Digits value in previous epoch when diff not 1 in gDPB "
487 "%02u; TS []; Digit []; Value[]",
488 uGdpb),
489 10, -0.5, 9.5, 10, -0.5, 9.5));
490 fhEpochsJumpDigitsNew_gDPB.push_back(new TH2D(Form("hEpochsJumpDigitsNew_gDPB%02u", uGdpb),
491 Form("Digits value in new epoch when diff not 1 in gDPB %02u; "
492 "TS []; Digit []; Value[]",
493 uGdpb),
494 10, -0.5, 9.5, 10, -0.5, 9.5));
495 fhStartEpochPerMs_gDPB.push_back(new TH2D(Form("fhStartEpochPerMs_gDPB%02u", uGdpb),
496 Form("MS start with Epoch in gDPB %02u?; TS []; 1st Msg is "
497 "Epoch? []; MS nb[]",
498 uGdpb),
499 10000, 0, 10000, 2, -0.5, 1.5));
500 fhCloseEpochPerMs_gDPB.push_back(new TH2D(Form("fhCloseEpochPerMs_gDPB%02u", uGdpb),
501 Form("MS close with Epoch in gDPB %02u?; TS []; Last Msg is "
502 "Epoch? []; MS nb[]",
503 uGdpb),
504 10000, 0, 10000, 2, -0.5, 1.5));
505 fhHitsPerMsFirstChan_gDPB.push_back(new TH2D(Form("hHitsPerMsFirstChan_gDPB%02u", uGdpb),
506 Form("Hit Counts per MS in first channel in gDPB %02u; TS []; "
507 "Hits/MS []; MS nb[]",
508 uGdpb),
509 10000, 0, 10000, 150, -0.5, 149.5));
510 fvhChannelRatePerMs_gDPB.push_back(new TProfile2D(Form("hChannelRatePerMs_gDPB%02u", uGdpb),
511 Form("Mean Hit count per MS and channel vs Time in gDPB "
512 "%02u; TS []; Channel []; <Hits/Ms> []",
513 uGdpb),
514 10000, 0, 10000, fuNrOfChannelsPerGdpb, -0.5,
515 fuNrOfChannelsPerGdpb - 0.5));
516 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
517
518 if (server) {
519 server->Register("/TofRaw", fhMessType);
520 server->Register("/TofRaw", fhSysMessType);
521 server->Register("/TofRaw", fhGet4MessType);
522 server->Register("/TofRaw", fhGet4ChanScm);
523 server->Register("/TofRaw", fhGet4ChanErrors);
524 server->Register("/TofRaw", fhGet4EpochFlags);
525
526 server->Register("/TofRaw", fhGdpbMessType);
527 server->Register("/TofRaw", fhGdpbSysMessType);
528 server->Register("/TofRaw", fhGdpbSysMessPattType);
529 server->Register("/TofRaw", fhGdpbEpochFlags);
530 server->Register("/TofRaw", fhGdpbEpochSyncEvo);
531 server->Register("/TofRaw", fhGdpbEpochMissEvo);
532
533 server->Register("/TofRaw", fhPatternMissmatch);
534 server->Register("/TofRaw", fhPatternEnable);
535 server->Register("/TofRaw", fhPatternResync);
536
537 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
538 server->Register("/TofRaw", fvhGdpbGet4MessType[uGdpb]);
539 server->Register("/TofRaw", fvhGdpbGet4ChanErrors[uGdpb]);
540
541 server->Register("/Tof_Ep_FineCount", fhEpochsPerMs_gDPB[uGdpb]);
542 server->Register("/Tof_Ep_FineCount", fhEpochsPerMsPerTs_gDPB[uGdpb]);
543 server->Register("/Tof_Ep_FineCount", fhEpochsDiff_gDPB[uGdpb]);
544 server->Register("/Tof_Ep_FineCount", fhEpochsDiffPerTs_gDPB[uGdpb]);
545 server->Register("/Tof_Ep_FineCount", fhEpochsJumpBitsPre_gDPB[uGdpb]);
546 server->Register("/Tof_Ep_FineCount", fhEpochsJumpBitsNew_gDPB[uGdpb]);
547 server->Register("/Tof_Ep_FineCount", fhEpochsJumpDigitsPre_gDPB[uGdpb]);
548 server->Register("/Tof_Ep_FineCount", fhEpochsJumpDigitsNew_gDPB[uGdpb]);
549 server->Register("/Tof_Ep_FineCount", fhStartEpochPerMs_gDPB[uGdpb]);
550 server->Register("/Tof_Ep_FineCount", fhCloseEpochPerMs_gDPB[uGdpb]);
551
552 server->Register("/ChanFineRate", fhHitsPerMsFirstChan_gDPB[uGdpb]);
553 server->Register("/ChanFineRate", fvhChannelRatePerMs_gDPB[uGdpb]);
554 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
555
556 server->RegisterCommand("/Reset_All_eTOF", "bCheckFormatGdpbResetHistos=kTRUE");
557 server->RegisterCommand("/Save_All_eTof", "bCheckFormatGdpbSaveHistos=kTRUE");
558
559 server->Restrict("/Reset_All_eTof", "allow=admin");
560 server->Restrict("/Save_All_eTof", "allow=admin");
561 } // if( server )
562
564 Double_t w = 10;
565 Double_t h = 10;
566 fcSummary = new TCanvas("cSummary", "gDPB Monitoring Summary");
567 fcSummary->Divide(2, 3);
568
569 // 1st Column: Messages types
570 fcSummary->cd(1);
571 gPad->SetLogy();
572 fhMessType->Draw();
573
574 fcSummary->cd(2);
575 gPad->SetLogy();
576 fhSysMessType->Draw();
577
578 fcSummary->cd(3);
579 gPad->SetLogz();
580 fhGet4MessType->Draw("colz");
581
582 // 2nd Column: GET4 Errors + Epoch flags + SCm
583 fcSummary->cd(4);
584 gPad->SetLogz();
585 fhGet4ChanErrors->Draw("colz");
586
587 fcSummary->cd(5);
588 gPad->SetLogz();
589 fhGet4EpochFlags->Draw("colz");
590
591 fcSummary->cd(6);
592 fhGet4ChanScm->Draw("colz");
593
594 server->Register("/canvases", fcSummary);
595 /*****************************/
596
597 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
598 fcFormatGdpb.push_back(new TCanvas(Form("cFormatGdpb%02u", uGdpb), Form("gDPB %02u Data Format Check", uGdpb)));
599 fcFormatGdpb[uGdpb]->Divide(4, 2);
600
601 fcFormatGdpb[uGdpb]->cd(1);
602 gPad->SetGridx();
603 gPad->SetGridy();
604 fhEpochsPerMsPerTs_gDPB[uGdpb]->Draw("colz");
605
606 fcFormatGdpb[uGdpb]->cd(2);
607 gPad->SetGridx();
608 gPad->SetGridy();
609 fhEpochsDiffPerTs_gDPB[uGdpb]->Draw("colz");
610
611 fcFormatGdpb[uGdpb]->cd(3);
612 gPad->SetGridx();
613 gPad->SetGridy();
614 fhStartEpochPerMs_gDPB[uGdpb]->Draw("colz");
615
616 fcFormatGdpb[uGdpb]->cd(4);
617 gPad->SetGridx();
618 gPad->SetGridy();
619 fhCloseEpochPerMs_gDPB[uGdpb]->Draw("colz");
620
621 fcFormatGdpb[uGdpb]->cd(5);
622 gPad->SetGridx();
623 gPad->SetGridy();
624 fhHitsPerMsFirstChan_gDPB[uGdpb]->Draw("colz");
625
626 fcFormatGdpb[uGdpb]->cd(6);
627 gPad->SetGridx();
628 gPad->SetGridy();
629 gPad->SetLogz();
630 fvhChannelRatePerMs_gDPB[uGdpb]->Draw("colz");
631
632 fcFormatGdpb[uGdpb]->cd(7);
633 gPad->SetGridx();
634 gPad->SetGridy();
635 gPad->SetLogz();
636 fhEpochsJumpBitsPre_gDPB[uGdpb]->Draw("colz");
637
638 fcFormatGdpb[uGdpb]->cd(8);
639 gPad->SetGridx();
640 gPad->SetGridy();
641 gPad->SetLogz();
642 fhEpochsJumpBitsNew_gDPB[uGdpb]->Draw("colz");
643
644 server->Register("/canvases", fcFormatGdpb[uGdpb]);
645 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
646 /*****************************/
647
649 // Try to recover canvas in case it was created already by another monitor
650 // If not existing, create it
651 fcMsSizeAll = dynamic_cast<TCanvas*>(gROOT->FindObject("cMsSizeAll"));
652 if (NULL == fcMsSizeAll) {
653 fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h);
654 fcMsSizeAll->Divide(4, 3);
655 LOG(info) << "Created MS size canvas in TOF monitor";
656 } // if( NULL == fcMsSizeAll )
657 else
658 LOG(info) << "Recovered MS size canvas in TOF monitor";
659
660 server->Register("/canvases", fcMsSizeAll);
661
662 LOG(info) << "Leaving CreateHistograms";
663}
664
665Bool_t CbmCheckDataFormatGdpb2018::DoUnpack(const fles::Timeslice& ts, size_t component)
666{
668 LOG(info) << "Reset eTOF STAR histos ";
671 } // if( bCheckFormatGdpbResetHistos )
673 LOG(info) << "Start saving eTOF STAR histos ";
674 SaveAllHistos("data/histos_Shift_StarTof.root");
676 } // if( bSaveStsHistos )
677
679 std::chrono::time_point<std::chrono::system_clock> timeCurrent = std::chrono::system_clock::now();
680 std::chrono::duration<double> elapsed_seconds = timeCurrent - fTimeLastHistoSaving;
681 if (0 == fTimeLastHistoSaving.time_since_epoch().count()) {
682 fTimeLastHistoSaving = timeCurrent;
683 } // if( 0 == fTimeLastHistoSaving.time_since_epoch().count() )
684 else if (300 < elapsed_seconds.count()) {
685 std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t(timeCurrent);
686 char tempBuff[80];
687 std::strftime(tempBuff, 80, "%F %T", localtime(&cTimeCurrent));
688 fTimeLastHistoSaving = timeCurrent;
689 SaveAllHistos("data/histosCheckGdpbAuto.root");
690 } // else if( 300 < elapsed_seconds.count() )
691
692 LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) << "microslices.";
693
695 if (0 == ts.index()) return kTRUE;
696
698 UInt_t uNbMsLoop = fuNbCoreMsPerTs;
699 if (kFALSE == fbIgnoreOverlapMs) uNbMsLoop += fuNbOverMsPerTs;
700
702 // UInt_t uTsIndexHeader = ts.index();
703 UInt_t uTsIndexHeader = fulCurrentTsIndex;
704
705 Int_t messageType = -111;
706 // Double_t dTsStartTime = -1;
707
709 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
710 if (fuMsAcceptsPercent < uMsIdx) continue;
711
712 fuCurrentMs = uMsIdx;
713
714 if (0 == fulCurrentTsIndex && 0 == uMsIdx) {
715 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
716 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
717 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
718 /*
719 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
720 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
721 static_cast<unsigned int>(msDescriptor.hdr_id),
722 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
723 static_cast<unsigned int>(msDescriptor.sys_id),
724 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
725 msDescriptor.size, msDescriptor.offset );
726*/
727 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
728 } // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
729 } // if( 0 == fulCurrentTsIndex && 0 == uMsIdx )
730
732 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
733 constexpr uint32_t kuBytesPerMessage = 8;
734
735 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
736 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
737 fiEquipmentId = msDescriptor.eq_id;
738 fdMsIndex = static_cast<double>(msDescriptor.idx);
739 fuCurrentMsSysId = static_cast<unsigned int>(msDescriptor.sys_id);
740 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
741
742 uint32_t size = msDescriptor.size;
743 // fulLastMsIdx = msDescriptor.idx;
744 if (size > 0) LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size;
745
746 // if( 0 == uMsIdx && 0 == uMsCompIdx )
747 // dTsStartTime = (1e-9) * fdMsIndex;
748
749 if (fdStartTimeMsSz < 0) fdStartTimeMsSz = (1e-9) * fdMsIndex;
750 fvhMsSzPerLink[uMsComp]->Fill(size);
751 fvhMsSzTimePerLink[uMsComp]->Fill((1e-9) * fdMsIndex - fdStartTimeMsSz, size);
752
753 // If not integer number of message in input buffer, print warning/error
754 if (0 != (size % kuBytesPerMessage))
755 LOG(error) << "The input microslice buffer does NOT "
756 << "contain only complete nDPB messages!";
757
758 // Compute the number of complete messages in the input microslice buffer
759 uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) / kuBytesPerMessage;
760
761 // Get the gDPB ID from the MS header
763
765 auto it = fGdpbIdIndexMap.find(fuGdpbId);
766 if (it == fGdpbIdIndexMap.end()) {
767 LOG(info) << "---------------------------------------------------------------";
768 /*
769 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
770 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
771 static_cast<unsigned int>(msDescriptor.hdr_id),
772 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
773 static_cast<unsigned int>(msDescriptor.sys_id),
774 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
775 msDescriptor.size, msDescriptor.offset );
776*/
777 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
778 LOG(error) << "Could not find the gDPB index for AFCK id 0x" << std::hex << fuGdpbId << std::dec
779 << " in timeslice " << fulCurrentTsIndex << " in microslice " << fdMsIndex << " component "
780 << uMsCompIdx << "\n"
781 << "If valid this index has to be added in the TOF "
782 "parameter file in the RocIdArray field";
783 continue;
784 } // if( it == fGdpbIdIndexMap.end() )
785 else
787
788 // Prepare variables for the loop on contents
789 const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent);
790 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
791 // Fill message
792 uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]);
793
795 if (0 == uIdx) { continue; } // if( 0 == uIdx && kFALSE == fbOldFwData )
796
797 gdpbv100::Message mess(ulData);
798
799 // Detect message types
800 // and fill the corresponding histogram
801 messageType = mess.getMessageType();
802 fhMessType->Fill(messageType);
803 fhGdpbMessType->Fill(messageType, fuGdpbNr);
804
809
811 LOG(warning) << "Message with Get4 ID too high: " << fuGet4Id << " VS " << fuNrOfGet4PerGdpb
812 << " set in parameters.";
813
814 if (1 == uIdx) fhStartEpochPerMs_gDPB[fuGdpbNr]->Fill(uTsIndexHeader, gdpbv100::MSG_EPOCH == messageType);
815 if (uNbMessages - 1 == uIdx)
816 fhCloseEpochPerMs_gDPB[fuGdpbNr]->Fill(uTsIndexHeader, gdpbv100::MSG_EPOCH == messageType);
817
818 switch (messageType) {
819 case gdpbv100::MSG_HIT: {
820 if (mess.getGdpbHitIs24b()) {
821 fhGet4MessType->Fill(fuGet4Nr, 4);
824 } // if( getGdpbHitIs24b() )
825 else {
826 fhGet4MessType->Fill(fuGet4Nr, 0);
828
829 UInt_t uChannel = mess.getGdpbHitChanId();
830 UInt_t uChannelNr = fuGet4Id * fuNrOfChannelsPerGet4 + uChannel;
831 fvvuChanNbHitsPerMs[fuGdpbNr][uChannelNr]++;
832 } // else of if( getGdpbHitIs24b() )
833 break;
834 } // case gdpbv100::MSG_HIT:
835 case gdpbv100::MSG_EPOCH: {
837 if (1 == mess.getGdpbEpSync()) {
838 fhGdpbEpochFlags->Fill(fuGdpbNr, 0);
840 } // if (1 == mess.getGdpbEpSync())
841
842 if (1 == mess.getGdpbEpDataLoss()) fhGdpbEpochFlags->Fill(fuGdpbNr, 1);
843
844 if (1 == mess.getGdpbEpEpochLoss()) fhGdpbEpochFlags->Fill(fuGdpbNr, 2);
845
846 if (1 == mess.getGdpbEpMissmatch()) {
847 fhGdpbEpochFlags->Fill(fuGdpbNr, 3);
849 } // if (1 == mess.getGdpbEpMissmatch())
850
851 for (uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGet4Index++) {
852 fuGet4Id = uGet4Index;
854 gdpbv100::Message tmpMess(mess);
855 tmpMess.setGdpbGenChipId(uGet4Index);
856
857 fhGet4MessType->Fill(fuGet4Nr, 1);
859 } // for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGetIndex ++ )
860
863
865 ULong64_t ulEpochNr = mess.getGdpbEpEpochNb();
866 Long64_t iEpDiff = ulEpochNr;
867 iEpDiff -= fvulCurrentEpoch[fuGdpbNr];
868 fhEpochsDiff_gDPB[fuGdpbNr]->Fill(iEpDiff);
869 fhEpochsDiffPerTs_gDPB[fuGdpbNr]->Fill(uTsIndexHeader, iEpDiff);
870
871 if (1 != iEpDiff && 0 < fvulCurrentEpoch[fuGdpbNr]) {
872 for (UInt_t uBit = 0; uBit < 32; ++uBit) {
873 fhEpochsJumpBitsPre_gDPB[fuGdpbNr]->Fill(uBit, (fvulCurrentEpoch[fuGdpbNr] >> uBit) & 0x1);
874 fhEpochsJumpBitsNew_gDPB[fuGdpbNr]->Fill(uBit, (ulEpochNr >> uBit) & 0x1);
875 } // for( UInt_t uBit = 0; uBit < 32; ++uBit )
876
877 UInt_t uPower = 1;
878 for (UInt_t uDigit = 0; uDigit < 10; ++uDigit) {
880 uDigit, TMath::Floor((fvulCurrentEpoch[fuGdpbNr] % (10 * uPower)) / uPower));
882 TMath::Floor((ulEpochNr % (10 * uPower)) / uPower));
883 uPower *= 10;
884 } // for( UInt_t uDigit = 0; uDigit < 10; ++uDigit )
885 /*
886 LOG(info) << Form( " Non consecutive epochs for Gdpb %2u in TS %8u MS %4u Msg %6u",
887 fuGdpbNr, uTsIndexHeader, uMsIdx, uIdx )
888 << Form( " : old Ep %08llx new Ep %08llx Diff %lld ", fvulCurrentEpoch[ fuGdpbNr ], ulEpochNr, iEpDiff )
889 << std::endl;
890*/
891 } // if( 1 != iEpDiff )
892
894 fvulCurrentEpoch[fuGdpbNr] = ulEpochNr;
895 } // if this epoch message is a merged one valid for all chips
896 else {
898 } // if single chip epoch message
899 break;
900 } // case gdpbv100::MSG_EPOCH:
901 case gdpbv100::MSG_SLOWC: {
902 fhGet4MessType->Fill(fuGet4Nr, 2);
904 break;
905 } // case gdpbv100::MSG_SLOWC:
906 case gdpbv100::MSG_SYST: {
907 fhSysMessType->Fill(mess.getGdpbSysSubType());
910 fhGet4MessType->Fill(fuGet4Nr, 3);
912
913 // UInt_t uFeeNr = (fuGet4Id / fuNrOfGet4PerFee);
914
915 Int_t dGdpbChId = fuGet4Id * fuNrOfChannelsPerGet4 + mess.getGdpbSysErrChanId();
916 Int_t dFullChId = fuGet4Nr * fuNrOfChannelsPerGet4 + mess.getGdpbSysErrChanId();
917 switch (mess.getGdpbSysErrData()) {
919 fhGet4ChanErrors->Fill(dFullChId, 0);
920 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 0);
921 break;
923 fhGet4ChanErrors->Fill(dFullChId, 1);
924 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 1);
925 break;
927 fhGet4ChanErrors->Fill(dFullChId, 2);
928 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 2);
929 break;
931 fhGet4ChanErrors->Fill(dFullChId, 3);
932 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 3);
933 break;
935 fhGet4ChanErrors->Fill(dFullChId, 4);
936 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 4);
937 break;
939 fhGet4ChanErrors->Fill(dFullChId, 5);
940 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 5);
941 break;
943 fhGet4ChanErrors->Fill(dFullChId, 6);
944 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 6);
945 break;
947 fhGet4ChanErrors->Fill(dFullChId, 7);
948 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 7);
949 break;
951 fhGet4ChanErrors->Fill(dFullChId, 8);
952 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 8);
953 break;
955 fhGet4ChanErrors->Fill(dFullChId, 9);
956 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 9);
957 break;
959 fhGet4ChanErrors->Fill(dFullChId, 10);
960 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 10);
961 break;
963 fhGet4ChanErrors->Fill(dFullChId, 11);
964 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 11);
965 break;
967 fhGet4ChanErrors->Fill(dFullChId, 12);
968 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 12);
969 break;
971 fhGet4ChanErrors->Fill(dFullChId, 13);
972 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 13);
973 break;
975 fhGet4ChanErrors->Fill(dFullChId, 14);
976 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 14);
977 break;
979 fhGet4ChanErrors->Fill(dFullChId, 15);
980 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 15);
981 break;
983 fhGet4ChanErrors->Fill(dFullChId, 16);
984 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 16);
985 break;
987 fhGet4ChanErrors->Fill(dFullChId, 17);
988 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 17);
989 break;
991 fhGet4ChanErrors->Fill(dFullChId, 18);
992 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 18);
993 break;
995 fhGet4ChanErrors->Fill(dFullChId, 19);
996 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 19);
997 break;
999 fhGet4ChanErrors->Fill(dFullChId, 20);
1000 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 20);
1001 break;
1002 default: // Corrupt error or not yet supported error
1003 fhGet4ChanErrors->Fill(dFullChId, 21);
1004 fvhGdpbGet4ChanErrors[fuGdpbNr]->Fill(dGdpbChId, 21);
1005 break;
1006 } // Switch( mess.getGdpbSysErrData() )
1007 } // if( gdpbv100::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType() )
1010 } // if( gdpbv100::SYS_PATTERN == mess.getGdpbSysSubType() )
1011 break;
1012 } // case gdpbv100::MSG_SYST:
1017 fhGet4MessType->Fill(fuGet4Nr, 5);
1019 break;
1020 default:
1021 LOG(error) << "Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
1022 << " not included in Get4 unpacker.";
1023 } // switch( mess.getMessageType() )
1024 } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
1025 } // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
1026
1027 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1028 fhEpochsPerMs_gDPB[uGdpb]->Fill(fvuGdpbNbEpochPerMs[uGdpb]);
1029 fhEpochsPerMsPerTs_gDPB[uGdpb]->Fill(uTsIndexHeader, fvuGdpbNbEpochPerMs[uGdpb]);
1030 fhHitsPerMsFirstChan_gDPB[uGdpb]->Fill(uTsIndexHeader, fvvuChanNbHitsPerMs[uGdpb][0]);
1031 for (UInt_t uChan = 0; uChan < fuNrOfChannelsPerGdpb; ++uChan) {
1032 fvhChannelRatePerMs_gDPB[uGdpb]->Fill(uTsIndexHeader, uChan, 1.0 * fvvuChanNbHitsPerMs[uGdpb][uChan]);
1033 fvvuChanNbHitsPerMs[uGdpb][uChan] = 0;
1034 } // for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerGdpb; ++uChan )
1035 fvuGdpbNbEpochPerMs[uGdpb] = 0;
1036 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1037 } // for( UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx ++ )
1038
1040
1041 return kTRUE;
1042}
1043
1045
1047
1049{
1051 TFile* oldFile = gFile;
1052 TDirectory* oldDir = gDirectory;
1053
1054 TFile* histoFile = NULL;
1055 if ("" != sFileName) {
1056 // open separate histo file in recreate mode
1057 histoFile = new TFile(sFileName, "RECREATE");
1058 histoFile->cd();
1059 } // if( "" != sFileName )
1060
1061 gDirectory->mkdir("Tof_Raw_gDPB");
1062 gDirectory->cd("Tof_Raw_gDPB");
1063
1064 fhMessType->Write();
1065 fhSysMessType->Write();
1066 fhGet4MessType->Write();
1067 fhGet4ChanScm->Write();
1068 fhGet4ChanErrors->Write();
1069 fhGet4EpochFlags->Write();
1070
1071 fhGdpbMessType->Write();
1072 fhGdpbSysMessType->Write();
1073 fhGdpbSysMessPattType->Write();
1074 fhGdpbEpochFlags->Write();
1075 fhGdpbEpochSyncEvo->Write();
1076 fhGdpbEpochMissEvo->Write();
1077
1078 fhPatternMissmatch->Write();
1079 fhPatternEnable->Write();
1080 fhPatternResync->Write();
1081
1082 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1083 fvhGdpbGet4MessType[uGdpb]->Write();
1084 fvhGdpbGet4ChanErrors[uGdpb]->Write();
1085 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1086
1087
1088 gDirectory->mkdir("Tof_Ep_FineCount");
1089 gDirectory->cd("Tof_Ep_FineCount");
1090 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1091 fhEpochsPerMs_gDPB[uGdpb]->Write();
1092 fhEpochsPerMsPerTs_gDPB[uGdpb]->Write();
1093 fhEpochsDiff_gDPB[uGdpb]->Write();
1094 fhEpochsDiffPerTs_gDPB[uGdpb]->Write();
1095 fhEpochsJumpBitsPre_gDPB[uGdpb]->Write();
1096 fhEpochsJumpBitsNew_gDPB[uGdpb]->Write();
1097 fhEpochsJumpDigitsPre_gDPB[uGdpb]->Write();
1098 fhEpochsJumpDigitsNew_gDPB[uGdpb]->Write();
1099 fhStartEpochPerMs_gDPB[uGdpb]->Write();
1100 fhCloseEpochPerMs_gDPB[uGdpb]->Write();
1101 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1102 gDirectory->cd("..");
1103
1104 gDirectory->mkdir("Tof_Chan_FineCount");
1105 gDirectory->cd("Tof_Chan_FineCount");
1106 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1107 fhHitsPerMsFirstChan_gDPB[uGdpb]->Write();
1108 fvhChannelRatePerMs_gDPB[uGdpb]->Write();
1109 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1110 gDirectory->cd("..");
1111
1112 gDirectory->mkdir("Flib_Raw");
1113 gDirectory->cd("Flib_Raw");
1114 for (UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++) {
1115 if (NULL == fvhMsSzPerLink[uLinks]) continue;
1116
1117 fvhMsSzPerLink[uLinks]->Write();
1118 fvhMsSzTimePerLink[uLinks]->Write();
1119 } // for( UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++ )
1120
1121 TH1* pMissedTsH1 = dynamic_cast<TH1*>(gROOT->FindObjectAny("Missed_TS"));
1122 if (NULL != pMissedTsH1) pMissedTsH1->Write();
1123
1124 TProfile* pMissedTsEvoP = dynamic_cast<TProfile*>(gROOT->FindObjectAny("Missed_TS_Evo"));
1125 if (NULL != pMissedTsEvoP) pMissedTsEvoP->Write();
1126
1127 gDirectory->cd("..");
1128
1129 gDirectory->mkdir("canvases");
1130 gDirectory->cd("canvases");
1131 fcSummary->Write();
1132 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1133 fcFormatGdpb[uGdpb]->Write();
1134 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1135 gDirectory->cd("..");
1136
1137 if ("" != sFileName) {
1138 // Restore original directory position
1139 histoFile->Close();
1140 } // if( "" != sFileName )
1141
1143 gFile = oldFile;
1144 gDirectory = oldDir;
1145}
1146
1148{
1149 LOG(info) << "Reseting all TOF histograms.";
1150
1151 fhMessType->Reset();
1152 fhSysMessType->Reset();
1153 fhGet4MessType->Reset();
1154 fhGet4ChanScm->Reset();
1155 fhGet4ChanErrors->Reset();
1156 fhGet4EpochFlags->Reset();
1157
1158 fhGdpbMessType->Reset();
1159 fhGdpbSysMessType->Reset();
1160 fhGdpbSysMessPattType->Reset();
1161 fhGdpbEpochFlags->Reset();
1162 fhGdpbEpochSyncEvo->Reset();
1163 fhGdpbEpochMissEvo->Reset();
1164
1165 fhPatternMissmatch->Reset();
1166 fhPatternEnable->Reset();
1167 fhPatternResync->Reset();
1168
1169
1170 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1171 fvhGdpbGet4MessType[uGdpb]->Reset();
1172 fvhGdpbGet4ChanErrors[uGdpb]->Reset();
1173 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1174
1175 for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) {
1176 fhEpochsPerMs_gDPB[uGdpb]->Reset();
1177 fhEpochsPerMsPerTs_gDPB[uGdpb]->Reset();
1178 fhEpochsDiff_gDPB[uGdpb]->Reset();
1179 fhEpochsDiffPerTs_gDPB[uGdpb]->Reset();
1180 fhEpochsJumpBitsPre_gDPB[uGdpb]->Reset();
1181 fhEpochsJumpBitsNew_gDPB[uGdpb]->Reset();
1182 fhEpochsJumpDigitsPre_gDPB[uGdpb]->Reset();
1183 fhEpochsJumpDigitsNew_gDPB[uGdpb]->Reset();
1184 fhStartEpochPerMs_gDPB[uGdpb]->Reset();
1185 fhCloseEpochPerMs_gDPB[uGdpb]->Reset();
1186 fhHitsPerMsFirstChan_gDPB[uGdpb]->Reset();
1187 fvhChannelRatePerMs_gDPB[uGdpb]->Reset();
1188 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1189
1190 for (UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++) {
1191 if (NULL == fvhMsSzPerLink[uLinks]) continue;
1192
1193 fvhMsSzPerLink[uLinks]->Reset();
1194 fvhMsSzTimePerLink[uLinks]->Reset();
1195 } // for( UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++ )
1196
1197 fdStartTimeMsSz = -1;
1198}
Bool_t bCheckFormatGdpbSaveHistos
Bool_t bCheckFormatGdpbResetHistos
ClassImp(CbmConverterManager)
std::string FormatMsHeaderPrintout(const fles::MicrosliceDescriptor &msDescriptor)
Histogram manager.
static constexpr size_t size()
Definition KfSimdPseudo.h:2
std::vector< TProfile2D * > fvhChannelRatePerMs_gDPB
std::vector< TH2 * > fhEpochsJumpBitsNew_gDPB
size_t fuMsAcceptsPercent
/‍** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **‍/
std::vector< std::vector< UInt_t > > fvvuChanNbHitsPerMs
void SaveAllHistos(TString sFileName="")
std::map< UInt_t, UInt_t > fGdpbIdIndexMap
Map of ID to index for the gDPBs.
std::vector< TH2 * > fvhGdpbGet4MessType
Per GET4 in gDPB.
std::vector< TCanvas * > fcFormatGdpb
TH2 * fhGet4MessType
Per GET4 in system.
std::chrono::time_point< std::chrono::system_clock > fTimeLastHistoSaving
std::vector< TH2 * > fhEpochsJumpBitsPre_gDPB
std::vector< TH2 * > fhEpochsJumpDigitsNew_gDPB
std::vector< TProfile * > fvhMsSzTimePerLink
TCanvas * fcMsSizeAll
Histograms and histogram control variables.
std::vector< ULong64_t > fvulCurrentEpoch
TH2 * fhPatternMissmatch
Pattern messages per gDPB.
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
std::vector< TH2 * > fhHitsPerMsFirstChan_gDPB
virtual void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
virtual void AddMsComponentToList(size_t component, UShort_t usDetectorId)
std::vector< size_t > fvMsComponentsList
FLES containers.
std::vector< TH2 * > fhEpochsJumpDigitsPre_gDPB
Int_t GetNrOfGdpbs()
FIXME: replace with method returning the correspondign constants! see Star2019 parameter.
Int_t GetGdpbId(Int_t i)
Int_t ElinkIdxToGet4Idx(UInt_t uElink)
Data class with information on a STS local track.
uint16_t getGdpbHitIs24b() const
uint32_t getGdpbEpEpochNb() const
uint16_t getGdpbSysPattType() const
uint16_t getGdpbSysSubType() const
bool getGdpbEpMissmatch() const
void setGdpbGenChipId(uint32_t v)
bool getGdpbEpSync() const
bool isStarTrigger() const
Returns true is message type is MSG_STAR_TRI_A, _B, _C, _D (STAR Trigger message)
bool getGdpbEpEpochLoss() const
uint16_t getGdpbGenChipId() const
bool getGdpbEpDataLoss() const
uint8_t getMessageType() const
Returns the message type. Valid for all message types. 4 bit.
uint16_t getGdpbSysErrData() const
uint16_t getGdpbSysErrChanId() const
uint16_t getGdpbHitChanId() const
@ GET4_V2X_ERR_LOST_EVT
@ GET4_V2X_ERR_TOT_RANGE
@ GET4_V2X_ERR_FIFO_WRITE
@ GET4_V2X_ERR_DLL_LOCK
@ GET4_V2X_ERR_EPOCH_OVERF
@ GET4_V2X_ERR_EP_CNT_SYNC
@ GET4_V2X_ERR_UNKNOWN
@ GET4_V2X_ERR_READ_INIT
@ GET4_V2X_ERR_DLL_RESET
@ GET4_V2X_ERR_ADD_RIS_EDG
@ GET4_V2X_ERR_TOK_RING_ST
@ GET4_V2X_ERR_TOKEN
@ GET4_V2X_ERR_TOT_OVERWRT
@ GET4_V2X_ERR_READOUT_ERR
@ GET4_V2X_ERR_EVT_DISCARD
@ GET4_V2X_ERR_UNPAIR_FALL
@ GET4_V2X_ERR_CHAN_STATE
@ GET4_V2X_ERR_SYNC
@ GET4_V2X_ERR_SEQUENCE_ER
const uint32_t kuChipIdMergedEpoch
@ SYS_GET4_SYNC_MISS