CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MonitorStsPulser.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// ----- CbmCosy2018MonitorPulser -----
8// ----- Created 11/05/18 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
12#include "CbmCosy2018MonitorPulser.h"
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 "THttpServer.h"
30#include "TMath.h"
31#include "TROOT.h"
32#include "TRandom.h"
33#include "TString.h"
34#include "TStyle.h"
35
36// C++11
37
38// C/C++
39#include <iomanip>
40#include <iostream>
41
42#include <stdint.h>
43
44Bool_t bCosy2018ResetPulser = kFALSE;
45Bool_t bCosy2018WritePulser = kFALSE;
46
48 : CbmTSUnpack()
49 , fuOverlapMsNb(0)
50 , fUnpackParHodo(NULL)
51 , fuNrOfDpbs(0)
52 , fDpbIdIndexMap()
53 , fuNbElinksPerDpb(0)
54 , fuNbStsXyters(0)
55 , fuNbChanPerAsic(0)
56 , fvuElinkToAsic()
57 , fsHistoFileFullname("data/SetupHistos.root")
58 , fbPrintMessages(kFALSE)
59 , fPrintMessCtrl(stsxyter::MessagePrintMask::msg_print_Human)
60 , fulCurrentTsIdx(0)
61 , fulCurrentMsIdx(0)
62 , fmMsgCounter()
63 , fuCurrentEquipmentId(0)
64 , fuCurrDpbId(0)
65 , fuCurrDpbIdx(0)
66 , fiRunStartDateTimeSec(-1)
67 , fiBinSizeDatePlots(-1)
68 , fvulCurrentTsMsb()
69 , fvuCurrentTsMsbCycle()
70 , fvuElinkLastTsHit()
71 , fvulChanLastHitTime()
72 , fvdChanLastHitTime()
73 , fvdMsTime()
74 , fvuChanNbHitsInMs()
75 , fvdChanLastHitTimeInMs()
76 , fvusChanLastHitAdcInMs()
77 ,
78 // fvmChanHitsInTs(),
79 fdStartTime(-1.0)
80 , fdStartTimeMsSz(-1.0)
81 , ftStartTimeUnix(std::chrono::steady_clock::now())
82 , fvmHitsInTs()
83 , fvmAsicHitsInTs()
84 , fuMaxNbMicroslices(100)
85 , fbLongHistoEnable(kFALSE)
86 , fuLongHistoNbSeconds(0)
87 , fuLongHistoBinSizeSec(0)
88 , fuLongHistoBinNb(0)
89 , fdCoincCenter(0.0)
90 , fdCoincBorder(50.0)
91 , fdCoincMin(fdCoincCenter - fdCoincBorder)
92 , fdCoincMax(fdCoincCenter + fdCoincBorder)
93 , fHM(new CbmHistManager())
94 , fhPulserMessType(NULL)
95 , fhPulserSysMessType(NULL)
96 , fhPulserMessTypePerDpb(NULL)
97 , fhPulserSysMessTypePerDpb(NULL)
98 , fhPulserMessTypePerElink(NULL)
99 , fhPulserSysMessTypePerElink(NULL)
100 , fhPulserChanCntRaw()
101 , fhPulserChanCntRawGood()
102 , fhPulserChanAdcRaw()
103 , fhPulserChanAdcRawProf()
104 , fhPulserChanRawTs()
105 , fhPulserChanMissEvt()
106 , fhPulserChanMissEvtEvo()
107 , fhPulserChanHitRateEvo()
108 , fhPulserFebRateEvo()
109 , fhPulserFebMissEvtEvo()
110 , fhPulserChanHitRateEvoLong()
111 , fhPulserFebRateEvoLong()
112 , fcMsSizeAll(NULL)
113 , fdStartTs(0.0)
114 , fvmLastHitAsic()
115 , fhPulserTimeDiffPerAsic()
116 , fhPulserTimeDiffPerAsicPair()
117 , fhPulserTimeDiffEvoPerAsicPair()
118 , fhPulserTsLsbMatchPerAsicPair()
119 , fhPulserTsMsbMatchPerAsicPair()
120 , fhPulserIntervalAsic()
121 , fhPulserIntervalLongAsic()
122{
123}
124
126
128{
129 LOG(info) << "Initializing flib StsXyter unpacker for STS";
130
131 FairRootManager* ioman = FairRootManager::Instance();
132 if (ioman == NULL) { LOG(fatal) << "No FairRootManager instance"; }
133
134 return kTRUE;
135}
136
138{
139 LOG(info) << "Setting parameter containers for " << GetName();
141 (CbmCern2017UnpackParHodo*) (FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo"));
142}
143
144
146{
147 LOG(info) << "Init parameter containers for " << GetName();
148
149 Bool_t bReInit = ReInitContainers();
151
152 return bReInit;
153}
154
156{
157 LOG(info) << "ReInit parameter containers for " << GetName();
158
159 fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs();
160 fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb();
161 fuNbStsXyters = fUnpackParHodo->GetNbStsXyters();
162 fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic();
163
164
165 LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs;
166
167 fDpbIdIndexMap.clear();
169 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
170 fDpbIdIndexMap[fUnpackParHodo->GetDpbId(uDpb)] = uDpb;
171 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " << std::setw(4) << std::hex
172 << fUnpackParHodo->GetDpbId(uDpb) << std::dec << " => " << fDpbIdIndexMap[fUnpackParHodo->GetDpbId(uDpb)];
173
174 fvuElinkToAsic[uDpb].resize(fuNbElinksPerDpb);
175 for (UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink)
176 fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx(uDpb * fuNbElinksPerDpb + uElink);
177 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
178
179 LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb;
180 LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters;
181 LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic;
182
183 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
184 LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": ";
185
186 std::stringstream ss;
187 for (UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink) {
188 if (0 == uElink % 10) ss << "\n------> ";
189
190 ss << std::setw(5) << fvuElinkToAsic[uDpb][uElink] << " ";
191 } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink )
192 LOG(info) << ss.str();
193 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
194
195 // Internal status initialization
199 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
200 fvulCurrentTsMsb[uDpb] = 0;
201 fvuCurrentTsMsbCycle[uDpb] = 0;
202 /*
203 fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb );
204 for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink )
205 {
206 fvuElinkLastTsHit[uDpb][uElink] = 0;
207 } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink )
208*/
209 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
210
223 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
224 fvulChanLastHitTime[uXyterIdx].resize(fuNbChanPerAsic);
225 fvdChanLastHitTime[uXyterIdx].resize(fuNbChanPerAsic);
226 fvuChanNbHitsInMs[uXyterIdx].resize(fuNbChanPerAsic);
227 fvdChanLastHitTimeInMs[uXyterIdx].resize(fuNbChanPerAsic);
228 fvusChanLastHitAdcInMs[uXyterIdx].resize(fuNbChanPerAsic);
229 fvmAsicHitsInTs[uXyterIdx].clear();
230 fhPulserTimeDiffPerAsicPair[uXyterIdx].clear();
231 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx].clear();
232 fhPulserTsLsbMatchPerAsicPair[uXyterIdx].clear();
233 fhPulserTsMsbMatchPerAsicPair[uXyterIdx].clear();
234 for (UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan) {
235 fvulChanLastHitTime[uXyterIdx][uChan] = 0;
236 fvdChanLastHitTime[uXyterIdx][uChan] = -1.0;
237
238 fvuChanNbHitsInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
239 fvdChanLastHitTimeInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
240 fvusChanLastHitAdcInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
241 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
242 fvuChanNbHitsInMs[uXyterIdx][uChan][uMsIdx] = 0;
243 fvdChanLastHitTimeInMs[uXyterIdx][uChan][uMsIdx] = -1.0;
244 fvusChanLastHitAdcInMs[uXyterIdx][uChan][uMsIdx] = 0;
245 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
246 } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan )
247 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
248 LOG(info) << "CbmCosy2018MonitorPulser::ReInitContainers => Changed "
249 "fvuChanNbHitsInMs size "
250 << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters;
251 LOG(info) << "CbmCosy2018MonitorPulser::ReInitContainers => Changed "
252 "fvuChanNbHitsInMs size "
253 << fvuChanNbHitsInMs[0].size() << " VS " << fuNbChanPerAsic;
254 LOG(info) << "CbmCosy2018MonitorPulser::ReInitContainers => Changed "
255 "fvuChanNbHitsInMs size "
256 << fvuChanNbHitsInMs[0][0].size() << " VS " << fuMaxNbMicroslices;
257
258 return kTRUE;
259}
260
261void CbmCosy2018MonitorPulser::SetCoincidenceBorder(Double_t dCenterPos, Double_t dBorderVal)
262{
263 fdCoincCenter = dCenterPos;
264 fdCoincBorder = dBorderVal;
265 fdCoincMin = dCenterPos - dBorderVal;
266 fdCoincMax = dCenterPos + dBorderVal;
267}
268
270{
271 TString sHistName {""};
272 TString title {""};
273
274 sHistName = "hPulserMessageType";
275 title = "Nb of message for each type; Type";
276 fhPulserMessType = new TH1I(sHistName, title, 5, 0., 5.);
277 fhPulserMessType->GetXaxis()->SetBinLabel(1, "Dummy");
278 fhPulserMessType->GetXaxis()->SetBinLabel(2, "Hit");
279 fhPulserMessType->GetXaxis()->SetBinLabel(3, "TsMsb");
280 fhPulserMessType->GetXaxis()->SetBinLabel(4, "Epoch");
281 fhPulserMessType->GetXaxis()->SetBinLabel(5, "Empty");
282 /* *** Missing int + MessType OP!!!! ****
283 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy");
284 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit");
285 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb");
286 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck");
287 fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack");
288*/
289
290 sHistName = "hPulserSysMessType";
291 title = "Nb of system message for each type; System Type";
292 fhPulserSysMessType = new TH1I(sHistName, title, 17, 0., 17.);
293 /*
294 hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START");
295 hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH");
296 hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B");
297*/
298
299 sHistName = "hPulserMessageTypePerDpb";
300 title = "Nb of message of each type for each DPB; DPB; Type";
301 fhPulserMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.);
302 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(1, "Dummy");
303 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(2, "Hit");
304 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(3, "TsMsb");
305 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(4, "Epoch");
306 fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel(5, "Empty");
307 /* *** Missing int + MessType OP!!!! ****
308 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy");
309 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit");
310 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb");
311 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck");
312 fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack");
313*/
314
315 sHistName = "hPulserSysMessTypePerDpb";
316 title = "Nb of system message of each type for each DPB; DPB; System Type";
317 fhPulserSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.);
318 /*
319 hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START");
320 hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH");
321 hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B");
322*/
323
324 sHistName = "hPulserMessageTypePerElink";
325 title = "Nb of message of each type for each eLink; eLink; Type";
327 new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.);
328 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1, "Dummy");
329 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(2, "Hit");
330 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(3, "TsMsb");
331 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(4, "ReadDataAck");
332 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(5, "Ack");
333 /* *** Missing int + MessType OP!!!! ****
334 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy");
335 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit");
336 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb");
337 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck");
338 fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack");
339*/
340
341 sHistName = "hPulserSysMessTypePerElink";
342 title = "Nb of system message of each type for each eLink; eLink; System Type";
344 new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.);
345 /*
346 fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START");
347 fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH");
348 fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B");
349*/
350
351 // Number of rate bins =
352 // 9 for the sub-unit decade
353 // + 9 for each unit of each decade * 10 for the subdecade range
354 // + 1 for the closing bin top edge
355 const Int_t iNbDecadesRate = 9;
356 const Int_t iNbStepsDecade = 9;
357 const Int_t iNbSubStepsInStep = 10;
358 const Int_t iNbBinsRate = iNbStepsDecade + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate + 1;
359 Double_t dBinsRate[iNbBinsRate];
360 // First fill sub-unit decade
361 for (Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU++)
362 dBinsRate[iSubU] = 0.1 * (1 + iSubU);
363 std::cout << std::endl;
364 // Then fill the main decades
365 Double_t dSubstepSize = 1.0 / iNbSubStepsInStep;
366 for (Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade++) {
367 Double_t dBase = std::pow(10, iDecade);
368 Int_t iDecadeIdx = iNbStepsDecade + iDecade * iNbStepsDecade * iNbSubStepsInStep;
369 for (Int_t iStep = 0; iStep < iNbStepsDecade; iStep++) {
370 Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep;
371 for (Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++) {
372 dBinsRate[iStepIdx + iSubStep] = dBase * (1 + iStep) + dBase * dSubstepSize * iSubStep;
373 } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
374 } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
375 } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++)
376 dBinsRate[iNbBinsRate - 1] = std::pow(10, iNbDecadesRate);
377
380 fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec;
381
382 UInt_t uNbBinEvo = (32768 + 1) * 2;
383 Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs * static_cast<Double_t>(uNbBinEvo) / 2.0;
384 Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0;
385
386 UInt_t uNbBinDt = static_cast<UInt_t>((fdCoincMax - fdCoincMin) / stsxyter::kdClockCycleNs);
387
388 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
389 // Channel counts
390 sHistName = Form("hPulserChanCntRaw_%03u", uXyterIdx);
391 title = Form("Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx);
392 fhPulserChanCntRaw.push_back(new TH1I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
393
394 sHistName = Form("hPulserChanCntRawGood_%03u", uXyterIdx);
395 title = Form("Hits Count per channel in good MS, StsXyter #%03u; Channel; Hits []", uXyterIdx);
396 fhPulserChanCntRawGood.push_back(new TH1I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
397
398 // Raw Adc Distribution
399 sHistName = Form("hPulserChanAdcRaw_%03u", uXyterIdx);
400 title = Form("Raw Adc distribution per channel, StsXyter #%03u; Channel "
401 "[]; Adc []; Hits []",
402 uXyterIdx);
403 fhPulserChanAdcRaw.push_back(new TH2I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5,
405
406 // Raw Adc Distribution profile
407 sHistName = Form("hPulserChanAdcRawProfc_%03u", uXyterIdx);
408 title = Form("Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx);
409 fhPulserChanAdcRawProf.push_back(new TProfile(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
410
411 // Raw Ts Distribution
412 sHistName = Form("hPulserChanRawTs_%03u", uXyterIdx);
413 title = Form("Raw Timestamp distribution per channel, StsXyter #%03u; "
414 "Channel []; Ts []; Hits []",
415 uXyterIdx);
416 fhPulserChanRawTs.push_back(new TH2I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5,
418
419 // Missed event flag
420 sHistName = Form("hPulserChanMissEvt_%03u", uXyterIdx);
421 title = Form("Missed Event flags per channel, StsXyter #%03u; Channel []; "
422 "Miss Evt []; Hits []",
423 uXyterIdx);
424 fhPulserChanMissEvt.push_back(
425 new TH2I(sHistName, title, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, 2, -0.5, 1.5));
426
427 // Missed event flag counts evolution
428
429 sHistName = Form("hPulserChanMissEvtEvo_%03u", uXyterIdx);
430 title = Form("Missed Evt flags per second & channel in StsXyter #%03u; "
431 "Time [s]; Channel []; Missed Evt flags []",
432 uXyterIdx);
433 fhPulserChanMissEvtEvo.push_back(
434 new TH2I(sHistName, title, 1800, 0, 1800, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
435
436 // Missed event flag counts evo per StsXyter
437
438 sHistName = Form("hPulserFebMissEvtEvo%03u", uXyterIdx);
439 title = Form("Missed Evt flags per second in StsXyter #%03u; Time [s]; "
440 "Missed Evt flags []",
441 uXyterIdx);
442 fhPulserFebMissEvtEvo.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
443
444 // Hit rates evo per channel
445 sHistName = Form("hPulserChanRateEvo_%03u", uXyterIdx);
446 title = Form("Hits per second & channel in StsXyter #%03u; Time [s]; "
447 "Channel []; Hits []",
448 uXyterIdx);
449 fhPulserChanHitRateEvo.push_back(
450 new TH2I(sHistName, title, 1800, 0, 1800, fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
451
452 // Hit rates evo per StsXyter
453 sHistName = Form("hPulserFebRateEvo_%03u", uXyterIdx);
454 title = Form("Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx);
455 fhPulserFebRateEvo.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
456
457 // Hit rates evo per channel, 1 minute bins, 24h
458 sHistName = Form("hPulserChanRateEvoLong_%03u", uXyterIdx);
459 title = Form("Hits per second & channel in StsXyter #%03u; Time [min]; "
460 "Channel []; Hits []",
461 uXyterIdx);
462 fhPulserChanHitRateEvoLong.push_back(new TH2D(sHistName, title, fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5,
463 fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5));
464
465 // Hit rates evo per StsXyter, 1 minute bins, 24h
466 sHistName = Form("hPulserFebRateEvoLong_%03u", uXyterIdx);
467 title = Form("Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx);
468 fhPulserFebRateEvoLong.push_back(new TH1D(sHistName, title, fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5));
469
471 sHistName = Form("fhPulserTimeDiffPerAsic_%03u", uXyterIdx);
472 title = Form("Time diff for pulser hits between ASIC %03u and other ASICs; "
473 "tn - t%03u [ns]; ASIC n; Counts",
474 uXyterIdx, uXyterIdx);
475 fhPulserTimeDiffPerAsic.push_back(
476 new TH2I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo, fuNbStsXyters, -0.5, fuNbStsXyters - 0.5));
477
478 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
479 if (uXyterIdxB == uXyterIdx) {
480 sHistName = Form("fhPulserTimeDiffSameAsic_%03u", uXyterIdx);
481 title = Form("Time diff for consecutive hits in ASIC %03u; tn - t [ns]; Counts", uXyterIdx);
482 } // if( uXyterIdxB == uXyterIdx )
483 else {
484 sHistName = Form("fhPulserTimeDiffPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
485 title = Form("Time diff for pulser hits in ASIC %03u and %03u; tn - t "
486 "[ns]; Counts",
487 uXyterIdx, uXyterIdxB);
488 } // else of if( uXyterIdxB == uXyterIdx )
489 fhPulserTimeDiffPerAsicPair[uXyterIdx].push_back(new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo));
490
491 if (uXyterIdxB == uXyterIdx) {
492 sHistName = Form("fhPulserTimeDiffEvoSameAsic_%03u", uXyterIdx);
493 title = Form("Time diff for consecutive hits in ASIC %03u; Time in run "
494 "[s]; tn - t [ns]; Counts",
495 uXyterIdx);
496 } // if( uXyterIdxB == uXyterIdx )
497 else {
498 sHistName = Form("fhPulserTimeDiffEvoPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
499 title = Form("Time diff for pulser hits in ASIC %03u and %03u; Time in "
500 "run [s]; tn - t [ns]; Counts",
501 uXyterIdx, uXyterIdxB);
502 } // else of if( uXyterIdxB == uXyterIdx )
503 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx].push_back(new TH2I(
504 sHistName, title, 3600, 0, 18000, 200, -100 * stsxyter::kdClockCycleNs, 100 * stsxyter::kdClockCycleNs));
505
506 sHistName = Form("fhPulserTsLsbMatchPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
507 title = Form("TS LSB for pulser hits in ASIC %03u and %03u; TS LSB %03u "
508 "[bin]; TS LSB %03u [bin]",
509 uXyterIdx, uXyterIdxB, uXyterIdx, uXyterIdxB);
510 fhPulserTsLsbMatchPerAsicPair[uXyterIdx].push_back(
511 new TH2I(sHistName, title, 256, -0.5, 255.5, 256, -0.5, 255.5));
512
513 sHistName = Form("fhPulserTsMsbMatchPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB);
514 title = Form("TS MSB for pulser hits in ASIC %03u and %03u; TS MSB %03u "
515 "[bin]; TS MSB %03u [bin]",
516 uXyterIdx, uXyterIdxB, uXyterIdx, uXyterIdxB);
517 fhPulserTsMsbMatchPerAsicPair[uXyterIdx].push_back(new TH2I(sHistName, title, 64, -0.5, 63.5, 64, -0.5, 63.5));
518 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
519
520 sHistName = Form("fhPulserIntervalAsic_%03u", uXyterIdx);
521 title = Form("Time diff between consecutive hits in ASIC %03us; dt [ns]; Counts", uXyterIdx, uXyterIdx);
522 fhPulserIntervalAsic.push_back(new TH1I(sHistName, title, 200, 0, 200 * stsxyter::kdClockCycleNs));
523
524 sHistName = Form("fhPulserIntervalLongAsic_%03u", uXyterIdx);
525 title = Form("Time diff between consecutive hits in ASIC %03us; dt [ns]; Counts", uXyterIdx, uXyterIdx);
526 fhPulserIntervalLongAsic.push_back(new TH1I(sHistName, title, 1e5, 0, 1e6 * stsxyter::kdClockCycleNs));
527
529 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
530
531
533
534 /*
535 // Distribution of the TS_MSB per StsXyter
536 sHistName = "hPulserFebTsMsb";
537 title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []";
538 fhPulserFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5,
539 fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 );
540 if( server ) server->Register("/StsRaw", fhPulserFebTsMsb );
541*/
542 // Miscroslice properties histos
543 for (Int_t component = 0; component < kiMaxNbFlibLinks; component++) {
544 fhMsSz[component] = NULL;
545 fhMsSzTime[component] = NULL;
546 } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ )
547
548 // Online histo browser commands
549 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
550 if (server) {
551 server->Register("/StsRaw", fhPulserMessType);
552 server->Register("/StsRaw", fhPulserSysMessType);
553 server->Register("/StsRaw", fhPulserMessTypePerDpb);
554 server->Register("/StsRaw", fhPulserSysMessTypePerDpb);
555 server->Register("/StsRaw", fhPulserMessTypePerElink);
556 server->Register("/StsRaw", fhPulserSysMessTypePerElink);
557 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
558 server->Register("/StsRaw", fhPulserChanCntRaw[uXyterIdx]);
559 server->Register("/StsRaw", fhPulserChanCntRawGood[uXyterIdx]);
560 server->Register("/StsRaw", fhPulserChanAdcRaw[uXyterIdx]);
561 server->Register("/StsRaw", fhPulserChanAdcRawProf[uXyterIdx]);
562 server->Register("/StsRaw", fhPulserChanRawTs[uXyterIdx]);
563 server->Register("/StsRaw", fhPulserChanMissEvt[uXyterIdx]);
564 server->Register("/StsRaw", fhPulserChanMissEvtEvo[uXyterIdx]);
565 server->Register("/StsRaw", fhPulserFebMissEvtEvo[uXyterIdx]);
566 server->Register("/StsRaw", fhPulserChanHitRateEvo[uXyterIdx]);
567 server->Register("/StsRaw", fhPulserFebRateEvo[uXyterIdx]);
568 server->Register("/StsRaw", fhPulserChanHitRateEvoLong[uXyterIdx]);
569 server->Register("/StsRaw", fhPulserFebRateEvoLong[uXyterIdx]);
570
571 server->Register("/DtAsic", fhPulserTimeDiffPerAsic[uXyterIdx]);
572 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
573 if (uXyterIdxB == uXyterIdx) {
574 server->Register("/DtChan", fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]);
575 server->Register("/DtChan", fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]);
576 } // if( uXyterIdxB == uXyterIdx )
577 else {
578 server->Register("/DtAsicPair", fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]);
579 server->Register("/DtAsicPair", fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]);
580 } // else of if( uXyterIdxB == uXyterIdx )
581 server->Register("/TsMatch", fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]);
582 server->Register("/TsMatch", fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]);
583 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
584 server->Register("/DtPulses", fhPulserIntervalAsic[uXyterIdx]);
585 server->Register("/DtPulses", fhPulserIntervalLongAsic[uXyterIdx]);
586
587 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
588
589 server->RegisterCommand("/Reset_All_Pulser", "bCosy2018ResetPulser=kTRUE");
590 server->RegisterCommand("/Write_All_Pulser", "bCosy2018WritePulser=kTRUE");
591
592 server->Restrict("/Reset_All_Pulser", "allow=admin");
593 server->Restrict("/Write_All_Pulser", "allow=admin");
594 } // if( server )
595
597 Double_t w = 10;
598 Double_t h = 10;
599
600 // Summary per StsXyter
601 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
602 TCanvas* cStsSumm =
603 new TCanvas(Form("cStsSum_%03u", uXyterIdx), Form("Summary plots for StsXyter %03u", uXyterIdx), w, h);
604 cStsSumm->Divide(2, 2);
605
606 cStsSumm->cd(1);
607 gPad->SetLogy();
608 fhPulserChanCntRaw[uXyterIdx]->Draw();
609
610 cStsSumm->cd(2);
611 gPad->SetLogz();
612 fhPulserChanAdcRaw[uXyterIdx]->Draw("colz");
613
614 cStsSumm->cd(3);
615 gPad->SetLogz();
616 fhPulserChanHitRateEvo[uXyterIdx]->Draw("colz");
617
618 cStsSumm->cd(4);
619 // gPad->SetLogy();
620 fhPulserChanAdcRawProf[uXyterIdx]->Draw();
621 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
622
623 //====================================================================//
624
625 //====================================================================//
626 TCanvas* cDtPerAsic = new TCanvas("cDtPerAsic", "Time Differences per ASIC", w, h);
627 cDtPerAsic->Divide(fuNbStsXyters / 2 + fuNbStsXyters % 2, 2);
628
629 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
630 cDtPerAsic->cd(1 + uXyterIdx);
631 gPad->SetGridx();
632 gPad->SetGridy();
633 gPad->SetLogz();
634 fhPulserTimeDiffPerAsic[uXyterIdx]->Draw(" colz");
635 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
636 //====================================================================//
637
638 //====================================================================//
639 TCanvas* cDtInAsic = new TCanvas("cDtInAsic", "Time Differences in ASIC", w, h);
640 cDtInAsic->Divide(fuNbStsXyters / 2 + fuNbStsXyters % 2, 2);
641
642 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
643 cDtInAsic->cd(1 + uXyterIdx);
644 gPad->SetGridx();
645 gPad->SetLogy();
646 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdx]->Draw("hist");
647 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
648 //====================================================================//
649
650 //====================================================================//
651 TCanvas* cDtAsicPairs = new TCanvas("cDtAsicPairs", "Time Differences in ASIC", w, h);
652 // cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 );
653 cDtAsicPairs->Divide(3);
654
655 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
656 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
657 cDtAsicPairs->cd(uXyterIdx + uXyterIdxB);
658 gPad->SetGridx();
659 gPad->SetLogy();
660 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("hist");
661 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
662 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
663 //====================================================================//
664
665 //====================================================================//
666 TCanvas* cTsLsbAsicPairs = new TCanvas("cTsLsbAsicPairs", "Time Differences in ASIC", w, h);
667 // cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 );
668 cTsLsbAsicPairs->Divide(3);
669
670 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
671 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
672 cTsLsbAsicPairs->cd(uXyterIdx + uXyterIdxB);
673 gPad->SetGridx();
674 gPad->SetGridy();
675 gPad->SetLogz();
676 fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("colz");
677 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
678 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
679 //====================================================================//
680
681 //====================================================================//
682 TCanvas* cTsMsbAsicPairs = new TCanvas("cTsMsbAsicPairs", "Time Differences in ASIC", w, h);
683 // cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 );
684 cTsMsbAsicPairs->Divide(3);
685
686 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx) {
687 for (UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
688 cTsMsbAsicPairs->cd(uXyterIdx + uXyterIdxB);
689 gPad->SetGridx();
690 gPad->SetGridy();
691 gPad->SetLogz();
692 fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Draw("colz");
693 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
694 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
695 //====================================================================//
696
697 //====================================================================//
699 // Try to recover canvas in case it was created already by another monitor
700 // If not existing, create it
701 fcMsSizeAll = dynamic_cast<TCanvas*>(gROOT->FindObject("cMsSizeAll"));
702 if (NULL == fcMsSizeAll) {
703 fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h);
704 fcMsSizeAll->Divide(4, 4);
705 LOG(info) << "Created MS size canvas in STS monitor";
706 } // if( NULL == fcMsSizeAll )
707 else
708 LOG(info) << "Recovered MS size canvas in STS monitor";
709 //====================================================================//
710
711 /*****************************/
712}
713
714Bool_t CbmCosy2018MonitorPulser::DoUnpack(const fles::Timeslice& ts, size_t component)
715{
716 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
717
720 bCosy2018ResetPulser = kFALSE;
721 } // if( bCosy2018ResetPulser )
724 bCosy2018WritePulser = kFALSE;
725 } // if( bCosy2018WritePulser )
726
727 LOG(debug) << "Timeslice contains " << ts.num_microslices(component) << "microslices.";
728
729 if (component < kiMaxNbFlibLinks)
730 if (NULL == fhMsSz[component]) {
731 TString sMsSzName = Form("MsSz_link_%02lu", component);
732 TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component);
733 fhMsSz[component] = new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.);
734 fHM->Add(sMsSzName.Data(), fhMsSz[component]);
735 if (server) server->Register("/FlibRaw", fhMsSz[component]);
736 sMsSzName = Form("MsSzTime_link_%02lu", component);
737 sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component);
738 fhMsSzTime[component] = new TProfile(sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300.);
739 fHM->Add(sMsSzName.Data(), fhMsSzTime[component]);
740 if (server) server->Register("/FlibRaw", fhMsSzTime[component]);
741 if (NULL != fcMsSizeAll) {
742 fcMsSizeAll->cd(1 + component);
743 gPad->SetLogy();
744 fhMsSzTime[component]->Draw("hist le0");
745 } // if( NULL != fcMsSizeAll )
746 LOG(info) << "Added MS size histo for component: " << component << " (DPB)";
747 } // if( NULL == fhMsSz[ component ] )
748
749 // Int_t messageType = -111;
750 // Loop over microslices
751 size_t numCompMsInTs = ts.num_microslices(component);
752 /*
753 if( fulCurrentTsIdx + 1 != ts.index() && 0 == component)
754 LOG(info) << "Missed TS from " << fulCurrentTsIdx
755 << " to " << ts.index();
756*/
757 fulCurrentTsIdx = ts.index();
758
759 if (fuMaxNbMicroslices < numCompMsInTs) {
760 fuMaxNbMicroslices = numCompMsInTs;
761
766 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
767 fvuChanNbHitsInMs[uXyterIdx].resize(fuNbChanPerAsic);
768 fvdChanLastHitTimeInMs[uXyterIdx].resize(fuNbChanPerAsic);
769 fvusChanLastHitAdcInMs[uXyterIdx].resize(fuNbChanPerAsic);
770 for (UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan) {
771 fvuChanNbHitsInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
772 fvdChanLastHitTimeInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
773 fvusChanLastHitAdcInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
774 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
775 fvuChanNbHitsInMs[uXyterIdx][uChan][uMsIdx] = 0;
776 fvdChanLastHitTimeInMs[uXyterIdx][uChan][uMsIdx] = -1.0;
777 fvusChanLastHitAdcInMs[uXyterIdx][uChan][uMsIdx] = 0;
778 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
779 } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan )
780 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
781 LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => Changed fvuChanNbHitsInMs size " << fvuChanNbHitsInMs.size()
782 << " VS " << fuNbStsXyters;
783 LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => Changed "
784 "fvuChanNbHitsInMs size "
785 << fvuChanNbHitsInMs[0].size() << " VS " << fuNbChanPerAsic;
786 LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => Changed "
787 "fvuChanNbHitsInMs size "
788 << fvuChanNbHitsInMs[0][0].size() << " VS " << fuMaxNbMicroslices;
789 } // if( fuMaxNbMicroslices < numCompMsInTs )
790
791 for (size_t m = 0; m < numCompMsInTs; ++m) {
792 // Ignore overlap ms if number defined by user
793 if (numCompMsInTs - fuOverlapMsNb <= m) continue;
794
795 auto msDescriptor = ts.descriptor(component, m);
796 fuCurrentEquipmentId = msDescriptor.eq_id;
797 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m));
798
799 uint32_t size = msDescriptor.size;
800 fulCurrentMsIdx = msDescriptor.idx;
801 Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
802 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
803 << " has size: " << size;
804
805 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
807
808 if (component < kiMaxNbFlibLinks) {
809 if (fdStartTimeMsSz < 0) fdStartTimeMsSz = dMsTime;
810 fhMsSz[component]->Fill(size);
811 fhMsSzTime[component]->Fill(dMsTime - fdStartTimeMsSz, size);
812 } // if( component < kiMaxNbFlibLinks )
813
814 // Store MS time for coincidence plots
815 fvdMsTime[m] = dMsTime;
816
817 // If not integer number of message in input buffer, print warning/error
818 if (0 != (size % kuBytesPerMessage))
819 LOG(error) << "The input microslice buffer does NOT "
820 << "contain only complete nDPB messages!";
821
822 // Compute the number of complete messages in the input microslice buffer
823 uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) / kuBytesPerMessage;
824
825 // Prepare variables for the loop on contents
826 const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>(msContent);
827
828 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
829 // Fill message
830 uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]);
831
832 stsxyter::Message mess(static_cast<uint32_t>(ulData & 0xFFFFFFFF));
833
834 // Print message if requested
835 if (fbPrintMessages) mess.PrintMess(std::cout, fPrintMessCtrl);
836
837 stsxyter::MessType typeMess = mess.GetMessType();
838 fmMsgCounter[typeMess]++;
839 fhPulserMessType->Fill(static_cast<uint16_t>(typeMess));
840 fhPulserMessTypePerDpb->Fill(fuCurrDpbIdx, static_cast<uint16_t>(typeMess));
841
842 switch (typeMess) {
844 // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific!
845 UShort_t usElinkIdx = mess.GetLinkIndex();
846 if (fuNbElinksPerDpb <= usElinkIdx) {
847 LOG(fatal) << "CbmCosy2018MonitorPulser::DoUnpack => "
848 << "eLink index out of bounds!" << usElinkIdx << " VS " << fuNbElinksPerDpb;
849 } // if( fuNbElinksPerDpb <= usElinkIdx )
850 fhPulserMessTypePerElink->Fill(fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, static_cast<uint16_t>(typeMess));
851
852 UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx];
853
854 FillHitInfo(mess, usElinkIdx, uAsicIdx, m);
855 break;
856 } // case stsxyter::MessType::Hit :
858 FillTsMsbInfo(mess, uIdx, m);
859 break;
860 } // case stsxyter::MessType::TsMsb :
862 // The first message in the TS is a special ones: EPOCH
863 FillEpochInfo(mess);
864
865 if (0 < uIdx)
866 LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => "
867 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
868 break;
869 } // case stsxyter::MessType::TsMsb :
871 // FillTsMsbInfo( mess );
872 break;
873 } // case stsxyter::MessType::Empty :
875 break;
876 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
877 default: {
878 LOG(fatal) << "CbmCosy2018MonitorPulser::DoUnpack => "
879 << "Unknown message type, should never happen, stopping here!";
880 }
881 } // switch( mess.GetMessType() )
882 } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx )
883 } // for( size_t m = 0; m < numCompMsInTs; ++m )
884
885 // End of TS, check if stuff to do with the hits inside each MS
886 // Usefull for low rate pulser tests
887 // Need to do it only when last DPB is processed, as they are done one by one
888 if (fuCurrDpbIdx == fuNrOfDpbs - 1) {
890 // Sort the buffer of hits
891 std::sort(fvmHitsInTs.begin(), fvmHitsInTs.end());
892
893 // Time differences plotting using the fully time sorted hits
894 if (0 < fvmHitsInTs.size()) {
895 ULong64_t ulLastHitTime = (*(fvmHitsInTs.rbegin())).GetTs();
896 std::vector<stsxyter::FinalHit>::iterator it;
897 std::vector<stsxyter::FinalHit>::iterator itB;
898
899 std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now();
900 Double_t dUnixTimeInRun = std::chrono::duration_cast<std::chrono::seconds>(tNow - ftStartTimeUnix).count();
901
902 for (it = fvmHitsInTs.begin(); it != fvmHitsInTs.end();
903 // it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns
904 ++it) {
905 UShort_t usAsicIdx = (*it).GetAsic();
906 UShort_t usChanIdx = (*it).GetChan();
907 ULong64_t ulHitTs = (*it).GetTs();
908 UShort_t usHitAdc = (*it).GetAdc();
909
910 Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime) * 1e-9;
911
912 fvmAsicHitsInTs[usAsicIdx].push_back((*it));
913 } // loop on time sorted hits and split per asic
914
915 // Remove all hits which were already used
916 fvmHitsInTs.erase(fvmHitsInTs.begin(), it);
917
918 for (UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++) {
919 for (it = fvmAsicHitsInTs[uAsic].begin(); it != fvmAsicHitsInTs[uAsic].end(); ++it) {
920 UShort_t usChanIdx = (*it).GetChan();
921 if (0.0 == fdStartTs) fdStartTs = (*it).GetTs() * stsxyter::kdClockCycleNs;
922 Double_t dTimeSinceStartSec = ((*it).GetTs() * stsxyter::kdClockCycleNs - fdStartTs) * 1e-9;
923
924 for (UInt_t uAsicB = uAsic; uAsicB < fuNbStsXyters; uAsicB++) {
925 for (itB = fvmAsicHitsInTs[uAsicB].begin(); itB != fvmAsicHitsInTs[uAsicB].end(); ++itB) {
926 UShort_t usChanIdxB = (*itB).GetChan();
927 Double_t dDt = (static_cast<Double_t>((*itB).GetTs()) - static_cast<Double_t>((*it).GetTs()))
929
930 fhPulserTimeDiffPerAsic[uAsic]->Fill(dDt, uAsicB);
931 fhPulserTimeDiffPerAsicPair[uAsic][uAsicB]->Fill(dDt);
932 fhPulserTimeDiffEvoPerAsicPair[uAsic][uAsicB]->Fill(dTimeSinceStartSec, dDt);
933
934 fhPulserTsLsbMatchPerAsicPair[uAsic][uAsicB]->Fill((*it).GetTs() & 0x000FF, (*itB).GetTs() & 0x000FF);
935 fhPulserTsMsbMatchPerAsicPair[uAsic][uAsicB]->Fill(((*it).GetTs() & 0x03F00) >> 8,
936 ((*itB).GetTs() & 0x03F00) >> 8);
937 } // for( it = fvmAsicHitsInTs[ uAsicB ].begin(); it != fvmAsicHitsInTs[ uAsicB ].end(); ++it )
938 } // for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++)
939
940 Double_t dDtPulse =
941 (static_cast<Double_t>((*it).GetTs()) - static_cast<Double_t>(fvmLastHitAsic[uAsic].GetTs()))
943 fhPulserIntervalAsic[uAsic]->Fill(dDtPulse);
944 fhPulserIntervalLongAsic[uAsic]->Fill(dDtPulse);
945 fvmLastHitAsic[uAsic] = (*it);
946 } // for( it = fvmAsicHitsInTs[ uAsic ].begin(); it != fvmAsicHitsInTs[ uAsic ].end(); ++it )
947
949 fvmAsicHitsInTs[uAsic].clear();
950 } // for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++)
951 } // if( 0 < fvmHitsInTs.size() )
952
953 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
954 fvdMsTime[uMsIdx] = 0.0;
955 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
956 } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 )
957
958 if (0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1) {
959 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
960 Double_t dTsMsbTime =
961 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
962 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins)
963 * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
964 dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9;
965
966 LOG(info) << "End of TS " << std::setw(7) << ts.index() << " eDPB " << std::setw(2) << uDpb
967 << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb]
968 << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb]
969 << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s";
970 }
971 } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 )
972
973 return kTRUE;
974}
975
976void CbmCosy2018MonitorPulser::FillHitInfo(stsxyter::Message mess, const UShort_t& usElinkIdx, const UInt_t& uAsicIdx,
977 const UInt_t& uMsIdx)
978{
979 UShort_t usChan = mess.GetHitChannel();
980 UShort_t usRawAdc = mess.GetHitAdc();
981 // UShort_t usFullTs = mess.GetHitTimeFull();
982 UShort_t usTsOver = mess.GetHitTimeOver();
983 UShort_t usRawTs = mess.GetHitTime();
984
985 fhPulserChanCntRaw[uAsicIdx]->Fill(usChan);
986 fhPulserChanAdcRaw[uAsicIdx]->Fill(usChan, usRawAdc);
987 fhPulserChanAdcRawProf[uAsicIdx]->Fill(usChan, usRawAdc);
988 fhPulserChanRawTs[uAsicIdx]->Fill(usChan, usRawTs);
989 fhPulserChanMissEvt[uAsicIdx]->Fill(usChan, mess.IsHitMissedEvts());
990
991 // Compute the Full time stamp
992 Long64_t ulOldHitTime = fvulChanLastHitTime[uAsicIdx][usChan];
993 Double_t dOldHitTime = fvdChanLastHitTime[uAsicIdx][usChan];
994
995 // Use TS w/o overlap bits as they will anyway come from the TS_MSB
996 fvulChanLastHitTime[uAsicIdx][usChan] = usRawTs;
997
998 fvulChanLastHitTime[uAsicIdx][usChan] +=
999 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
1000 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
1001
1002 // fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs;
1003
1004 // Convert the Hit time in bins to Hit time in ns
1005 Double_t dHitTimeNs = fvulChanLastHitTime[uAsicIdx][usChan] * stsxyter::kdClockCycleNs;
1006 /*
1007 // If needed fill the hit interval plots
1008 if( fbChanHitDtEna )
1009 {
1010 Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ];
1011 if( 0 == dDeltaT )
1012 fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan );
1013 else if( 0 < dDeltaT )
1014 fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan );
1015 else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan );
1016 } // if( fbChanHitDtEna )
1017*/
1018 // Store new value of Hit time in ns
1019 fvdChanLastHitTime[uAsicIdx][usChan] = fvulChanLastHitTime[uAsicIdx][usChan] * stsxyter::kdClockCycleNs;
1020 /*
1021 LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx
1022 << " Channel " << std::setw( 3 ) << usChan
1023 << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime)
1024 << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9;
1025*/
1026 // Pulser and MS
1027 fvuChanNbHitsInMs[uAsicIdx][usChan][uMsIdx]++;
1028 fvdChanLastHitTimeInMs[uAsicIdx][usChan][uMsIdx] = dHitTimeNs;
1029 fvusChanLastHitAdcInMs[uAsicIdx][usChan][uMsIdx] = usRawAdc;
1030 /*
1031 fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ],
1032 usRawAdc, uAsicIdx, usChan ) );
1033*/
1034 fvmHitsInTs.push_back(stsxyter::FinalHit(fvulChanLastHitTime[uAsicIdx][usChan], usRawAdc, uAsicIdx, usChan));
1035
1036 /*
1037 LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx
1038 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1039 << " MsInTs " << std::setw( 3 ) << uMsIdx
1040 << " Asic " << std::setw( 2 ) << uAsicIdx
1041 << " Channel " << std::setw( 3 ) << usChan
1042 << " ADC " << std::setw( 3 ) << usRawAdc
1043 << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS
1044 << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB
1045 << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB
1046 << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
1047 << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]
1048 << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ];
1049*/
1050 // Check Starting point of histos with time as X axis
1051 if (-1 == fdStartTime) fdStartTime = fvdChanLastHitTime[uAsicIdx][usChan];
1052
1053 // Fill histos with time as X axis
1054 Double_t dTimeSinceStartSec = (fvdChanLastHitTime[uAsicIdx][usChan] - fdStartTime) * 1e-9;
1055 Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0;
1056 fhPulserChanHitRateEvo[uAsicIdx]->Fill(dTimeSinceStartSec, usChan);
1057 fhPulserFebRateEvo[uAsicIdx]->Fill(dTimeSinceStartSec);
1058 fhPulserChanHitRateEvoLong[uAsicIdx]->Fill(dTimeSinceStartMin, usChan, 1.0 / 60.0);
1059 fhPulserFebRateEvoLong[uAsicIdx]->Fill(dTimeSinceStartMin, 1.0 / 60.0);
1060 if (mess.IsHitMissedEvts()) {
1061 fhPulserChanMissEvtEvo[uAsicIdx]->Fill(dTimeSinceStartSec, usChan);
1062 fhPulserFebMissEvtEvo[uAsicIdx]->Fill(dTimeSinceStartSec);
1063 } // if( mess.IsHitMissedEvts() )
1064 /*
1065 if( kTRUE == fbLongHistoEnable )
1066 {
1067 std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now();
1068 Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count();
1069 fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec );
1070 fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec );
1071 } // if( kTRUE == fbLongHistoEnable )
1072*/
1073}
1074
1075void CbmCosy2018MonitorPulser::FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx, UInt_t uMsIdx)
1076{
1077 UInt_t uVal = mess.GetTsMsbVal();
1078 /*
1079 if( 0 == fuCurrDpbIdx )
1080 LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx
1081 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1082 << " MsInTs " << std::setw( 3 ) << uMsIdx
1083 << " DPB " << std::setw( 2 ) << fuCurrDpbIdx
1084 << " Mess " << std::setw( 5 ) << uMessIdx
1085 << " TsMsb " << std::setw( 5 ) << uVal;
1086*/
1087 /*
1088 if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal &&
1089 !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS!
1090 {
1091 LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx
1092 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1093 << " MsInTs " << std::setw( 3 ) << uMsIdx
1094 << " DPB " << std::setw( 2 ) << fuCurrDpbIdx
1095 << " Mess " << std::setw( 5 ) << uMessIdx
1096 << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
1097 << " new TsMsb " << std::setw( 5 ) << uVal
1098 << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx]
1099 << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx];
1100 } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal )
1101*/
1102
1103 // Update Status counters
1104 if (uVal < fvulCurrentTsMsb[fuCurrDpbIdx]) {
1105
1106 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " DPB "
1107 << std::setw(2) << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx]
1108 << " Old MsbCy " << std::setw(5) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " new TsMsb " << std::setw(5)
1109 << uVal;
1110
1112 } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
1114 /*
1115 if( 1 < uMessIdx )
1116 {
1117 fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] );
1118 fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) );
1119 fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) );
1120 } // if( 0 < uMessIdx )
1121*/
1122 // fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
1123
1124 ULong64_t ulNewTsMsbTime =
1125 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
1126 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
1127}
1128
1130{
1131 UInt_t uVal = mess.GetTsMsbVal();
1132 /*
1133 // Update Status counters
1134 if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
1135 fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++;
1136 fvulCurrentTsMsb[fuCurrDpbIdx] = usVal;
1137
1138// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
1139*/
1140}
1141
1143
1145{
1146
1147 LOG(info) << "-------------------------------------";
1148 LOG(info) << "CbmCosy2018MonitorPulser statistics are ";
1149 LOG(info) << " Hit messages: " << fmMsgCounter[stsxyter::MessType::Hit] << "\n"
1150 << " Ts MSB messages: " << fmMsgCounter[stsxyter::MessType::TsMsb] << "\n"
1151 << " Dummy messages: " << fmMsgCounter[stsxyter::MessType::Dummy] << "\n"
1152 << " Epoch messages: " << fmMsgCounter[stsxyter::MessType::Epoch] << "\n"
1153 << " Empty messages: " << fmMsgCounter[stsxyter::MessType::Empty];
1154
1155 LOG(info) << "-------------------------------------";
1156
1158 SaveAllHistos();
1159}
1160
1161
1163{
1165 TFile* oldFile = gFile;
1166 TDirectory* oldDir = gDirectory;
1167
1168 TFile* histoFile = NULL;
1169 if ("" != sFileName) {
1170 // open separate histo file in recreate mode
1171 histoFile = new TFile(sFileName, "RECREATE");
1172 histoFile->cd();
1173 } // if( "" != sFileName )
1174
1175 /***************************/
1176 gDirectory->mkdir("Sts_Raw");
1177 gDirectory->cd("Sts_Raw");
1178
1179 fhPulserMessType->Write();
1180 fhPulserSysMessType->Write();
1181 fhPulserMessTypePerDpb->Write();
1183 fhPulserMessTypePerElink->Write();
1185
1186 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
1187 fhPulserChanCntRaw[uXyterIdx]->Write();
1188 fhPulserChanAdcRaw[uXyterIdx]->Write();
1189 fhPulserChanAdcRawProf[uXyterIdx]->Write();
1190 fhPulserChanRawTs[uXyterIdx]->Write();
1191 fhPulserChanMissEvt[uXyterIdx]->Write();
1192 fhPulserChanMissEvtEvo[uXyterIdx]->Write();
1193 fhPulserFebMissEvtEvo[uXyterIdx]->Write();
1194 fhPulserChanHitRateEvo[uXyterIdx]->Write();
1195 fhPulserFebRateEvo[uXyterIdx]->Write();
1196 fhPulserChanHitRateEvoLong[uXyterIdx]->Write();
1197 fhPulserFebRateEvoLong[uXyterIdx]->Write();
1198 /*
1199 if( kTRUE == fbLongHistoEnable )
1200 {
1201 fhFebRateEvoLong[ uXyterIdx ]->Write();
1202 fhFebChRateEvoLong[ uXyterIdx ]->Write();
1203 } // if( kTRUE == fbLongHistoEnable )
1204*/
1205 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1206
1207 gDirectory->cd("..");
1208 /***************************/
1209
1210 /***************************/
1211 // Flib Histos
1212 gDirectory->mkdir("Flib_Raw");
1213 gDirectory->cd("Flib_Raw");
1214 for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks++) {
1215 TString sMsSzName = Form("MsSz_link_%02u", uLinks);
1216 if (fHM->Exists(sMsSzName.Data())) fHM->H1(sMsSzName.Data())->Write();
1217
1218 sMsSzName = Form("MsSzTime_link_%02u", uLinks);
1219 if (fHM->Exists(sMsSzName.Data())) fHM->P1(sMsSzName.Data())->Write();
1220 } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++)
1221
1222 TH1* pMissedTsH1 = dynamic_cast<TH1*>(gROOT->FindObjectAny("Missed_TS"));
1223 if (NULL != pMissedTsH1) pMissedTsH1->Write();
1224
1225 TProfile* pMissedTsEvoP = dynamic_cast<TProfile*>(gROOT->FindObjectAny("Missed_TS_Evo"));
1226 if (NULL != pMissedTsEvoP) pMissedTsEvoP->Write();
1227
1228 gDirectory->cd("..");
1229 /***************************/
1230
1231 if ("" != sFileName) {
1232 // Restore original directory position
1233 histoFile->Close();
1234 } // if( "" != sFileName )
1235
1237 gFile = oldFile;
1238 gDirectory = oldDir;
1239}
1241{
1242 LOG(info) << "Reseting all STS histograms.";
1243
1244 fhPulserMessType->Reset();
1245 fhPulserSysMessType->Reset();
1246 fhPulserMessTypePerDpb->Reset();
1248 fhPulserMessTypePerElink->Reset();
1250
1251 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
1252 fhPulserChanCntRaw[uXyterIdx]->Reset();
1253 fhPulserChanAdcRaw[uXyterIdx]->Reset();
1254 fhPulserChanAdcRawProf[uXyterIdx]->Reset();
1255 fhPulserChanRawTs[uXyterIdx]->Reset();
1256 fhPulserChanMissEvt[uXyterIdx]->Reset();
1257 fhPulserChanMissEvtEvo[uXyterIdx]->Reset();
1258 fhPulserFebMissEvtEvo[uXyterIdx]->Reset();
1259 fhPulserChanHitRateEvo[uXyterIdx]->Reset();
1260 fhPulserFebRateEvo[uXyterIdx]->Reset();
1261 fhPulserChanHitRateEvoLong[uXyterIdx]->Reset();
1262 fhPulserFebRateEvoLong[uXyterIdx]->Reset();
1263 /*
1264 if( kTRUE == fbLongHistoEnable )
1265 {
1266 ftStartTimeUnix = std::chrono::steady_clock::now();
1267 fhFebRateEvoLong[ uXyterIdx ]->Reset();
1268 fhFebChRateEvoLong[ uXyterIdx ]->Reset();
1269 } // if( kTRUE == fbLongHistoEnable )
1270*/
1271
1272 fhPulserTimeDiffPerAsic[uXyterIdx]->Reset();
1273 for (UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB) {
1274 fhPulserTimeDiffPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1275 fhPulserTimeDiffEvoPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1276 fhPulserTsLsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1277 fhPulserTsMsbMatchPerAsicPair[uXyterIdx][uXyterIdxB]->Reset();
1278 } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB )
1279 fhPulserIntervalAsic[uXyterIdx]->Reset();
1280 fhPulserIntervalLongAsic[uXyterIdx]->Reset();
1281 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
1282
1283 for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks) {
1284 TString sMsSzName = Form("MsSz_link_%02u", uLinks);
1285 if (fHM->Exists(sMsSzName.Data())) fHM->H1(sMsSzName.Data())->Reset();
1286
1287 sMsSzName = Form("MsSzTime_link_%02u", uLinks);
1288 if (fHM->Exists(sMsSzName.Data())) fHM->P1(sMsSzName.Data())->Reset();
1289 } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks )
1290
1291 fdStartTime = -1;
1292 fdStartTimeMsSz = -1;
1293}
1294
1295void CbmCosy2018MonitorPulser::SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize)
1296{
1297 TDatime* fRunStartDateTime = new TDatime(dateIn, timeIn);
1298 fiRunStartDateTimeSec = fRunStartDateTime->Convert();
1299 fiBinSizeDatePlots = iBinSize;
1300
1301 LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString();
1302}
1303
1304void CbmCosy2018MonitorPulser::SetLongDurationLimits(UInt_t uDurationSeconds, UInt_t uBinSize)
1305{
1306 fbLongHistoEnable = kTRUE;
1307 fuLongHistoNbSeconds = uDurationSeconds;
1308 fuLongHistoBinSizeSec = uBinSize;
1309}
1310
ClassImp(CbmConverterManager)
Histogram manager.
Bool_t bCosy2018ResetPulser
Bool_t bCosy2018WritePulser
static constexpr size_t size()
Definition KfSimdPseudo.h:2
std::vector< UInt_t > fvuElinkLastTsHit
Current TS MSB cycle for DPB.
Double_t fdStartTime
Last hit ADC in bins in each MS for each Channel.
UInt_t fuNbChanPerAsic
Number of StsXyter ASICs.
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
stsxyter::MessagePrintMask fPrintMessCtrl
CbmCern2017UnpackParHodo * fUnpackParHodo
std::vector< std::vector< TH1 * > > fhPulserTimeDiffPerAsicPair
std::vector< TH2 * > fhPulserChanMissEvtEvo
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
std::vector< std::vector< TH2 * > > fhPulserTsLsbMatchPerAsicPair
std::map< UInt_t, UInt_t > fDpbIdIndexMap
Total number of Sts DPBs in system.
Int_t fiRunStartDateTimeSec
Index of the DPB from which the MS currently unpacked is coming.
std::vector< TH1 * > fhPulserChanCntRawGood
std::vector< Double_t > fvdMsTime
Last hit time in ns for each Channel.
std::chrono::steady_clock::time_point ftStartTimeUnix
std::vector< TH1 * > fhPulserIntervalLongAsic
std::vector< std::vector< ULong64_t > > fvulChanLastHitTime
TS from last hit for DPB.
void FillEpochInfo(stsxyter::Message mess)
void SetCoincidenceBorder(Double_t dCenterPos, Double_t dBorderVal)
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
void SetLongDurationLimits(UInt_t uDurationSeconds=3600, UInt_t uBinSize=1)
std::vector< ULong64_t > fvulCurrentTsMsb
Bin size in s for the plots with date as X axis.
std::vector< TH2 * > fhPulserTimeDiffPerAsic
Last hits in each ASIC.
std::vector< std::vector< TH2 * > > fhPulserTsMsbMatchPerAsicPair
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
void SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize=5)
std::vector< std::vector< stsxyter::FinalHit > > fvmAsicHitsInTs
All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator.
std::vector< stsxyter::FinalHit > fvmLastHitAsic
Last hits in each ASIC.
Double_t fdStartTs
Pulser time difference histos.
std::vector< TH2 * > fhPulserChanHitRateEvoLong
std::vector< std::vector< UInt_t > > fvuElinkToAsic
Number of channels per StsXyter ASIC => should be constant somewhere!!!!
std::vector< UInt_t > fvuCurrentTsMsbCycle
Current TS MSB for each DPB.
std::vector< TH1 * > fhPulserFebRateEvoLong
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< stsxyter::FinalHit > fvmHitsInTs
std::vector< std::vector< TH2 * > > fhPulserTimeDiffEvoPerAsicPair
std::vector< std::vector< Double_t > > fvdChanLastHitTime
Last hit time in bins for each Channel.
std::vector< TProfile * > fhPulserChanAdcRawProf
UInt_t fuNbElinksPerDpb
Map of DPB Identifier to DPB index.
UInt_t fuMaxNbMicroslices
All hits (time in bins, ADC in bins, asic, channel) in last TS, per ASIC, sorted with "<" operator.
void FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs
Number of hits in each MS for each Channel.
TProfile * fhMsSzTime[kiMaxNbFlibLinks]
std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs
Last hit time in bins in each MS for each Channel.
UInt_t fuNbStsXyters
Number of possible eLinks per DPB.
static const Int_t kiMaxNbFlibLinks
Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb].
std::vector< TH2 * > fhPulserChanHitRateEvo
std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs
Header time of each MS.
TH1 * fhPulserMessType
Histogram manager.
void SaveAllHistos(TString sFileName="")
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.
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 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 GetHitTimeOver() const
For Hit data: Returns timestamp overlap bits (2 bits field, overlap with 2 LSBs of TS_MSB message)
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.