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