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