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