CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MonitorMcbmPulser.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-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// ----- CbmMcbm2018MonitorMcbmPulser -----
8// ----- Created 20/02/19 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
13
14// Data
15
16// CbmRoot
17#include "CbmMcbm2018StsPar.h"
18#include "CbmMcbm2018TofPar.h"
19
20// FairRoot
21#include "FairRootManager.h"
22#include "FairRun.h"
23#include "FairRunOnline.h"
24#include "FairRuntimeDb.h"
25#include <Logger.h>
26
27// Root
28#include "TClonesArray.h"
29#include "TF1.h"
30#include "THttpServer.h"
31#include "TMath.h"
32#include "TROOT.h"
33#include "TRandom.h"
34#include "TString.h"
35#include "TStyle.h"
36#include <TFile.h>
37
38// C++11
39
40// C/C++
41#include <iomanip>
42#include <iostream>
43
44#include <stdint.h>
45
46Bool_t bMcbm2018ResetPulser = kFALSE;
47Bool_t bMcbm2018WritePulser = kFALSE;
48/*
49Bool_t bMcbm2018ResetPulser = kFALSE;
50Bool_t bMcbm2018WritePulser = kFALSE;
51*/
52/*
53Bool_t bMcbm2018SyncResetHistosTof = kFALSE;
54Bool_t bMcbm2018SyncSaveHistosTof = kFALSE;
55Bool_t bMcbm2018SyncUpdateZoomedFit = kFALSE;
56*/
57
60 , fvMsComponentsListSts()
61 , fvMsComponentsListTof()
62 , fuNbCoreMsPerTs(0)
63 , fuNbOverMsPerTs(0)
64 , fbIgnoreOverlapMs(kFALSE)
65 , fUnpackParSts(nullptr)
66 , fuStsNrOfDpbs(0)
67 , fmStsDpbIdIndexMap()
68 , fuMuchDpbIdx(1)
69 , fUnpackParTof(nullptr)
70 , fuTofNrOfDpbs(0)
71 , fmTofDpbIdIndexMap()
72 , fuDiamondDpbIdx(2)
73 , fuTotalNrOfDpb(0)
74 , fdStsTofOffsetNs(0.0)
75 , fdMuchTofOffsetNs(0.0)
76 , fbUseBestPair(kFALSE)
77 , fbTsLevelAna(kFALSE)
78 , fsHistoFileFullname("data/mCBMsyncHistos.root")
79 , fbPrintMessages(kFALSE)
80 , fPrintMessCtrlSts(stsxyter::MessagePrintMask::msg_print_Human)
81 , fulCurrentTsIdx(0)
82 , fulCurrentMsIdx(0)
83 , fmMsgCounter()
84 , fuCurrentEquipmentId(0)
85 , fuCurrDpbId(0)
86 , fuCurrDpbIdx(0)
87 , fiRunStartDateTimeSec(-1)
88 , fiBinSizeDatePlots(-1)
89 , fvulStsCurrentTsMsb()
90 , fvuStsCurrentTsMsbCycle()
91 , fvmStsSdpbHitsInMs()
92 , fvmStsSdpbHitsInTs()
93 , fulTofCurrentTsIndex(0)
94 , fuTofCurrentMs(0)
95 , fdTofMsIndex(0)
96 , fuTofGdpbId(0)
97 , fuTofGdpbNr(0)
98 , fiTofEquipmentId(0)
99 , fviTofMsgCounter(1 + gdpbv100::MSG_STAR_TRI_D, 0)
100 , fvulTofCurrentEpoch()
101 , fvulTofCurrentEpochCycle()
102 , fvulTofCurrentEpochFull()
103 , fulTofCurrentEpochTime(0)
104 , fvmTofEpSupprBuffer()
105 , fvmTofGdpbHitsInMs()
106 , fvmTofGdpbHitsInTs()
107 , fhMcbmHitsNbPerMs()
108 , fvhMcbmTimeDiffToSelDpb()
109 , fvhMcbmTimeDiffToSelDpbWide()
110 , fvhMcbmTimeDiffToSelDpbTs()
111 , fvhMcbmTimeDiffToDiamondEvoDpb()
112 , fvhMcbmTimeDiffToDiamondWideEvoDpb()
113 , fvhMcbmTimeDiffToDiamondTsEvoDpb()
114 , fvhMcbmTimeDiffToTofEvoDpb()
115 , fvhMcbmTimeDiffToTofWideEvoDpb()
116 , fvhMcbmTimeDiffToTofTsEvoDpb()
117{
118}
119
121
123{
124 LOG(info) << "Initializing flib StsXyter unpacker for STS";
125
126 FairRootManager* ioman = FairRootManager::Instance();
127 if (ioman == nullptr) { LOG(fatal) << "No FairRootManager instance"; }
128
129 return kTRUE;
130}
131
133{
134 LOG(info) << "Setting parameter containers for " << GetName();
135 fUnpackParSts = (CbmMcbm2018StsPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMcbm2018StsPar"));
136 fUnpackParTof = (CbmMcbm2018TofPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMcbm2018TofPar"));
137}
138
139
141{
142 LOG(info) << "Init parameter containers for " << GetName();
143
144 Bool_t bReInit = ReInitContainers();
148
149 return bReInit;
150}
151
153{
154 LOG(info) << "ReInit parameter containers for " << GetName();
155
156 /***************** STS parameters *************************************/
158 LOG(info) << "Nr. of STS DPBs: " << fuStsNrOfDpbs;
159
160 fmStsDpbIdIndexMap.clear();
161 for (UInt_t uDpb = 0; uDpb < fuStsNrOfDpbs; ++uDpb) {
163 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = 0x" << std::setw(4) << std::hex
164 << fUnpackParSts->GetDpbId(uDpb) << std::dec << " => "
166 } // for( UInt_t uDpb = 0; uDpb < fuStsNrOfDpbs; ++uDpb )
167
172 /***************** STS parameters *************************************/
173
174 /***************** TOF parameters *************************************/
176 LOG(info) << "Nr. of Tof GDPBs: " << fuTofNrOfDpbs;
177
178 fmTofDpbIdIndexMap.clear();
179 for (UInt_t i = 0; i < fuTofNrOfDpbs; ++i) {
181 LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackParTof->GetGdpbId(i) << std::dec;
182 } // for( UInt_t i = 0; i < fuTofNrOfDpbs; ++i )
183
191 /***************** TOF parameters *************************************/
192
193 return kTRUE;
194}
195
196void CbmMcbm2018MonitorMcbmPulser::AddMsComponentToList(size_t component, UShort_t usDetectorId)
197{
198 switch (usDetectorId) {
199 case 0x10: //fles::Subsystem::STS:
200 {
201 AddMsComponentToListSts(component);
202 break;
203 } // case 0x10:
204 case 0x60: //fles::Subsystem::TOF:
205 {
206 AddMsComponentToListTof(component);
207 break;
208 } // case 0x60:
209 default: {
210 LOG(warning) << "CbmMcbm2018MonitorStsSync::AddMsComponentToList => "
211 << "Ignore component " << component << " as detector id " << usDetectorId
212 << " is not supported by this unpacker.";
213 break;
214 } // default:
215 } // switch( iDetectorId )
216}
218{
220 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsListSts.size(); ++uCompIdx)
221 if (component == fvMsComponentsListSts[uCompIdx]) return;
222
224 fvMsComponentsListSts.push_back(component);
225}
227{
229 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsListTof.size(); ++uCompIdx)
230 if (component == fvMsComponentsListTof[uCompIdx]) return;
231
233 fvMsComponentsListTof.push_back(component);
234}
235void CbmMcbm2018MonitorMcbmPulser::SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
236{
237 fuNbCoreMsPerTs = uCoreMsNb;
238 fuNbOverMsPerTs = uOverlapMsNb;
239
240 // UInt_t uNbMsTotal = fuNbCoreMsPerTs + fuNbOverMsPerTs;
241}
242
243/***************** STS Histograms *************************************/
245{
246 TString sHistName {""};
247 TString title {""};
248 /*
249 sHistName = "hPulserMessageType";
250 title = "Nb of message for each type; Type";
251 fhStsMessType = new TH1I(sHistName, title, 5, 0., 5.);
252 fhStsMessType->GetXaxis()->SetBinLabel( 1, "Dummy");
253 fhStsMessType->GetXaxis()->SetBinLabel( 2, "Hit");
254 fhStsMessType->GetXaxis()->SetBinLabel( 3, "TsMsb");
255 fhStsMessType->GetXaxis()->SetBinLabel( 4, "Epoch");
256 fhStsMessType->GetXaxis()->SetBinLabel( 5, "Empty");
257
258 // Online histo browser commands
259#ifdef USE_HTTP_SERVER
260 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
261 if( server )
262 {
263 server->Register("/StsRaw", fhStsMessType );
264
265 server->RegisterCommand("/Reset_All_Pulser", "bMcbm2018ResetPulser=kTRUE");
266 server->RegisterCommand("/Write_All_Pulser", "bMcbm2018WritePulser=kTRUE");
267
268 server->Restrict("/Reset_All_Pulser", "allow=admin");
269 server->Restrict("/Write_All_Pulser", "allow=admin");
270 } // if( server )
271#endif
272*/
274 /*
275 Double_t w = 10;
276 Double_t h = 10;
277
278 // Summary per StsXyter
279 for( UInt_t uXyterIdx = 0; uXyterIdx < fuStsNbStsXyters; ++uXyterIdx )
280 {
281 TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ),
282 Form("Summary plots for StsXyter %03u", uXyterIdx ),
283 w, h);
284 cStsSumm->Divide( 2, 2 );
285
286 cStsSumm->cd(1);
287 gPad->SetLogy();
288 fhStsChanCntRaw[ uXyterIdx ]->Draw();
289
290 cStsSumm->cd(2);
291 gPad->SetLogz();
292 fhStsChanAdcRaw[ uXyterIdx ]->Draw( "colz" );
293
294 cStsSumm->cd(3);
295 gPad->SetLogz();
296 fhStsChanHitRateEvo[ uXyterIdx ]->Draw( "colz" );
297
298 cStsSumm->cd(4);
299// gPad->SetLogy();
300 fhStsChanAdcRawProf[ uXyterIdx ]->Draw();
301 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuStsNbStsXyters; ++uXyterIdx )
302
303//====================================================================//
304*/
305 /*****************************/
306 LOG(info) << "Done Creating STS Histograms";
307}
308/***************** STS Histograms *************************************/
309
310/***************** TOF Histograms *************************************/
312{
313 TString sHistName {""};
314 TString title {""};
315
316 /*******************************************************************/
317 /*
318
319 sHistName = "hMessageType";
320 title = "Nb of message for each type; Type";
321 // Test Big Data readout with plotting
322 fhTofMessType = new TH1I(sHistName, title, 1 + gdpbv100::MSG_STAR_TRI_A, 0., 1 + gdpbv100::MSG_STAR_TRI_A);
323 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_HIT, "HIT");
324 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_EPOCH, "EPOCH");
325 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SLOWC, "SLOWC");
326 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_SYST, "SYST");
327 fhTofMessType->GetXaxis()->SetBinLabel(1 + gdpbv100::MSG_STAR_TRI_A, "MSG_STAR_TRI");
328*/
329 /*******************************************************************/
330 /*
331#ifdef USE_HTTP_SERVER
332 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
333 if( server )
334 {
335 server->Register("/TofRaw", fhTofMessType );
336
337 server->RegisterCommand("/Reset_All_TOF", "bMcbm2018SyncResetHistosTof=kTRUE");
338 server->RegisterCommand("/Save_All_Tof", "bMcbm2018SyncSaveHistosTof=kTRUE");
339 server->RegisterCommand("/Update_PulsFit", "bMcbm2018SyncUpdateZoomedFit=kTRUE");
340
341 server->Restrict("/Reset_All_Tof", "allow=admin");
342 server->Restrict("/Save_All_Tof", "allow=admin");
343 server->Restrict("/Update_PulsFit", "allow=admin");
344 } // if( server )
345#endif
346*/
348 /*
349 Double_t w = 10;
350 Double_t h = 10;
351 TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h);
352 cSummary->Divide(2, 3);
353
354 // 1st Column: Messages types
355 cSummary->cd(1);
356 gPad->SetLogy();
357 fhTofMessType->Draw();
358
359 cSummary->cd(2);
360 gPad->SetLogy();
361 fhTofSysMessType->Draw();
362
363 cSummary->cd(3);
364 gPad->SetLogz();
365 fhTofGet4MessType->Draw("colz");
366
367 // 2nd Column: GET4 Errors + Epoch flags + SCm
368 cSummary->cd(4);
369 gPad->SetLogz();
370 fhTofGet4ChanErrors->Draw("colz");
371
372 cSummary->cd(5);
373 gPad->SetLogz();
374 fhTofGet4EpochFlags->Draw("colz");
375
376 cSummary->cd(6);
377 fhTofGet4ChanScm->Draw("colz");
378*/
379 /*****************************/
380
381 LOG(info) << "Done Creating TOF Histograms";
382}
383/***************** TOF Histograms *************************************/
384
385/***************** mCBM Histograms ************************************/
387{
388 TString sHistName {""};
389 TString sHistTitle {""};
390
392
393 sHistName = "hMcbmHitsNbPerMs";
394 sHistTitle = "Nb of hits per DPB; Nb of hits []; DPB []";
395 fhMcbmHitsNbPerMs = new TH2D(sHistName, sHistTitle, 1000.0, 0., 1000., fuTotalNrOfDpb, 0., fuTotalNrOfDpb);
396
397 for (UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb) {
398 sHistName = Form("hMcbmTimeDiffToDpb%02u", uDpb);
399 sHistTitle = Form("Time difference for STS and TOF hits, per DPB, against "
400 "any hits in DPB %02u; <tn - tRef> [ns]; DPB []",
401 uDpb);
402 fvhMcbmTimeDiffToSelDpb.push_back(new TH2D(sHistName, sHistTitle, 1001, -500.5 * stsxyter::kdClockCycleNs,
404 sHistName = Form("hMcbmTimeDiffToDpb%02uWide", uDpb);
405 sHistTitle = Form("Time difference for STS and TOF hits, per DPB, against any hits in "
406 "DPB %02u, wide range; <tn - tRef> [us]; DPB []",
407 uDpb);
409 new TH2D(sHistName, sHistTitle, 6000.0, -300., 300., fuTotalNrOfDpb, 0., fuTotalNrOfDpb));
410 sHistName = Form("hMcbmTimeDiffToDpb%02uTs", uDpb);
411 sHistTitle = Form("Time difference for STS and TOF hits, per DPB, against any hits in "
412 "DPB %02u, TS range; <tn - tRef> [ms]; DPB []",
413 uDpb);
415 new TH2D(sHistName, sHistTitle, 2000.0, -10., 10., fuTotalNrOfDpb, 0., fuTotalNrOfDpb));
416
417 sHistName = Form("hMcbmTimeDiffToDiamondEvoDpb%02u", uDpb);
418 sHistTitle = Form("Evolution of time difference for STS or TOF hits from DPB %02u "
419 "against any Diamond hit; TS []; <tn - tDia> [ns]",
420 uDpb);
421 fvhMcbmTimeDiffToDiamondEvoDpb.push_back(new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 1001,
423 500.5 * stsxyter::kdClockCycleNs));
424
425 sHistName = Form("hMcbmTimeDiffToDiamondWideEvoDpb%02u", uDpb);
426 sHistTitle = Form("Evolution of time difference for STS or TOF hits from DPB %02u "
427 "against any Diamond hit, wide range; TS []; <tn - tDia> [us]",
428 uDpb);
430 new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 4000.0, -200., 200.));
431
432 sHistName = Form("hMcbmTimeDiffToDiamondTsEvoDpb%02u", uDpb);
433 sHistTitle = Form("Evolution of time difference for STS or TOF hits from DPB %02u "
434 "against any Diamond hit, TS range; TS []; <tn - tDia> [ms]",
435 uDpb);
436 fvhMcbmTimeDiffToDiamondTsEvoDpb.push_back(new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 200.0, -10., 10.));
437
438 sHistName = Form("hMcbmTimeDiffToTofEvoDpb%02u", uDpb);
439 sHistTitle = Form("Evolution of time difference for STS or TOF hits from "
440 "DPB %02u against any Tof hit; TS []; <tn - tTof> [ns]",
441 uDpb);
442 fvhMcbmTimeDiffToTofEvoDpb.push_back(new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 1001,
444
445 sHistName = Form("hMcbmTimeDiffToTofWideEvoDpb%02u", uDpb);
446 sHistTitle = Form("Evolution of time difference for STS or TOF hits from DPB %02u "
447 "against any Tof hit, wide range; TS []; <tn - tTof> [us]",
448 uDpb);
449 fvhMcbmTimeDiffToTofWideEvoDpb.push_back(new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 4000.0, -200., 200.));
450
451 sHistName = Form("hMcbmTimeDiffToTofTsEvoDpb%02u", uDpb);
452 sHistTitle = Form("Evolution of time difference for STS or TOF hits from DPB %02u "
453 "against any Tof hit, TS range; TS []; <tn - tTof> [ms]",
454 uDpb);
455 fvhMcbmTimeDiffToTofTsEvoDpb.push_back(new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 200.0, -10., 10.));
456 } // for( UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb )
457#ifdef USE_HTTP_SERVER
458 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
459 if (server) {
460 server->Register("/mCbmDt", fhMcbmHitsNbPerMs);
461
462 for (UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb) {
463 server->Register("/mCbmDt", fvhMcbmTimeDiffToSelDpb[uDpb]);
464 server->Register("/mCbmDt", fvhMcbmTimeDiffToSelDpbWide[uDpb]);
465 server->Register("/mCbmDt", fvhMcbmTimeDiffToSelDpbTs[uDpb]);
466
467 server->Register("/mCbmDt", fvhMcbmTimeDiffToDiamondEvoDpb[uDpb]);
468 server->Register("/mCbmDt", fvhMcbmTimeDiffToDiamondWideEvoDpb[uDpb]);
469 server->Register("/mCbmDt", fvhMcbmTimeDiffToDiamondTsEvoDpb[uDpb]);
470
471 server->Register("/mCbmDt", fvhMcbmTimeDiffToTofEvoDpb[uDpb]);
472 server->Register("/mCbmDt", fvhMcbmTimeDiffToTofWideEvoDpb[uDpb]);
473 server->Register("/mCbmDt", fvhMcbmTimeDiffToTofTsEvoDpb[uDpb]);
474 } // for( UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb )
475
476 server->RegisterCommand("/Reset_All", "bMcbm2018ResetPulser=kTRUE");
477 server->RegisterCommand("/Save_All", "bMcbm2018WritePulser=kTRUE");
478
479 server->Restrict("/Reset_All", "allow=admin");
480 server->Restrict("/Save_All", "allow=admin");
481 } // if( server )
482#endif
483
484 Double_t w = 10;
485 Double_t h = 10;
487 for (UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb) {
488 TCanvas* cSyncMcbmDpb = new TCanvas(Form("cSyncMcbmDpb%02u", uDpb),
489 Form("Time difference for STS and TOF hits, per DPB, against "
490 "any DPB %02u hit",
491 uDpb),
492 w, h);
493 cSyncMcbmDpb->Divide(3);
494
495 cSyncMcbmDpb->cd(1);
496 gPad->SetGridx();
497 gPad->SetGridy();
498 gPad->SetLogz();
499 fvhMcbmTimeDiffToSelDpb[uDpb]->Draw("colz");
500
501 cSyncMcbmDpb->cd(2);
502 gPad->SetGridx();
503 gPad->SetGridy();
504 gPad->SetLogz();
505 fvhMcbmTimeDiffToSelDpbWide[uDpb]->Draw("colz");
506
507 cSyncMcbmDpb->cd(3);
508 gPad->SetGridx();
509 gPad->SetGridy();
510 gPad->SetLogz();
511 fvhMcbmTimeDiffToSelDpbTs[uDpb]->Draw("colz");
512 } // for( UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb )
513 /*****************************/
514
515 LOG(info) << "Done Creating mCBM Histograms";
516}
517/***************** mCBM Histograms ************************************/
518
519Bool_t CbmMcbm2018MonitorMcbmPulser::DoUnpack(const fles::Timeslice& ts, size_t component)
520{
524 bMcbm2018ResetPulser = kFALSE;
525 } // if( bMcbm2018ResetPulser )
528 bMcbm2018WritePulser = kFALSE;
529 } // if( bMcbm2018WritePulser )
530
531 LOG(debug) << "Timeslice contains " << ts.num_microslices(component) << "microslices.";
532 fulCurrentTsIdx = ts.index();
533
535 if (0 == fulCurrentTsIdx) return kTRUE;
536
537 if (fulCurrentTsIdx < 30) LOG(info) << Form("TS %2llu", fulCurrentTsIdx);
538
539 // Ignore overlap ms if flag set by user
540 UInt_t uNbMsLoop = fuNbCoreMsPerTs;
541 if (kFALSE == fbIgnoreOverlapMs) uNbMsLoop += fuNbOverMsPerTs;
542
543 // Loop over core microslices (and overlap ones if chosen)
544 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
545 // Loop over registered STS components
546 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsListSts.size(); ++uMsCompIdx) {
547 UInt_t uMsComp = fvMsComponentsListSts[uMsCompIdx];
548
549 if (kFALSE == ProcessStsMs(ts, uMsComp, uMsIdx)) return kFALSE;
550 } // for( UInt_t uMsComp = 0; uMsComp < fvMsComponentsListSts.size(); ++uMsComp )
551
552 // Loop over registered TOF components
553 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsListTof.size(); ++uMsCompIdx) {
554 UInt_t uMsComp = fvMsComponentsListTof[uMsCompIdx];
555
556 if (kFALSE == ProcessTofMs(ts, uMsComp, uMsIdx)) return kFALSE;
557 } // for( UInt_t uMsComp = 0; uMsComp < fvMsComponentsListSts.size(); ++uMsComp )
558
559
560 /****************** STS Sync ******************************************/
562 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb)
563 std::sort(fvmStsSdpbHitsInMs[uSdpb].begin(), fvmStsSdpbHitsInMs[uSdpb].end());
564 /****************** STS Sync ******************************************/
565
566 /****************** TOF Sync ******************************************/
568 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb)
569 std::sort(fvmTofGdpbHitsInMs[uGdpb].begin(), fvmTofGdpbHitsInMs[uGdpb].end());
570 /****************** TOF Sync ******************************************/
571
572 /****************** mCBM Sync *****************************************/
574 for (UInt_t uRefSdpb = 0; uRefSdpb < fuStsNrOfDpbs; ++uRefSdpb) {
575 UInt_t uNbRefHits = fvmStsSdpbHitsInMs[uRefSdpb].size();
576 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
577 Double_t dRefTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInMs[uRefSdpb][uHitRef].GetTs();
578 if (fuMuchDpbIdx == uRefSdpb) dRefTime -= fdMuchTofOffsetNs;
579 else
580 dRefTime -= fdStsTofOffsetNs;
581
582 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
583 UInt_t uNbHits = fvmStsSdpbHitsInMs[uSdpb].size();
584 Double_t dBestDt = 1e9;
585 // UInt_t uBestAdc = 0;
586 UInt_t uNbIncrDt = 0;
587
588 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
589 if (uRefSdpb == uSdpb && uHitRef == uHit) continue;
590
591 Double_t dHitTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInMs[uSdpb][uHit].GetTs();
592 if (fuMuchDpbIdx == uSdpb) dHitTime -= fdMuchTofOffsetNs;
593 else
594 dHitTime -= fdStsTofOffsetNs;
595
596 Double_t dDt = dHitTime - dRefTime;
597
598 if (kTRUE == fbUseBestPair) {
600 if (TMath::Abs(dDt) < TMath::Abs(dBestDt)) {
601 dBestDt = dDt;
602 // uBestAdc = fvmStsSdpbHitsInMs[ uSdpb ][ uHit ].GetAdc();
603 } // if( TMath::Abs( dDt ) < TMath::Abs( dBestDt ) )
604 else if (dBestDt < dDt)
605 uNbIncrDt++;
606
608 if (5 == dBestDt) break;
609 } // if( kTRUE == fbUseBestPair )
610 else {
611 fvhMcbmTimeDiffToSelDpb[uRefSdpb]->Fill(dDt, uSdpb);
612 fvhMcbmTimeDiffToSelDpbWide[uRefSdpb]->Fill(dDt / 1000.0, uSdpb);
613 } // else of if( kTRUE == fbUseBestPair )
614 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
615
616 if (kTRUE == fbUseBestPair) {
617 fvhMcbmTimeDiffToSelDpb[uRefSdpb]->Fill(dBestDt, uSdpb);
618 fvhMcbmTimeDiffToSelDpbWide[uRefSdpb]->Fill(dBestDt / 1000.0, uSdpb);
619 } // if( kTRUE == fbUseBestPair )
620 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
621
622 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
623 UInt_t uNbHits = fvmTofGdpbHitsInMs[uGdpb].size();
624 Double_t dBestDt = 1e9;
625 UInt_t uNbIncrDt = 0;
626
627 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
628 Double_t dHitTime = fvmTofGdpbHitsInMs[uGdpb][uHit].GetFullTimeNs();
629
630 Double_t dDt = dHitTime - dRefTime;
631
632 if (kTRUE == fbUseBestPair) {
634 if (TMath::Abs(dDt) < TMath::Abs(dBestDt)) dBestDt = dDt;
635 else if (dBestDt < dDt)
636 uNbIncrDt++;
637
639 if (5 == dBestDt) break;
640 } // if( kTRUE == fbUseBestPair )
641 else {
642 fvhMcbmTimeDiffToSelDpb[uRefSdpb]->Fill(dDt, uGdpb + fuStsNrOfDpbs);
643 fvhMcbmTimeDiffToSelDpbWide[uRefSdpb]->Fill(dDt / 1000.0, uGdpb + fuStsNrOfDpbs);
644 } // else of if( kTRUE == fbUseBestPair )
645 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
646
647 if (kTRUE == fbUseBestPair) {
648 fvhMcbmTimeDiffToSelDpb[uRefSdpb]->Fill(dBestDt, uGdpb + fuStsNrOfDpbs);
649 fvhMcbmTimeDiffToSelDpbWide[uRefSdpb]->Fill(dBestDt / 1000.0, uGdpb + fuStsNrOfDpbs);
650 } // if( kTRUE == fbUseBestPair )
651 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
652 } // for( UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++)
653 } // for( UInt_t uRefSdpb = 0; uRefSdpb < fuStsNrOfDpbs; ++uRefSdpb )
654
656 for (UInt_t uRefGdpb = 0; uRefGdpb < fuTofNrOfDpbs; ++uRefGdpb) {
657 UInt_t uNbRefHits = fvmTofGdpbHitsInMs[uRefGdpb].size();
658 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
659 Double_t dRefTime = fvmTofGdpbHitsInMs[uRefGdpb][uHitRef].GetFullTimeNs();
660
661 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
662 UInt_t uNbHits = fvmStsSdpbHitsInMs[uSdpb].size();
663 Double_t dBestDt = 1e9;
664 UInt_t uNbIncrDt = 0;
665
666 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
667 Double_t dHitTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInMs[uSdpb][uHit].GetTs();
668 if (fuMuchDpbIdx == uSdpb) dHitTime -= fdMuchTofOffsetNs;
669 else
670 dHitTime -= fdStsTofOffsetNs;
671
672 Double_t dDt = dHitTime - dRefTime;
673
674 if (kTRUE == fbUseBestPair) {
676 if (TMath::Abs(dDt) < TMath::Abs(dBestDt)) dBestDt = dDt;
677 else if (dBestDt < dDt)
678 uNbIncrDt++;
679
681 if (5 == dBestDt) break;
682 } // if( kTRUE == fbUseBestPair )
683 else {
684 fvhMcbmTimeDiffToSelDpb[uRefGdpb + fuStsNrOfDpbs]->Fill(dDt, uSdpb);
685 fvhMcbmTimeDiffToSelDpbWide[uRefGdpb + fuStsNrOfDpbs]->Fill(dDt / 1000.0, uSdpb);
686
687 if (fuDiamondDpbIdx == uRefGdpb) {
689 fvhMcbmTimeDiffToDiamondWideEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dDt / 1000.0);
690 } // if( fuDiamondDpbIdx == uRefGdpb )
691 else {
693 fvhMcbmTimeDiffToTofWideEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dDt / 1000.0);
694 } // else of if( fuDiamondDpbIdx == uRefGdpb )
695
696 } // else of if( kTRUE == fbUseBestPair )
697 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
698
699 if (kTRUE == fbUseBestPair) {
700 fvhMcbmTimeDiffToSelDpb[uRefGdpb + fuStsNrOfDpbs]->Fill(dBestDt, uSdpb);
701 fvhMcbmTimeDiffToSelDpbWide[uRefGdpb + fuStsNrOfDpbs]->Fill(dBestDt / 1000.0, uSdpb);
702
703 if (fuDiamondDpbIdx == uRefGdpb) {
704 fvhMcbmTimeDiffToDiamondEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dBestDt);
705 fvhMcbmTimeDiffToDiamondWideEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dBestDt / 1000.0);
706 } // if( fuDiamondDpbIdx == uRefGdpb )
707 else {
708 fvhMcbmTimeDiffToTofEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dBestDt);
709 fvhMcbmTimeDiffToTofWideEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dBestDt / 1000.0);
710 } // else of if( fuDiamondDpbIdx == uRefGdpb )
711 } // if( kTRUE == fbUseBestPair )
712 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
713
714 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
715 UInt_t uNbHits = fvmTofGdpbHitsInMs[uGdpb].size();
716 Double_t dBestDt = 1e9;
717 UInt_t uNbIncrDt = 0;
718
719 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
720
721 if (uRefGdpb == uGdpb && uHitRef == uHit) continue;
722
723 Double_t dHitTime = fvmTofGdpbHitsInMs[uGdpb][uHit].GetFullTimeNs();
724
725 Double_t dDt = dHitTime - dRefTime;
726
727 if (kTRUE == fbUseBestPair) {
729 if (TMath::Abs(dDt) < TMath::Abs(dBestDt)) dBestDt = dDt;
730 else if (dBestDt < dDt)
731 uNbIncrDt++;
732
734 if (5 == dBestDt) break;
735 } // if( kTRUE == fbUseBestPair )
736 else {
737 fvhMcbmTimeDiffToSelDpb[uRefGdpb + fuStsNrOfDpbs]->Fill(dDt, uGdpb + fuStsNrOfDpbs);
738 fvhMcbmTimeDiffToSelDpbWide[uRefGdpb + fuStsNrOfDpbs]->Fill(dDt / 1000.0, uGdpb + fuStsNrOfDpbs);
739
740 if (fuDiamondDpbIdx == uRefGdpb) {
743 } // if( fuDiamondDpbIdx == uRefGdpb )
744 else {
747 } // else of if( fuDiamondDpbIdx == uRefGdpb )
748 } // else of if( kTRUE == fbUseBestPair )
749 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
750
751 if (kTRUE == fbUseBestPair) {
752 fvhMcbmTimeDiffToSelDpb[uRefGdpb + fuStsNrOfDpbs]->Fill(dBestDt, uGdpb + fuStsNrOfDpbs);
753 fvhMcbmTimeDiffToSelDpbWide[uRefGdpb + fuStsNrOfDpbs]->Fill(dBestDt / 1000.0, uGdpb + fuStsNrOfDpbs);
754
755 if (fuDiamondDpbIdx == uRefGdpb) {
757 fvhMcbmTimeDiffToDiamondWideEvoDpb[uGdpb + fuStsNrOfDpbs]->Fill(fulCurrentTsIdx, dBestDt / 1000.0);
758 } // if( fuDiamondDpbIdx == uRefGdpb )
759 else {
761 fvhMcbmTimeDiffToTofWideEvoDpb[uGdpb + fuStsNrOfDpbs]->Fill(fulCurrentTsIdx, dBestDt / 1000.0);
762 } // else of if( fuDiamondDpbIdx == uRefGdpb )
763 } // if( kTRUE == fbUseBestPair )
764 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
765 } // for( UInt_t uHitDia = 0; uHitDia < uNbRefHits; uHitDia++)
766 } // for( UInt_t uRefGdpb = 0; uRefGdpb < fuTofNrOfDpbs; ++uRefGdpb )
767
769 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
770 fhMcbmHitsNbPerMs->Fill(fvmStsSdpbHitsInMs[uSdpb].size(), uSdpb);
771
772 if (fbTsLevelAna)
773 fvmStsSdpbHitsInTs[uSdpb].insert(fvmStsSdpbHitsInTs[uSdpb].end(), fvmStsSdpbHitsInMs[uSdpb].begin(),
774 fvmStsSdpbHitsInMs[uSdpb].end());
775
776 fvmStsSdpbHitsInMs[uSdpb].clear();
777 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
778 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
780
781 if (fbTsLevelAna)
782 fvmTofGdpbHitsInTs[uGdpb].insert(fvmTofGdpbHitsInTs[uGdpb].end(), fvmTofGdpbHitsInMs[uGdpb].begin(),
783 fvmTofGdpbHitsInMs[uGdpb].end());
784
785 fvmTofGdpbHitsInMs[uGdpb].clear();
786 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
787 /****************** mCBM Sync *****************************************/
788
789 } // for( UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx ++ )
790
791 /****************** mCBM Sync *****************************************/
793 for (UInt_t uRefSdpb = 0; uRefSdpb < fuStsNrOfDpbs; ++uRefSdpb) {
794 UInt_t uNbRefHits = fvmStsSdpbHitsInTs[uRefSdpb].size();
795 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
796 Double_t dRefTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInTs[fuMuchDpbIdx][uHitRef].GetTs();
797 if (fuMuchDpbIdx == uRefSdpb) dRefTime -= fdMuchTofOffsetNs;
798 else
799 dRefTime -= fdStsTofOffsetNs;
800
801 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
802 UInt_t uNbHits = fvmStsSdpbHitsInTs[uSdpb].size();
803 // Double_t dBestDt = 1e9;
804 // UInt_t uBestAdc = 0;
805 // UInt_t uNbIncrDt = 0;
806
807 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
808 if (uRefSdpb == uSdpb && uHitRef == uHit) continue;
809
810 Double_t dHitTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInTs[uSdpb][uHit].GetTs();
811 if (fuMuchDpbIdx == uSdpb) dHitTime -= fdMuchTofOffsetNs;
812 else
813 dHitTime -= fdStsTofOffsetNs;
814
815 Double_t dDt = dHitTime - dRefTime;
816
818 if (300e3 < dDt) break;
819
820 fvhMcbmTimeDiffToSelDpbTs[uRefSdpb]->Fill(dDt / 1e6, uSdpb);
821 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
822 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
823
824 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
825 UInt_t uNbHits = fvmTofGdpbHitsInTs[uGdpb].size();
826 // Double_t dBestDt = 1e9;
827 // UInt_t uNbIncrDt = 0;
828
829 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
830 Double_t dHitTime = fvmTofGdpbHitsInTs[uGdpb][uHit].GetFullTimeNs();
831
832 Double_t dDt = dHitTime - dRefTime;
833
835 if (300e3 < dDt) break;
836
837 fvhMcbmTimeDiffToSelDpbTs[uRefSdpb]->Fill(dDt / 1e6, uGdpb + fuStsNrOfDpbs);
838 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
839 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
840 } // for( UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++)
841 } // for( UInt_t uRefSdpb = 0; uRefSdpb < fuStsNrOfDpbs; ++uRefSdpb )
842
844 for (UInt_t uRefGdpb = 0; uRefGdpb < fuTofNrOfDpbs; ++uRefGdpb) {
845 UInt_t uNbRefHits = fvmTofGdpbHitsInTs[uRefGdpb].size();
846 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
847 Double_t dRefTime = fvmTofGdpbHitsInTs[uRefGdpb][uHitRef].GetFullTimeNs();
848
849 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
850 UInt_t uNbHits = fvmStsSdpbHitsInTs[uSdpb].size();
851 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
852 Double_t dHitTime = stsxyter::kdClockCycleNs * fvmStsSdpbHitsInTs[uSdpb][uHit].GetTs();
853
854 Double_t dDt = dHitTime - dRefTime;
855
857 if (300e3 < dDt) break;
858
859 fvhMcbmTimeDiffToSelDpbTs[uRefGdpb + fuStsNrOfDpbs]->Fill(dDt / 1e6, uSdpb);
860
861 if (fuDiamondDpbIdx == uRefGdpb) fvhMcbmTimeDiffToDiamondTsEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dDt / 1e6);
862 else
863 fvhMcbmTimeDiffToTofTsEvoDpb[uSdpb]->Fill(fulCurrentTsIdx, dDt / 1e6);
864 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
865 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
866
867 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
868 UInt_t uNbHits = fvmTofGdpbHitsInTs[uGdpb].size();
869 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
870 if (uRefGdpb == uGdpb && uHitRef == uHit) continue;
871
872 Double_t dHitTime = fvmTofGdpbHitsInTs[uGdpb][uHit].GetFullTimeNs();
873
874 Double_t dDt = dHitTime - dRefTime;
875
877 if (300e3 < dDt) break;
878
879 fvhMcbmTimeDiffToSelDpbTs[uRefGdpb + fuStsNrOfDpbs]->Fill(dDt / 1e6, uGdpb + fuStsNrOfDpbs);
880
881 if (fuDiamondDpbIdx == uRefGdpb)
883 else
885 } // for( UInt_t uHit = 0; uHit < uNbHits; ++uHit )
886 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
887 } // for( UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++)
888 } // for( UInt_t uRefGdpb = 0; uRefGdpb < fuTofNrOfDpbs; ++uRefGdpb )
889
891 for (UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb) {
892 fvmStsSdpbHitsInTs[uSdpb].clear();
893 } // for( UInt_t uSdpb = 0; uSdpb < fuStsNrOfDpbs; ++uSdpb )
894 for (UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb) {
895 fvmTofGdpbHitsInTs[uGdpb].clear();
896 } // for( UInt_t uGdpb = 0; uGdpb < fuTofNrOfDpbs; ++uGdpb )
897
898 /****************** mCBM Sync *****************************************/
899
900 if (0 == ts.index() % 1000) {
901 LOG(info) << "End of TS " << std::setw(7) << ts.index();
902 } // if( 0 == ts.index() % 1000 )
903
904 return kTRUE;
905}
906
907/****************** STS Sync ******************************************/
908Bool_t CbmMcbm2018MonitorMcbmPulser::ProcessStsMs(const fles::Timeslice& ts, size_t uMsComp, UInt_t uMsIdx)
909{
910 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
911 fuCurrentEquipmentId = msDescriptor.eq_id;
912 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
913
914 uint32_t uSize = msDescriptor.size;
915 fulCurrentMsIdx = msDescriptor.idx;
916 // Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
917 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
918 << " has size: " << uSize;
919
920 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
922
924 UInt_t uTsMsbCycleHeader = std::floor(fulCurrentMsIdx / (stsxyter::kulTsCycleNbBins * stsxyter::kdClockCycleNs));
925
926 if (0 == uMsIdx) {
927 fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
929 } // if( 0 == uMsIdx )
930 else if (uTsMsbCycleHeader != fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] && 4194303 != fvulStsCurrentTsMsb[fuCurrDpbIdx]) {
931 LOG(warning) << "TS MSB cycle from MS header does not match current cycle from data "
932 << "for TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
933 << " MsInTs " << std::setw(3) << uMsIdx << " ====> " << fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] << " VS "
934 << uTsMsbCycleHeader;
935 fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
936 }
937
938 // If not integer number of message in input buffer, print warning/error
939 if (0 != (uSize % kuStsBytesPerMessage))
940 LOG(error) << "The input microslice buffer does NOT "
941 << "contain only complete nDPB messages!";
942
943 // Compute the number of complete messages in the input microslice buffer
944 uint32_t uNbMessages = (uSize - (uSize % kuStsBytesPerMessage)) / kuStsBytesPerMessage;
945
946 // Prepare variables for the loop on contents
947 const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>(msContent);
948
949 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
950 // Fill message
951 uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]);
952
953 stsxyter::Message mess(static_cast<uint32_t>(ulData & 0xFFFFFFFF));
954
955 // Print message if requested
956 if (fbPrintMessages) mess.PrintMess(std::cout, fPrintMessCtrlSts);
957
958 stsxyter::MessType typeMess = mess.GetMessType();
959 fmMsgCounter[typeMess]++;
960
961 switch (typeMess) {
963
964 FillStsHitInfo(mess, uMsIdx);
965 break;
966 } // case stsxyter::MessType::Hit :
968 FillStsTsMsbInfo(mess, uIdx, uMsIdx);
969 break;
970 } // case stsxyter::MessType::TsMsb :
972 // The first message in the TS is a special ones: EPOCH
973 FillStsEpochInfo(mess);
974
975 if (0 < uIdx)
976 LOG(info) << "CbmMcbm2018MonitorMcbmPulser::DoUnpack => "
977 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
978 break;
979 } // case stsxyter::MessType::TsMsb :
983 break;
984 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
985 default: {
986 LOG(fatal) << "CbmMcbm2018MonitorMcbmPulser::DoUnpack => "
987 << "Unknown message type, should never happen, stopping here!";
988 }
989 } // switch( mess.GetMessType() )
990 } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx )
991 return kTRUE;
992}
993
995{
996 UShort_t usChan = mess.GetHitChannel();
997 UShort_t usRawAdc = mess.GetHitAdc();
998 // UShort_t usFullTs = mess.GetHitTimeFull();
999 // UShort_t usTsOver = mess.GetHitTimeOver();
1000 UShort_t usRawTs = mess.GetHitTime();
1001
1002 UInt_t uAsicIdx = 0;
1003
1004 if (fuCurrDpbIdx == fuMuchDpbIdx) {
1006 switch (usChan) {
1007 case 101:
1008 case 99:
1009 case 91:
1010 case 89:
1011 case 88:
1012 case 86:
1013 case 84:
1014 case 83:
1015 case 80:
1016 case 78:
1017 case 76:
1018 case 50:
1019 case 39:
1020 case 37:
1021 case 35:
1022 case 20: {
1023 return;
1024 break;
1025 } // if bad channel
1026 default: break;
1027 } // switch( usChan )
1028 } // if( fuCurrDpbIdx == fuMuchDpbIdx )
1029 else {
1031 if (usRawAdc < 15) return;
1032
1034 uAsicIdx = fUnpackParSts->ElinkIdxToAsicIdx(kFALSE, mess.GetLinkIndex());
1035 UInt_t uChanIdx = usChan + fUnpackParSts->GetNbChanPerAsic() * uAsicIdx;
1036 switch (uChanIdx) {
1037 case 781:
1038 case 270:
1039 case 411:
1040 case 518: {
1041 return;
1042 break;
1043 } // if bad channel
1044 default: break;
1045 } // switch( mess.GetLinkIndex() )
1046 if ((0 == uChanIdx % 2) && (543 < uChanIdx) && (uChanIdx < 633)) { return; } // if bad channel
1047 } // else of if( fuCurrDpbIdx == fuMuchDpbIdx )
1048
1049 // Compute the Full time stamp
1050 // Use TS w/o overlap bits as they will anyway come from the TS_MSB
1051 Long64_t ulStsHitTime = usRawTs;
1052
1053 ulStsHitTime +=
1054 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulStsCurrentTsMsb[fuCurrDpbIdx])
1055 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins)
1056 * static_cast<ULong64_t>(fvuStsCurrentTsMsbCycle[fuCurrDpbIdx]);
1057
1058 // Convert the Hit time in bins to Hit time in ns
1059 // Double_t dHitTimeNs = ulStsHitTime * stsxyter::kdClockCycleNs;
1060
1061
1062 // Pulser and MS
1063 fvmStsSdpbHitsInMs[fuCurrDpbIdx].push_back(stsxyter::FinalHit(ulStsHitTime, usRawAdc, uAsicIdx, usChan));
1064}
1065
1067{
1068 UInt_t uVal = mess.GetTsMsbVal();
1069
1070 // Update Status counters
1071 if (uVal < fvulStsCurrentTsMsb[fuCurrDpbIdx]) {
1072
1073 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " DPB "
1074 << std::setw(2) << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulStsCurrentTsMsb[fuCurrDpbIdx]
1075 << " Old MsbCy " << std::setw(5) << fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] << " new TsMsb " << std::setw(5)
1076 << uVal;
1077
1079 } // if( uVal < fvulStsCurrentTsMsb[fuCurrDpbIdx] )
1080 if (uVal != fvulStsCurrentTsMsb[fuCurrDpbIdx] + 1 && 0 != uVal && 4194303 != fvulStsCurrentTsMsb[fuCurrDpbIdx]
1081 && 1 != uMessIdx) {
1082 LOG(info) << "TS MSb Jump in "
1083 << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
1084 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
1085 << fuCurrDpbIdx << " => Old TsMsb " << std::setw(5) << fvulStsCurrentTsMsb[fuCurrDpbIdx] << " new TsMsb "
1086 << std::setw(5) << uVal;
1087 } // if( uVal + 1 != fvulStsCurrentTsMsb[fuCurrDpbIdx] && 4194303 != uVal && 0 != fvulStsCurrentTsMsb[fuCurrDpbIdx] )
1089 /*
1090 ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins )
1091 * static_cast< ULong64_t >( fvulStsCurrentTsMsb[fuCurrDpbIdx])
1092 + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins )
1093 * static_cast< ULong64_t >( fvuStsCurrentTsMsbCycle[fuCurrDpbIdx] );
1094*/
1095}
1096
1098{
1099 // UInt_t uVal = mess.GetTsMsbVal();
1100}
1101/****************** STS Sync ******************************************/
1102
1103/****************** TOF Sync ******************************************/
1104
1105Bool_t CbmMcbm2018MonitorMcbmPulser::ProcessTofMs(const fles::Timeslice& ts, size_t uMsComp, UInt_t uMsIdx)
1106{
1107 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
1108 fuCurrentEquipmentId = msDescriptor.eq_id;
1109 fdTofMsIndex = static_cast<double>(msDescriptor.idx);
1110 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
1111
1112 uint32_t size = msDescriptor.size;
1113 // fulLastMsIdx = msDescriptor.idx;
1114 if (size > 0) LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size;
1115
1116 Int_t messageType = -111;
1117
1118 // If not integer number of message in input buffer, print warning/error
1119 if (0 != (size % kuTofBytesPerMessage))
1120 LOG(error) << "The input microslice buffer does NOT "
1121 << "contain only complete nDPB messages!";
1122
1123 // Compute the number of complete messages in the input microslice buffer
1124 uint32_t uNbMessages = (size - (size % kuTofBytesPerMessage)) / kuTofBytesPerMessage;
1125
1126 // Get the gDPB ID from the MS header
1129
1130 // Prepare variables for the loop on contents
1131 const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent);
1132 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
1133 // Fill message
1134 uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]);
1135 gdpbv100::Message mess(ulData);
1136
1138 if (0 == uIdx) {
1139 FillTofEpochCycle(ulData);
1140 continue;
1141 } // if( 0 == uIdx )
1142
1143 if (fair::Logger::Logging(fair::Severity::debug2)) {
1144 mess.printDataCout();
1145 } // if (fair::Logger::Logging( fair::Severity::debug2 ))
1146
1147 // Increment counter for different message types
1148 // and fill the corresponding histogram
1149 messageType = mess.getMessageType();
1150 fviTofMsgCounter[messageType]++;
1151
1152 switch (messageType) {
1153 case gdpbv100::MSG_HIT: {
1154 if (!mess.getGdpbHitIs24b()) { fvmTofEpSupprBuffer[fuTofGdpbNr].push_back(mess); } // if( !getGdpbHitIs24b() )
1155 break;
1156 } // case gdpbv100::MSG_HIT:
1157 case gdpbv100::MSG_EPOCH: {
1159 FillTofEpochInfo(mess);
1160 } // if this epoch message is a merged one valiud for all chips
1161 else
1162 LOG(fatal) << "Bad epoch: " << mess.getGdpbGenChipId();
1163 break;
1164 } // case gdpbv100::MSG_EPOCH:
1166 case gdpbv100::MSG_SYST:
1170 case gdpbv100::MSG_STAR_TRI_D: break;
1171 default:
1172 LOG(error) << "Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
1173 << " not included in Get4 unpacker.";
1174 } // switch( mess.getMessageType() )
1175 } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
1176
1177 return kTRUE;
1178}
1179
1181{
1182 uint64_t ulEpochCycleVal = ulCycleData & gdpbv100::kulEpochCycleFieldSz;
1183 fvulTofCurrentEpochCycle[fuTofGdpbNr] = ulEpochCycleVal;
1184
1185 return;
1186}
1187
1189{
1190 // UInt_t uChannel = mess.getGdpbHitChanId();
1191 // UInt_t uTot = mess.getGdpbHit32Tot();
1192 // UInt_t uFts = mess.getGdpbHitFineTs();
1193
1194 ULong64_t ulCurEpochGdpbGet4 = fvulTofCurrentEpochFull[fuTofGdpbNr];
1195
1196 // In Ep. Suppr. Mode, receive following epoch instead of previous
1197 if (0 < ulCurEpochGdpbGet4) ulCurEpochGdpbGet4--;
1198 else
1199 ulCurEpochGdpbGet4 = gdpbv100::kuEpochCounterSz; // Catch epoch cycle!
1200
1201 // ULong_t ulHitTime = mess.getMsgFullTime(ulCurEpochGdpbGet4);
1202 // Double_t dHitTime = mess.getMsgFullTimeD(ulCurEpochGdpbGet4);
1203
1204 // In 32b mode the coarse counter is already computed back to 112 FTS bins
1205 // => need to hide its contribution from the Finetime
1206 // => FTS = Fullt TS modulo 112
1207 // uFts = mess.getGdpbHitFullTs() % 112;
1208
1210 fvmTofGdpbHitsInMs[fuTofGdpbNr].push_back(gdpbv100::FullMessage(mess, ulCurEpochGdpbGet4));
1211}
1212
1214{
1215 ULong64_t ulEpochNr = mess.getGdpbEpEpochNb();
1216
1217 fvulTofCurrentEpoch[fuTofGdpbNr] = ulEpochNr;
1220
1221 fulTofCurrentEpochTime = mess.getMsgFullTime(ulEpochNr);
1222
1225 if (0 < ulEpochNr) mess.setGdpbEpEpochNb(ulEpochNr - 1);
1226 else
1228
1229 Int_t iBufferSize = fvmTofEpSupprBuffer[fuTofGdpbNr].size();
1230 if (0 < iBufferSize) {
1231 LOG(debug) << "Now processing stored messages for for gDPB " << fuTofGdpbNr << " with epoch number "
1233
1236 std::stable_sort(fvmTofEpSupprBuffer[fuTofGdpbNr].begin(), fvmTofEpSupprBuffer[fuTofGdpbNr].begin());
1237
1238 for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
1240 } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ )
1241
1243 } // if( 0 < fvmTofEpSupprBuffer[fuTofGdpbNr] )
1244}
1245/****************** TOF Sync ******************************************/
1246
1247/****************** STS histos ****************************************/
1248/****************** STS histos ****************************************/
1249
1250/****************** TOF histos ****************************************/
1251/****************** TOF Histos ****************************************/
1252
1254
1256{
1257 /*
1258 LOG(info) << "-------------------------------------";
1259 LOG(info) << "CbmMcbm2018MonitorMcbmPulser statistics are ";
1260 LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n"
1261 << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n"
1262 << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n"
1263 << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n"
1264 << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ];
1265*/
1266 LOG(info) << "-------------------------------------";
1267
1269 SaveAllHistos();
1270}
1271
1272
1274{
1276 TFile* oldFile = gFile;
1277 TDirectory* oldDir = gDirectory;
1278
1279 TFile* histoFile = nullptr;
1280 if ("" != sFileName) {
1281 // open separate histo file in recreate mode
1282 histoFile = new TFile(sFileName, "RECREATE");
1283 histoFile->cd();
1284 } // if( "" != sFileName )
1285
1286 /****************** STS Sync ******************************************/
1287 /****************** STS Sync ******************************************/
1288
1289 /****************** MUCH Sync *****************************************/
1290 /****************** MUCH Sync *****************************************/
1291
1292 /****************** TOF Sync ******************************************/
1293 /****************** TOF Sync ******************************************/
1294
1295 /****************** mCBM Sync *****************************************/
1296 gDirectory->mkdir("mcbmDt");
1297 gDirectory->cd("mcbmDt");
1298
1299 for (UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb) {
1300 fvhMcbmTimeDiffToSelDpb[uDpb]->Reset();
1301 fvhMcbmTimeDiffToSelDpbWide[uDpb]->Reset();
1302 fvhMcbmTimeDiffToSelDpbTs[uDpb]->Reset();
1303
1304 fvhMcbmTimeDiffToDiamondEvoDpb[uDpb]->Write();
1306 fvhMcbmTimeDiffToDiamondTsEvoDpb[uDpb]->Write();
1307
1308 fvhMcbmTimeDiffToTofEvoDpb[uDpb]->Write();
1309 fvhMcbmTimeDiffToTofWideEvoDpb[uDpb]->Write();
1310 fvhMcbmTimeDiffToTofTsEvoDpb[uDpb]->Write();
1311 } // for( UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb )
1312
1313 gDirectory->cd("..");
1314 /****************** mCBM Sync *****************************************/
1315
1316 if ("" != sFileName) {
1317 // Restore original directory position
1318 histoFile->Close();
1319 } // if( "" != sFileName )
1320
1322 gFile = oldFile;
1323 gDirectory = oldDir;
1324}
1326{
1327 /****************** STS Sync ******************************************/
1328 /****************** STS Sync ******************************************/
1329
1330 /****************** MUCH Sync *****************************************/
1331 /****************** MUCH Sync *****************************************/
1332
1333 /****************** TOF Sync ******************************************/
1334 /****************** TOF Sync ******************************************/
1335
1336
1337 /****************** mCBM Sync *****************************************/
1338 for (UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb) {
1339 fvhMcbmTimeDiffToSelDpb[uDpb]->Reset();
1340 fvhMcbmTimeDiffToSelDpbWide[uDpb]->Reset();
1341 fvhMcbmTimeDiffToSelDpbTs[uDpb]->Reset();
1342
1343 fvhMcbmTimeDiffToDiamondEvoDpb[uDpb]->Reset();
1345 fvhMcbmTimeDiffToDiamondTsEvoDpb[uDpb]->Reset();
1346
1347 fvhMcbmTimeDiffToTofEvoDpb[uDpb]->Reset();
1348 fvhMcbmTimeDiffToTofWideEvoDpb[uDpb]->Reset();
1349 fvhMcbmTimeDiffToTofTsEvoDpb[uDpb]->Reset();
1350 } // for( UInt_t uDpb = 0; uDpb < fuTotalNrOfDpb; ++uDpb )
1351 /****************** mCBM Sync *****************************************/
1352}
1353
ClassImp(CbmConverterManager)
Bool_t bMcbm2018WritePulser
Bool_t bMcbm2018ResetPulser
static constexpr size_t size()
Definition KfSimdPseudo.h:2
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
std::vector< std::vector< stsxyter::FinalHit > > fvmStsSdpbHitsInTs
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
Bool_t ProcessTofMs(const fles::Timeslice &ts, size_t uMsComp, UInt_t uMsIdx)
std::map< UInt_t, UInt_t > fmStsDpbIdIndexMap
Total number of Sts DPBs in system.
std::vector< UInt_t > fvuStsCurrentTsMsbCycle
Current TS MSB for each DPB.
std::vector< std::vector< gdpbv100::Message > > fvmTofEpSupprBuffer
Buffer for suppressed epoch processing.
virtual void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
void FillStsEpochInfo(stsxyter::Message mess)
std::vector< std::vector< gdpbv100::FullMessage > > fvmTofGdpbHitsInMs
Buffer for system sync check.
std::vector< TH2 * > fvhMcbmTimeDiffToDiamondTsEvoDpb
std::vector< std::vector< stsxyter::FinalHit > > fvmStsSdpbHitsInMs
Current TS MSB cycle for DPB.
UInt_t fuMuchDpbIdx
Map of DPB Identifier to DPB index.
virtual void AddMsComponentToList(size_t component, UShort_t usDetectorId)
void FillStsTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
stsxyter::MessagePrintMask fPrintMessCtrlSts
std::vector< ULong64_t > fvulStsCurrentTsMsb
Bin size in s for the plots with date as X axis.
CbmMcbm2018TofPar * fUnpackParTof
Unpacking and mapping parameters for TOF.
std::vector< ULong64_t > fvulTofCurrentEpochFull
std::map< UInt_t, UInt_t > fmTofDpbIdIndexMap
Total number of GDPBs in the system.
std::vector< ULong64_t > fvulTofCurrentEpochCycle
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
static const UInt_t kuTofBytesPerMessage
TODO => move to the message class!!
void CreateStsHistograms()
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
std::vector< std::vector< gdpbv100::FullMessage > > fvmTofGdpbHitsInTs
std::vector< TH2 * > fvhMcbmTimeDiffToDiamondWideEvoDpb
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
void FillStsHitInfo(stsxyter::Message mess, const UInt_t &uMsIdx)
Bool_t ProcessStsMs(const fles::Timeslice &ts, size_t uMsComp, UInt_t uMsIdx)
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
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)
Data class with information on a STS local track.
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.