CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MonitorMcbmRate.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// ----- CbmMcbm2018MonitorMcbmRate -----
8// ----- Created 11/05/18 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
13
15
16// Data
17
18// CbmRoot
19#include "CbmMcbm2018StsPar.h"
20#include "CbmMcbm2018TofPar.h"
21
22// FairRoot
23#include "FairRootManager.h"
24#include "FairRun.h"
25#include "FairRunOnline.h"
26#include "FairRuntimeDb.h"
27#include <Logger.h>
28
29// Root
30#include "TClonesArray.h"
31#include "TF1.h"
32#include "THttpServer.h"
33#include "TMath.h"
34#include "TROOT.h"
35#include "TRandom.h"
36#include "TString.h"
37#include "TStyle.h"
38#include <TFile.h>
39
40// C++11
41
42// C/C++
43#include <iomanip>
44#include <iostream>
45
46#include <stdint.h>
47/*
48Bool_t bMcbm2018ResetSync = kFALSE;
49Bool_t bMcbm2018WriteSync = kFALSE;
50*/
51/*
52Bool_t bMcbm2018ResetSync = kFALSE;
53Bool_t bMcbm2018WriteSync = kFALSE;
54*/
55/*
56Bool_t bMcbm2018SyncResetHistosTof = kFALSE;
57Bool_t bMcbm2018SyncSaveHistosTof = kFALSE;
58Bool_t bMcbm2018SyncUpdateZoomedFit = kFALSE;
59*/
60
63 , fvMsComponentsListSts()
64 , fvMsComponentsListTof()
65 , fuNbCoreMsPerTs(0)
66 , fuNbOverMsPerTs(0)
67 , fbIgnoreOverlapMs(kFALSE)
68 , fUnpackParSts(nullptr)
69 , fuStsNrOfDpbs(0)
70 , fmStsDpbIdIndexMap()
71 , fuMuchDpbIdx(1)
72 , fUnpackParTof(nullptr)
73 , fuTofNrOfDpbs(0)
74 , fmTofDpbIdIndexMap()
75 , fuDiamondDpbIdx(2)
76 , fuTotalNrOfDpb(0)
77 , fdStsTofOffsetNs(0.0)
78 , fdMuchTofOffsetNs(0.0)
79 , fsHistoFileFullname("data/mCBMsyncHistos.root")
80 , fbPrintMessages(kFALSE)
81 , fPrintMessCtrlSts(stsxyter::MessagePrintMask::msg_print_Human)
82 , fulCurrentTsIdx(0)
83 , fulCurrentMsIdx(0)
84 , fmMsgCounter()
85 , fuCurrentEquipmentId(0)
86 , fuCurrDpbId(0)
87 , fuCurrDpbIdx(0)
88 , fiRunStartDateTimeSec(-1)
89 , fiBinSizeDatePlots(-1)
90 , fvulStsCurrentTsMsb()
91 , fvuStsCurrentTsMsbCycle()
92 , fvmStsSdpbHitsInMs()
93 , fvmStsSdpbHitsInTs()
94 , fulTofCurrentTsIndex(0)
95 , fuTofCurrentMs(0)
96 , fdTofMsIndex(0)
97 , fuTofGdpbId(0)
98 , fuTofGdpbNr(0)
99 , fiTofEquipmentId(0)
100 , fviTofMsgCounter(1 + gdpbv100::MSG_STAR_TRI_D, 0)
101 , fvulTofCurrentEpoch()
102 , fvulTofCurrentEpochCycle()
103 , fvulTofCurrentEpochFull()
104 , fulTofCurrentEpochTime(0)
105 , fvmTofEpSupprBuffer()
106 , fvmTofGdpbHitsInMs()
107 , fvmTofGdpbHitsInTs()
108 , fvuHitsNbInTimeBinSts(kuNbTimeBins, 0)
109 , fvuHitsNbInTimeBinMuch(kuNbTimeBins, 0)
110 , fvuHitsNbInTimeBinTof(kuNbTimeBins, 0)
111 , fvuHitsNbInTimeBinDiam(kuNbTimeBins, 0)
112 , fhMcbmHitsNbPerTsEvo()
113 , fhMcbmHitsNbFineEvo()
114 , fhMcbmHitsRateEvo()
115 , fhDiamondHitsRateMapEvo()
116 , fhDiamondHitsRateDerivative()
117 , fhMuchVsStsHitsNbPerTimeBin()
118 , fhTofVsStsHitsNbPerTimeBin()
119 , fhDiamVsStsHitsNbPerTimeBin()
120 , fhStsVsMuchHitsNbPerTimeBin()
121 , fhTofVsMuchHitsNbPerTimeBin()
122 , fhDiamVsMuchHitsNbPerTimeBin()
123 , fhStsVsTofHitsNbPerTimeBin()
124 , fhMuchVsTofHitsNbPerTimeBin()
125 , fhDiamVsTofHitsNbPerTimeBin()
126 , fhStsVsDiamHitsNbPerTimeBin()
127 , fhTofVsDiamHitsNbPerTimeBin()
128 , fhMuchVsDiamHitsNbPerTimeBin()
129{
130}
131
133
135{
136 LOG(info) << "Initializing flib StsXyter unpacker for STS";
137
138 FairRootManager* ioman = FairRootManager::Instance();
139 if (ioman == nullptr) { LOG(fatal) << "No FairRootManager instance"; }
140
141 return kTRUE;
142}
143
145{
146 LOG(info) << "Setting parameter containers for " << GetName();
147 fUnpackParSts = (CbmMcbm2018StsPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMcbm2018StsPar"));
148 fUnpackParTof = (CbmMcbm2018TofPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMcbm2018TofPar"));
149}
150
151
153{
154 LOG(info) << "Init parameter containers for " << GetName();
155
156 Bool_t bReInit = ReInitContainers();
160
161 return bReInit;
162}
163
165{
166 LOG(info) << "ReInit parameter containers for " << GetName();
167
168 /***************** STS parameters *************************************/
170 LOG(info) << "Nr. of STS DPBs: " << fuStsNrOfDpbs;
171
172 fmStsDpbIdIndexMap.clear();
173 for (UInt_t uDpb = 0; uDpb < fuStsNrOfDpbs; ++uDpb) {
175 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = 0x" << std::setw(4) << std::hex
176 << fUnpackParSts->GetDpbId(uDpb) << std::dec << " => "
178 } // for( UInt_t uDpb = 0; uDpb < fuStsNrOfDpbs; ++uDpb )
179
184 /***************** STS parameters *************************************/
185
186 /***************** TOF parameters *************************************/
188 LOG(info) << "Nr. of Tof GDPBs: " << fuTofNrOfDpbs;
189
190 fmTofDpbIdIndexMap.clear();
191 for (UInt_t i = 0; i < fuTofNrOfDpbs; ++i) {
193 LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackParTof->GetGdpbId(i) << std::dec;
194 } // for( UInt_t i = 0; i < fuTofNrOfDpbs; ++i )
195
203 /***************** TOF parameters *************************************/
204
205 return kTRUE;
206}
207
208void CbmMcbm2018MonitorMcbmRate::AddMsComponentToList(size_t component, UShort_t usDetectorId)
209{
210 switch (usDetectorId) {
211 case 0x10: //fles::Subsystem::STS:
212 {
213 AddMsComponentToListSts(component);
214 break;
215 } // case 0x10:
216 case 0x60: //fles::Subsystem::TOF:
217 {
218 AddMsComponentToListTof(component);
219 break;
220 } // case 0x60:
221 default: {
222 LOG(warning) << "CbmMcbm2018MonitorStsSync::AddMsComponentToList => "
223 << "Ignore component " << component << " as detector id " << usDetectorId
224 << " is not supported by this unpacker.";
225 break;
226 } // default:
227 } // switch( iDetectorId )
228}
230{
232 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsListSts.size(); ++uCompIdx)
233 if (component == fvMsComponentsListSts[uCompIdx]) return;
234
236 fvMsComponentsListSts.push_back(component);
237}
239{
241 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsListTof.size(); ++uCompIdx)
242 if (component == fvMsComponentsListTof[uCompIdx]) return;
243
245 fvMsComponentsListTof.push_back(component);
246}
247void CbmMcbm2018MonitorMcbmRate::SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
248{
249 fuNbCoreMsPerTs = uCoreMsNb;
250 fuNbOverMsPerTs = uOverlapMsNb;
251
252 // UInt_t uNbMsTotal = fuNbCoreMsPerTs + fuNbOverMsPerTs;
253}
254
255/***************** STS Histograms *************************************/
257{
258 TString sHistName {""};
259 TString title {""};
260 /*
261 sHistName = "hPulserMessageType";
262 title = "Nb of message for each type; Type";
263 fhStsMessType = new TH1I(sHistName, title, 5, 0., 5.);
264 fhStsMessType->GetXaxis()->SetBinLabel( 1, "Dummy");
265 fhStsMessType->GetXaxis()->SetBinLabel( 2, "Hit");
266 fhStsMessType->GetXaxis()->SetBinLabel( 3, "TsMsb");
267 fhStsMessType->GetXaxis()->SetBinLabel( 4, "Epoch");
268 fhStsMessType->GetXaxis()->SetBinLabel( 5, "Empty");
269
270 // Online histo browser commands
271 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
272 if( server )
273 {
274 server->Register("/StsRaw", fhStsMessType );
275
276 server->RegisterCommand("/Reset_All_Pulser", "bMcbm2018ResetSync=kTRUE");
277 server->RegisterCommand("/Write_All_Pulser", "bMcbm2018WriteSync=kTRUE");
278
279 server->Restrict("/Reset_All_Pulser", "allow=admin");
280 server->Restrict("/Write_All_Pulser", "allow=admin");
281 } // if( server )
282*/
284 /*
285 Double_t w = 10;
286 Double_t h = 10;
287
288 // Summary per StsXyter
289 for( UInt_t uXyterIdx = 0; uXyterIdx < fuStsNbStsXyters; ++uXyterIdx )
290 {
291 TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ),
292 Form("Summary plots for StsXyter %03u", uXyterIdx ),
293 w, h);
294 cStsSumm->Divide( 2, 2 );
295
296 cStsSumm->cd(1);
297 gPad->SetLogy();
298 fhStsChanCntRaw[ uXyterIdx ]->Draw();
299
300 cStsSumm->cd(2);
301 gPad->SetLogz();
302 fhStsChanAdcRaw[ uXyterIdx ]->Draw( "colz" );
303
304 cStsSumm->cd(3);
305 gPad->SetLogz();
306 fhStsChanHitRateEvo[ uXyterIdx ]->Draw( "colz" );
307
308 cStsSumm->cd(4);
309// gPad->SetLogy();
310 fhStsChanAdcRawProf[ uXyterIdx ]->Draw();
311 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuStsNbStsXyters; ++uXyterIdx )
312
313//====================================================================//
314*/
315 /*****************************/
316 LOG(info) << "Done Creating STS Histograms";
317}
318/***************** STS Histograms *************************************/
319
320/***************** TOF Histograms *************************************/
322{
323 TString sHistName {""};
324 TString title {""};
325
326 /*******************************************************************/
327 /*
328
329 sHistName = "hMessageType";
330 title = "Nb of message for each type; Type";
331 // Test Big Data readout with plotting
332 fhTofMessType = new TH1I(sHistName, title, 1 + gdpbv100::MSG_STAR_TRI_A, 0., 1 + gdpbv100::MSG_STAR_TRI_A);
333 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_HIT, "HIT");
334 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_EPOCH, "EPOCH");
335 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SLOWC, "SLOWC");
336 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SYST, "SYST");
337 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_A, "MSG_STAR_TRI");
338*/
339 /*******************************************************************/
340 /*
341 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
342 if( server )
343 {
344 server->Register("/TofRaw", fhTofMessType );
345
346 server->RegisterCommand("/Reset_All_TOF", "bMcbm2018SyncResetHistosTof=kTRUE");
347 server->RegisterCommand("/Save_All_Tof", "bMcbm2018SyncSaveHistosTof=kTRUE");
348 server->RegisterCommand("/Update_PulsFit", "bMcbm2018SyncUpdateZoomedFit=kTRUE");
349
350 server->Restrict("/Reset_All_Tof", "allow=admin");
351 server->Restrict("/Save_All_Tof", "allow=admin");
352 server->Restrict("/Update_PulsFit", "allow=admin");
353 } // if( server )
354*/
356 /*
357 Double_t w = 10;
358 Double_t h = 10;
359 TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h);
360 cSummary->Divide(2, 3);
361
362 // 1st Column: Messages types
363 cSummary->cd(1);
364 gPad->SetLogy();
365 fhTofMessType->Draw();
366
367 cSummary->cd(2);
368 gPad->SetLogy();
369 fhTofSysMessType->Draw();
370
371 cSummary->cd(3);
372 gPad->SetLogz();
373 fhTofGet4MessType->Draw("colz");
374
375 // 2nd Column: GET4 Errors + Epoch flags + SCm
376 cSummary->cd(4);
377 gPad->SetLogz();
378 fhTofGet4ChanErrors->Draw("colz");
379
380 cSummary->cd(5);
381 gPad->SetLogz();
382 fhTofGet4EpochFlags->Draw("colz");
383
384 cSummary->cd(6);
385 fhTofGet4ChanScm->Draw("colz");
386*/
387 /*****************************/
388
389 LOG(info) << "Done Creating TOF Histograms";
390}
391/***************** TOF Histograms *************************************/
392
393/***************** mCBM Histograms ************************************/
395{
396 TString sHistName {""};
397 TString sHistTitle {""};
398
400
401 sHistName = "hMcbmHitsNbPerTsEvo";
402 sHistTitle = "Nb STS or TOF hits, per DPB and per TS; TS index []; DPB []; Nb Hits []";
403 fhMcbmHitsNbPerTsEvo = new TH2D(sHistName, sHistTitle, 400001, -0.5, 400000.5, fuTotalNrOfDpb, 0., fuTotalNrOfDpb);
404
405 sHistName = "hMcbmHitsNbFineEvo";
406 sHistTitle = "Nb STS or TOF hits, per DPB and per 100 ms; t [s]; DPB []; Hit rate [1/s]";
407 fhMcbmHitsNbFineEvo = new TH2D(sHistName, sHistTitle, 40001, -0.05, 4000.05, fuTotalNrOfDpb, 0., fuTotalNrOfDpb);
408
409 sHistName = "hMcbmHitsRateEvo";
410 sHistTitle = "STS or TOF hits rate per DPB as function of time in run; t "
411 "[s]; DPB []; Hit rate [1/s]";
412 fhMcbmHitsRateEvo = new TH2D(sHistName, sHistTitle, 4001, -0.5, 4000.5, fuTotalNrOfDpb, 0., fuTotalNrOfDpb);
413
414 sHistName = "hDiamondHitsRateMapEvo";
415 sHistTitle = "Counts per diamond strip and 100 ms as function of time in "
416 "run; t [s]; strip []; Counts []";
417 fhDiamondHitsRateMapEvo = new TH2D(sHistName, sHistTitle, 40001, -0.05, 4000.05, 8, 0., 8.);
418
419 sHistName = "hDiamondHitsRateDerivative";
420 sHistTitle = "Variation of the diamond counts per s in 100 ms bins as "
421 "function of time in run; t [s]; Delta(Counts/s) []";
422 fhDiamondHitsRateDerivative = new TH1D(sHistName, sHistTitle, 40000, 0., 4000.);
423
424 sHistName = "hMuchVsStsHitsNbPerTimeBin";
425 sHistTitle = Form("Nb Hits in MUCH vs Sts in time bins of %5u ns; Nb Hits "
426 "STS []; Nb Hits TOF []; Time bins []",
428 fhMuchVsStsHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
429 sHistName = "hTofVsStsHitsNbPerTimeBin";
430 sHistTitle = Form("Nb Hits in TOF vs Sts in time bins of %5u ns; Nb Hits STS "
431 "[]; Nb Hits MUCH []; Time bins []",
433 fhTofVsStsHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
434 sHistName = "hDiamVsStsHitsNbPerTimeBin";
435 sHistTitle = Form("Nb Hits in Diam vs Sts in time bins of %5u ns; Nb Hits "
436 "STS []; Nb Hits Diam []; Time bins []",
438 fhDiamVsStsHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
439
440 sHistName = "hStsVsMuchHitsNbPerTimeBin";
441 sHistTitle = Form("Nb Hits in STS vs MUCH in time bins of %5u ns; Nb Hits "
442 "MUCH []; Nb Hits STS []; Time bins []",
444 fhStsVsMuchHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
445 sHistName = "hTofVsMuchHitsNbPerTimeBin";
446 sHistTitle = Form("Nb Hits in TOF vs MUCH in time bins of %5u ns; Nb Hits "
447 "MUCH []; Nb Hits TOF []; Time bins []",
449 fhTofVsMuchHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
450 sHistName = "hDiamVsMuchHitsNbPerTimeBin";
451 sHistTitle = Form("Nb Hits in Diam vs MUCH in time bins of %5u ns; Nb Hits "
452 "MUCH []; Nb Hits Diam []; Time bins []",
454 fhDiamVsMuchHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
455
456 sHistName = "hStsVsTofHitsNbPerTimeBin";
457 sHistTitle = Form("Nb Hits in STS vs TOF in time bins of %5u ns; Nb Hits TOF "
458 "[]; Nb Hits STS []; Time bins []",
460 fhStsVsTofHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
461 sHistName = "hMuchVsTofHitsNbPerTimeBin";
462 sHistTitle = Form("Nb Hits in MUCH vs TOF in time bins of %5u ns; Nb Hits "
463 "TOF []; Nb Hits MUCH []; Time bins []",
465 fhMuchVsTofHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
466 sHistName = "hDiamVsTofHitsNbPerTimeBin";
467 sHistTitle = Form("Nb Hits in Diam vs TOF in time bins of %5u ns; Nb Hits "
468 "TOF []; Nb Hits Diam []; Time bins []",
470 fhDiamVsTofHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
471
472 sHistName = "hStsVsDiamHitsNbPerTimeBin";
473 sHistTitle = Form("Nb Hits in STS vs Diam in time bins of %5u ns; Nb Hits "
474 "Diam []; Nb Hits STS []; Time bins []",
476 fhStsVsDiamHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
477 sHistName = "hTofVsDiamHitsNbPerTimeBin";
478 sHistTitle = Form("Nb Hits in TOF vs Diam in time bins of %5u ns; Nb Hits "
479 "Diam []; Nb Hits TOF []; Time bins []",
481 fhTofVsDiamHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
482 sHistName = "hMuchVsDiamHitsNbPerTimeBin";
483 sHistTitle = Form("Nb Hits in MUCH vs Diam in time bins of %5u ns; Nb Hits "
484 "Diam []; Nb Hits MUCH []; Time bins []",
486 fhMuchVsDiamHitsNbPerTimeBin = new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
487
488 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
489 if (server) {
490 server->Register("/mCbmRate", fhMcbmHitsNbPerTsEvo);
491 server->Register("/mCbmRate", fhMcbmHitsNbFineEvo);
492 server->Register("/mCbmRate", fhMcbmHitsRateEvo);
493 /*
494 server->RegisterCommand("/Reset_All", "bMcbm2018ResetSync=kTRUE");
495 server->RegisterCommand("/Save_All", "bMcbm2018WriteSync=kTRUE");
496
497 server->Restrict("/Reset_All", "allow=admin");
498 server->Restrict("/Save_All", "allow=admin");
499*/
500 } // if( server )
501
502 // Double_t w = 10;
503 // Double_t h = 10;
505 /*
506 TCanvas* cSyncMcbm = new TCanvas("cSyncMcbm", "Time difference for STS and TOF hits, per DPB, against any Diamond hit", w, h);
507 cSyncMcbm->Divide( 2);
508
509 cSyncMcbm->cd(1);
510 gPad->SetGridx();
511 gPad->SetGridy();
512 gPad->SetLogz();
513 fhMcbmTimeDiffToDiamond->Draw( "colz" );
514
515 cSyncMcbm->cd(2);
516 gPad->SetGridx();
517 gPad->SetGridy();
518 gPad->SetLogz();
519 fhMcbmTimeDiffToDiamondWide->Draw( "colz" );
520*/
521 /*****************************/
522 LOG(info) << "Done Creating mCBM Histograms";
523}
524/***************** mCBM Histograms ************************************/
525
526Bool_t CbmMcbm2018MonitorMcbmRate::DoUnpack(const fles::Timeslice& ts, size_t component)
527{
529 /*
530 if( bMcbm2018ResetSync )
531 {
532 ResetAllHistos();
533 bMcbm2018ResetSync = kFALSE;
534 } // if( bMcbm2018ResetSync )
535 if( bMcbm2018WriteSync )
536 {
537 SaveAllHistos( fsHistoFileFullname );
538 bMcbm2018WriteSync = kFALSE;
539 } // if( bMcbm2018WriteSync )
540*/
541
542 LOG(debug) << "Timeslice contains " << ts.num_microslices(component) << "microslices.";
543 fulCurrentTsIdx = ts.index();
544 fulCurrentTsStartTime = ts.descriptor(0, 0).idx;
545
547 if (0 == fulCurrentTsIdx) return kTRUE;
548
549 if (fulCurrentTsIdx < 30) LOG(info) << Form("TS %2llu", fulCurrentTsIdx);
550
551 // Ignore overlap ms if flag set by user
552 UInt_t uNbMsLoop = fuNbCoreMsPerTs;
553 if (kFALSE == fbIgnoreOverlapMs) uNbMsLoop += fuNbOverMsPerTs;
554
555 // Loop over core microslices (and overlap ones if chosen)
556 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
557 // Loop over registered STS components
558 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsListSts.size(); ++uMsCompIdx) {
559 UInt_t uMsComp = fvMsComponentsListSts[uMsCompIdx];
560
561 if (kFALSE == ProcessStsMs(ts, uMsComp, uMsIdx)) return kFALSE;
562 } // for( UInt_t uMsComp = 0; uMsComp < fvMsComponentsListSts.size(); ++uMsComp )
563
564 // Loop over registered TOF components
565 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsListTof.size(); ++uMsCompIdx) {
566 UInt_t uMsComp = fvMsComponentsListTof[uMsCompIdx];
567
568 if (kFALSE == ProcessTofMs(ts, uMsComp, uMsIdx)) return kFALSE;
569 } // for( UInt_t uMsComp = 0; uMsComp < fvMsComponentsListSts.size(); ++uMsComp )
570
571 /****************** STS Sync ******************************************/
572 /*
574 for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
575 std::sort( fvmStsSdpbHitsInMs[ uSdpb ].begin(), fvmStsSdpbHitsInMs[ uSdpb ].end() );
576*/
577 /****************** STS Sync ******************************************/
578
579 /****************** TOF Sync ******************************************/
580 /*
582 for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
583 std::sort( fvmTofGdpbHitsInMs[ uGdpb ].begin(), fvmTofGdpbHitsInMs[ uGdpb ].end() );
584*/
585 UInt_t uNbDiaHits = fvmTofGdpbHitsInMs[fuDiamondDpbIdx].size();
586 for (UInt_t uHitDia = 0; uHitDia < uNbDiaHits; uHitDia++) {
587 // Double_t dDiaTime = fvmTofGdpbHitsInMs[ fuDiamondDpbIdx ][ uHitDia ].GetFullTimeNs() / 1e-9;
588 UInt_t uChan = 8;
589
590 switch (fvmTofGdpbHitsInMs[fuDiamondDpbIdx][uHitDia].getGdpbHitChanId()) {
591 case 0: uChan = 0; break;
592 case 32: uChan = 1; break;
593 case 64: uChan = 2; break;
594 case 96: uChan = 3; break;
595 case 160: uChan = 4; break;
596 case 192: uChan = 5; break;
597 case 224: uChan = 6; break;
598 case 256: uChan = 7; break;
599 } // switch( fvmTofGdpbHitsInMs[ fuDiamondDpbIdx ][ uHitDia ].GetHitChannel() )
600
601 if (uChan < 8)
602 // fhDiamondHitsRateMapEvo->Fill( dDiaTime, uChan, 0.1 );
603 fhDiamondHitsRateMapEvo->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx), uChan, 0.1);
604 } // for( UInt_t uHitDia = 0; uHitDia < uNbDiaHits; uHitDia++)
605 /****************** TOF Sync ******************************************/
606
607 /****************** mCBM Sync *****************************************/
609 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
610 UInt_t uNbHitsInMs = fvmStsSdpbHitsInMs[uSdpb].size();
611 fhMcbmHitsNbPerTsEvo->Fill(fulCurrentTsIdx, uSdpb, uNbHitsInMs);
612 fhMcbmHitsNbFineEvo->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx), uSdpb, uNbHitsInMs / 0.1);
613 fhMcbmHitsRateEvo->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx), uSdpb, uNbHitsInMs);
614
615 for (UInt_t uHit = 0; uHit < uNbHitsInMs; ++uHit) {
616 Double_t dHitTimeInTs =
618
620 if (fuMuchDpbIdx == uSdpb) dHitTimeInTs -= fdMuchTofOffsetNs;
621 else
622 dHitTimeInTs -= fdStsTofOffsetNs;
623
624 Int_t iTimeBin = static_cast<Int_t>(dHitTimeInTs / kuTimeBinSizeNs);
625 if (iTimeBin < 0 || kuNbTimeBins <= static_cast<UInt_t>(iTimeBin)) {
626 LOG(debug) << "sDPB hits with time out of the TS!! " << dHitTimeInTs << " " << iTimeBin;
627 continue;
628 } // if( iTimeBin < 0 || kuNbTimeBins <= iTimeBin )
629
630 if (fuMuchDpbIdx == uSdpb) fvuHitsNbInTimeBinMuch[iTimeBin]++;
631 else
632 fvuHitsNbInTimeBinSts[iTimeBin]++;
633 } // for( UInt_t uHit = 0; uHit < uNbHitsInMs; ++uHit )
634 /*
636 if( 0 < uSdpb )
637 fvmStsSdpbHitsInTs[ uSdpb ].insert( fvmStsSdpbHitsInTs[ uSdpb ].end(),
638 fvmStsSdpbHitsInMs[ uSdpb ].begin(),
639 fvmStsSdpbHitsInMs[ uSdpb ].end() );
640*/
641 fvmStsSdpbHitsInMs[uSdpb].clear();
642 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
643 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
644 UInt_t uNbHitsInMs = fvmTofGdpbHitsInMs[uGdpb].size();
645 fhMcbmHitsNbPerTsEvo->Fill(fulCurrentTsIdx, uGdpb + fuStsNrOfDpbs, uNbHitsInMs);
646 fhMcbmHitsNbFineEvo->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx), uGdpb + fuStsNrOfDpbs,
647 uNbHitsInMs / 0.1);
648 fhMcbmHitsRateEvo->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx), uGdpb + fuStsNrOfDpbs, uNbHitsInMs);
649
650 if (fuDiamondDpbIdx == uGdpb) {
652 fhDiamondHitsRateDerivative->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx) - 0.05,
653 fvmTofGdpbHitsInMs[uGdpb].size() / 0.1);
655 fhDiamondHitsRateDerivative->Fill((1e-9) * static_cast<double>(fulCurrentMsIdx) + 0.05,
656 fvmTofGdpbHitsInMs[uGdpb].size() / -0.1);
657 } // if( fuDiamondDpbIdx == uGdpb )
658
659 for (UInt_t uHit = 0; uHit < uNbHitsInMs; ++uHit) {
660 Double_t dHitTimeInTs = fvmTofGdpbHitsInMs[uGdpb][uHit].GetFullTimeNs() - fulCurrentTsStartTime;
661
662 Int_t iTimeBin = static_cast<Int_t>(dHitTimeInTs / kuTimeBinSizeNs);
663 if (iTimeBin < 0 || kuNbTimeBins <= static_cast<UInt_t>(iTimeBin)) {
664 LOG(debug) << "gDPB hits with time out of the TS!! " << fvmTofGdpbHitsInMs[uGdpb][uHit].GetFullTimeNs() << " "
665 << fulCurrentTsStartTime << " " << iTimeBin;
666 continue;
667 } // if( iTimeBin < 0 || kuNbTimeBins <= iTimeBin )
668
669 if (fuDiamondDpbIdx == uGdpb) fvuHitsNbInTimeBinDiam[iTimeBin]++;
670 else
671 fvuHitsNbInTimeBinTof[iTimeBin]++;
672 } // for( UInt_t uHit = 0; uHit < uNbHitsInMs; ++uHit )
673
674 /*
675 fvmTofGdpbHitsInTs[ uGdpb ].insert( fvmTofGdpbHitsInTs[ uGdpb ].end(),
676 fvmTofGdpbHitsInMs[ uGdpb ].begin(),
677 fvmTofGdpbHitsInMs[ uGdpb ].end() );
678*/
679 fvmTofGdpbHitsInMs[uGdpb].clear();
680 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
681 /****************** mCBM Sync *****************************************/
682 } // for( UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx ++ )
683
684 /****************** mCBM Sync *****************************************/
685 /*
687 UInt_t uNbDiaHits = fvmTofGdpbHitsInTs[ fuDiamondDpbIdx ].size();
688 for( UInt_t uHitDia = 0; uHitDia < uNbDiaHits; uHitDia++)
689 {
690 Double_t dDiaTime = fvmTofGdpbHitsInTs[ fuDiamondDpbIdx ][ uHitDia ].GetFullTimeNs();
691
693 for( UInt_t uSdpb = 1; uSdpb < fuStsNrOfDpbs; ++uSdpb )
694 {
695 UInt_t uNbHits = fvmStsSdpbHitsInTs[ uSdpb ].size();
696 for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
697 {
698 Double_t dHitTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInTs[ uSdpb ][ uHit ].GetTs();
699
700 Double_t dDt = dHitTime - dDiaTime;
701 fhMcbmTimeDiffToDiamondTs->Fill( dDt / 1e6, uSdpb );
702
703 fvhMcbmTimeDiffToDiamondTsEvoDpb[ uSdpb ]->Fill( fulCurrentTsIdx, dDt / 1e6 );
704 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
705 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
706
707 for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
708 {
709 if( fuDiamondDpbIdx == uGdpb )
710 continue;
711
712 UInt_t uNbHits = fvmTofGdpbHitsInTs[ uGdpb ].size();
713 for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
714 {
715 Double_t dHitTime = fvmTofGdpbHitsInTs[ uGdpb ][ uHit ].GetFullTimeNs();
716
717 Double_t dDt = dHitTime - dDiaTime;
718 fhMcbmTimeDiffToDiamondTs->Fill( dDt / 1e6, uGdpb + fuStsNrOfDpbs );
719
720 fvhMcbmTimeDiffToDiamondTsEvoDpb[ uGdpb + fuStsNrOfDpbs ]->Fill( fulCurrentTsIdx, dDt / 1e6 );
721 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
722 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
723 } // for( UInt_t uHitDia = 0; uHitDia < uNbDiaHits; uHitDia++)
724
726 for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
727 {
728 fvmStsSdpbHitsInTs[ uSdpb ].clear();
729 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
730 for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
731 {
732 fvmTofGdpbHitsInTs[ uGdpb ].clear();
733 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
734*/
735
736 for (UInt_t uTimeBin = 0; uTimeBin < kuNbTimeBins; ++uTimeBin) {
737 if (0 < fvuHitsNbInTimeBinSts[uTimeBin]) {
738 if (0 < fvuHitsNbInTimeBinMuch[uTimeBin])
740 if (0 < fvuHitsNbInTimeBinTof[uTimeBin])
742 if (0 < fvuHitsNbInTimeBinDiam[uTimeBin])
744 } // if( 0 < fvuHitsNbInTimeBinSts[ uTimeBin ] )
745
746 if (0 < fvuHitsNbInTimeBinMuch[uTimeBin]) {
747 if (0 < fvuHitsNbInTimeBinSts[uTimeBin])
749 if (0 < fvuHitsNbInTimeBinTof[uTimeBin])
751 if (0 < fvuHitsNbInTimeBinDiam[uTimeBin])
753 } // if( 0 < fvuHitsNbInTimeBinMuch[ uTimeBin ] )
754
755 if (0 < fvuHitsNbInTimeBinTof[uTimeBin]) {
756 if (0 < fvuHitsNbInTimeBinSts[uTimeBin])
758 if (0 < fvuHitsNbInTimeBinMuch[uTimeBin])
760 if (0 < fvuHitsNbInTimeBinDiam[uTimeBin])
762 } // if( 0 < fvuHitsNbInTimeBinTof[ uTimeBin ] )
763
764 if (0 < fvuHitsNbInTimeBinDiam[uTimeBin]) {
765 if (0 < fvuHitsNbInTimeBinSts[uTimeBin])
767 if (0 < fvuHitsNbInTimeBinMuch[uTimeBin])
769 if (0 < fvuHitsNbInTimeBinTof[uTimeBin])
771 } // if( 0 < fvuHitsNbInTimeBinDiam[ uTimeBin ] )
772
773 fvuHitsNbInTimeBinSts[uTimeBin] = 0;
774 fvuHitsNbInTimeBinMuch[uTimeBin] = 0;
775 fvuHitsNbInTimeBinTof[uTimeBin] = 0;
776 fvuHitsNbInTimeBinDiam[uTimeBin] = 0;
777 } // for( UInt_t uTimeBin = 0; uTimeBin < kuNbTimeBins; ++uTimeBin )
778 /****************** mCBM Sync *****************************************/
779
780 if (0 == ts.index() % 1000) {
781 LOG(info) << "End of TS " << std::setw(7) << ts.index();
782 } // if( 0 == ts.index() % 1000 )
783
784 return kTRUE;
785}
786
787/****************** STS Sync ******************************************/
788Bool_t CbmMcbm2018MonitorMcbmRate::ProcessStsMs(const fles::Timeslice& ts, size_t uMsComp, UInt_t uMsIdx)
789{
790 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
791 fuCurrentEquipmentId = msDescriptor.eq_id;
792 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
793
794 uint32_t uSize = msDescriptor.size;
795 fulCurrentMsIdx = msDescriptor.idx;
796 // Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
797 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
798 << " has size: " << uSize;
799
800 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
801 // fuCurrDpbIdx = fmStsDpbIdIndexMap[ fuCurrDpbId ];
802
804 auto it = fmStsDpbIdIndexMap.find(fuCurrDpbId);
805 if (it == fmStsDpbIdIndexMap.end()) {
806 LOG(info) << "---------------------------------------------------------------";
807 /*
808 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
809 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
810 static_cast<unsigned int>(msDescriptor.hdr_id),
811 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
812 static_cast<unsigned int>(msDescriptor.sys_id),
813 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
814 msDescriptor.size, msDescriptor.offset );
815*/
816 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
817 LOG(warning) << "Could not find the sDPB index for AFCK id 0x" << std::hex << fuCurrDpbId << std::dec
818 << " in timeslice " << fulCurrentTsIdx << " in microslice " << uMsIdx << " component " << uMsComp
819 << "\n"
820 << "If valid this index has to be added in the STS/MUCH "
821 "parameter file in the RocIdArray field";
822 return kFALSE;
823 } // if( it == fmStsDpbIdIndexMap.end() )
824 else
826
828 UInt_t uTsMsbCycleHeader = std::floor(fulCurrentMsIdx / (stsxyter::kulTsCycleNbBins * stsxyter::kdClockCycleNs));
829
830 if (0 == uMsIdx) {
831 fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
833 } // if( 0 == uMsIdx )
834 else if (uTsMsbCycleHeader != fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] && 4194303 != fvulStsCurrentTsMsb[fuCurrDpbIdx]) {
835 LOG(warning) << "TS MSB cycle from MS header does not match current cycle from data "
836 << "for TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
837 << " MsInTs " << std::setw(3) << uMsIdx << " ====> " << fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] << " VS "
838 << uTsMsbCycleHeader;
839 fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
840 }
841
842 // If not integer number of message in input buffer, print warning/error
843 if (0 != (uSize % kuStsBytesPerMessage))
844 LOG(error) << "The input microslice buffer does NOT "
845 << "contain only complete nDPB messages!";
846
847 // Compute the number of complete messages in the input microslice buffer
848 uint32_t uNbMessages = (uSize - (uSize % kuStsBytesPerMessage)) / kuStsBytesPerMessage;
849
850 // Prepare variables for the loop on contents
851 const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>(msContent);
852
853 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
854 // Fill message
855 uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]);
856
857 stsxyter::Message mess(static_cast<uint32_t>(ulData & 0xFFFFFFFF));
858
859 // Print message if requested
860 if (fbPrintMessages) mess.PrintMess(std::cout, fPrintMessCtrlSts);
861
862 stsxyter::MessType typeMess = mess.GetMessType();
863 fmMsgCounter[typeMess]++;
864
865 switch (typeMess) {
867
868 FillStsHitInfo(mess, uMsIdx);
869 break;
870 } // case stsxyter::MessType::Hit :
872 FillStsTsMsbInfo(mess, uIdx, uMsIdx);
873 break;
874 } // case stsxyter::MessType::TsMsb :
876 // The first message in the TS is a special ones: EPOCH
877 FillStsEpochInfo(mess);
878
879 if (0 < uIdx)
880 LOG(info) << "CbmMcbm2018MonitorMcbmRate::DoUnpack => "
881 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
882 break;
883 } // case stsxyter::MessType::TsMsb :
887 break;
888 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
889 default: {
890 LOG(fatal) << "CbmMcbm2018MonitorMcbmRate::DoUnpack => "
891 << "Unknown message type, should never happen, stopping here!";
892 }
893 } // switch( mess.GetMessType() )
894 } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx )
895 return kTRUE;
896}
897
899{
900 UShort_t usChan = mess.GetHitChannel();
901 UShort_t usRawAdc = mess.GetHitAdc();
902 // UShort_t usFullTs = mess.GetHitTimeFull();
903 // UShort_t usTsOver = mess.GetHitTimeOver();
904 UShort_t usRawTs = mess.GetHitTime();
905
906 UInt_t uAsicIdx = 0;
907
908 if (fuCurrDpbIdx == fuMuchDpbIdx) {
910 switch (usChan) {
911 case 101:
912 case 99:
913 case 91:
914 case 89:
915 case 88:
916 case 86:
917 case 84:
918 case 83:
919 case 80:
920 case 78:
921 case 76:
922 case 50:
923 case 39:
924 case 37:
925 case 35:
926 case 20: {
927 return;
928 break;
929 } // if bad channel
930 default: break;
931 } // switch( usChan )
932 } // if( fuCurrDpbIdx == fuMuchDpbIdx )
933 else {
935 uAsicIdx = fUnpackParSts->ElinkIdxToAsicIdx(kFALSE, mess.GetLinkIndex());
936 UInt_t uChanIdx = usChan + fUnpackParSts->GetNbChanPerAsic() * uAsicIdx;
937 switch (uChanIdx) {
938 case 781:
939 case 270:
940 case 411:
941 case 518: {
942 return;
943 break;
944 } // if bad channel
945 default: break;
946 } // switch( mess.GetLinkIndex() )
947 if ((0 == uChanIdx % 2) && (543 < uChanIdx) && (uChanIdx < 633)) { return; } // if bad channel
948 } // else of if( fuCurrDpbIdx == fuMuchDpbIdx )
949
950 // Compute the Full time stamp
951 // Use TS w/o overlap bits as they will anyway come from the TS_MSB
952 Long64_t ulStsHitTime = usRawTs;
953
954 ulStsHitTime +=
955 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulStsCurrentTsMsb[fuCurrDpbIdx])
956 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins)
957 * static_cast<ULong64_t>(fvuStsCurrentTsMsbCycle[fuCurrDpbIdx]);
958
959 // Convert the Hit time in bins to Hit time in ns
960 // Double_t dHitTimeNs = ulStsHitTime * stsxyter::kdClockCycleNs;
961
962 // Pulser and MS
963 fvmStsSdpbHitsInMs[fuCurrDpbIdx].push_back(stsxyter::FinalHit(ulStsHitTime, usRawAdc, uAsicIdx, usChan));
964}
965
966void CbmMcbm2018MonitorMcbmRate::FillStsTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx, UInt_t uMsIdx)
967{
968 UInt_t uVal = mess.GetTsMsbVal();
969
970 // Update Status counters
971 if (uVal < fvulStsCurrentTsMsb[fuCurrDpbIdx]) {
972
973 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " DPB "
974 << std::setw(2) << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulStsCurrentTsMsb[fuCurrDpbIdx]
975 << " Old MsbCy " << std::setw(5) << fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] << " new TsMsb " << std::setw(5)
976 << uVal;
977
979 } // if( uVal < fvulStsCurrentTsMsb[fuCurrDpbIdx] )
980 if (uVal != fvulStsCurrentTsMsb[fuCurrDpbIdx] + 1 && 0 != uVal && 4194303 != fvulStsCurrentTsMsb[fuCurrDpbIdx]
981 && 1 != uMessIdx) {
982 LOG(info) << "TS MSb Jump in "
983 << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
984 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
985 << fuCurrDpbIdx << " => Old TsMsb " << std::setw(5) << fvulStsCurrentTsMsb[fuCurrDpbIdx] << " new TsMsb "
986 << std::setw(5) << uVal;
987 } // if( uVal + 1 != fvulStsCurrentTsMsb[fuCurrDpbIdx] && 4194303 != uVal && 0 != fvulStsCurrentTsMsb[fuCurrDpbIdx] )
989 /*
990 ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins )
991 * static_cast< ULong64_t >( fvulStsCurrentTsMsb[fuCurrDpbIdx])
992 + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins )
993 * static_cast< ULong64_t >( fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] );
994*/
995}
996
998{
999 // UInt_t uVal = mess.GetTsMsbVal();
1000}
1001/****************** STS Sync ******************************************/
1002
1003/****************** TOF Sync ******************************************/
1004
1005Bool_t CbmMcbm2018MonitorMcbmRate::ProcessTofMs(const fles::Timeslice& ts, size_t uMsComp, UInt_t uMsIdx)
1006{
1007 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
1008 fuCurrentEquipmentId = msDescriptor.eq_id;
1009 fdTofMsIndex = static_cast<double>(msDescriptor.idx);
1010 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
1011
1012 uint32_t size = msDescriptor.size;
1013 // fulLastMsIdx = msDescriptor.idx;
1014 if (size > 0) LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size;
1015
1016 Int_t messageType = -111;
1017
1018 // If not integer number of message in input buffer, print warning/error
1019 if (0 != (size % kuTofBytesPerMessage))
1020 LOG(error) << "The input microslice buffer does NOT "
1021 << "contain only complete nDPB messages!";
1022
1023 // Compute the number of complete messages in the input microslice buffer
1024 uint32_t uNbMessages = (size - (size % kuTofBytesPerMessage)) / kuTofBytesPerMessage;
1025
1026 // Get the gDPB ID from the MS header
1028 // fuTofGdpbNr = fmTofDpbIdIndexMap[fuTofGdpbId];
1029
1031 auto it = fmTofDpbIdIndexMap.find(fuTofGdpbId);
1032 if (it == fmTofDpbIdIndexMap.end()) {
1033 LOG(info) << "---------------------------------------------------------------";
1034 /*
1035 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
1036 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
1037 static_cast<unsigned int>(msDescriptor.hdr_id),
1038 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
1039 static_cast<unsigned int>(msDescriptor.sys_id),
1040 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
1041 msDescriptor.size, msDescriptor.offset );
1042*/
1043 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
1044 LOG(warning) << "Could not find the gDPB index for AFCK id 0x" << std::hex << fuTofGdpbId << std::dec
1045 << " in timeslice " << fulCurrentTsIdx << " in microslice " << uMsIdx << " component " << uMsComp
1046 << "\n"
1047 << "If valid this index has to be added in the TOF parameter "
1048 "file in the RocIdArray field";
1049 return kFALSE;
1050 } // if( it == fmTofDpbIdIndexMap.end() )
1051 else
1053
1054 // Prepare variables for the loop on contents
1055 const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent);
1056 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
1057 // Fill message
1058 uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]);
1059 gdpbv100::Message mess(ulData);
1060
1062 if (0 == uIdx) {
1063 FillTofEpochCycle(ulData);
1064 continue;
1065 } // if( 0 == uIdx )
1066
1067 if (fair::Logger::Logging(fair::Severity::debug2)) {
1068 mess.printDataCout();
1069 } // if (fair::Logger::Logging( fair::Severity::debug2 ))
1070
1071 // Increment counter for different message types
1072 // and fill the corresponding histogram
1073 messageType = mess.getMessageType();
1074 fviTofMsgCounter[messageType]++;
1075
1076 switch (messageType) {
1077 case gdpbv100::MSG_HIT: {
1078 if (!mess.getGdpbHitIs24b()) { fvmTofEpSupprBuffer[fuTofGdpbNr].push_back(mess); } // if( !getGdpbHitIs24b() )
1079 break;
1080 } // case gdpbv100::MSG_HIT:
1081 case gdpbv100::MSG_EPOCH: {
1083 FillTofEpochInfo(mess);
1084 } // if this epoch message is a merged one valiud for all chips
1085 else
1086 LOG(fatal) << "Bad epoch: " << mess.getGdpbGenChipId();
1087 break;
1088 } // case gdpbv100::MSG_EPOCH:
1090 case gdpbv100::MSG_SYST:
1094 case gdpbv100::MSG_STAR_TRI_D: break;
1095 default:
1096 LOG(error) << "Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
1097 << " not included in Get4 unpacker.";
1098 } // switch( mess.getMessageType() )
1099 } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
1100
1101 return kTRUE;
1102}
1103
1105{
1106 uint64_t ulEpochCycleVal = ulCycleData & gdpbv100::kulEpochCycleFieldSz;
1107 fvulTofCurrentEpochCycle[fuTofGdpbNr] = ulEpochCycleVal;
1108
1109 return;
1110}
1111
1113{
1114 // UInt_t uChannel = mess.getGdpbHitChanId();
1115 // UInt_t uTot = mess.getGdpbHit32Tot();
1116 // UInt_t uFts = mess.getGdpbHitFineTs();
1117
1118 ULong64_t ulCurEpochGdpbGet4 = fvulTofCurrentEpochFull[fuTofGdpbNr];
1119
1120 // In Ep. Suppr. Mode, receive following epoch instead of previous
1121 if (0 < ulCurEpochGdpbGet4) ulCurEpochGdpbGet4--;
1122 else
1123 ulCurEpochGdpbGet4 = gdpbv100::kuEpochCounterSz; // Catch epoch cycle!
1124
1125 // ULong_t ulHitTime = mess.getMsgFullTime(ulCurEpochGdpbGet4);
1126 // Double_t dHitTime = mess.getMsgFullTimeD(ulCurEpochGdpbGet4);
1127
1128 // In 32b mode the coarse counter is already computed back to 112 FTS bins
1129 // => need to hide its contribution from the Finetime
1130 // => FTS = Fullt TS modulo 112
1131 // uFts = mess.getGdpbHitFullTs() % 112;
1132
1134 fvmTofGdpbHitsInMs[fuTofGdpbNr].push_back(gdpbv100::FullMessage(mess, ulCurEpochGdpbGet4));
1135}
1136
1138{
1139 ULong64_t ulEpochNr = mess.getGdpbEpEpochNb();
1140
1141 fvulTofCurrentEpoch[fuTofGdpbNr] = ulEpochNr;
1144
1145 fulTofCurrentEpochTime = mess.getMsgFullTime(ulEpochNr);
1146
1149 if (0 < ulEpochNr) mess.setGdpbEpEpochNb(ulEpochNr - 1);
1150 else
1152
1153 Int_t iBufferSize = fvmTofEpSupprBuffer[fuTofGdpbNr].size();
1154 if (0 < iBufferSize) {
1155 LOG(debug) << "Now processing stored messages for for gDPB " << fuTofGdpbNr << " with epoch number "
1157
1160 std::stable_sort(fvmTofEpSupprBuffer[fuTofGdpbNr].begin(), fvmTofEpSupprBuffer[fuTofGdpbNr].begin());
1161
1162 for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
1164 } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
1165
1167 } // if( 0 < fvmTofEpSupprBuffer[fuTofGdpbNr] )
1168}
1169/****************** TOF Sync ******************************************/
1170
1171/****************** STS histos ****************************************/
1172/****************** STS histos ****************************************/
1173
1174/****************** TOF histos ****************************************/
1175/****************** TOF Histos ****************************************/
1176
1178
1180{
1181 /*
1182 LOG(info) << "-------------------------------------";
1183 LOG(info) << "CbmMcbm2018MonitorMcbmRate statistics are ";
1184 LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n"
1185 << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n"
1186 << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n"
1187 << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n"
1188 << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ];
1189*/
1190 LOG(info) << "-------------------------------------";
1191
1193 SaveAllHistos();
1194}
1195
1196
1198{
1200 TFile* oldFile = gFile;
1201 TDirectory* oldDir = gDirectory;
1202
1203 TFile* histoFile = nullptr;
1204 if ("" != sFileName) {
1205 // open separate histo file in recreate mode
1206 histoFile = new TFile(sFileName, "RECREATE");
1207 histoFile->cd();
1208 } // if( "" != sFileName )
1209
1210 /****************** STS Sync ******************************************/
1211 /****************** STS Sync ******************************************/
1212
1213 /****************** TOF Sync ******************************************/
1214 /****************** TOF Sync ******************************************/
1215
1216 /****************** mCBM Sync *****************************************/
1217 gDirectory->mkdir("mCbmRate");
1218 gDirectory->cd("mCbmRate");
1219 fhMcbmHitsNbPerTsEvo->Write();
1220 fhMcbmHitsNbFineEvo->Write();
1221 fhMcbmHitsRateEvo->Write();
1222 fhDiamondHitsRateMapEvo->Write();
1224 gDirectory->cd("..");
1225
1226 gDirectory->mkdir("mCbmCounts");
1227 gDirectory->cd("mCbmCounts");
1240 gDirectory->cd("..");
1241 /****************** mCBM Sync *****************************************/
1242
1243 if ("" != sFileName) {
1244 // Restore original directory position
1245 histoFile->Close();
1246 } // if( "" != sFileName )
1247
1249 gFile = oldFile;
1250 gDirectory = oldDir;
1251}
1253{
1254 /****************** STS Sync ******************************************/
1255 /****************** STS Sync ******************************************/
1256
1257 /****************** TOF Sync ******************************************/
1258
1259 /****************** TOF Sync ******************************************/
1260
1261 /****************** mCBM Sync *****************************************/
1262 fhMcbmHitsNbPerTsEvo->Reset();
1263 fhMcbmHitsNbFineEvo->Reset();
1264 fhMcbmHitsRateEvo->Reset();
1265 fhDiamondHitsRateMapEvo->Reset();
1267
1280 /****************** mCBM Sync *****************************************/
1281}
1282
ClassImp(CbmConverterManager)
std::string FormatMsHeaderPrintout(const fles::MicrosliceDescriptor &msDescriptor)
static constexpr size_t size()
Definition KfSimdPseudo.h:2
Bool_t ProcessStsMs(const fles::Timeslice &ts, size_t uMsComp, UInt_t uMsIdx)
stsxyter::MessagePrintMask fPrintMessCtrlSts
void FillStsHitInfo(stsxyter::Message mess, const UInt_t &uMsIdx)
void AddMsComponentToListSts(size_t component)
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
UInt_t fuTotalNrOfDpb
Global parameters.
std::vector< UInt_t > fvuHitsNbInTimeBinSts
std::map< UInt_t, UInt_t > fmStsDpbIdIndexMap
Total number of Sts DPBs in system.
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
std::vector< std::vector< gdpbv100::FullMessage > > fvmTofGdpbHitsInMs
Buffer for system sync check.
std::vector< UInt_t > fvuHitsNbInTimeBinTof
std::vector< ULong64_t > fvulTofCurrentEpoch
void SaveAllHistos(TString sFileName="")
Bool_t ProcessTofMs(const fles::Timeslice &ts, size_t uMsComp, UInt_t uMsIdx)
void FillTofEpochCycle(uint64_t ulCycleData)
std::vector< std::vector< gdpbv100::Message > > fvmTofEpSupprBuffer
Buffer for suppressed epoch processing.
void FillStsTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
std::vector< std::vector< stsxyter::FinalHit > > fvmStsSdpbHitsInMs
Current TS MSB cycle for DPB.
virtual void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
std::map< UInt_t, UInt_t > fmTofDpbIdIndexMap
Total number of GDPBs in the system.
std::vector< UInt_t > fvuHitsNbInTimeBinMuch
void CreateTofHistograms()
Processing methods.
std::vector< ULong64_t > fvulTofCurrentEpochCycle
void FillStsEpochInfo(stsxyter::Message mess)
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
std::vector< std::vector< stsxyter::FinalHit > > fvmStsSdpbHitsInTs
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
std::vector< size_t > fvMsComponentsListSts
void AddMsComponentToListTof(size_t component)
virtual void AddMsComponentToList(size_t component, UShort_t usDetectorId)
std::vector< size_t > fvMsComponentsListTof
std::vector< UInt_t > fvuHitsNbInTimeBinDiam
std::vector< ULong64_t > fvulTofCurrentEpochFull
std::vector< ULong64_t > fvulStsCurrentTsMsb
Bin size in s for the plots with date as X axis.
void CreateStsHistograms()
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
static const UInt_t kuTofBytesPerMessage
TODO => move to the message class!!
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
CbmMcbm2018TofPar * fUnpackParTof
Unpacking and mapping parameters for TOF.
std::vector< std::vector< gdpbv100::FullMessage > > fvmTofGdpbHitsInTs
UInt_t fuMuchDpbIdx
Map of DPB Identifier to DPB index.
std::vector< UInt_t > fvuStsCurrentTsMsbCycle
Current TS MSB for each DPB.
UInt_t GetDpbId(UInt_t uDpbIdx)
UInt_t ElinkIdxToAsicIdx(Bool_t bFebType, UInt_t uElink)
static constexpr UInt_t GetNbChanPerAsic()
Int_t GetNrOfGdpbs()
FIXME: replace with method returning the correspondign constants! see Star2019 parameter.
Int_t GetGdpbId(Int_t i)
uint16_t getGdpbHitIs24b() const
uint32_t getGdpbEpEpochNb() const
void setGdpbEpEpochNb(uint32_t v)
uint16_t getGdpbGenChipId() const
void printDataCout(unsigned kind=msg_print_Prefix|msg_print_Data, uint32_t epoch=0) const
Print message in human readable format to cout.
uint8_t getMessageType() const
Returns the message type. Valid for all message types. 4 bit.
uint64_t getMsgFullTime(uint64_t epoch) const
Returns expanded and adjusted time of message (in ns)
XPU_D uint16_t GetHitAdc() const
For Hit data: Returns ADC value (5 bit field)
XPU_D uint16_t GetHitChannel() const
For Hit data: Returns StsXYTER channel number (7 bit field)
bool PrintMess(std::ostream &os, MessagePrintMask ctrl=MessagePrintMask::msg_print_Human, bool bBinning=true) const
XPU_D uint16_t GetLinkIndex() const
For all data: Returns the (global) index of the eLink on which the message was received (n bit field)
XPU_D MessType GetMessType() const
Returns the message type, see enum MessType.
XPU_D uint16_t GetHitTime() const
For Hit data: Returns timestamp (8 bit field, 2 MSB bits overlap removed)
XPU_D uint32_t GetTsMsbVal() const
For TS MSB data: Returns the TS MSB 22 bit field)
const uint64_t kulEpochCycleBins
const uint32_t kuChipIdMergedEpoch
const uint32_t kuEpochCounterSz
const uint64_t kulEpochCycleFieldSz
static constexpr uint64_t kulTsCycleNbBins
static constexpr uint32_t kuHitNbTsBins
static constexpr double kdClockCycleNs
MessType
Message types.