CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MonitorStsSync.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// ----- CbmMcbm2018MonitorStsSync -----
8// ----- Created 11/05/18 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
13
14// Data
15
16// CbmRoot
17#include "CbmCern2017UnpackParHodo.h"
18#include "CbmHistManager.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 "TFile.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
37// C++11
38#include <bitset>
39
40// C/C++
41#include <iomanip>
42#include <iostream>
43
44#include <stdint.h>
45
46Bool_t bMcbm2018ResetStsSync = kFALSE;
47Bool_t bMcbm2018WriteStsSync = kFALSE;
48
51 , fvMsComponentsList()
52 , fuNbCoreMsPerTs(0)
53 , fuNbOverMsPerTs(0)
54 , fbIgnoreOverlapMs(kFALSE)
55 , fUnpackParHodo(NULL)
56 , fuNrOfDpbs(0)
57 , fDpbIdIndexMap()
58 , fuNbElinksPerDpb(0)
59 , fuNbStsXyters(0)
60 , fuNbChanPerAsic(0)
61 , fvuElinkToAsic()
62 , fsHistoFileFullname("data/SetupHistos.root")
63 , fbPrintMessages(kFALSE)
64 , fPrintMessCtrl(stsxyter::MessagePrintMask::msg_print_Human)
65 , fulCurrentTsIdx(0)
66 , fulCurrentMsIdx(0)
67 , fmMsgCounter()
68 , fuCurrentEquipmentId(0)
69 , fuCurrDpbId(0)
70 , fuCurrDpbIdx(0)
71 , fiRunStartDateTimeSec(-1)
72 , fiBinSizeDatePlots(-1)
73 , fvulCurrentTsMsb()
74 , fvuCurrentTsMsbCycle()
75 , fvuInitialHeaderDone()
76 , fvuInitialTsMsbCycleHeader()
77 , fvuElinkLastTsHit()
78 , fvulChanLastHitTime()
79 , fvdChanLastHitTime()
80 , fvdMsTime()
81 , fvuChanNbHitsInMs()
82 , fvdChanLastHitTimeInMs()
83 , fvusChanLastHitAdcInMs()
84 ,
85 // fvmChanHitsInTs(),
86 fdStartTime(-1.0)
87 , fdStartTimeMsSz(-1.0)
88 , ftStartTimeUnix(std::chrono::steady_clock::now())
89 , fvmHitsInMs()
90 , fvmAsicHitsInMs()
91 , fuMaxNbMicroslices(100)
92 , fbLongHistoEnable(kFALSE)
93 , fuLongHistoNbSeconds(0)
94 , fuLongHistoBinSizeSec(0)
95 , fuLongHistoBinNb(0)
96 , fdCoincCenter(0.0)
97 , fdCoincBorder(50.0)
98 , fdCoincMin(fdCoincCenter - fdCoincBorder)
99 , fdCoincMax(fdCoincCenter + fdCoincBorder)
100 , fHM(new CbmHistManager())
101 , fhPulserMessType(NULL)
102 , fhPulserSysMessType(NULL)
103 , fhPulserMessTypePerDpb(NULL)
104 , fhPulserSysMessTypePerDpb(NULL)
105 , fhPulserMessTypePerElink(NULL)
106 , fhPulserSysMessTypePerElink(NULL)
107 , fhPulserStatusMessType(NULL)
108 , fhPulserMsStatusFieldType(NULL)
109 , fhPulserChanCntRaw()
110 , fhPulserChanCntRawGood()
111 , fhPulserChanAdcRaw()
112 , fhPulserChanAdcRawProf()
113 , fhPulserChanRawTs()
114 , fhPulserChanMissEvt()
115 , fhPulserChanMissEvtEvo()
116 , fhPulserChanHitRateEvo()
117 , fhPulserFebRateEvo()
118 , fhPulserFebMissEvtEvo()
119 , fhPulserChanHitRateEvoLong()
120 , fhPulserFebRateEvoLong()
121 , fcMsSizeAll(NULL)
122 , fdStartTs(0.0)
123 , fvmLastHitAsic()
124 , fhPulserTimeDiffPerAsic()
125 , fhPulserTimeDiffPerAsicPair()
126 , fhPulserTimeDiffClkPerAsicPair()
127 , fhPulserTimeDiffEvoPerAsicPair()
128 , fhPulserTimeDiffEvoPerAsicPairProf()
129 , fhPulserRawTimeDiffEvoPerAsicPairProf()
130 , fhPulserTsLsbMatchPerAsicPair()
131 , fhPulserTsMsbMatchPerAsicPair()
132 , fhPulserTsLsbDiffEvoPerAsicPairProf()
133 , fhPulserTsMsbDiffEvoPerAsicPairProf()
134 , fhPulserIntervalAsic()
135 , fhPulserIntervalLongAsic()
136 , fvdLastTimeDiffValuesAsicPair()
137 , fvuLastTimeDiffSlotAsicPair()
138 , fvdMeanTimeDiffAsicPair()
139{
140}
141
143
145{
146 LOG(info) << "Initializing flib StsXyter unpacker for STS";
147
148 FairRootManager* ioman = FairRootManager::Instance();
149 if (ioman == NULL) { LOG(fatal) << "No FairRootManager instance"; }
150
151 return kTRUE;
152}
153
155{
156 LOG(info) << "Setting parameter containers for " << GetName();
158 (CbmCern2017UnpackParHodo*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo"));
159}
160
161
163{
164 LOG(info) << "Init parameter containers for " << GetName();
165
166 Bool_t bReInit = ReInitContainers();
168
169 return bReInit;
170}
171
173{
174 LOG(info) << "ReInit parameter containers for " << GetName();
175
176 fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs();
177 fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb();
178 fuNbStsXyters = fUnpackParHodo->GetNbStsXyters();
179 fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic();
180
181
182 LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs;
183
184 fDpbIdIndexMap.clear();
186 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
187 fDpbIdIndexMap[fUnpackParHodo->GetDpbId(uDpb)] = uDpb;
188 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " << std::setw(4) << std::hex
189 << fUnpackParHodo->GetDpbId(uDpb) << std::dec << " => " << fDpbIdIndexMap[fUnpackParHodo->GetDpbId(uDpb)];
190
191 fvuElinkToAsic[uDpb].resize(fuNbElinksPerDpb);
192 for (UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink)
193 fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx(uDpb * fuNbElinksPerDpb + uElink);
194 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
195
196 LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb;
197 LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters;
198 LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic;
199
200 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
201 LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": ";
202
203 std::stringstream ss;
204 for (UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink) {
205 if (0 == uElink % 10) ss << "\n------> ";
206
207 ss << std::setw(5) << fvuElinkToAsic[uDpb][uElink] << " ";
208 } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink )
209 LOG(info) << ss.str();
210 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
211
212 // Internal status initialization
218 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
219 fvulCurrentTsMsb[uDpb] = 0;
220 fvuCurrentTsMsbCycle[uDpb] = 0;
221 fvuInitialHeaderDone[uDpb] = kFALSE;
223 /*
224 fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb );
225 for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink )
226 {
227 fvuElinkLastTsHit[uDpb][uElink] = 0;
228 } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink )
229*/
230 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
231
249 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
250 fvulChanLastHitTime[uXyterIdx].resize(fuNbChanPerAsic);
251 fvdChanLastHitTime[uXyterIdx].resize(fuNbChanPerAsic);
252 fvuChanNbHitsInMs[uXyterIdx].resize(fuNbChanPerAsic);
253 fvdChanLastHitTimeInMs[uXyterIdx].resize(fuNbChanPerAsic);
254 fvusChanLastHitAdcInMs[uXyterIdx].resize(fuNbChanPerAsic);
255 fvmAsicHitsInMs[uXyterIdx].clear();
256 fhPulserTimeDiffPerAsicPair[uXyterIdx].clear();
257 fhPulserTimeDiffClkPerAsicPair[uXyterIdx].clear();
258 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx].clear();
259 fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx].clear();
260 fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx].clear();
261 fhPulserTsLsbMatchPerAsicPair[uXyterIdx].clear();
262 fhPulserTsMsbMatchPerAsicPair[uXyterIdx].clear();
263 fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx].clear();
264 fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx].clear();
265 for (UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan) {
266 fvulChanLastHitTime[uXyterIdx][uChan] = 0;
267 fvdChanLastHitTime[uXyterIdx][uChan] = -1.0;
268
269 fvuChanNbHitsInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
270 fvdChanLastHitTimeInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
271 fvusChanLastHitAdcInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
272 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
273 fvuChanNbHitsInMs[uXyterIdx][uChan][uMsIdx] = 0;
274 fvdChanLastHitTimeInMs[uXyterIdx][uChan][uMsIdx] = -1.0;
275 fvusChanLastHitAdcInMs[uXyterIdx][uChan][uMsIdx] = 0;
276 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
277 } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan )
278 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
279 LOG(info) << "CbmMcbm2018MonitorStsSync::ReInitContainers => Changed "
280 "fvuChanNbHitsInMs size "
281 << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters;
282 LOG(info) << "CbmMcbm2018MonitorStsSync::ReInitContainers => Changed "
283 "fvuChanNbHitsInMs size "
284 << fvuChanNbHitsInMs[0].size() << " VS " << fuNbChanPerAsic;
285 LOG(info) << "CbmMcbm2018MonitorStsSync::ReInitContainers => Changed "
286 "fvuChanNbHitsInMs size "
287 << fvuChanNbHitsInMs[0][0].size() << " VS " << fuMaxNbMicroslices;
288
289 return kTRUE;
290}
291
292void CbmMcbm2018MonitorStsSync::AddMsComponentToList(size_t component, UShort_t /*usDetectorId*/)
293{
295 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
296 if (component == fvMsComponentsList[uCompIdx]) return;
297
299 fvMsComponentsList.push_back(component);
300
302 if (component < kiMaxNbFlibLinks)
303 if (NULL == fhMsSz[component]) {
304 TString sMsSzName = Form("MsSz_link_%02lu", component);
305 TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component);
306 fhMsSz[component] = new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.);
307 fHM->Add(sMsSzName.Data(), fhMsSz[component]);
308
309 sMsSzName = Form("MsSzTime_link_%02lu", component);
310 sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component);
311 fhMsSzTime[component] = new TProfile(sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300.);
312 fHM->Add(sMsSzName.Data(), fhMsSzTime[component]);
313
314 if (NULL != fcMsSizeAll) {
315 fcMsSizeAll->cd(1 + component);
316 gPad->SetLogy();
317 fhMsSzTime[component]->Draw("hist le0");
318 } // if( NULL != fcMsSizeAll )
319 LOG(info) << "Added MS size histo for component: " << component << " (DPB)";
320
321 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
322 if (server) {
323 server->Register("/FlibRaw", fhMsSz[component]);
324 server->Register("/FlibRaw", fhMsSzTime[component]);
325 } // if( server )
326 } // if( NULL == fhMsSz[ component ] )
327}
328void CbmMcbm2018MonitorStsSync::SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
329{
330 fuNbCoreMsPerTs = uCoreMsNb;
331 fuNbOverMsPerTs = uOverlapMsNb;
332
333 UInt_t uNbMsTotal = fuNbCoreMsPerTs + fuNbOverMsPerTs;
334
335 if (fuMaxNbMicroslices < uNbMsTotal) {
336 fuMaxNbMicroslices = uNbMsTotal;
337
342 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
343 fvuChanNbHitsInMs[uXyterIdx].resize(fuNbChanPerAsic);
344 fvdChanLastHitTimeInMs[uXyterIdx].resize(fuNbChanPerAsic);
345 fvusChanLastHitAdcInMs[uXyterIdx].resize(fuNbChanPerAsic);
346 for (UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan) {
347 fvuChanNbHitsInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
348 fvdChanLastHitTimeInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
349 fvusChanLastHitAdcInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
350 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
351 fvuChanNbHitsInMs[uXyterIdx][uChan][uMsIdx] = 0;
352 fvdChanLastHitTimeInMs[uXyterIdx][uChan][uMsIdx] = -1.0;
353 fvusChanLastHitAdcInMs[uXyterIdx][uChan][uMsIdx] = 0;
354 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
355 } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan )
356 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
357 LOG(info) << "CbmMcbm2018MonitorStsSync::DoUnpack => Changed "
358 "fvuChanNbHitsInMs size "
359 << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters;
360 LOG(info) << "CbmMcbm2018MonitorStsSync::DoUnpack => Changed "
361 "fvuChanNbHitsInMs size "
362 << fvuChanNbHitsInMs[0].size() << " VS " << fuNbChanPerAsic;
363 LOG(info) << "CbmMcbm2018MonitorStsSync::DoUnpack => Changed "
364 "fvuChanNbHitsInMs size "
365 << fvuChanNbHitsInMs[0][0].size() << " VS " << fuMaxNbMicroslices;
366 } // if( fuMaxNbMicroslices < uNbMsTotal )
367}
368
369void CbmMcbm2018MonitorStsSync::SetCoincidenceBorder(Double_t dCenterPos, Double_t dBorderVal)
370{
371 fdCoincCenter = dCenterPos;
372 fdCoincBorder = dBorderVal;
373 fdCoincMin = dCenterPos - dBorderVal;
374 fdCoincMax = dCenterPos + dBorderVal;
375}
376
378{
379 TString sHistName {""};
380 TString title {""};
381
382 sHistName = "hPulserMessageType";
383 title = "Nb of message for each type; Type";
384 fhPulserMessType = new TH1I(sHistName, title, 6, 0., 6.);
385 fhPulserMessType->GetXaxis()->SetBinLabel(1, "Dummy");
386 fhPulserMessType->GetXaxis()->SetBinLabel(2, "Hit");
387 fhPulserMessType->GetXaxis()->SetBinLabel(3, "TsMsb");
388 fhPulserMessType->GetXaxis()->SetBinLabel(4, "Epoch");
389 fhPulserMessType->GetXaxis()->SetBinLabel(5, "Status");
390 fhPulserMessType->GetXaxis()->SetBinLabel(6, "Empty");
391 /* *** Missing int + MessType OP!!!! ****
392 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy");
393 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit");
394 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb");
395 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck");
396 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack");
397*/
398
399 sHistName = "hPulserSysMessType";
400 title = "Nb of system message for each type; System Type";
401 fhPulserSysMessType = new TH1I(sHistName, title, 17, 0., 17.);
402 /*
403 hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START");
404 hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH");
405 hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B");
406*/
407
408 sHistName = "hPulserMessageTypePerDpb";
409 title = "Nb of message of each type for each DPB; DPB; Type";
410 fhPulserMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 6, 0., 6.);
411 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(1, "Dummy");
412 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(2, "Hit");
413 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(3, "TsMsb");
414 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(4, "Epoch");
415 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(5, "Status");
416 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(6, "Empty");
417 /* *** Missing int + MessType OP!!!! ****
418 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy");
419 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit");
420 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb");
421 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck");
422 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack");
423*/
424
425 sHistName = "hPulserSysMessTypePerDpb";
426 title = "Nb of system message of each type for each DPB; DPB; System Type";
427 fhPulserSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.);
428 /*
429 hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START");
430 hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH");
431 hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B");
432*/
433
434 sHistName = "hPulserMessageTypePerElink";
435 title = "Nb of message of each type for each eLink; eLink; Type";
437 new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.);
438 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1, "Dummy");
439 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(2, "Hit");
440 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(3, "TsMsb");
441 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(4, "ReadDataAck");
442 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(5, "Ack");
443 /* *** Missing int + MessType OP!!!! ****
444 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy");
445 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit");
446 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb");
447 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck");
448 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack");
449*/
450
451 sHistName = "hPulserSysMessTypePerElink";
452 title = "Nb of system message of each type for each eLink; eLink; System Type";
454 new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.);
455 /*
456 fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START");
457 fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH");
458 fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B");
459*/
460
461 sHistName = "hPulserStatusMessType";
462 title = "Nb of status message of each type for each DPB; eLink; Status Type";
464 new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 16, 0., 16.);
465 /*
466 fhPulserStatusMessType->GetYaxis()->SetBinLabel( 1, "Dummy");
467 fhPulserStatusMessType->GetYaxis()->SetBinLabel( 2, "Hit");
468 fhPulserStatusMessType->GetYaxis()->SetBinLabel( 3, "TsMsb");
469 fhPulserStatusMessType->GetYaxis()->SetBinLabel( 4, "Epoch");
470*/
471 sHistName = "hPulserMsStatusFieldType";
472 title = "For each flag in the MS header, ON/OFF counts; Flag bit []; ON/OFF; MS []";
473 fhPulserMsStatusFieldType = new TH2I(sHistName, title, 16, -0.5, 15.5, 2, -0.5, 1.5);
474 /*
475 fhPulserMsStatusFieldType->GetYaxis()->SetBinLabel( 1, "Dummy");
476 fhPulserMsStatusFieldType->GetYaxis()->SetBinLabel( 2, "Hit");
477 fhPulserMsStatusFieldType->GetYaxis()->SetBinLabel( 3, "TsMsb");
478 fhPulserMsStatusFieldType->GetYaxis()->SetBinLabel( 4, "Epoch");
479*/
480 /*
481 // Number of rate bins =
482 // 9 for the sub-unit decade
483 // + 9 for each unit of each decade * 10 for the subdecade range
484 // + 1 for the closing bin top edge
485 const Int_t iNbDecadesRate = 9;
486 const Int_t iNbStepsDecade = 9;
487 const Int_t iNbSubStepsInStep = 10;
488 const Int_t iNbBinsRate = iNbStepsDecade
489 + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate
490 + 1;
491 Double_t dBinsRate[iNbBinsRate];
492 // First fill sub-unit decade
493 for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ )
494 dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU );
495 std::cout << std::endl;
496 // Then fill the main decades
497 Double_t dSubstepSize = 1.0 / iNbSubStepsInStep;
498 for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++)
499 {
500 Double_t dBase = std::pow( 10, iDecade );
501 Int_t iDecadeIdx = iNbStepsDecade
502 + iDecade * iNbStepsDecade * iNbSubStepsInStep;
503 for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
504 {
505 Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep;
506 for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
507 {
508 dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep)
509 + dBase * dSubstepSize * iSubStep;
510 } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
511 } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
512 } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++)
513 dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate );
514*/
517 fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec;
518
519 UInt_t uNbBinEvo = (32768 + 1) * 2;
520 Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs * static_cast<Double_t>(uNbBinEvo) / 2.0;
521 Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0;
522
523 // UInt_t uNbBinDt = static_cast<UInt_t>( (fdCoincMax - fdCoincMin )/stsxyter::kdClockCycleNs );
524
525 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
526 // Channel counts
527 sHistName = Form("hPulserChanCntRaw_%03u", uXyterIdx);
528 title = Form("Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx);
529 fhPulserChanCntRaw.push_back(new TH1I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
530
531 sHistName = Form("hPulserChanCntRawGood_%03u", uXyterIdx);
532 title = Form("Hits Count per channel in good MS, StsXyter #%03u; Channel; Hits []", uXyterIdx);
533 fhPulserChanCntRawGood.push_back(new TH1I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
534
535 // Raw Adc Distribution
536 sHistName = Form("hPulserChanAdcRaw_%03u", uXyterIdx);
537 title = Form("Raw Adc distribution per channel, StsXyter #%03u; Channel "
538 "[]; Adc []; Hits []",
539 uXyterIdx);
540 fhPulserChanAdcRaw.push_back(new TH2I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5,
542
543 // Raw Adc Distribution profile
544 sHistName = Form("hPulserChanAdcRawProfc_%03u", uXyterIdx);
545 title = Form("Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx);
546 fhPulserChanAdcRawProf.push_back(new TProfile(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
547
548 // Raw Ts Distribution
549 sHistName = Form("hPulserChanRawTs_%03u", uXyterIdx);
550 title = Form("Raw Timestamp distribution per channel, StsXyter #%03u; "
551 "Channel []; Ts []; Hits []",
552 uXyterIdx);
553 fhPulserChanRawTs.push_back(new TH2I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5,
555
556 // Missed event flag
557 sHistName = Form("hPulserChanMissEvt_%03u", uXyterIdx);
558 title = Form("Missed Event flags per channel, StsXyter #%03u; Channel []; "
559 "Miss Evt []; Hits []",
560 uXyterIdx);
561 fhPulserChanMissEvt.push_back(
562 new TH2I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, 2, -0.5, 1.5));
563
564 // Missed event flag counts evolution
565
566 sHistName = Form("hPulserChanMissEvtEvo_%03u", uXyterIdx);
567 title = Form("Missed Evt flags per second & channel in StsXyter #%03u; "
568 "Time [s]; Channel []; Missed Evt flags []",
569 uXyterIdx);
570 fhPulserChanMissEvtEvo.push_back(
571 new TH2I(sHistName, title, 1800, 0, 1800, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
572
573 // Missed event flag counts evo per StsXyter
574
575 sHistName = Form("hPulserFebMissEvtEvo%03u", uXyterIdx);
576 title = Form("Missed Evt flags per second in StsXyter #%03u; Time [s]; "
577 "Missed Evt flags []",
578 uXyterIdx);
579 fhPulserFebMissEvtEvo.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
580
581 // Hit rates evo per channel
582 sHistName = Form("hPulserChanRateEvo_%03u", uXyterIdx);
583 title = Form("Hits per second & channel in StsXyter #%03u; Time [s]; "
584 "Channel []; Hits []",
585 uXyterIdx);
586 fhPulserChanHitRateEvo.push_back(
587 new TH2I(sHistName, title, 1800, 0, 1800, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
588
589 // Hit rates evo per StsXyter
590 sHistName = Form("hPulserFebRateEvo_%03u", uXyterIdx);
591 title = Form("Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx);
592 fhPulserFebRateEvo.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
593
594 // Hit rates evo per channel, 1 minute bins, 24h
595 sHistName = Form("hPulserChanRateEvoLong_%03u", uXyterIdx);
596 title = Form("Hits per second & channel in StsXyter #%03u; Time [min]; "
597 "Channel []; Hits []",
598 uXyterIdx);
599 fhPulserChanHitRateEvoLong.push_back(new TH2D(sHistName, title, fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5,
600 fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
601
602 // Hit rates evo per StsXyter, 1 minute bins, 24h
603 sHistName = Form("hPulserFebRateEvoLong_%03u", uXyterIdx);
604 title = Form("Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx);
605 fhPulserFebRateEvoLong.push_back(new TH1D(sHistName, title, fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5));
606
608 sHistName = Form("fhPulserTimeDiffPerAsic_%03u", uXyterIdx);
609 title = Form("Time diff for pulser hits between ASIC %03u and other ASICs; "
610 "tn - t%03u [ns]; ASIC n; Counts",
611 uXyterIdx, uXyterIdx);
612 fhPulserTimeDiffPerAsic.push_back(
613 new TH2I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo, fuNbStsXyters, -0.5, fuNbStsXyters - 0.5));
614
615 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
616 if (uXyterIdxB == uXyterIdx) {
617 sHistName = Form("fhPulserTimeDiffSameAsic_%03u", uXyterIdx);
618 title = Form("Time diff for consecutive hits in ASIC %03u; tn - t [ns]; Counts", uXyterIdx);
619 } // if( uXyterIdxB == uXyterIdx )
620 else {
621 sHistName = Form("fhPulserTimeDiffPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
622 title = Form("Time diff for pulser hits in ASIC %03u and %03u; tn - t "
623 "[ns]; Counts",
624 uXyterIdx, uXyterIdxB);
625 } // else of if( uXyterIdxB == uXyterIdx )
626 fhPulserTimeDiffPerAsicPair[uXyterIdx].push_back(new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo));
627
628 if (uXyterIdxB == uXyterIdx) {
629 sHistName = Form("fhPulserTimeDiffClkSameAsic_%03u", uXyterIdx);
630 title = Form("Time diff for consecutive hits in ASIC %03u; tn - t [Clk]; Counts", uXyterIdx);
631 } // if( uXyterIdxB == uXyterIdx )
632 else {
633 sHistName = Form("fhPulserTimeDiffClkPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
634 title = Form("Time diff for pulser hits in ASIC %03u and %03u; tn - t "
635 "[Clk]; Counts",
636 uXyterIdx, uXyterIdxB);
637 } // else of if( uXyterIdxB == uXyterIdx )
638 fhPulserTimeDiffClkPerAsicPair[uXyterIdx].push_back(new TH1I(sHistName, title, 601, -300.5, 300.5));
639
640 if (uXyterIdxB == uXyterIdx) {
641 sHistName = Form("fhPulserTimeDiffEvoSameAsic_%03u", uXyterIdx);
642 title = Form("Time diff for consecutive hits in ASIC %03u; Time in run "
643 "[s]; tn - t [ns]; Counts",
644 uXyterIdx);
645 } // if( uXyterIdxB == uXyterIdx )
646 else {
647 sHistName = Form("fhPulserTimeDiffEvoPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
648 title = Form("Time diff for pulser hits in ASIC %03u and %03u; Time in "
649 "run [s]; tn - t [ns]; Counts",
650 uXyterIdx, uXyterIdxB);
651 } // else of if( uXyterIdxB == uXyterIdx )
652 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx].push_back(new TH2I(
653 sHistName, title, 3600, 0, 18000, 200, -100 * stsxyter::kdClockCycleNs, 100 * stsxyter::kdClockCycleNs));
654
655 if (uXyterIdxB == uXyterIdx) {
656 sHistName = Form("fhPulserTimeDiffEvoSameAsicProf_%03u", uXyterIdx);
657 title = Form("Time diff for consecutive hits in ASIC %03u; Time in run "
658 "[s]; tn - t [ns]",
659 uXyterIdx);
660 } // if( uXyterIdxB == uXyterIdx )
661 else {
662 sHistName = Form("fhPulserTimeDiffEvoPerAsicPairProf_%03u_%03u", uXyterIdx, uXyterIdxB);
663 title = Form("Time diff for pulser hits in ASIC %03u and %03u; Time in "
664 "run [s]; tn - t [ns]",
665 uXyterIdx, uXyterIdxB);
666 } // else of if( uXyterIdxB == uXyterIdx )
667 fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx].push_back(new TProfile(sHistName, title, 52000, 0, 52000));
668
669 if (uXyterIdxB == uXyterIdx) {
670 sHistName = Form("fhPulserRawTimeDiffEvoSameAsicProf_%03u", uXyterIdx);
671 title = Form("Time diff for consecutive hits in ASIC %03u; Time in run "
672 "[s]; tn - t [ns]",
673 uXyterIdx);
674 } // if( uXyterIdxB == uXyterIdx )
675 else {
676 sHistName = Form("fhPulserRawTimeDiffEvoPerAsicPairProf_%03u_%03u", uXyterIdx, uXyterIdxB);
677 title = Form("Time diff for pulser hits in ASIC %03u and %03u; Time in "
678 "run [s]; tn - t [ns]",
679 uXyterIdx, uXyterIdxB);
680 } // else of if( uXyterIdxB == uXyterIdx )
681 fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx].push_back(new TProfile(sHistName, title, 10400, 0, 52000));
682
683 sHistName = Form("fhPulserTsLsbMatchPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
684 title = Form("TS LSB for pulser hits in ASIC %03u and %03u; TS LSB %03u "
685 "[bin]; TS LSB %03u [bin]",
686 uXyterIdx, uXyterIdxB, uXyterIdx, uXyterIdxB);
687 fhPulserTsLsbMatchPerAsicPair[uXyterIdx].push_back(
688 new TH2I(sHistName, title, 256, -0.5, 255.5, 256, -0.5, 255.5));
689
690 sHistName = Form("fhPulserTsMsbMatchPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
691 title = Form("TS MSB for pulser hits in ASIC %03u and %03u; TS MSB %03u "
692 "[bin]; TS MSB %03u [bin]",
693 uXyterIdx, uXyterIdxB, uXyterIdx, uXyterIdxB);
694 fhPulserTsMsbMatchPerAsicPair[uXyterIdx].push_back(new TH2I(sHistName, title, 64, -0.5, 63.5, 64, -0.5, 63.5));
695
696 if (uXyterIdxB == uXyterIdx) {
697 sHistName = Form("fhPulserTsLsbDiffEvoSameAsicProf_%03u", uXyterIdx);
698 title = Form("TS LSB diff for consecutive hits in ASIC %03u; Time in "
699 "run [s]; LSBn - LSB [bins]",
700 uXyterIdx);
701 } // if( uXyterIdxB == uXyterIdx )
702 else {
703 sHistName = Form("fhPulserTsLsbDiffEvoPerAsicPairProf_%03u_%03u", uXyterIdx, uXyterIdxB);
704 title = Form("TS LSB diff for pulser hits in ASIC %03u and %03u; Time "
705 "in run [s]; LSBn - LSB [Bins]",
706 uXyterIdx, uXyterIdxB);
707 } // else of if( uXyterIdxB == uXyterIdx )
708 fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx].push_back(new TProfile(sHistName, title, 52000, 0, 52000));
709
710 if (uXyterIdxB == uXyterIdx) {
711 sHistName = Form("fhPulserTsMsbDiffEvoSameAsicProf_%03u", uXyterIdx);
712 title = Form("TS MSB diff for consecutive hits in ASIC %03u; Time in "
713 "run [s]; MSBn - MSB [bins]",
714 uXyterIdx);
715 } // if( uXyterIdxB == uXyterIdx )
716 else {
717 sHistName = Form("fhPulserTsMsbDiffEvoPerAsicPairProf_%03u_%03u", uXyterIdx, uXyterIdxB);
718 title = Form("TS MSB diff for pulser hits in ASIC %03u and %03u; Time "
719 "in run [s]; MSBn - MSB [Bins]",
720 uXyterIdx, uXyterIdxB);
721 } // else of if( uXyterIdxB == uXyterIdx )
722 fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx].push_back(new TProfile(sHistName, title, 52000, 0, 52000));
723
724 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
725
726 sHistName = Form("fhPulserIntervalAsic_%03u", uXyterIdx);
727 title = Form("Time diff between consecutive hits in ASIC %03us; dt [ns]; Counts", uXyterIdx);
728 fhPulserIntervalAsic.push_back(new TH1I(sHistName, title, 200, 0, 200 * stsxyter::kdClockCycleNs));
729
730 sHistName = Form("fhPulserIntervalLongAsic_%03u", uXyterIdx);
731 title = Form("Time diff between consecutive hits in ASIC %03us; dt [ns]; Counts", uXyterIdx);
732 fhPulserIntervalLongAsic.push_back(new TH1I(sHistName, title, 1e5, 0, 1e6 * stsxyter::kdClockCycleNs));
733
735 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
739 for (UInt_t uAsicA = 0; uAsicA < fhPulserTimeDiffPerAsicPair.size(); ++uAsicA) {
742 fvdMeanTimeDiffAsicPair[uAsicA].resize(fhPulserTimeDiffPerAsicPair[uAsicA].size(), 0.0);
743 } // for( UInt_t uAsicA = 0; uAsicA < fhPulserTimeDiffPerAsicPair.size(); ++uAsicA )
744
745
747
748 /*
749 // Distribution of the TS_MSB per StsXyter
750 sHistName = "hPulserFebTsMsb";
751 title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []";
752 fhPulserFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5,
753 fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 );
754 if( server ) server->Register("/StsRaw", fhPulserFebTsMsb );
755*/
756 // Miscroslice properties histos
757 for (Int_t component = 0; component < kiMaxNbFlibLinks; component++) {
758 fhMsSz[component] = NULL;
759 fhMsSzTime[component] = NULL;
760 } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ )
761
762 // Online histo browser commands
763 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
764 if (server) {
765 server->Register("/StsRaw", fhPulserMessType);
766 server->Register("/StsRaw", fhPulserSysMessType);
767 server->Register("/StsRaw", fhPulserMessTypePerDpb);
768 server->Register("/StsRaw", fhPulserSysMessTypePerDpb);
769 server->Register("/StsRaw", fhPulserMessTypePerElink);
770 server->Register("/StsRaw", fhPulserSysMessTypePerElink);
771 server->Register("/StsRaw", fhPulserStatusMessType);
772 server->Register("/StsRaw", fhPulserMsStatusFieldType);
773 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
774 server->Register("/StsRaw", fhPulserChanCntRaw[uXyterIdx]);
775 server->Register("/StsRaw", fhPulserChanCntRawGood[uXyterIdx]);
776 server->Register("/StsRaw", fhPulserChanAdcRaw[uXyterIdx]);
777 server->Register("/StsRaw", fhPulserChanAdcRawProf[uXyterIdx]);
778 server->Register("/StsRaw", fhPulserChanRawTs[uXyterIdx]);
779 server->Register("/StsRaw", fhPulserChanMissEvt[uXyterIdx]);
780 server->Register("/StsRaw", fhPulserChanMissEvtEvo[uXyterIdx]);
781 server->Register("/StsRaw", fhPulserFebMissEvtEvo[uXyterIdx]);
782 server->Register("/StsRaw", fhPulserChanHitRateEvo[uXyterIdx]);
783 server->Register("/StsRaw", fhPulserFebRateEvo[uXyterIdx]);
784 server->Register("/StsRaw", fhPulserChanHitRateEvoLong[uXyterIdx]);
785 server->Register("/StsRaw", fhPulserFebRateEvoLong[uXyterIdx]);
786
787 server->Register("/DtAsic", fhPulserTimeDiffPerAsic[uXyterIdx]);
788 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
789 if (uXyterIdxB == uXyterIdx) {
790 server->Register("/DtChan", fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]);
791 server->Register("/DtChan", fhPulserTimeDiffClkPerAsicPair[uXyterIdx][uXyterIdxB]);
792 server->Register("/DtChan", fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]);
793 server->Register("/DtChan", fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
794 server->Register("/DtChan", fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
795 server->Register("/DtChan", fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
796 server->Register("/DtChan", fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
797 } // if( uXyterIdxB == uXyterIdx )
798 else {
799 server->Register("/DtAsicPair", fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]);
800 server->Register("/DtAsicPair", fhPulserTimeDiffClkPerAsicPair[uXyterIdx][uXyterIdxB]);
801 server->Register("/DtAsicPair", fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]);
802 server->Register("/DtAsicPair", fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
803 server->Register("/DtAsicPair", fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
804 server->Register("/DtAsicPair", fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
805 server->Register("/DtAsicPair", fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]);
806 } // else of if( uXyterIdxB == uXyterIdx )
807 server->Register("/TsMatch", fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]);
808 server->Register("/TsMatch", fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]);
809 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
810 server->Register("/DtPulses", fhPulserIntervalAsic[uXyterIdx]);
811 server->Register("/DtPulses", fhPulserIntervalLongAsic[uXyterIdx]);
812
813 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
814
815 server->RegisterCommand("/Reset_All_Pulser", "bMcbm2018ResetStsSync=kTRUE");
816 server->RegisterCommand("/Write_All_Pulser", "bMcbm2018WriteStsSync=kTRUE");
817
818 server->Restrict("/Reset_All_Pulser", "allow=admin");
819 server->Restrict("/Write_All_Pulser", "allow=admin");
820 } // if( server )
821
823 Double_t w = 10;
824 Double_t h = 10;
825
826 // Summary per StsXyter
827 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
828 TCanvas* cStsSumm =
829 new TCanvas(Form("cStsSum_%03u", uXyterIdx), Form("Summary plots for StsXyter %03u", uXyterIdx), w, h);
830 cStsSumm->Divide(2, 2);
831
832 cStsSumm->cd(1);
833 gPad->SetLogy();
834 fhPulserChanCntRaw[uXyterIdx]->Draw();
835
836 cStsSumm->cd(2);
837 gPad->SetLogz();
838 fhPulserChanAdcRaw[uXyterIdx]->Draw("colz");
839
840 cStsSumm->cd(3);
841 gPad->SetLogz();
842 fhPulserChanHitRateEvo[uXyterIdx]->Draw("colz");
843
844 cStsSumm->cd(4);
845 // gPad->SetLogy();
846 fhPulserChanAdcRawProf[uXyterIdx]->Draw();
847 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
848
849 //====================================================================//
850
851 //====================================================================//
852 TCanvas* cDtPerAsic = new TCanvas("cDtPerAsic", "Time Differences per ASIC", w, h);
853 cDtPerAsic->Divide(fuNbStsXyters / 2 + fuNbStsXyters % 2, 2);
854
855 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
856 cDtPerAsic->cd(1 + uXyterIdx);
857 gPad->SetGridx();
858 gPad->SetGridy();
859 gPad->SetLogz();
860 fhPulserTimeDiffPerAsic[uXyterIdx]->Draw(" colz");
861 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
862 //====================================================================//
863
864 //====================================================================//
865 TCanvas* cDtInAsic = new TCanvas("cDtInAsic", "Time Differences in ASIC", w, h);
866 cDtInAsic->Divide(fuNbStsXyters / 2 + fuNbStsXyters % 2, 2);
867
868 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
869 cDtInAsic->cd(1 + uXyterIdx);
870 gPad->SetGridx();
871 gPad->SetLogy();
872 // gStyle->SetOptStat("emrou");
873 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdx]->Draw("hist");
874 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
875 //====================================================================//
876
877 //====================================================================//
878 TCanvas* cDtAsicPairs = new TCanvas("cDtAsicPairs", "Time Differences in ASIC", w, h);
879 cDtAsicPairs->Divide(2, 3);
880 UInt_t uHistoIdx = 0;
881 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
882 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
883 cDtAsicPairs->cd(1 + uHistoIdx);
884 gPad->SetGridx();
885 gPad->SetLogy();
886 // gStyle->SetOptStat("emrou");
887 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("hist");
888
889 uHistoIdx++;
890 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
891 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
892 //====================================================================//
893
894 //====================================================================//
895 TCanvas* cDtClkAsicPairs = new TCanvas("cDtClkAsicPairs", "Time Differences in ASIC", w, h);
896 cDtClkAsicPairs->Divide(fuNbStsXyters - 1);
897 for (UInt_t uXyterIdxB = 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
898 cDtClkAsicPairs->cd(uXyterIdxB);
899 gPad->SetGridx();
900 gPad->SetLogy();
901 // gStyle->SetOptStat("emrou");
902 fhPulserTimeDiffClkPerAsicPair[0][uXyterIdxB]->Draw("hist");
903 } // for( UInt_t uXyterIdxB = 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
904 //====================================================================//
905
906 //====================================================================//
907 TCanvas* cDtAsicPairsEvo = new TCanvas("cDtAsicPairsEvo", "Time Differences Evo in ASIC", w, h);
908 cDtAsicPairsEvo->Divide(2, 3);
909 uHistoIdx = 0;
910 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
911 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
912 cDtAsicPairsEvo->cd(1 + uHistoIdx);
913 gPad->SetGridx();
914 gPad->SetGridy();
915 gPad->SetLogz();
916 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("colz");
917
918 uHistoIdx++;
919 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
920 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
921 //====================================================================//
922
923 //====================================================================//
924 TCanvas* cDtAsicPairsEvoProf = new TCanvas("cDtAsicPairsEvoProf", "Time Differences Evo in ASIC", w, h);
925 cDtAsicPairsEvoProf->Divide(2, 3);
926 uHistoIdx = 0;
927 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
928 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
929 cDtAsicPairsEvoProf->cd(1 + uHistoIdx);
930 gPad->SetGridx();
931 gPad->SetGridy();
932 gPad->SetLogz();
933 fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Draw("hist e0");
934
935 uHistoIdx++;
936 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
937 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
938 //====================================================================//
939
940 //====================================================================//
941 TCanvas* cDtAsicPairsEvoProfRaw = new TCanvas("cDtAsicPairsEvoProfRaw", "Time Differences Evo in ASIC", w, h);
942 cDtAsicPairsEvoProfRaw->Divide(2, 3);
943 uHistoIdx = 0;
944 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
945 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
946 cDtAsicPairsEvoProfRaw->cd(1 + uHistoIdx);
947 gPad->SetGridx();
948 gPad->SetGridy();
949 gPad->SetLogz();
950 fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Draw("hist e0");
951
952 uHistoIdx++;
953 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
954 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
955 //====================================================================//
956
957 //====================================================================//
958 TCanvas* cTsLsbAsicPairs = new TCanvas("cTsLsbAsicPairs", "Time Differences in ASIC", w, h);
959 cTsLsbAsicPairs->Divide(2, 3);
960 uHistoIdx = 0;
961 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
962 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
963 cTsLsbAsicPairs->cd(1 + uHistoIdx);
964 gPad->SetGridx();
965 gPad->SetGridy();
966 gPad->SetLogz();
967 fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("colz");
968
969 uHistoIdx++;
970 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
971 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
972 //====================================================================//
973
974 //====================================================================//
975 TCanvas* cTsMsbAsicPairs = new TCanvas("cTsMsbAsicPairs", "Time Differences in ASIC", w, h);
976 // cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 );
977 cTsMsbAsicPairs->Divide(2, 3);
978 uHistoIdx = 0;
979 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
980 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
981 cTsMsbAsicPairs->cd(1 + uHistoIdx);
982 gPad->SetGridx();
983 gPad->SetGridy();
984 gPad->SetLogz();
985 fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("colz");
986
987 uHistoIdx++;
988 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
989 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
990 //====================================================================//
991
992 //====================================================================//
993 TCanvas* cDlsbAsicPairsEvoProf = new TCanvas("cDlsbAsicPairsEvoProf", "Time Differences Evo in ASIC", w, h);
994 cDlsbAsicPairsEvoProf->Divide(2, 3);
995 uHistoIdx = 0;
996 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
997 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
998 cDlsbAsicPairsEvoProf->cd(1 + uHistoIdx);
999 gPad->SetGridx();
1000 gPad->SetGridy();
1001 gPad->SetLogz();
1002 fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Draw("hist e0");
1003
1004 uHistoIdx++;
1005 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
1006 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1007 //====================================================================//
1008
1009 //====================================================================//
1010 TCanvas* cDmsbAsicPairsEvoProf = new TCanvas("cDmsbAsicPairsEvoProf", "Time Differences Evo in ASIC", w, h);
1011 cDmsbAsicPairsEvoProf->Divide(2, 3);
1012 uHistoIdx = 0;
1013 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
1014 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
1015 cDmsbAsicPairsEvoProf->cd(1 + uHistoIdx);
1016 gPad->SetGridx();
1017 gPad->SetGridy();
1018 gPad->SetLogz();
1019 fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Draw("hist e0");
1020
1021 uHistoIdx++;
1022 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
1023 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1024 //====================================================================//
1025
1026 //====================================================================//
1028 // Try to recover canvas in case it was created already by another monitor
1029 // If not existing, create it
1030 fcMsSizeAll = dynamic_cast<TCanvas*>(gROOT->FindObject("cMsSizeAll"));
1031 if (NULL == fcMsSizeAll) {
1032 fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h);
1033 fcMsSizeAll->Divide(4, 4);
1034 LOG(info) << "Created MS size canvas in STS monitor";
1035 } // if( NULL == fcMsSizeAll )
1036 else
1037 LOG(info) << "Recovered MS size canvas in STS monitor";
1038 //====================================================================//
1039
1040 /*****************************/
1041}
1042
1043Bool_t CbmMcbm2018MonitorStsSync::DoUnpack(const fles::Timeslice& ts, size_t component)
1044{
1047 bMcbm2018ResetStsSync = kFALSE;
1048 } // if( bMcbm2018ResetStsSync )
1051 bMcbm2018WriteStsSync = kFALSE;
1052 } // if( bMcbm2018WriteStsSync )
1053
1054 LOG(debug) << "Timeslice contains " << ts.num_microslices(component) << "microslices.";
1055 fulCurrentTsIdx = ts.index();
1056
1057 // Ignore overlap ms if flag set by user
1058 UInt_t uNbMsLoop = fuNbCoreMsPerTs;
1059 if (kFALSE == fbIgnoreOverlapMs) uNbMsLoop += fuNbOverMsPerTs;
1060
1061 // Loop over core microslices (and overlap ones if chosen)
1062 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
1063 // Loop over registered components
1064 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
1065 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
1066 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
1067 fuCurrentEquipmentId = msDescriptor.eq_id;
1068 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
1069
1070 uint32_t uSize = msDescriptor.size;
1071 fulCurrentMsIdx = msDescriptor.idx;
1072 Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
1073
1074 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
1076
1077 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
1078 << " (DPB Idx " << std::setw(2) << fuCurrDpbIdx << " )"
1079 << " has size: " << uSize;
1080
1081 if (uMsComp < kiMaxNbFlibLinks) {
1082 if (fdStartTimeMsSz < 0) fdStartTimeMsSz = dMsTime;
1083 fhMsSz[uMsComp]->Fill(uSize);
1084 fhMsSzTime[uMsComp]->Fill(dMsTime - fdStartTimeMsSz, uSize);
1085 } // if( uMsComp < kiMaxNbFlibLinks )
1086
1087 // Store MS time for coincidence plots
1088 fvdMsTime[uMsCompIdx] = dMsTime;
1089
1091 uint16_t uMsHeaderFlags = msDescriptor.flags;
1092 for (UInt_t uBit = 0; uBit < 16; ++uBit)
1093 fhPulserMsStatusFieldType->Fill(uBit, (uMsHeaderFlags >> uBit) & 0x1);
1094
1096 UInt_t uTsMsbCycleHeader = std::floor(fulCurrentMsIdx / (stsxyter::kulTsCycleNbBins * stsxyter::kdClockCycleNs))
1098 if (kFALSE == fvuInitialHeaderDone[fuCurrDpbIdx]) {
1099 fvuInitialTsMsbCycleHeader[fuCurrDpbIdx] = uTsMsbCycleHeader;
1101 } // if( kFALSE == fvuInitialHeaderDone[ fuCurrDpbIdx ] )
1102 else if (uTsMsbCycleHeader != fvuCurrentTsMsbCycle[fuCurrDpbIdx] && 4194303 != fvulCurrentTsMsb[fuCurrDpbIdx]) {
1103 LOG(warning) << "TS MSB cycle from MS header does not match current "
1104 "cycle from data "
1105 << "for TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
1106 << " MsInTs " << std::setw(3) << uMsIdx << " ====> " << fvuCurrentTsMsbCycle[fuCurrDpbIdx]
1107 << " VS " << uTsMsbCycleHeader;
1108 fvuCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
1109 }
1110
1111 // If not integer number of message in input buffer, print warning/error
1112 if (0 != (uSize % kuBytesPerMessage))
1113 LOG(error) << "The input microslice buffer does NOT "
1114 << "contain only complete nDPB messages!";
1115
1116 // Compute the number of complete messages in the input microslice buffer
1117 uint32_t uNbMessages = (uSize - (uSize % kuBytesPerMessage)) / kuBytesPerMessage;
1118
1119 // Prepare variables for the loop on contents
1120 const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>(msContent);
1121
1122
1123 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
1124 // Fill message
1125 uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]);
1126
1127 stsxyter::Message mess(static_cast<uint32_t>(ulData & 0xFFFFFFFF));
1128
1129 // Print message if requested
1130 if (fbPrintMessages) {
1131 std::cout << Form("DPB %2u TS %12llu MS %12llu mess %5u ", fuCurrDpbIdx, fulCurrentTsIdx, fulCurrentMsIdx,
1132 uIdx);
1133 mess.PrintMess(std::cout, fPrintMessCtrl);
1134 } // if( fbPrintMessages )
1135
1136 stsxyter::MessType typeMess = mess.GetMessType();
1137 fmMsgCounter[typeMess]++;
1138 fhPulserMessType->Fill(static_cast<uint16_t>(typeMess));
1139 fhPulserMessTypePerDpb->Fill(fuCurrDpbIdx, static_cast<uint16_t>(typeMess));
1140
1141 switch (typeMess) {
1143 // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific!
1144 UShort_t usElinkIdx = mess.GetLinkIndex();
1145 if (fuNbElinksPerDpb <= usElinkIdx) {
1146 LOG(fatal) << "CbmMcbm2018MonitorStsSync::DoUnpack => "
1147 << "eLink index out of bounds!" << usElinkIdx << " VS " << fuNbElinksPerDpb;
1148 } // if( fuNbElinksPerDpb <= usElinkIdx )
1150 static_cast<uint16_t>(typeMess));
1151
1152 UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx];
1153
1154 FillHitInfo(mess, usElinkIdx, uAsicIdx, uMsIdx);
1155 break;
1156 } // case stsxyter::MessType::Hit :
1158 FillTsMsbInfo(mess, uIdx, uMsIdx);
1159 break;
1160 } // case stsxyter::MessType::TsMsb :
1162 // The first message in the TS is a special ones: EPOCH
1163 FillEpochInfo(mess);
1164
1165 if (0 < uIdx)
1166 LOG(info) << "CbmMcbm2018MonitorStsSync::DoUnpack => "
1167 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
1168 break;
1169 } // case stsxyter::MessType::TsMsb :
1171 UShort_t usElinkIdx = mess.GetStatusLink();
1172 UShort_t usStatusField = mess.GetStatusStatus();
1173 fhPulserStatusMessType->Fill(fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, usStatusField);
1174
1176 std::cout << Form("DPB %2u TS %12llu MS %12llu mess %5u ", fuCurrDpbIdx, fulCurrentTsIdx, fulCurrentMsIdx,
1177 uIdx);
1178 mess.PrintMess(std::cout, fPrintMessCtrl);
1179 // FillTsMsbInfo( mess );
1180 break;
1181 } // case stsxyter::MessType::Empty :
1183 // FillTsMsbInfo( mess );
1184 break;
1185 } // case stsxyter::MessType::Empty :
1187 break;
1188 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
1189 default: {
1190 LOG(fatal) << "CbmMcbm2018MonitorStsSync::DoUnpack => "
1191 << "Unknown message type, should never happen, stopping here!";
1192 }
1193 } // switch( mess.GetMessType() )
1194 } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx )
1195 } // for( UInt_t uMsComp = 0; uMsComp < fvMsComponentsList.size(); ++uMsComp )
1196
1198 if (0 < fvmHitsInMs.size()) {
1199 // Sort the buffer of hits
1200 std::sort(fvmHitsInMs.begin(), fvmHitsInMs.end());
1201
1202 // Make sure we analyse only MS where all ASICs were detected (remove noise and MS borders)
1203 if (fuNbStsXyters != fvmHitsInMs.size()) fvmHitsInMs.erase(fvmHitsInMs.begin(), fvmHitsInMs.end());
1204
1205 // ULong64_t ulLastHitTime = ( *( fvmHitsInMs.rbegin() ) ).GetTs();
1206 std::vector<stsxyter::FinalHit>::iterator it;
1207 std::vector<stsxyter::FinalHit>::iterator itB;
1208
1209 // std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now();
1210 // Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count();
1211
1212 for (it = fvmHitsInMs.begin(); it != fvmHitsInMs.end();
1213 // it != fvmHitsInMs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns
1214 ++it) {
1215 UShort_t usAsicIdx = (*it).GetAsic();
1216 // UShort_t usChanIdx = (*it).GetChan();
1217 // ULong64_t ulHitTs = (*it).GetTs();
1218 // UShort_t usHitAdc = (*it).GetAdc();
1219
1220 // Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9;
1221
1222 fvmAsicHitsInMs[usAsicIdx].push_back((*it));
1223 } // loop on time sorted hits and split per asic
1224
1225 // Remove all hits which were already used
1226 fvmHitsInMs.erase(fvmHitsInMs.begin(), it);
1227
1228 for (UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++) {
1229 for (it = fvmAsicHitsInMs[uAsic].begin(); it != fvmAsicHitsInMs[uAsic].end(); ++it) {
1230 // UShort_t usChanIdx = (*it).GetChan();
1231 if (0.0 == fdStartTs) fdStartTs = (*it).GetTs() * stsxyter::kdClockCycleNs;
1232 Double_t dTimeSinceStartSec = ((*it).GetTs() * stsxyter::kdClockCycleNs - fdStartTs) * 1e-9;
1233
1234 for (UInt_t uAsicB = uAsic; uAsicB < fuNbStsXyters; uAsicB++) {
1235 for (itB = fvmAsicHitsInMs[uAsicB].begin(); itB != fvmAsicHitsInMs[uAsicB].end(); ++itB) {
1236 // UShort_t usChanIdxB = (*itB).GetChan();
1237 Double_t dDtClk = static_cast<Double_t>((*itB).GetTs()) - static_cast<Double_t>((*it).GetTs());
1238 Double_t dDt = dDtClk * stsxyter::kdClockCycleNs;
1239 Double_t dDtRaw = (static_cast<Double_t>((*itB).GetTs() % stsxyter::kulTsCycleNbBins)
1240 - static_cast<Double_t>((*it).GetTs() % stsxyter::kulTsCycleNbBins))
1242
1243 fhPulserTimeDiffPerAsic[uAsic]->Fill(dDt, uAsicB);
1244 fhPulserTimeDiffPerAsicPair[uAsic][uAsicB]->Fill(dDt);
1245 fhPulserTimeDiffClkPerAsicPair[uAsic][uAsicB]->Fill(dDtClk);
1246 fhPulserTimeDiffEvoPerAsicPair[uAsic][uAsicB]->Fill(dTimeSinceStartSec, dDt);
1247 fhPulserTimeDiffEvoPerAsicPairProf[uAsic][uAsicB]->Fill(dTimeSinceStartSec, dDt);
1248 fhPulserRawTimeDiffEvoPerAsicPairProf[uAsic][uAsicB]->Fill(dTimeSinceStartSec, dDtRaw);
1249
1250 fhPulserTsLsbMatchPerAsicPair[uAsic][uAsicB]->Fill((*it).GetTs() & 0x000FF, (*itB).GetTs() & 0x000FF);
1251 fhPulserTsMsbMatchPerAsicPair[uAsic][uAsicB]->Fill(((*it).GetTs() & 0x03F00) >> 8,
1252 ((*itB).GetTs() & 0x03F00) >> 8);
1253 /*
1254 Int_t iDtLsb = static_cast< Int_t >( (*itB).GetTs() & 0x000FF )
1255 - static_cast< Int_t >( (*it ).GetTs() & 0x000FF );
1256*/
1257 Int_t iDtLsb = (((*itB).GetTs() & 0x000FF) > ((*it).GetTs() & 0x000FF) ? (*itB).GetTs() & 0x000FF
1258 : 255 + ((*itB).GetTs() & 0x000FF))
1259 - ((*it).GetTs() & 0x000FF);
1260 Int_t iDtMsb = static_cast<Int_t>(((*itB).GetTs() & 0x03F00) >> 8)
1261 - static_cast<Int_t>(((*it).GetTs() & 0x03F00) >> 8);
1262 fhPulserTsLsbDiffEvoPerAsicPairProf[uAsic][uAsicB]->Fill(dTimeSinceStartSec, iDtLsb);
1263 fhPulserTsMsbDiffEvoPerAsicPairProf[uAsic][uAsicB]->Fill(dTimeSinceStartSec, iDtMsb);
1264
1265 if ((kdPulserPeriod * -0.5 < dDt && dDt < kdPulserPeriod * 0.5 && 10 < (*it).GetAdc()
1266 && 10 < (*itB).GetAdc()) // &&
1267 // !( 2 == uAsic && 3 == uAsicB && 240 < dDt )
1268 ) {
1269 /*
1270 if( ( dDt < fvdMeanTimeDiffAsicPair[ uAsic ][ uAsicB ] - kdTimeDiffToMeanMargin ||
1271 dDt > fvdMeanTimeDiffAsicPair[ uAsic ][ uAsicB ] + kdTimeDiffToMeanMargin )
1272 && !( 3 == uAsicB )
1273
1274 )
1275 {
1276 LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => "
1277 << " TS " << std::setw( 12 ) << fulCurrentTsIdx
1278 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1279 << " Potential jump in timestamp for ASIC "
1280 << uAsic << " and " << uAsicB
1281 << ": time diff is " << std::setw( 8 ) << dDt
1282 << " while mean time diff of last " << kuNbValuesForTimeDiffMean
1283 << " pairs is " << std::setw( 8 ) << fvdMeanTimeDiffAsicPair[ uAsic ][ uAsicB ];
1284 LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => "
1285 << " Buffer slot idx is " << std::setw( 3 ) << fvuLastTimeDiffSlotAsicPair[ uAsic ][ uAsicB ]
1286 << " Buffer size is " << std::setw( 3 ) << fvdLastTimeDiffValuesAsicPair[ uAsic ][ uAsicB ].size();
1287
1288 } // if dDt outside of MeanTimeDiffPair +/- margin
1289*/
1290 UpdatePairMeanValue(uAsic, uAsicB, dDt);
1291 } // if( kdPulserPeriod * -0.5 < dDt && dDt < kdPulserPeriod * 0.5 )
1292 } // for( it = fvmAsicHitsInMs[ uAsicB ].begin(); it != fvmAsicHitsInMs[ uAsicB ].end(); ++it )
1293 } // for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++)
1294
1295 Double_t dDtPulse =
1296 (static_cast<Double_t>((*it).GetTs()) - static_cast<Double_t>(fvmLastHitAsic[uAsic].GetTs()))
1298 fhPulserIntervalAsic[uAsic]->Fill(dDtPulse);
1299 fhPulserIntervalLongAsic[uAsic]->Fill(dDtPulse);
1300 fvmLastHitAsic[uAsic] = (*it);
1301 } // for( it = fvmAsicHitsInMs[ uAsic ].begin(); it != fvmAsicHitsInMs[ uAsic ].end(); ++it )
1302
1304 fvmAsicHitsInMs[uAsic].clear();
1305 } // for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++)
1306 } // if( 0 < fvmHitsInMs.size() )
1307 } // for( UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx ++ )
1308 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
1309 fvdMsTime[uMsIdx] = 0.0;
1310 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
1311
1312 if (0 == ts.index() % 1000) {
1313 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
1314 Double_t dTsMsbTime =
1315 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
1316 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins)
1317 * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
1318 dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9;
1319
1320 LOG(info) << "End of TS " << std::setw(7) << ts.index() << " eDPB " << std::setw(2) << uDpb
1321 << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb]
1322 << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb]
1323 << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s";
1324 }
1325 } // if( 0 == ts.index() % 1000 )
1326
1327 if (0 == ts.index() % 10000) SavePulserHistos("data/PulserPeriodicHistosSave.root");
1328
1329 return kTRUE;
1330}
1331
1332void CbmMcbm2018MonitorStsSync::FillHitInfo(stsxyter::Message mess, const UShort_t& /*usElinkIdx*/,
1333 const UInt_t& uAsicIdx, const UInt_t& uMsIdx)
1334{
1335 UShort_t usChan = mess.GetHitChannel();
1336 UShort_t usRawAdc = mess.GetHitAdc();
1337 // UShort_t usFullTs = mess.GetHitTimeFull();
1338 // UShort_t usTsOver = mess.GetHitTimeOver();
1339 UShort_t usRawTs = mess.GetHitTime();
1340
1341 fhPulserChanCntRaw[uAsicIdx]->Fill(usChan);
1342 fhPulserChanAdcRaw[uAsicIdx]->Fill(usChan, usRawAdc);
1343 fhPulserChanAdcRawProf[uAsicIdx]->Fill(usChan, usRawAdc);
1344 fhPulserChanRawTs[uAsicIdx]->Fill(usChan, usRawTs);
1345 fhPulserChanMissEvt[uAsicIdx]->Fill(usChan, mess.IsHitMissedEvts());
1346
1347 // Compute the Full time stamp
1348 // Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ];
1349 // Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ];
1350
1351 // Use TS w/o overlap bits as they will anyway come from the TS_MSB
1352 fvulChanLastHitTime[uAsicIdx][usChan] = usRawTs;
1353
1354 fvulChanLastHitTime[uAsicIdx][usChan] +=
1355 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
1356 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
1357
1358 // fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs;
1359
1360 // Convert the Hit time in bins to Hit time in ns
1361 Double_t dHitTimeNs = fvulChanLastHitTime[uAsicIdx][usChan] * stsxyter::kdClockCycleNs;
1362 /*
1363 // If needed fill the hit interval plots
1364 if( fbChanHitDtEna )
1365 {
1366 Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ];
1367 if( 0 == dDeltaT )
1368 fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan );
1369 else if( 0 < dDeltaT )
1370 fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan );
1371 else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan );
1372 } // if( fbChanHitDtEna )
1373*/
1374 // Store new value of Hit time in ns
1375 fvdChanLastHitTime[uAsicIdx][usChan] = fvulChanLastHitTime[uAsicIdx][usChan] * stsxyter::kdClockCycleNs;
1376 /*
1377 LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx
1378 << " Channel " << std::setw( 3 ) << usChan
1379 << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime)
1380 << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9;
1381*/
1382 // Pulser and MS
1383 fvuChanNbHitsInMs[uAsicIdx][usChan][uMsIdx]++;
1384 fvdChanLastHitTimeInMs[uAsicIdx][usChan][uMsIdx] = dHitTimeNs;
1385 fvusChanLastHitAdcInMs[uAsicIdx][usChan][uMsIdx] = usRawAdc;
1386 /*
1387 fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ],
1388 usRawAdc, uAsicIdx, usChan ) );
1389*/
1390 fvmHitsInMs.push_back(stsxyter::FinalHit(fvulChanLastHitTime[uAsicIdx][usChan], usRawAdc, uAsicIdx, usChan));
1391
1392 /*
1393 if( ( 214514 < fulCurrentTsIdx && fulCurrentTsIdx < 214517 ) ||
1394 ( 260113 < fulCurrentTsIdx && fulCurrentTsIdx < 260116 ) ||
1395 ( 388109 < fulCurrentTsIdx && fulCurrentTsIdx < 388114 ) ||
1396 ( 573361 < fulCurrentTsIdx && fulCurrentTsIdx < 573364 ) ||
1397 ( 661731 < fulCurrentTsIdx && fulCurrentTsIdx < 661734 ) ||
1398 ( 712982 < fulCurrentTsIdx && fulCurrentTsIdx < 712985 ) ||
1399 ( 713857 < fulCurrentTsIdx && fulCurrentTsIdx < 713860 ) ||
1400 ( 739365 < fulCurrentTsIdx && fulCurrentTsIdx < 739368 ))
1401 {
1402 LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx
1403 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1404 << " MsInTs " << std::setw( 3 ) << uMsIdx
1405 << " Asic " << std::setw( 2 ) << uAsicIdx
1406 << " Channel " << std::setw( 3 ) << usChan
1407 << " ADC " << std::setw( 3 ) << usRawAdc
1408 << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS
1409 << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB
1410 << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB
1411 << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
1412 << " TS(b) " << std::bitset<9>(usRawTs)
1413 << " TSM(b) " << std::bitset<24>(fvulCurrentTsMsb[fuCurrDpbIdx])
1414 << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]
1415 << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ];
1416 }
1417*/
1418 // Check Starting point of histos with time as X axis
1419 if (-1 == fdStartTime) fdStartTime = fvdChanLastHitTime[uAsicIdx][usChan];
1420
1421 // Fill histos with time as X axis
1422 Double_t dTimeSinceStartSec = (fvdChanLastHitTime[uAsicIdx][usChan] - fdStartTime) * 1e-9;
1423 Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0;
1424 fhPulserChanHitRateEvo[uAsicIdx]->Fill(dTimeSinceStartSec, usChan);
1425 fhPulserFebRateEvo[uAsicIdx]->Fill(dTimeSinceStartSec);
1426 fhPulserChanHitRateEvoLong[uAsicIdx]->Fill(dTimeSinceStartMin, usChan, 1.0 / 60.0);
1427 fhPulserFebRateEvoLong[uAsicIdx]->Fill(dTimeSinceStartMin, 1.0 / 60.0);
1428 if (mess.IsHitMissedEvts()) {
1429 fhPulserChanMissEvtEvo[uAsicIdx]->Fill(dTimeSinceStartSec, usChan);
1430 fhPulserFebMissEvtEvo[uAsicIdx]->Fill(dTimeSinceStartSec);
1431 } // if( mess.IsHitMissedEvts() )
1432 /*
1433 if( kTRUE == fbLongHistoEnable )
1434 {
1435 std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now();
1436 Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count();
1437 fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec );
1438 fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec );
1439 } // if( kTRUE == fbLongHistoEnable )
1440*/
1441}
1442
1443void CbmMcbm2018MonitorStsSync::FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx, UInt_t uMsIdx)
1444{
1445 UInt_t uVal = mess.GetTsMsbVal();
1446 /*
1447 if( ( 419369 < fulCurrentTsIdx && fulCurrentTsIdx < 419371 ) )
1448 LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx
1449 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1450 << " MsInTs " << std::setw( 3 ) << uMsIdx
1451 << " DPB " << std::setw( 2 ) << fuCurrDpbIdx
1452 << " Mess " << std::setw( 5 ) << uMessIdx
1453 << " TsMsb " << std::setw( 5 ) << uVal;
1454*/
1455 /*
1456 if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal &&
1457 !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS!
1458 {
1459 LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx
1460 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1461 << " MsInTs " << std::setw( 3 ) << uMsIdx
1462 << " DPB " << std::setw( 2 ) << fuCurrDpbIdx
1463 << " Mess " << std::setw( 5 ) << uMessIdx
1464 << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
1465 << " new TsMsb " << std::setw( 5 ) << uVal
1466 << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx]
1467 << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx];
1468 } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal )
1469*/
1470
1471 // Update Status counters
1472 if (uVal < fvulCurrentTsMsb[fuCurrDpbIdx]) {
1473
1474 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
1475 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
1476 << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " Old MsbCy "
1477 << std::setw(5) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " new TsMsb " << std::setw(5) << uVal;
1478
1480 } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
1481 if (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1 && 0 != uVal && 4194303 != fvulCurrentTsMsb[fuCurrDpbIdx]
1482 && 1 != uMessIdx) {
1483 LOG(info) << "TS MSb Jump in "
1484 << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
1485 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
1486 << fuCurrDpbIdx << " => Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " new TsMsb "
1487 << std::setw(5) << uVal;
1488 } // if( uVal + 1 != fvulCurrentTsMsb[fuCurrDpbIdx] && 4194303 != uVal && 0 != fvulCurrentTsMsb[fuCurrDpbIdx] )
1490 /*
1491 if( 1 < uMessIdx )
1492 {
1493 fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] );
1494 fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) );
1495 fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) );
1496 } // if( 0 < uMessIdx )
1497*/
1498 // fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
1499 /*
1500 ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins )
1501 * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx])
1502 + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins )
1503 * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] );
1504*/
1505}
1506
1508{
1509 // UInt_t uVal = mess.GetEpochVal();
1510 // UInt_t uCurrentCycle = uVal % stsxyter::kulTsCycleNbBins;
1511
1512 /*
1513 // Update Status counters
1514 if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
1515 fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++;
1516 fvulCurrentTsMsb[fuCurrDpbIdx] = usVal;
1517
1518// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
1519*/
1520}
1521
1523
1525{
1526
1527 LOG(info) << "-------------------------------------";
1528 LOG(info) << "CbmMcbm2018MonitorStsSync statistics are ";
1529 LOG(info) << " Hit messages: " << fmMsgCounter[stsxyter::MessType::Hit] << "\n"
1530 << " Ts MSB messages: " << fmMsgCounter[stsxyter::MessType::TsMsb] << "\n"
1531 << " Dummy messages: " << fmMsgCounter[stsxyter::MessType::Dummy] << "\n"
1532 << " Epoch messages: " << fmMsgCounter[stsxyter::MessType::Epoch] << "\n"
1533 << " Empty messages: " << fmMsgCounter[stsxyter::MessType::Empty];
1534
1535 LOG(info) << "-------------------------------------";
1536
1538 SaveAllHistos();
1539}
1540
1542{
1544 TFile* oldFile = gFile;
1545 TDirectory* oldDir = gDirectory;
1546
1547 TFile* histoFile = NULL;
1548 if ("" != sFileName) {
1549 // open separate histo file in recreate mode
1550 histoFile = new TFile(sFileName, "RECREATE");
1551 histoFile->cd();
1552 } // if( "" != sFileName )
1553
1554 /***************************/
1555 gDirectory->mkdir("Sts_Raw");
1556 gDirectory->cd("Sts_Raw");
1557
1558 fhPulserMessType->Write();
1559 fhPulserSysMessType->Write();
1560 fhPulserMessTypePerDpb->Write();
1562 fhPulserMessTypePerElink->Write();
1564 fhPulserStatusMessType->Write();
1566
1567 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
1568 fhPulserChanCntRaw[uXyterIdx]->Write();
1569 fhPulserChanAdcRaw[uXyterIdx]->Write();
1570 fhPulserChanAdcRawProf[uXyterIdx]->Write();
1571 fhPulserChanRawTs[uXyterIdx]->Write();
1572 fhPulserChanMissEvt[uXyterIdx]->Write();
1573 fhPulserChanMissEvtEvo[uXyterIdx]->Write();
1574 fhPulserFebMissEvtEvo[uXyterIdx]->Write();
1575 fhPulserChanHitRateEvo[uXyterIdx]->Write();
1576 fhPulserFebRateEvo[uXyterIdx]->Write();
1577 fhPulserChanHitRateEvoLong[uXyterIdx]->Write();
1578 fhPulserFebRateEvoLong[uXyterIdx]->Write();
1579 /*
1580 if( kTRUE == fbLongHistoEnable )
1581 {
1582 fhFebRateEvoLong[ uXyterIdx ]->Write();
1583 fhFebChRateEvoLong[ uXyterIdx ]->Write();
1584 } // if( kTRUE == fbLongHistoEnable )
1585*/
1586 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1587
1588 gDirectory->cd("..");
1589 /***************************/
1590
1591 /***************************/
1592 gDirectory->mkdir("Sts_Pulser");
1593 gDirectory->cd("Sts_Pulser");
1594
1595 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
1596 fhPulserTimeDiffPerAsic[uXyterIdx]->Write();
1597 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
1598 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]->Write();
1599 fhPulserTimeDiffClkPerAsicPair[uXyterIdx][uXyterIdxB]->Write();
1600 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]->Write();
1601 fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Write();
1602 fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Write();
1603 fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Write();
1604 fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Write();
1605 fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Write();
1606 fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Write();
1607 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
1608 fhPulserIntervalAsic[uXyterIdx]->Write();
1609 fhPulserIntervalLongAsic[uXyterIdx]->Write();
1610 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1611
1612 gDirectory->cd("..");
1613 /***************************/
1614
1615 /***************************/
1616 // Flib Histos
1617 gDirectory->mkdir("Flib_Raw");
1618 gDirectory->cd("Flib_Raw");
1619 for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks++) {
1620 TString sMsSzName = Form("MsSz_link_%02u", uLinks);
1621 if (fHM->Exists(sMsSzName.Data())) fHM->H1(sMsSzName.Data())->Write();
1622
1623 sMsSzName = Form("MsSzTime_link_%02u", uLinks);
1624 if (fHM->Exists(sMsSzName.Data())) fHM->P1(sMsSzName.Data())->Write();
1625 } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++)
1626
1627 TH1* pMissedTsH1 = dynamic_cast<TH1*>(gROOT->FindObjectAny("Missed_TS"));
1628 if (NULL != pMissedTsH1) pMissedTsH1->Write();
1629
1630 TProfile* pMissedTsEvoP = dynamic_cast<TProfile*>(gROOT->FindObjectAny("Missed_TS_Evo"));
1631 if (NULL != pMissedTsEvoP) pMissedTsEvoP->Write();
1632
1633 gDirectory->cd("..");
1634 /***************************/
1635
1636 if ("" != sFileName) {
1637 // Restore original directory position
1638 histoFile->Close();
1639 } // if( "" != sFileName )
1640
1642 gFile = oldFile;
1643 gDirectory = oldDir;
1644}
1646{
1648 TFile* oldFile = gFile;
1649 TDirectory* oldDir = gDirectory;
1650
1651 TFile* histoFile = NULL;
1652 if ("" != sFileName) {
1653 // open separate histo file in recreate mode
1654 histoFile = new TFile(sFileName, "RECREATE");
1655 histoFile->cd();
1656 } // if( "" != sFileName )
1657
1658 /***************************/
1659 gDirectory->mkdir("Sts_Pulser");
1660 gDirectory->cd("Sts_Pulser");
1661
1662 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
1663 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
1664 fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Write();
1665 fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Write();
1666 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
1667 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1668
1669 gDirectory->cd("..");
1670 /***************************/
1671
1672 if ("" != sFileName) {
1673 // Restore original directory position
1674 histoFile->Close();
1675 } // if( "" != sFileName )
1676
1678 gFile = oldFile;
1679 gDirectory = oldDir;
1680}
1682{
1683 LOG(info) << "Reseting all STS histograms.";
1684
1685 fhPulserMessType->Reset();
1686 fhPulserSysMessType->Reset();
1687 fhPulserMessTypePerDpb->Reset();
1689 fhPulserMessTypePerElink->Reset();
1691 fhPulserStatusMessType->Reset();
1693
1694 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
1695 fhPulserChanCntRaw[uXyterIdx]->Reset();
1696 fhPulserChanAdcRaw[uXyterIdx]->Reset();
1697 fhPulserChanAdcRawProf[uXyterIdx]->Reset();
1698 fhPulserChanRawTs[uXyterIdx]->Reset();
1699 fhPulserChanMissEvt[uXyterIdx]->Reset();
1700 fhPulserChanMissEvtEvo[uXyterIdx]->Reset();
1701 fhPulserFebMissEvtEvo[uXyterIdx]->Reset();
1702 fhPulserChanHitRateEvo[uXyterIdx]->Reset();
1703 fhPulserFebRateEvo[uXyterIdx]->Reset();
1704 fhPulserChanHitRateEvoLong[uXyterIdx]->Reset();
1705 fhPulserFebRateEvoLong[uXyterIdx]->Reset();
1706 /*
1707 if( kTRUE == fbLongHistoEnable )
1708 {
1709 ftStartTimeUnix = std::chrono::steady_clock::now();
1710 fhFebRateEvoLong[ uXyterIdx ]->Reset();
1711 fhFebChRateEvoLong[ uXyterIdx ]->Reset();
1712 } // if( kTRUE == fbLongHistoEnable )
1713*/
1714
1715 fhPulserTimeDiffPerAsic[uXyterIdx]->Reset();
1716 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
1717 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1718 fhPulserTimeDiffClkPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1719 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1720 fhPulserTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Reset();
1721 fhPulserRawTimeDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Reset();
1722 fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1723 fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1724 fhPulserTsLsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Reset();
1725 fhPulserTsMsbDiffEvoPerAsicPairProf[uXyterIdx][uXyterIdxB]->Reset();
1726 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
1727 fhPulserIntervalAsic[uXyterIdx]->Reset();
1728 fhPulserIntervalLongAsic[uXyterIdx]->Reset();
1729 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1730
1731 for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks) {
1732 TString sMsSzName = Form("MsSz_link_%02u", uLinks);
1733 if (fHM->Exists(sMsSzName.Data())) fHM->H1(sMsSzName.Data())->Reset();
1734
1735 sMsSzName = Form("MsSzTime_link_%02u", uLinks);
1736 if (fHM->Exists(sMsSzName.Data())) fHM->P1(sMsSzName.Data())->Reset();
1737 } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks )
1738
1739 fdStartTime = -1;
1740 fdStartTimeMsSz = -1;
1741}
1742
1743void CbmMcbm2018MonitorStsSync::UpdatePairMeanValue(UInt_t uAsicA, UInt_t uAsicB, Double_t dNewValue)
1744{
1745 if (fvuLastTimeDiffSlotAsicPair.size() < uAsicA) {
1746 LOG(warning) << "CbmMcbm2018MonitorStsSync::UpdatePairMeanValue => wrong "
1747 "ASIC A value: "
1748 << uAsicA << " VS " << fvuLastTimeDiffSlotAsicPair.size();
1749 return;
1750 } // if( fvuLastTimeDiffSlotAsicPair.size() < uAsicA )
1751 if (fvuLastTimeDiffSlotAsicPair[uAsicA].size() < uAsicB) {
1752 LOG(warning) << "CbmMcbm2018MonitorStsSync::UpdatePairMeanValue => wrong "
1753 "ASIC B value: "
1754 << uAsicB << " VS " << fvuLastTimeDiffSlotAsicPair[uAsicA].size();
1755 return;
1756 } // if( fvuLastTimeDiffSlotAsicPair[ uAsicA ].size() < uAsicB )
1757
1759 fvdLastTimeDiffValuesAsicPair[uAsicA][uAsicB][fvuLastTimeDiffSlotAsicPair[uAsicA][uAsicB]] = dNewValue;
1760 fvuLastTimeDiffSlotAsicPair[uAsicA][uAsicB] =
1762 } // if( kuNbValuesForTimeDiffMean == fvdLastTimeDiffValuesAsicPair[ uAsicA ][ uAsicB ].size() )
1763 else
1764 fvdLastTimeDiffValuesAsicPair[uAsicA][uAsicB].push_back(dNewValue);
1765
1766 Double_t dNewMean = 0.0;
1767 UInt_t uNbVal = fvdLastTimeDiffValuesAsicPair[uAsicA][uAsicB].size();
1768 for (UInt_t uIdx = 0; uIdx < uNbVal; ++uIdx)
1769 dNewMean += fvdLastTimeDiffValuesAsicPair[uAsicA][uAsicB][uIdx];
1770 dNewMean /= uNbVal;
1771
1772 fvdMeanTimeDiffAsicPair[uAsicA][uAsicB] = dNewMean;
1773}
1774
1775void CbmMcbm2018MonitorStsSync::SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize)
1776{
1777 TDatime* fRunStartDateTime = new TDatime(dateIn, timeIn);
1778 fiRunStartDateTimeSec = fRunStartDateTime->Convert();
1779 fiBinSizeDatePlots = iBinSize;
1780
1781 LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString();
1782}
1783
1784void CbmMcbm2018MonitorStsSync::SetLongDurationLimits(UInt_t uDurationSeconds, UInt_t uBinSize)
1785{
1786 fbLongHistoEnable = kTRUE;
1787 fuLongHistoNbSeconds = uDurationSeconds;
1788 fuLongHistoBinSizeSec = uBinSize;
1789}
1790
ClassImp(CbmConverterManager)
Histogram manager.
Bool_t bMcbm2018WriteStsSync
Bool_t bMcbm2018ResetStsSync
static constexpr size_t size()
Definition KfSimdPseudo.h:2
Histogram manager.
TProfile * P1(const std::string &name) const
Return pointer to TProfile.
Bool_t Exists(const std::string &name) const
Check existence of object in manager.
void Add(const std::string &name, TNamed *object)
Add new named object to manager.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
std::vector< std::vector< Double_t > > fvdChanLastHitTime
Last hit time in bins for each Channel.
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
virtual void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
stsxyter::MessagePrintMask fPrintMessCtrl
std::vector< std::vector< Double_t > > fvdMeanTimeDiffAsicPair
std::vector< std::vector< TH2 * > > fhPulserTimeDiffEvoPerAsicPair
static const UInt_t kuNbValuesForTimeDiffMean
std::vector< std::vector< TH2 * > > fhPulserTsLsbMatchPerAsicPair
std::vector< UInt_t > fvuCurrentTsMsbCycle
Current TS MSB for each DPB.
std::vector< std::vector< ULong64_t > > fvulChanLastHitTime
TS from last hit for DPB.
std::vector< TH1 * > fhPulserFebRateEvoLong
std::vector< stsxyter::FinalHit > fvmHitsInMs
Int_t fiRunStartDateTimeSec
Index of the DPB from which the MS currently unpacked is coming.
std::vector< stsxyter::FinalHit > fvmLastHitAsic
Last hits in each ASIC.
void SavePulserHistos(TString sFileName="")
static const Int_t kiMaxNbFlibLinks
Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb].
UInt_t fuNbElinksPerDpb
Map of DPB Identifier to DPB index.
std::vector< TH1 * > fhPulserChanCntRawGood
std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs
Number of hits in each MS for each Channel.
Double_t fdStartTs
Pulser time difference histos.
std::vector< Double_t > fvdMsTime
Last hit time in ns for each Channel.
UInt_t fuMaxNbMicroslices
All hits (time in bins, ADC in bins, asic, channel) in last TS, per ASIC, sorted with "<" operator.
std::vector< std::vector< TH1 * > > fhPulserTimeDiffClkPerAsicPair
std::vector< TH2 * > fhPulserChanMissEvtEvo
UInt_t fuNbStsXyters
Number of possible eLinks per DPB.
std::vector< TH2 * > fhPulserChanHitRateEvoLong
std::map< UInt_t, UInt_t > fDpbIdIndexMap
Total number of Sts DPBs in system.
void SaveAllHistos(TString sFileName="")
CbmCern2017UnpackParHodo * fUnpackParHodo
/‍** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **‍/
UInt_t fuNbChanPerAsic
Number of StsXyter ASICs.
std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs
Header time of each MS.
void FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
std::vector< UInt_t > fvuInitialHeaderDone
Current TS MSB cycle for DPB.
void SetLongDurationLimits(UInt_t uDurationSeconds=3600, UInt_t uBinSize=1)
std::vector< TH1 * > fhPulserIntervalAsic
std::vector< std::vector< std::vector< Double_t > > > fvdLastTimeDiffValuesAsicPair
std::vector< std::vector< UInt_t > > fvuLastTimeDiffSlotAsicPair
void SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize=5)
std::vector< std::vector< TProfile * > > fhPulserTimeDiffEvoPerAsicPairProf
std::vector< UInt_t > fvuInitialTsMsbCycleHeader
Flag set after seeing MS header in 1st MS for DPB.
virtual void AddMsComponentToList(size_t component, UShort_t usDetectorId)
std::vector< std::vector< UInt_t > > fvuElinkToAsic
Number of channels per StsXyter ASIC => should be constant somewhere!!!!
std::vector< std::vector< TProfile * > > fhPulserRawTimeDiffEvoPerAsicPairProf
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
std::vector< std::vector< TProfile * > > fhPulserTsMsbDiffEvoPerAsicPairProf
std::vector< std::vector< TH2 * > > fhPulserTsMsbMatchPerAsicPair
std::vector< UInt_t > fvuElinkLastTsHit
TS MSB cycle from MS header in 1st MS for DPB.
std::vector< std::vector< TProfile * > > fhPulserTsLsbDiffEvoPerAsicPairProf
Double_t fdStartTime
Last hit ADC in bins in each MS for each Channel.
void FillHitInfo(stsxyter::Message mess, const UShort_t &usElinkIdx, const UInt_t &uAsicIdx, const UInt_t &uMsIdx)
Int_t fiBinSizeDatePlots
Start of run time since "epoch" in s, for the plots with date as X axis.
std::vector< size_t > fvMsComponentsList
TProfile * fhMsSzTime[kiMaxNbFlibLinks]
std::vector< TH1 * > fhPulserIntervalLongAsic
std::vector< std::vector< TH1 * > > fhPulserTimeDiffPerAsicPair
static constexpr const double kdPulserPeriod
std::vector< ULong64_t > fvulCurrentTsMsb
Bin size in s for the plots with date as X axis.
std::vector< TProfile * > fhPulserChanAdcRawProf
std::vector< std::vector< stsxyter::FinalHit > > fvmAsicHitsInMs
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
std::vector< TH2 * > fhPulserChanHitRateEvo
TH1 * fhPulserMessType
Histogram manager.
std::vector< TH2 * > fhPulserTimeDiffPerAsic
Last hits in each ASIC.
void SetCoincidenceBorder(Double_t dCenterPos, Double_t dBorderVal)
void FillEpochInfo(stsxyter::Message mess)
std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs
Last hit time in bins in each MS for each Channel.
void UpdatePairMeanValue(UInt_t uAsicA, UInt_t uAsicB, Double_t dNewValue)
std::vector< TH1 * > fhPulserFebMissEvtEvo
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
Data class with information on a STS local track.
XPU_D bool IsHitMissedEvts() const
For Hit data: Returns Missed event flag (1 bit field)
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 uint16_t GetStatusStatus() const
For Status data: Returns the Status field from ACK frame (4 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)
XPU_D uint16_t GetStatusLink() const
For Status data: Returns the Link Inedx (9 bit field)
Hash for CbmL1LinkKey.
static constexpr uint64_t kulTsCycleNbBins
static constexpr uint32_t kuHitNbTsBins
static constexpr uint32_t kuHitNbAdcBins
Status/properties constants.
static constexpr double kdClockCycleNs
MessType
Message types.