CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018MonitorAlgoMuchLite.cxx
Go to the documentation of this file.
1/* Copyright (C) 2021 Variable Energy Cyclotron Centre, Kolkata
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Vikas Singhal [committer] */
4
6
7// Data
8//
9// // CbmRoot
11#include "CbmHistManager.h"
12#include "CbmMcbm2018MuchPar.h"
13
14// // FairRoot
15#include "FairRootManager.h"
16#include "FairRun.h"
17#include "FairRunOnline.h"
18#include "FairRuntimeDb.h"
19#include "Logger.h"
20//
21// // Root
22#include "TClonesArray.h"
23#include "THttpServer.h"
24#include "TMath.h"
25#include "TProfile.h"
26#include "TROOT.h"
27#include "TRandom.h"
28#include "TString.h"
29#include "TStyle.h"
30#include <TFile.h>
31
32// C++11
33#include <bitset>
34
35// C/C++
36#include <iomanip>
37#include <iostream>
38
39#include <stdint.h>
40
41
42/*Bool_t bMcbmResetAlgoMuchLite = kFALSE;
43 Bool_t bMcbm2018WriteAlgoMuchLite = kFALSE;
44 Bool_t bMcbm2018ScanNoisyAlgoMuchLite = kFALSE;*/
45
48 , fbMuchMode(kFALSE)
49 , fvbMaskedComponents()
50 , fvmHitsInMs()
51 , fsHistoFilename("data/HistosMonitorMuch.root")
52 , fbPrintMessages(kFALSE)
53 , fPrintMessCtrl(stsxyter::MessagePrintMask::msg_print_Human)
54 , fulCurrentTsIdx(0)
55 , fuNbCoreMsPerTs(0)
56 , fuNrOfDpbs(0)
57 , fDpbIdIndexMap()
58 , fvbCrobActiveFlag()
59 , fuNbFebs(0)
60 , fuNbStsXyters(0)
61 , fmMsgCounter()
62 , fUnpackParMuch(NULL)
63 , fuCurrentEquipmentId(0)
64 , fuCurrDpbId(0)
65 , fuCurrDpbIdx(0)
66 , fiRunStartDateTimeSec(-1)
67 , fiBinSizeDatePlots(-1)
68 , fvulCurrentTsMsb()
69 , fvuCurrentTsMsbCycle()
70 , fvuInitialHeaderDone()
71 , fvuInitialTsMsbCycleHeader()
72 , fvuElinkLastTsHit()
73 , fvulChanLastHitTime()
74 , fvdChanLastHitTime()
75 , fvdPrevMsTime()
76 , fvdMsTime()
77 , fvdChanLastHitTimeInMs()
78 , fvusChanLastHitAdcInMs()
79 , fvmAsicHitsInMs()
80 , fvmFebHitsInMs()
81 , fiTimeIntervalRateUpdate(10)
82 , fviFebTimeSecLastRateUpdate()
83 , fviFebCountsSinceLastRateUpdate()
84 , fvdFebChanCountsSinceLastRateUpdate()
85 , Counter(0)
86 , Counter1(0)
87 , fHM(new CbmHistManager())
88 , fhMuchMessType(NULL)
89 , fhMuchSysMessType(NULL)
90 , fhMuchFebChanAdcRaw_combined(NULL)
91 , fhMuchMessTypePerDpb(NULL)
92 , fhMuchSysMessTypePerDpb(NULL)
93 , fhStatusMessType(NULL)
94 , fhMsStatusFieldType(NULL)
95 , fhMuchHitsElinkPerDpb(NULL)
96 , fhRate(NULL)
97 , fhRateAdcCut(NULL)
98 , fHistPadDistr()
99 , fRealHistPadDistr()
100 , fhMuchFebChanCntRaw()
101 , fhMuchFebChanAdcRaw()
102 , fhMuchFebChanAdcRawProf()
103 , fhMuchFebChanRawTs()
104 , fhMuchFebChanHitRateEvo()
105 , fhMuchFebChanHitRateProf()
106 , fhMuchFebHitRateEvo()
107 , fhMuchFebHitRateEvo_mskch()
108 , fhMuchFebHitRateEvo_mskch_adccut()
109 , fhMuchFebHitRateEvo_WithoutDupli()
110 , fdMuchFebChanLastTimeForDist()
111 , fhMuchFebChanDistT()
112 , fhMuchFebDuplicateHitProf()
113 , fcMsSizeAll(NULL)
114 , fvMsComponentsList()
115 , fuMaxNbMicroslices(100)
116 , fvuChanNbHitsInMs()
117 , fhElinkIdxHit(NULL)
118 , fuNbOverMsPerTs(0)
119// , fhElinkIdxTsMsb(NULL)
120// , fhElinkIdxEpoch(NULL)
121// , fhElinkIdxStatus(NULL)
122{
123}
124
127{
128 LOG(info) << "Initializing flib StsXyter unpacker for MUCH";
129
130 FairRootManager* ioman = FairRootManager::Instance();
131 if (ioman == NULL) { LOG(fatal) << "No FairRootManager instance"; }
132
133 return kTRUE;
134}
135
137
139{
140 //fhElinkIdx->Draw();
141 LOG(info) << "-------------------------------------";
142 LOG(info) << "CbmMcbm2018MonitorAlgoMuchLite statistics are ";
143 LOG(info) << " Hit messages: " << fmMsgCounter[stsxyter::MessType::Hit] << "\n"
144 << " Ts MSB messages: " << fmMsgCounter[stsxyter::MessType::TsMsb] << "\n"
145 << " Dummy messages: " << fmMsgCounter[stsxyter::MessType::Dummy] << "\n"
146 << " Epoch messages: " << fmMsgCounter[stsxyter::MessType::Epoch] << "\n"
147 << " Empty messages: " << fmMsgCounter[stsxyter::MessType::Empty];
148
149 LOG(info) << "-------------------------------------";
150
151 //SaveAllHistos(fsHistoFileFullname);
152 //SaveAllHistos();
153}
154
156{
157 LOG(info) << "Init parameter containers for CbmMcbm2018MonitorAlgoMuchLite";
158
159 Bool_t bInit = InitMuchParameters();
160 //LOG(info) << "bInit ok.";
161 //if (kTRUE == bInit) CreateHistograms();
162 //fhElinkIdxHit = new TH1I("ElinkIdxHit", "Active Elink Ids for Hit Messages", 42, 0,41);
163 //fhElinkIdxTsMsb = new TH1I("ElinkIdxTsMsb", "Active Elink Ids for TsMsb", 42, 0,41);
164 //fhElinkIdxEpoch = new TH1I("ElinkIdxEpoch", "Active Elink Ids for Epoch", 42, 0,41);
165 //fhElinkIdxStatus = new TH1I("ElinkIdxStatus", "Active Elink Ids for Status", 42, 0,41);
166
167 return bInit;
168}
169
171{
172 LOG(info) << "ReInit parameter containers for CbmMcbm2018MonitorAlgoMuchLite";
173
174 return InitMuchParameters();
175}
176
178{
179 if (nullptr == fParCList) fParCList = new TList();
180 fUnpackParMuch = new CbmMcbm2018MuchPar("CbmMcbm2018MuchPar");
182
183 return fParCList;
184}
185
187{
188
189 fUnpackParMuch = (CbmMcbm2018MuchPar*) fParCList->FindObject("CbmMcbm2018MuchPar");
190 if (nullptr == fUnpackParMuch) {
191 LOG(info) << "Much parameters could not be initialized";
192 return kFALSE;
193 }
194
196 LOG(info) << "Nr. of MUCH DPBs: " << fuNrOfDpbs;
197
198 fDpbIdIndexMap.clear();
199 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
201 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = 0x" << std::setw(4) << std::hex
202 << fUnpackParMuch->GetDpbId(uDpb) << std::dec << " => " << fDpbIdIndexMap[fUnpackParMuch->GetDpbId(uDpb)];
203 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
204
206 LOG(info) << "Nr. of FEBs: " << fuNbFebs;
207
209 LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters;
210
212 //fvdFebAdcGain.resize( fuNrOfDpbs );
213 // //fvdFebAdcOffs.resize( fuNrOfDpbs );
214 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
216 //fvdFebAdcGain[ uDpb ].resize( fUnpackParMuch->GetNbCrobsPerDpb() );
217 // //fvdFebAdcOffs[ uDpb ].resize( fUnpackParMuch->GetNbCrobsPerDpb() );
218 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackParMuch->GetNbCrobsPerDpb(); ++uCrobIdx) {
219 fvbCrobActiveFlag[uDpb][uCrobIdx] = fUnpackParMuch->IsCrobActive(uDpb, uCrobIdx);
220 // fvdFebAdcGain[ uDpb ][ uCrobIdx ].resize( fUnpackParMuch->GetNbFebsPerCrob(), 0.0 );
221 // //fvdFebAdcOffs[ uDpb ][ uCrobIdx ].resize( fUnpackParMuch->GetNbFebsPerCrob(), 0.0 );
222 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackParMuch->GetNbCrobsPerDpb(); ++uCrobIdx )
223 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
224
225 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
226 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackParMuch->GetNbCrobsPerDpb(); ++uCrobIdx) {
227 LOG(info) << Form("DPB #%02u CROB #%02u Active: ", uDpb, uCrobIdx) << fvbCrobActiveFlag[uDpb][uCrobIdx];
228 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackParMuch->GetNbCrobsPerDpb(); ++uCrobIdx )
229 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
230
231 if (fbBinningFw) LOG(info) << "Unpacking data in bin sorter FW mode";
232 else
233 LOG(info) << "Unpacking data in full time sorter FW mode (legacy)";
234
235 // Internal status initialization
236 LOG(info) << "Internal status initialization";
242 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
243 fvulCurrentTsMsb[uDpb] = 0;
244 fvuCurrentTsMsbCycle[uDpb] = 0;
245 fvuInitialHeaderDone[uDpb] = kFALSE;
247 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
248 LOG(info) << "ongoing internal status initialization";
249
258
259 //fvdMsTime.resize( fuMaxNbMicroslices );
260 //fvuChanNbHitsInMs.resize( fuNbStsXyters );
261 //fvdChanLastHitTimeInMs.resize( fuNbStsXyters );
262 //fvusChanLastHitAdcInMs.resize( fuNbStsXyters );
263 //fvmAsicHitsInMs.resize( fuNbStsXyters );
264
265 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbFebs; ++uXyterIdx) {
271 fvmAsicHitsInMs[uXyterIdx].clear();
272
273 for (UInt_t uChan = 0; uChan < fUnpackParMuch->GetNbChanPerAsic(); ++uChan) {
274 fvulChanLastHitTime[uXyterIdx][uChan] = 0;
275 fvdChanLastHitTime[uXyterIdx][uChan] = -1.0;
276
277 fvuChanNbHitsInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
278 fvdChanLastHitTimeInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
279 fvusChanLastHitAdcInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
280 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
281 fvuChanNbHitsInMs[uXyterIdx][uChan][uMsIdx] = 0;
282 fvdChanLastHitTimeInMs[uXyterIdx][uChan][uMsIdx] = -1.0;
283 fvusChanLastHitAdcInMs[uXyterIdx][uChan][uMsIdx] = 0;
284 } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx )
285 } // for( UInt_t uChan = 0; uChan < fUnpackParMuch->GetNbChanPerAsic(); ++uChan )
286 } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx )
287
288 LOG(info) << "CbmMcbm2018MonitorAlgoMuchLite::ReInitContainers => Changed "
289 "fvuChanNbHitsInMs size "
290 << fvuChanNbHitsInMs.size() << " VS " << fuNbFebs;
291 LOG(info) << "CbmMcbm2018MonitorAlgoMuchLite::ReInitContainers => Changed "
292 "fvuChanNbHitsInMs size "
293 << fvuChanNbHitsInMs[0].size() << " VS " << fUnpackParMuch->GetNbChanPerAsic();
294 LOG(info) << "CbmMcbm2018MonitorAlgoMuchLite::ReInitContainers => Changed "
295 "fvuChanNbHitsInMs size "
296 << fvuChanNbHitsInMs[0][0].size() << " VS " << fuMaxNbMicroslices;
297
298 fvmFebHitsInMs.resize(fuNbFebs);
303 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
304 fvmFebHitsInMs[uFebIdx].clear();
307 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
308
310 // SmxErrInitializeVariables();
312
313 return kTRUE;
314}
315
316/* void CbmMcbm2018MonitorAlgoMuchLite::SetNbMsInTs(size_t uCoreMsNb,
317 size_t uOverlapMsNb) {
318 fuNbCoreMsPerTs = uCoreMsNb;
319 fuNbOverMsPerTs = uOverlapMsNb;
320 //LOG(info) <<" fuNbCoreMsPerTs "<<fuNbCoreMsPerTs<<" fuNbOverMsPerTs "<<fuNbOverMsPerTs;
321 UInt_t uNbMsTotal = fuNbCoreMsPerTs + fuNbOverMsPerTs;
322
323 if (fuMaxNbMicroslices < uNbMsTotal) {
324 fuMaxNbMicroslices = uNbMsTotal;
325 fvdMsTime.resize(fuMaxNbMicroslices);
326 fvuChanNbHitsInMs.resize(fuNbStsXyters);
327 fvdChanLastHitTimeInMs.resize(fuNbStsXyters);
328 fvusChanLastHitAdcInMs.resize(fuNbStsXyters);
329 for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx) {
330 fvuChanNbHitsInMs[uXyterIdx].resize(fUnpackParMuch->GetNbChanPerAsic());
331 fvdChanLastHitTimeInMs[uXyterIdx].resize(
332 fUnpackParMuch->GetNbChanPerAsic());
333 fvusChanLastHitAdcInMs[uXyterIdx].resize(
334 fUnpackParMuch->GetNbChanPerAsic());
335 for (UInt_t uChan = 0; uChan < fUnpackParMuch->GetNbChanPerAsic();
336 ++uChan) {
337 fvuChanNbHitsInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
338 fvdChanLastHitTimeInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
339 fvusChanLastHitAdcInMs[uXyterIdx][uChan].resize(fuMaxNbMicroslices);
340 for (UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx) {
341 fvuChanNbHitsInMs[uXyterIdx][uChan][uMsIdx] = 0;
342 fvdChanLastHitTimeInMs[uXyterIdx][uChan][uMsIdx] = -1.0;
343 fvusChanLastHitAdcInMs[uXyterIdx][uChan][uMsIdx] = 0;
344 LOG(info) << "CbmMcbm2018MonitorMuchLite::DoUnpack => Changed "
345 "fvuChanNbHitsInMs size "
346 << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters;
347 LOG(info) << "CbmMcbm2018MonitorMuchLite::DoUnpack => Changed "
348 "fvuChanNbHitsInMs size "
349 << fvuChanNbHitsInMs[0].size() << " VS "
350 << fUnpackParMuch->GetNbChanPerAsic();
351 LOG(info) << "CbmMcbm2018MonitorMuchLite::DoUnpack => Changed "
352 "fvuChanNbHitsInMs size "
353 << fvuChanNbHitsInMs[0][0].size() << " VS " << fuMaxNbMicroslices;
354 } // if( fuMaxNbMicroslices < uNbMsTotal )
355 }
356 }
357 }
358} */
359
360
361void CbmMcbm2018MonitorAlgoMuchLite::AddMsComponentToList(size_t component, UShort_t /*usDetectorId*/)
362{
364 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
365 if (component == fvMsComponentsList[uCompIdx]) return;
366
368 if (kiMaxNbFlibLinks <= component) {
369 LOG(error) << "CbmMcbm2018MonitorAlgoMuchLite::AddMsComponentToList => "
370 << "Ignored the addition of component " << component << " as it is above the hadcoded limit of "
371 << static_cast<Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! "
372 << "\n"
373 << " To change this behavior check kiMaxNbFlibLinks in "
374 "CbmMcbm2018MonitorAlgoMuchLite.cxx";
375 return;
376 } // if( kiMaxNbFlibLinks <= component )
377
378
380 fvMsComponentsList.push_back(component);
381 LOG(info) << "CbmMcbm2018MonitorAlgoMuchLite::AddMsComponentToList => Added component: " << component;
382
384 if (NULL == fhMsSz[component]) {
385 TString sMsSzName = Form("MsSz_link_%02lu", component);
386 TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component);
387 fhMsSz[component] = new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.);
388 fHM->Add(sMsSzName.Data(), fhMsSz[component]);
389
390 sMsSzName = Form("MsSzTime_link_%02lu", component);
391 sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component);
392 fhMsSzTime[component] = new TProfile(sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300.);
393 fHM->Add(sMsSzName.Data(), fhMsSzTime[component]);
394
395 if (NULL != fcMsSizeAll) {
396 fcMsSizeAll->cd(1 + component);
397 gPad->SetLogy();
398 fhMsSzTime[component]->Draw("hist le0");
399 } // if( NULL != fcMsSizeAll )
400 LOG(info) << "Added MS size histo for component: " << component << " (DPB)";
401
402 // THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
403 // if (server) {
404 //server->Register("/FlibRaw", fhMsSz[component]); //closed by me
405 AddHistoToVector(fhMsSz[component], "FlibRaw");
406 //server->Register("/FlibRaw", fhMsSzTime[component]);// closed by me
407 AddHistoToVector(fhMsSzTime[component], "FlibRaw");
408 // } // if( server )
409 } // if( NULL == fhMsSz[ component ] )
410}
411
412
414{
415 TString sHistName {""};
416 TString title {""};
417
418 sHistName = "hMessageType";
419 title = "Nb of message for each type; Type";
420 fhMuchMessType = new TH1I(sHistName, title, 6, 0., 6.);
421 fhMuchMessType->GetXaxis()->SetBinLabel(1, "Dummy");
422 fhMuchMessType->GetXaxis()->SetBinLabel(2, "Hit");
423 fhMuchMessType->GetXaxis()->SetBinLabel(3, "TsMsb");
424 fhMuchMessType->GetXaxis()->SetBinLabel(4, "Epoch");
425 fhMuchMessType->GetXaxis()->SetBinLabel(5, "Status");
426 fhMuchMessType->GetXaxis()->SetBinLabel(6, "Empty");
427
428
429 sHistName = "hSysMessType";
430 title = "Nb of system message for each type; System Type";
431 fhMuchSysMessType = new TH1I(sHistName, title, 17, 0., 17.);
432
433 sHistName = "hMuchFebChanAdcRaw_combined";
434 title = "ADC hist combined";
436 new TH1I(sHistName, title, stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins - 0.5);
437
438 LOG(debug) << "Initialized 1st Histo";
439 sHistName = "hMessageTypePerDpb";
440 title = "Nb of message of each type for each DPB; DPB; Type";
441 fhMuchMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 6, 0., 6.);
442 fhMuchMessTypePerDpb->GetYaxis()->SetBinLabel(1, "Dummy");
443 fhMuchMessTypePerDpb->GetYaxis()->SetBinLabel(2, "Hit");
444 fhMuchMessTypePerDpb->GetYaxis()->SetBinLabel(3, "TsMsb");
445 fhMuchMessTypePerDpb->GetYaxis()->SetBinLabel(4, "Epoch");
446 fhMuchMessTypePerDpb->GetYaxis()->SetBinLabel(5, "Status");
447 fhMuchMessTypePerDpb->GetYaxis()->SetBinLabel(6, "Empty");
448
449 sHistName = "hMuchMessTypePerElink";
450 title = "Nb of message of each type for each Elink; Elink; Type";
451 fhMuchMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fUnpackParMuch->GetNbElinkPerCrob(), 0,
453 fhMuchMessTypePerElink->GetYaxis()->SetBinLabel(1, "Dummy");
454 fhMuchMessTypePerElink->GetYaxis()->SetBinLabel(2, "Hit");
455 fhMuchMessTypePerElink->GetYaxis()->SetBinLabel(3, "TsMsb");
456 fhMuchMessTypePerElink->GetYaxis()->SetBinLabel(4, "Epoch");
457 fhMuchMessTypePerElink->GetYaxis()->SetBinLabel(5, "Status");
458 fhMuchMessTypePerElink->GetYaxis()->SetBinLabel(6, "Empty");
459
460
461 fhElinkIdxHit = new TH1I("ElinkIdxHit", "Active Elink Ids for Hit Messages", 42, 0, 41);
462
463 for (UInt_t uModuleId = 0; uModuleId < 2; ++uModuleId) {
465 sHistName = Form("HistPadDistr_Module_%01u", uModuleId);
466 title = Form("Pad distribution for, Module #%01u; ", uModuleId);
467
468 //Below for Rectangular Module shape VS
469 fHistPadDistr.push_back(new TH2I(sHistName, title, 23, -0.5, 22.5, 97, -0.5, 96.5));
470
471 sHistName = Form("RealHistPadDistr_Module_%01u", uModuleId);
472 title = Form("Progressive Pad distribution for, Module #%01u; ", uModuleId);
473 //Below for Progressive Geometry Module shape VS
474 fRealHistPadDistr.push_back(new TH2D(sHistName, title, 500, -0.5, 499.5, 1000, -0.5, 999.5));
475
476
478 sHistName = Form("hMuchFebDuplicateHitProf_%01u", uModuleId);
479 title = Form("FEB wise Duplicate Hit for Module #%01u; FEB []; Hit []", uModuleId);
480 if (uModuleId == 0)
481 //fhMuchFebDuplicateHitProf.push_back( new TProfile(sHistName, title,fUnpackParMuch->GetNrOfFebsInGemA(), -0.5, fUnpackParMuch->GetNrOfFebsInGemA() - 0.5 ) );
482 fhMuchFebDuplicateHitProf.push_back(new TProfile(sHistName, title, 18, -0.5, 18 - 0.5));
483 if (uModuleId == 1)
484 //fhMuchFebDuplicateHitProf.push_back( new TProfile(sHistName, title,fUnpackParMuch->GetNrOfFebsInGemB(), -0.5, fUnpackParMuch->GetNrOfFebsInGemB() - 0.5 ) );
485 fhMuchFebDuplicateHitProf.push_back(new TProfile(sHistName, title, 18, -0.5, 18 - 0.5));
486 }
487
488 sHistName = "hRate";
489 title = "Rate in kHz";
490 fhRate = new TH1I(sHistName, title, 10000, -0.5, 9999.5);
491
492 sHistName = "hRateAdcCut";
493 title = "Rate in kHz with Adc cut";
494 fhRateAdcCut = new TH1I(sHistName, title, 10000, -0.5, 9999.5);
495
496
497 sHistName = "hFEBcount";
498 title = "Count vs FEB number; FEB Number; Count";
499 fhFEBcount = new TH1I(sHistName, title, 40, -0.5, 39.5);
500
501
502 sHistName = "hSysMessTypePerDpb";
503 title = "Nb of system message of each type for each DPB; DPB; System Type";
504 fhMuchSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.);
505
506 sHistName = "hStatusMessType";
507 title = "Nb of status message of each type for each DPB; ASIC; Status Type";
508 fhStatusMessType = new TH2I(sHistName, title, fuNbStsXyters, 0, fuNbStsXyters, 16, 0., 16.);
509
510
511 sHistName = "hMsStatusFieldType";
512 title = "For each flag in the MS header, ON/OFF counts; Flag bit []; ON/OFF; MS []";
513 fhMsStatusFieldType = new TH2I(sHistName, title, 16, -0.5, 15.5, 2, -0.5, 1.5);
514
515 //For mCBM March 2019 data taking we will have only one eLink enable for each FEB
516 sHistName = "hMuchHitsElinkPerDpb";
517 title = "Nb of hit messages per eLink for each DPB; DPB; eLink; Hits nb []";
518 fhMuchHitsElinkPerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 42, 0., 42.);
519
520
521 LOG(debug) << "Initialized 2nd Histo";
522 /*
523 // Number of rate bins =
524 // 9 for the sub-unit decade
525 // + 9 for each unit of each decade * 10 for the subdecade range
526 // + 1 for the closing bin top edge
527 const Int_t iNbDecadesRate = 9;
528 const Int_t iNbStepsDecade = 9;
529 const Int_t iNbSubStepsInStep = 10;
530 const Int_t iNbBinsRate = iNbStepsDecade
531 + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate
532 + 1;
533 Double_t dBinsRate[iNbBinsRate];
534 // First fill sub-unit decade
535 for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ )
536 dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU );
537 std::cout << std::endl;
538 // Then fill the main decades
539 Double_t dSubstepSize = 1.0 / iNbSubStepsInStep;
540 for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++)
541 {
542 Double_t dBase = std::pow( 10, iDecade );
543 Int_t iDecadeIdx = iNbStepsDecade
544 + iDecade * iNbStepsDecade * iNbSubStepsInStep;
545 for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
546 {
547 Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep;
548 for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
549 {
550 dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep)
551 + dBase * dSubstepSize * iSubStep;
552 } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
553 } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
554 } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++)
555 dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate );
556*/
557 LOG(debug) << "Initialized 3rd Histo";
559 //UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec);
560 // UInt_t uAlignedLimit = 0;
561
562 // UInt_t uNbBinEvo = (32768 + 1) * 2;
563 // Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs
564 // * static_cast< Double_t >( uNbBinEvo ) / 2.0;
565 // Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0;
566
567 //UInt_t uNbBinDt = static_cast<UInt_t>( (fdCoincMax - fdCoincMin )/stsxyter::kdClockCycleNs );
568
569 // Miscroslice properties histos
570 for (Int_t component = 0; component < kiMaxNbFlibLinks; component++) {
571 fhMsSz[component] = NULL;
572 fhMsSzTime[component] = NULL;
573 } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ )
574
576 // fhMuchFebChanDtCoinc.resize( fuNbFebs );
577 // fhMuchFebChanCoinc.resize( fuNbFebs );
578 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
580 sHistName = Form("hMuchFebChanCntRaw_%03u", uFebIdx);
581 title = Form("Hits Count per channel, FEB #%03u; Channel; Hits []", uFebIdx);
582 fhMuchFebChanCntRaw.push_back(
583 new TH1I(sHistName, title, fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5));
584
585 //sHistName = Form( "hMuchFebChanCntRawGood_%03u", uFebIdx );
586 //title = Form( "Hits Count per channel in good MS (SX2 bug flag off), FEB #%03u; Channel; Hits []", uFebIdx );
587 //fhMuchFebChanCntRawGood.push_back( new TH1I(sHistName, title,
588 // fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5 ) );
589
590 sHistName = Form("fhMuchFebSpill_%03u", uFebIdx);
591 title = Form("Time distribution of hits, FEB #%03u; Time ; Counts ", uFebIdx);
592 fhMuchFebSpill.push_back(new TH1I(sHistName, title, 2000, 0, 2000));
593
594
595 sHistName = Form("hMuchChannelTime_FEB%03u", uFebIdx);
596 title = Form("Time vs Channel, FEB #%03u; TIME(s) ; CHANNEL ", uFebIdx);
597 fhMuchChannelTime.push_back(new TH2I(sHistName, title, 1000, 0, 1000, 129, -0.5, 128.5));
598
599
600 sHistName = Form("hMuchFebADC_%03u", uFebIdx);
601 title = Form("CHANNEL vs ADC, FEB #%03u; CHANNEL ; ADC ", uFebIdx);
602 fhMuchFebADC.push_back(new TH2I(sHistName, title, 129, -0.5, 128.5, 34, -0.5, 33.5));
603
604
606 sHistName = Form("hMuchFebChanAdcRaw_%03u", uFebIdx);
607 title = Form("Raw Adc distribution per channel, FEB #%03u; Channel []; Adc "
608 "[]; Hits []",
609 uFebIdx);
610 fhMuchFebChanAdcRaw.push_back(new TH2I(sHistName, title, fUnpackParMuch->GetNbChanPerFeb(), -0.5,
613
615 sHistName = Form("hMuchFebChanAdcRawProfc_%03u", uFebIdx);
616 title = Form("Raw Adc prodile per channel, FEB #%03u; Channel []; Adc []", uFebIdx);
617 fhMuchFebChanAdcRawProf.push_back(
618 new TProfile(sHistName, title, fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5));
619
621 //sHistName = Form( "hMuchFebChanAdcCal_%03u", uFebIdx );
622 //title = Form( "Cal. Adc distribution per channel, FEB #%03u; Channel []; Adc [e-]; Hits []", uFebIdx );
623 //fhMuchFebChanAdcCal.push_back( new TH2I(sHistName, title,
624 // fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5,
625 // 50, 0., 100000. ) );
626
628 //sHistName = Form( "hMuchFebChanAdcCalProfc_%03u", uFebIdx );
629 //title = Form( "Cal. Adc prodile per channel, FEB #%03u; Channel []; Adc [e-]", uFebIdx );
630 //fhMuchFebChanAdcCalProf.push_back( new TProfile(sHistName, title,
631 // fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5 ) );
632
634 sHistName = Form("hMuchFebChanRawTs_%03u", uFebIdx);
635 title = Form("Raw Timestamp distribution per channel, FEB #%03u; Channel "
636 "[]; Ts []; Hits []",
637 uFebIdx);
638 fhMuchFebChanRawTs.push_back(new TH2I(sHistName, title, fUnpackParMuch->GetNbChanPerFeb(), -0.5,
641
643 sHistName = Form("hMuchFebChanRateEvo_%03u", uFebIdx);
644 title = Form("Hits per second & channel in FEB #%03u; Time [s]; Channel []; Hits []", uFebIdx);
645 fhMuchFebChanHitRateEvo.push_back(new TH2I(sHistName, title, 1800, 0, 1800, fUnpackParMuch->GetNbChanPerFeb(), -0.5,
647
649 sHistName = Form("hMuchFebChanRateProf_%03u", uFebIdx);
650 title = Form("Hits per second for each channel in FEB #%03u; Channel []; Hits/s []", uFebIdx);
651 fhMuchFebChanHitRateProf.push_back(
652 new TProfile(sHistName, title, fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5));
653
655 // sHistName = Form( "hMuchFebAsicRateEvo_%03u", uFebIdx );
656 // title = Form( "Hits per second & StsXyter in FEB #%03u; Time [s]; Asic []; Hits []", uFebIdx );
657 // fhMuchFebAsicHitRateEvo.push_back( new TH2I( sHistName, title, 1800, 0, 1800,
658 // fUnpackParMuch->GetNbAsicsPerFeb(), -0.5, fUnpackParMuch->GetNbAsicsPerFeb() - 0.5 ) );
659
661 sHistName = Form("hMuchFebRateEvo_%03u", uFebIdx);
662 title = Form("Hits per second in FEB #%03u; Time [s]; Hits []", uFebIdx);
663 fhMuchFebHitRateEvo.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
664
665
667 sHistName = Form("hMuchFebRateEvo_mskch_%03u", uFebIdx);
668 title = Form("Hits per second in FEB #%03u; Time [s]; Hits []", uFebIdx);
669 fhMuchFebHitRateEvo_mskch.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
670
672 sHistName = Form("hMuchFebRateEvo_mskch_adcut_%03u", uFebIdx);
673 title = Form("Hits per second in FEB #%03u; Time [s]; Hits []", uFebIdx);
674 fhMuchFebHitRateEvo_mskch_adccut.push_back(new TH1I(sHistName, title, 1800, 0, 1800));
675
677 sHistName = Form("hMuchFebRateEvo_WithoutDupli_%03u", uFebIdx);
678 title = Form("Hits per second in FEB #%03u; Time [s]; Hits []", uFebIdx);
679 fhMuchFebHitRateEvo_WithoutDupli.push_back(new TH1I(sHistName, title, 50000, 0, 5000));
680
682 //sHistName = Form( "hMuchFebChanRateEvoLong_%03u", uFebIdx );
683 //title = Form( "Hits per second & channel in FEB #%03u; Time [min]; Channel []; Hits []", uFebIdx );
684 //fhMuchFebChanHitRateEvoLong.push_back( new TH2D( sHistName, title,
685 // fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5,
686 // fUnpackParMuch->GetNbChanPerFeb(), -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5 ) );
687
689 //sHistName = Form( "hMuchFebAsicRateEvoLong_%03u", uFebIdx );
690 //title = Form( "Hits per second & StsXyter in FEB #%03u; Time [min]; Asic []; Hits []", uFebIdx );
691 //fhMuchFebAsicHitRateEvoLong.push_back( new TH2D( sHistName, title,
692 // fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5,
693 // fUnpackParMuch->GetNbAsicsPerFeb(), -0.5, fUnpackParMuch->GetNbAsicsPerFeb() - 0.5 ) );
694
696 //sHistName = Form( "hMuchFebRateEvoLong_%03u", uFebIdx );
697 //title = Form( "Hits per second in FEB #%03u; Time [min]; Hits []", uFebIdx );
698 //fhMuchFebHitRateEvoLong.push_back( new TH1D(sHistName, title,
699 // fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) );
700
702 sHistName = Form("hMuchFebChanDistT_%03u", uFebIdx);
703 title = Form("Time distance between hits on same channel in between FEB "
704 "#%03u; Time difference [ns]; Channel []; ",
705 uFebIdx);
706 fhMuchFebChanDistT.push_back(new TH2I(sHistName, title, 1000, -0.5, 6250.0 - 0.5, fUnpackParMuch->GetNbChanPerFeb(),
707 -0.5, fUnpackParMuch->GetNbChanPerFeb() - 0.5));
708
709 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
710
713 new TH2I("fhDpbMsErrors", "; DPB []; Error type []; Counts []", fuNrOfDpbs, 0, fuNrOfDpbs, 4, -0.5, 3.5);
715
716 // Miscroslice properties histos
717 for (Int_t component = 0; component < kiMaxNbFlibLinks; component++) {
718 fhMsSz[component] = NULL;
719 fhMsSzTime[component] = NULL;
720 } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ )
721
722 LOG(debug) << "Initialized 6th Histo before FairRunOnlne Instance";
723 // THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
724 // if (server) {
725 for (UInt_t uModuleId = 0; uModuleId < 2; ++uModuleId) {
726 //server->Register("/MuchRaw", fHistPadDistr[uModuleId] );
727 AddHistoToVector(fHistPadDistr[uModuleId], "MuchRaw");
728 //server->Register("/MuchRaw", fRealHistPadDistr[uModuleId] );
729 AddHistoToVector(fRealHistPadDistr[uModuleId], "MuchRaw");
730 // server->Register("/MuchFeb", fhMuchFebDuplicateHitProf[uModuleId] );
731 }
732
733 // server->Register("/MuchRaw", fhRate );
734 // server->Register("/MuchRaw", fhRateAdcCut );
735 // server->Register("/MuchRaw", fhFEBcount); //closed by me
736 AddHistoToVector(fhFEBcount, "MuchRaw");
738 // server->Register("/MuchRaw", fhMuchMessType); //closed by me
740 //AddHistoToVector(fhElinkIdxTsMsb, "MuchRaw");
741 //AddHistoToVector(fhElinkIdxEpoch, "MuchRaw");
742 //AddHistoToVector(fhElinkIdxStatus, "MuchRaw");
743 // server->Register("/MuchRaw", fhMuchSysMessType );
744 //server->Register("/MuchRaw", fhMuchMessTypePerDpb); //closed by me
747 //server->Register("/MuchRaw", fhMuchSysMessTypePerDpb); //closed by me
749 // server->Register("/MuchRaw", fhStatusMessType );
750 //server->Register("/MuchRaw", fhMsStatusFieldType); // closed by me
752 //server->Register("/MuchRaw", fhMuchHitsElinkPerDpb); // closed by me
754 //server->Register("/MuchRaw", fhMuchFebChanAdcRaw_combined); // closed by me
756 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
757 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
758 //server->Register("/MuchFeb", fhMuchFebChanCntRaw[uFebIdx]); //closed by me
759 AddHistoToVector(fhMuchFebChanCntRaw[uFebIdx], "MuchFeb");
760 //server->Register("/MuchFeb", fhMuchFebSpill[uFebIdx]); // closed by me
761 AddHistoToVector(fhMuchFebSpill[uFebIdx], "MuchFeb");
762 //server->Register("/MuchFeb", fhMuchFebADC[uFebIdx]); // closed by me
763 AddHistoToVector(fhMuchFebADC[uFebIdx], "MuchFeb");
764 //server->Register("/MuchFeb", fhMuchChannelTime[uFebIdx]); // closed by me
765 AddHistoToVector(fhMuchChannelTime[uFebIdx], "MuchFeb");
766
767 //server->Register("/MuchFeb", fhMuchFebChanCntRawGood[ uFebIdx ] );
769 // server->Register("/MuchFeb", fhMuchFebChanAdcRawProf[ uFebIdx ] );
770 //server->Register("/MuchFeb", fhMuchFebChanAdcCal[ uFebIdx ] );
771 //server->Register("/MuchFeb", fhMuchFebChanAdcCalProf[ uFebIdx ] );
773 //server->Register("/MuchFeb", fhMuchFebChanHitRateEvo[ uFebIdx ] );
774 // server->Register("/MuchFeb", fhMuchFebChanHitRateProf[ uFebIdx ] );
775 //server->Register("/MuchFeb", fhMuchFebAsicHitRateEvo[ uFebIdx ] );
776 // server->Register("/MuchFeb", fhMuchFebHitRateEvo[ uFebIdx ] );
778 // server->Register("/MuchFeb", fhMuchFebHitRateEvo_mskch_adccut[ uFebIdx ] );
779 // server->Register("/MuchFeb", fhMuchFebHitRateEvo_WithoutDupli[ uFebIdx ] );
780 LOG(debug) << "Initialized fhMuchFebHitRateEvo_WithoutDupli number " << uFebIdx;
781 /*server->Register("/MuchFeb", fhMuchFebChanHitRateEvoLong[ uFebIdx ] );
782 server->Register("/MuchFeb", fhMuchFebAsicHitRateEvoLong[ uFebIdx ] );
783 server->Register("/MuchFeb", fhMuchFebHitRateEvoLong[ uFebIdx ] );
784 server->Register("/MuchFeb", fhMuchFebChanDistT[ uFebIdx ] );*/
785
786 } // if( kTRUE == fUnpackParMuch->IsFebActive( uFebIdx ) )
787 //server->Register("/MuchRaw", fhDpbMsErrors); //closed by me
788 //AddHistoToVector(fhDpbMsErrors, "MuchRaw");
789 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
791
792 // LOG(debug) << "Initialized FEB 8th Histo";
793 /*server->RegisterCommand("/Reset_All", "bMcbm2018ResetAlgoMuchLite=kTRUE");
794 server->RegisterCommand("/Write_All", "bMcbm2018WriteAlgoMuchLite=kTRUE");
795 server->RegisterCommand("/ScanNoisyCh", "bMcbm2018ScanNoisyAlgoMuchLite=kTRUE");
796 server->Restrict("/Reset_All", "allow=admin");
797 server->Restrict("/Write_All", "allow=admin");
798 server->Restrict("/ScanNoisyCh", "allow=admin"); */
799 // } // if( server )
800
801 LOG(debug) << "Initialized All Histos 8th Histo";
803 Double_t w = 10;
804 Double_t h = 10;
805 LOG(debug) << "Initialized 7th Histo before Summary per FEB";
806
807 TCanvas* cChannel = new TCanvas(Form("CHANNELS"),
808 Form("CHANNELS")); //,
809 // w, h);
810 cChannel->Divide(4, 9);
811 // Summary per FEB
812 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
813 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
814 cChannel->cd(uFebIdx + 1);
816 // gPad->SetGridy();
817 gPad->SetLogy();
818 fhMuchFebChanCntRaw[uFebIdx]->Draw();
819
820 } // if( kTRUE == fUnpackParMuch->IsFebActive( uFebIdx ) )
821 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
822
823 //server->Register("/canvases", cChannel); //closed by me
824 AddCanvasToVector(cChannel, "canvases");
825 //All Feb hit rate together on one Canvas
826
827 TCanvas* cspill = new TCanvas(Form("SPILLS"), Form("SPILLS")); //,w, h);
828 cspill->Divide(4, 9);
829
830 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
831 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
832 UInt_t flPad = 1 + uFebIdx;
833 cspill->cd(flPad);
834 //gPad->SetGridx();
835 //gPad->SetGridy();
836 // gPad->SetLogy();
837 fhMuchFebSpill[uFebIdx]->Draw();
838 }
839 // server->Register("/canvases", cspill);
840 }
841 // server->Register("/canvases", cspill); //closed by me
842 AddCanvasToVector(cspill, "canvases");
843
844 TCanvas* cadc = new TCanvas(Form("ADC"), Form("ADC"), w, h);
845 cadc->Divide(4, 9);
846
847 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
848 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
849 UInt_t flPad = 1 + uFebIdx;
850 cadc->cd(flPad);
851 //gPad->SetGridx();
852 //gPad->SetGridy();
853 //gPad->SetLogy();
854 fhMuchFebADC[uFebIdx]->Draw("colz");
855 }
856 }
857 //server->Register("/canvases", cadc); //closed by me
858 AddCanvasToVector(cadc, "canvases");
859 TCanvas* cChanneltime = new TCanvas(Form("ChannelvsTime"), Form("ChannelvsTime"), w, h);
860 cChanneltime->Divide(4, 9);
861
862 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
863 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
864 UInt_t flPad = 1 + uFebIdx;
865 cChanneltime->cd(flPad);
866 //gPad->SetGridx();
867 //gPad->SetGridy();
868 //gPad->SetLogy();
869 fhMuchChannelTime[uFebIdx]->Draw("colz");
870 }
871 }
872 // server->Register("/canvases", cChanneltime); //closed by me
873 AddCanvasToVector(cChanneltime, "canvases");
874 //====================================================================//
875 LOG(debug) << "Initialized Last Histo before exiting CreateHistograms";
876 //====================================================================//
878 // Try to recover canvas in case it was created already by another monitor
879 // If not existing, create it
880 fcMsSizeAll = dynamic_cast<TCanvas*>(gROOT->FindObject("cMsSizeAll"));
881 if (NULL == fcMsSizeAll) {
882 fcMsSizeAll = new TCanvas("cMsSizeAll",
883 "Evolution of MS size in last 300 s"); //, w, h);
884 fcMsSizeAll->Divide(1, 8);
885 LOG(info) << "Created MS size canvas in Much monitor";
886 //server->Register("/canvases", fcMsSizeAll); //closed by me
887 AddCanvasToVector(fcMsSizeAll, "canvases");
888 } // if( NULL == fcMsSizeAll )
889 else
890 LOG(info) << "Recovered MS size canvas in Much monitor";
891 //====================================================================//
892
893 /*****************************/
894 return kTRUE;
895}
896
897Bool_t CbmMcbm2018MonitorAlgoMuchLite::ProcessTs(const fles::Timeslice& ts)
898{
899 fulCurrentTsIdx = ts.index();
900 fdTsStartTime = static_cast<Double_t>(ts.descriptor(0, 0).idx);
901
903 if (0 == fulCurrentTsIdx) return kTRUE;
904
906 if (-1.0 == fdTsCoreSizeInNs) {
907 fuNbCoreMsPerTs = ts.num_core_microslices();
908 fuNbOverMsPerTs = ts.num_microslices(0) - ts.num_core_microslices();
911 LOG(info) << "Timeslice parameters: each TS has " << fuNbCoreMsPerTs << " Core MS and " << fuNbOverMsPerTs
912 << " Overlap MS, for a core duration of " << fdTsCoreSizeInNs << " ns and a full duration of "
913 << fdTsFullSizeInNs << " ns";
914
918 LOG(info) << "In each TS " << fuNbMsLoop << " MS will be looped over";
919 } // if( -1.0 == fdTsCoreSizeInNs )
920
923 // LOG(info) << Form( "TS %5d Start %12f Stop %12f", fulCurrentTsIdx, fdTsStartTime, fdTsStopTimeCore );
924
926 for (fuMsIndex = 0; fuMsIndex < fuNbMsLoop; fuMsIndex++) {
928 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
929 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
930
931 if (kFALSE == ProcessMs(ts, uMsComp, fuMsIndex)) {
932 LOG(error) << "Failed to process ts " << fulCurrentTsIdx << " MS " << fuMsIndex << " for component " << uMsComp;
933 return kFALSE;
934 } // if( kFALSE == ProcessMs( ts, uMsCompIdx, fuMsIndex ) )
935 // LOG(info) << "TS index : " << fulCurrentTsIdx << " end processing MS";
936 } // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
937 /*
939 std::sort( fvmHitsInMs.begin(), fvmHitsInMs.end() );
940
942 for( auto itHitIn = fvmHitsInMs.begin(); itHitIn < fvmHitsInMs.end(); ++itHitIn )
943 {
944 UInt_t uFebIdx = itHitIn->GetAsic() / fUnpackPar->GetNbAsicsPerFeb()
945 + ( itHitIn->GetDpb() * fUnpackPar->GetNbCrobsPerDpb() + itHitIn->GetCrob() )
946 * fUnpackPar->GetNbFebsPerCrob();
947 UInt_t uChanInFeb = itHitIn->GetChan()
948 + fUnpackPar->GetNbChanPerAsic() * (itHitIn->GetAsic() % fUnpackPar->GetNbAsicsPerFeb());
949
950 ULong64_t ulTimeInNs = static_cast< ULong64_t >( itHitIn->GetTs() * stsxyter::kdClockCycleNs - fdTimeOffsetNs );
951
952 fDigiVect.push_back( CbmTofDigi( fviFebAddress[ uFebIdx ], uChanInFeb, ulTimeInNs, itHitIn->GetAdc() ) );
953 } // for( auto itHitIn = fvmHitsInMs.begin(); itHitIn < fvmHitsInMs.end(); ++itHitIn )
954*/
956 fvmHitsInMs.clear();
957 } // for( fuMsIndex = 0; fuMsIndex < uNbMsLoop; fuMsIndex ++ )
958
960 fvmHitsInMs.clear();
961 /*
962 for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
963 {
964 fvmHitsInMs[ uDpb ].clear();
965 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
966*/
968 if (fbMonitorMode) {
969 //if (kFALSE == FillHistograms()) {
970 /* if (kFALSE == CreateHistograms()) {
971 LOG(error) << "Failed to fill histos in ts " << fulCurrentTsIdx;
972 return kFALSE;
973 }*/ // if( kFALSE == FillHistograms() ) //closed by me
974 } // if( fbMonitorMode )
975
976 return kTRUE;
977}
978
979Bool_t CbmMcbm2018MonitorAlgoMuchLite::ProcessMs(const fles::Timeslice& ts, size_t uMsComp, size_t uMsIdx)
980{
981 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
982 fuCurrentEquipmentId = msDescriptor.eq_id;
983 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsComp, uMsIdx));
984
985 fulCurrentTsIdx = ts.index();
986 if (0 == fvbMaskedComponents.size()) fvbMaskedComponents.resize(ts.num_components(), kFALSE);
987
988 if (0 == fulCurrentTsIdx && 0 == uMsIdx) {
989 /*
990 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
991 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
992 static_cast<unsigned int>(msDescriptor.hdr_id),
993 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
994 static_cast<unsigned int>(msDescriptor.sys_id),
995 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
996 msDescriptor.size, msDescriptor.offset );
997*/
998 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
999 } // if( 0 == fulCurrentTsIndex && 0 == uMsIdx )
1000 if (kFALSE == fvbMaskedComponents[uMsComp] && 0 == uMsIdx) {
1001 auto it = fDpbIdIndexMap.find(fuCurrentEquipmentId);
1002 if (fDpbIdIndexMap.end() == it) {
1003 LOG(warning) << "Could not find the sDPB index for AFCK id 0x" << std::hex << fuCurrentEquipmentId << std::dec
1004 << " component " << uMsComp << "\n"
1005 << "If valid this index has to be added in the TOF parameter file in "
1006 "the RocIdArray field"
1007 << "\n"
1008 << "For now we remove it from the list of components analyzed";
1009 fvbMaskedComponents[uMsComp] = kTRUE;
1010 } // if( fDpbIdIndexMap.end() == it )
1011
1012 } // if( kFALSE == fvbMaskedComponents[ uMsComp ] && 0 == uMsIdx )
1013
1014 if (kTRUE == fvbMaskedComponents[uMsComp]) return kTRUE;
1015
1016 uint32_t uSize = msDescriptor.size;
1017 fulCurrentMsIdx = msDescriptor.idx;
1018 Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
1019 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
1020 << " has size: " << uSize;
1021
1022 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
1024 //LOG(info) <<" fuCurrDpbIdx "<<fuCurrDpbIdx<<" fuCurrDpbId "<<fuCurrDpbId;
1025
1026 if (uMsComp < kiMaxNbFlibLinks) {
1027 if (fdStartTimeMsSz < 0) fdStartTimeMsSz = dMsTime;
1028 fhMsSz[uMsComp]->Fill(uSize);
1029 fhMsSzTime[uMsComp]->Fill(dMsTime - fdStartTimeMsSz, uSize);
1030 } // if( uMsComp < kiMaxNbFlibLinks )
1031
1033 if (static_cast<Int_t>(fvdPrevMsTime[uMsComp]) < static_cast<Int_t>(dMsTime)) {
1035 UInt_t uFebIdxOffset = fUnpackParMuch->GetNbFebsPerDpb() * fuCurrDpbIdx;
1036 for (UInt_t uFebIdx = 0; uFebIdx < fUnpackParMuch->GetNbFebsPerDpb(); ++uFebIdx) {
1037 UInt_t uFebIdxInSyst = uFebIdxOffset + uFebIdx;
1038
1040 if (0 == fviFebTimeSecLastRateUpdate[uFebIdxInSyst]) {
1041 fviFebTimeSecLastRateUpdate[uFebIdxInSyst] = static_cast<Int_t>(dMsTime);
1042 fviFebCountsSinceLastRateUpdate[uFebIdxInSyst] = 0;
1043 for (UInt_t uChan = 0; uChan < fUnpackParMuch->GetNbChanPerFeb(); ++uChan)
1044 fvdFebChanCountsSinceLastRateUpdate[uFebIdxInSyst][uChan] = 0.0;
1045 continue;
1046 } // if( 0 == fviFebTimeSecLastRateUpdate[uFebIdxInSyst] )
1047
1048 Int_t iTimeInt = static_cast<Int_t>(dMsTime) - fviFebTimeSecLastRateUpdate[uFebIdxInSyst];
1049 if (fiTimeIntervalRateUpdate <= iTimeInt) {
1051 if (0 == fviFebCountsSinceLastRateUpdate[uFebIdxInSyst]) {
1052 fviFebTimeSecLastRateUpdate[uFebIdxInSyst] = static_cast<Int_t>(dMsTime);
1053 continue;
1054 } // if( 0 == fviFebCountsSinceLastRateUpdate[uFebIdxInSyst] )
1055
1056 for (UInt_t uChan = 0; uChan < fUnpackParMuch->GetNbChanPerFeb(); ++uChan) {
1057 fhMuchFebChanHitRateProf[uFebIdxInSyst]->Fill(uChan, fvdFebChanCountsSinceLastRateUpdate[uFebIdxInSyst][uChan]
1058 / iTimeInt);
1059 fvdFebChanCountsSinceLastRateUpdate[uFebIdxInSyst][uChan] = 0.0;
1060 } // for( UInt_t uChan = 0; uChan < fUnpackParMuch->GetNbChanPerFeb(); ++uChan )
1061
1062 fviFebTimeSecLastRateUpdate[uFebIdxInSyst] = static_cast<Int_t>(dMsTime);
1063 fviFebCountsSinceLastRateUpdate[uFebIdxInSyst] = 0;
1064 } // if( fiTimeIntervalRateUpdate <= iTimeInt )
1065 } // for( UInt_t uFebIdx = 0; uFebIdx < fUnpackParMuch->GetNbFebsPerDpb(); ++uFebIdx )
1066 } // if( static_cast<Int_t>( fvdMsTime[ uMsCompIdx ] ) < static_cast<Int_t>( dMsTime ) )
1067
1068 // Store MS time for coincidence plots
1069 fvdPrevMsTime[uMsComp] = dMsTime;
1070
1072 uint16_t uMsHeaderFlags = msDescriptor.flags;
1073 for (UInt_t uBit = 0; uBit < 16; ++uBit)
1074 fhMsStatusFieldType->Fill(uBit, (uMsHeaderFlags >> uBit) & 0x1);
1075
1077 UInt_t uTsMsbCycleHeader = std::floor(fulCurrentMsIdx / (stsxyter::kulTsCycleNbBins * stsxyter::kdClockCycleNs))
1079
1081 if (kTRUE == fbBinningFw)
1084
1085 if (kFALSE == fvuInitialHeaderDone[fuCurrDpbIdx]) {
1086 fvuInitialTsMsbCycleHeader[fuCurrDpbIdx] = uTsMsbCycleHeader;
1088 } // if( kFALSE == fvuInitialHeaderDone[ fuCurrDpbIdx ] )
1089 else if (uTsMsbCycleHeader != fvuCurrentTsMsbCycle[fuCurrDpbIdx] && 4194303 != fvulCurrentTsMsb[fuCurrDpbIdx]) {
1090 /*
1091 LOG(warning) << "TS MSB cycle from MS header does not match current cycle from data "
1092 << "for TS " << std::setw( 12 ) << fulCurrentTsIdx
1093 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
1094 << " MsInTs " << std::setw( 3 ) << uMsIdx
1095 << " ====> " << fvuCurrentTsMsbCycle[ fuCurrDpbIdx ]
1096 << " VS " << uTsMsbCycleHeader;
1097*/
1098 fvuCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
1099 }
1100
1101 // If not integer number of message in input buffer, print warning/error
1102 if (0 != (uSize % kuBytesPerMessage))
1103 LOG(error) << "The input microslice buffer does NOT "
1104 << "contain only complete nDPB messages!";
1105
1106 // Compute the number of complete messages in the input microslice buffer
1107 uint32_t uNbMessages = (uSize - (uSize % kuBytesPerMessage)) / kuBytesPerMessage;
1108
1109 // Prepare variables for the loop on contents
1110 const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>(msContent);
1111
1112 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
1113 // Fill message
1114 uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]);
1115
1116 stsxyter::Message mess(static_cast<uint32_t>(ulData & 0xFFFFFFFF));
1117
1118 // Print message if requested
1119 if (fbPrintMessages) mess.PrintMess(std::cout, fPrintMessCtrl);
1120 /*
1121 if( 1000 == fulCurrentTsIdx )
1122 {
1123 mess.PrintMess( std::cout, fPrintMessCtrl );
1124 } // if( 0 == fulCurrentTsIdx )
1125*/
1126 stsxyter::MessType typeMess = mess.GetMessType();
1127 fmMsgCounter[typeMess]++;
1128 // fhMuchMessType->Fill( static_cast< uint16_t > (typeMess) );
1129 // fhMuchMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) );
1130
1131 switch (typeMess) {
1133 // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific!
1134 UShort_t usElinkIdx = mess.GetLinkIndex();
1136 if (kTRUE == fbBinningFw) usElinkIdx = mess.GetLinkIndexHitBinning();
1137 fhElinkIdxHit->Fill(usElinkIdx);
1138 //LOG(info) << "Elink Id" << usElinkIdx ;
1139 UInt_t uCrobIdx = usElinkIdx / fUnpackParMuch->GetNbElinkPerCrob();
1140 Int_t uFebIdx = fUnpackParMuch->ElinkIdxToFebIdx(usElinkIdx);
1141 // if(usElinkIdx!=0)
1142 LOG(debug) << " usElinkIdx " << usElinkIdx << " uCrobIdx " << uCrobIdx << " uFebIdx " << uFebIdx
1143 << " MessageTypeValue " << static_cast<uint16_t>(typeMess);
1144 if (kTRUE == fbMuchMode) uFebIdx = usElinkIdx;
1145 fhMuchHitsElinkPerDpb->Fill(fuCurrDpbIdx, usElinkIdx);
1147 static_cast<uint16_t>(typeMess));
1148 if (-1 == uFebIdx) {
1149 LOG(warning) << "CbmMcbm2018MonitorMuchLite::DoUnpack => "
1150 << "Wrong elink Idx! Elink raw " << Form("%d remap %d", usElinkIdx, uFebIdx);
1151 continue;
1152 } // if( -1 == uFebIdx )
1153 //LOG(info) << " uCrobIdx "<<uCrobIdx<<" fUnpackParMuch->ElinkIdxToAsicIdx( usElinkIdx ) "<<fUnpackParMuch->ElinkIdxToAsicIdx( usElinkIdx )<<" usElinkIdx "<<usElinkIdx;
1154 UInt_t uAsicIdx =
1156 + fUnpackParMuch->ElinkIdxToAsicIdx(usElinkIdx);
1157
1158 FillHitInfo(mess, usElinkIdx, uAsicIdx, uMsIdx);
1159 break;
1160 } // case stsxyter::MessType::Hit :
1162
1164 static_cast<uint16_t>(typeMess));
1165
1166 FillTsMsbInfo(mess, uIdx, uMsIdx);
1167 break;
1168 } // case stsxyter::MessType::TsMsb :
1170
1172 static_cast<uint16_t>(typeMess));
1173
1174 // The first message in the TS is a special ones: EPOCH
1175 FillEpochInfo(mess);
1176
1177 if (0 < uIdx)
1178 LOG(info) << "CbmMcbm2018MonitorMuchLite::DoUnpack => "
1179 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
1180 break;
1181 } // case stsxyter::MessType::TsMsb :
1183 // UShort_t usElinkIdx = mess.GetStatusLink(); // commented 03.07.20 FU unused
1184 // UInt_t uCrobIdx = usElinkIdx / fUnpackParMuch->GetNbElinkPerCrob(); // commented 03.07.20 FU unused
1185 // Int_t uFebIdx = fUnpackParMuch->ElinkIdxToFebIdx( usElinkIdx );
1186 // UInt_t uAsicIdx = ( fuCurrDpbIdx * fUnpackParMuch->GetNbCrobsPerDpb() + uCrobIdx // commented 03.07.20 FU unused
1187 // ) * fUnpackParMuch->GetNbAsicsPerCrob()
1188 // + fUnpackParMuch->ElinkIdxToAsicIdx( usElinkIdx );
1189
1190 // UShort_t usStatusField = mess.GetStatusStatus(); // commented 03.07.20 FU unused
1191
1192 // fhStatusMessType->Fill( uAsicIdx, usStatusField );
1194 // UShort_t usElinkIdx = mess.GetLinkIndex();
1196 //if (kTRUE == fbBinningFw) usElinkIdx = mess.GetLinkIndexHitBinning();
1197 // fhElinkIdxStatus->Fill(usElinkIdx);
1199 static_cast<uint16_t>(typeMess));
1200
1201 if (fbPrintMessages) {
1202 std::cout << Form("DPB %2u TS %12llu MS %12llu mess %5u ", fuCurrDpbIdx, fulCurrentTsIdx, fulCurrentMsIdx,
1203 uIdx);
1204 mess.PrintMess(std::cout, fPrintMessCtrl);
1205 } // if( fbPrintMessages )
1206 // FillTsMsbInfo( mess );
1207 break;
1208 } // case stsxyter::MessType::Status
1210 // FillTsMsbInfo( mess );
1212 static_cast<uint16_t>(typeMess));
1213 break;
1214 } // case stsxyter::MessType::Empty :
1216 if (mess.IsMsErrorFlagOn()) {
1218 } // if( pMess[uIdx].IsMsErrorFlagOn() )
1219 break;
1220 } // case stsxyter::MessType::EndOfMs :
1222 break;
1223 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
1224 default: {
1225 LOG(fatal) << "CbmMcbm2018MonitorMuchLite::DoUnpack => "
1226 << "Unknown message type, should never happen, stopping "
1227 "here! Type found was: "
1228 << static_cast<int>(typeMess);
1229 }
1230 } // switch( mess.GetMessType() )
1231 } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx )
1232
1233 //LOG(info) << "TS index: " << fulCurrentTsIdx << "a processing MS done";
1234 return kTRUE;
1235}
1236
1237void CbmMcbm2018MonitorAlgoMuchLite::FillHitInfo(stsxyter::Message mess, const UShort_t& /*usElinkIdx*/,
1238 const UInt_t& uAsicIdx, const UInt_t& /*uMsIdx*/)
1239{
1240 UShort_t usChan = mess.GetHitChannel();
1241 UShort_t usRawAdc = mess.GetHitAdc();
1242 UShort_t usRawTs = mess.GetHitTime();
1243
1245 if (kTRUE == fbBinningFw) usRawTs = mess.GetHitTimeBinning();
1246 //LOG(debug) << " AsicIdx " << uAsicIdx << " Channel Id " << usChan << " Adc " << usRawAdc << " Time " << usRawTs;
1247 //For MUCH each FEB has one StsXyter
1248 UInt_t uFebIdx = uAsicIdx;
1249 fhFEBcount->Fill(uFebIdx);
1250
1251 fhMuchFebChanCntRaw[uFebIdx]->Fill(usChan); //change the name of histogram
1252 fhMuchFebADC[uFebIdx]->Fill(usChan, usRawAdc);
1253 fvulChanLastHitTime[uAsicIdx][usChan] = usRawTs;
1254 fvulChanLastHitTime[uAsicIdx][usChan] +=
1255 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
1256 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
1258 if (kTRUE == fbBinningFw)
1259 fvulChanLastHitTime[uAsicIdx][usChan] =
1260 usRawTs
1261 + static_cast<ULong64_t>(stsxyter::kuHitNbTsBinsBinning) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
1262 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBinsBinning)
1263 * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
1264
1265 // Convert the Hit time in bins to Hit time in ns
1266 // Long64_t dHitTimeNs = fvulChanLastHitTime[uAsicIdx][usChan] * stsxyter::kdClockCycleNs;
1267
1268 fvdChanLastHitTime[uAsicIdx][usChan] = fvulChanLastHitTime[uAsicIdx][usChan] * stsxyter::kdClockCycleNs;
1269
1270 // Check Starting point of histos with time as X axis
1271 if (-1 == fdStartTime) fdStartTime = fvdChanLastHitTime[uAsicIdx][usChan];
1272
1273 Int_t constime = (fvdChanLastHitTime[uAsicIdx][usChan] - prevtime_new);
1274
1275 if (constime < 10000000) {
1276 if (usRawAdc > 1) { Counter1++; }
1277 Counter++;
1278 }
1279 else {
1280 //fhRate->Fill(Counter);
1281 // fhRateAdcCut->Fill(Counter1);
1282 Counter = 0;
1283 Counter1 = 0;
1284 prevtime_new = fvdChanLastHitTime[uAsicIdx][usChan];
1285 }
1286 // Fill histos with time as X axis
1287 Double_t dTimeSinceStartSec = (fvdChanLastHitTime[uAsicIdx][usChan] - fdStartTime) * 1e-9; //uTimeBin
1288 /* LOG(info) << "fvul Hit Time " << fvulChanLastHitTime[uAsicIdx][usChan] << " clock cycle Ns " << stsxyter::kdClockCycleNs;
1289 LOG(info) << "Last Hit Time " << fvdChanLastHitTime[uAsicIdx][usChan];
1290 LOG(info) << "1st Hit Time " << fdStartTime; */
1291 //LOG(info) << "Spill Time " << dTimeSinceStartSec;
1292 fhMuchFebSpill[uFebIdx]->Fill(dTimeSinceStartSec);
1293 fhMuchFebChanCntRaw[uFebIdx]->Fill(usChan);
1294 fhMuchChannelTime[uFebIdx]->Fill(dTimeSinceStartSec, usChan);
1295
1296 //---------------------------------------
1297 /* Below code for Monitoring Trapezoidal shape of REAL GEM and RPC Module. RealX and RealY taken from par file. */
1298 //Below FebID is according to FEB Position in Module GEM A or Module GEM B (Carefully write MUCH Par file)
1299 /*
1300 Int_t FebId = fUnpackParMuch->GetFebId(uAsicIdx);
1301
1302 //UInt_t uChanInFeb = usChan + fUnpackParMuch->GetNbChanPerAsic() * (uAsicIdx % fUnpackParMuch->GetNbAsicsPerFeb());
1303 Int_t ModuleNr = fUnpackParMuch->GetModule(uAsicIdx);
1304 Int_t sector = fUnpackParMuch->GetPadXA(FebId, usChan);
1305 Int_t channel = fUnpackParMuch->GetPadYA(FebId, usChan);
1306
1307 //Convert into Real X Y Position
1308 Double_t ActualX = fUnpackParMuch->GetRealX(channel, sector);
1309 Double_t ActualY = fUnpackParMuch->GetRealPadSize(channel, sector);
1310
1311 //Converting Module (Small side up)
1312 ActualX = 1000 - ActualX;
1313 channel = 96 - channel;
1314
1315 LOG(debug) << "Module Nr " << ModuleNr << " Sector Nr " << sector << " Channel Nr " << channel << "Actual X "
1316 << ActualX << "Actual Y " << ActualY << "uAsicIdx " << uAsicIdx;
1317
1318 fHistPadDistr[ModuleNr]->Fill(sector, channel);
1319 fRealHistPadDistr[ModuleNr]->Fill(ActualY, ActualX);
1320 */
1321 //----------------------------------------------------------
1322}
1323
1324void CbmMcbm2018MonitorAlgoMuchLite::FillTsMsbInfo(stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/)
1325{
1326 UInt_t uVal = mess.GetTsMsbVal();
1328 if (kTRUE == fbBinningFw) uVal = mess.GetTsMsbValBinning();
1329
1330 // Update Status counters
1331 if (uVal < fvulCurrentTsMsb[fuCurrDpbIdx]) {
1332
1334 } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
1336 /*
1337 ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins )
1338 * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx])
1339 + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins )
1340 * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] );
1341*/
1342}
1343
1345{
1346 // UInt_t uVal = mess.GetEpochVal();
1347 // UInt_t uCurrentCycle = uVal % stsxyter::kulTsCycleNbBins;
1348}
1349
1351{
1353 TFile* oldFile = gFile;
1354 TDirectory* oldDir = gDirectory;
1355
1356 TFile* histoFile = NULL;
1357 if ("" != sFileName) {
1358 // open separate histo file in recreate mode
1359 histoFile = new TFile(sFileName, "RECREATE");
1360 histoFile->cd();
1361 } // if( "" != sFileName )
1362
1363 /***************************/
1364 gDirectory->mkdir("Much_Raw");
1365 gDirectory->cd("Much_Raw");
1366
1367 for (UInt_t uModuleId = 0; uModuleId < 2; ++uModuleId) {
1368 fHistPadDistr[uModuleId]->Write();
1369 fRealHistPadDistr[uModuleId]->Write();
1370 // fhMuchFebDuplicateHitProf[uModuleId]->Write();
1371 }
1372 // fhRate->Write();
1373 // fhRateAdcCut->Write();
1374 fhFEBcount->Write();
1375 // fhMuchMessType->Write();
1376 // fhMuchSysMessType->Write();
1377 // fhMuchMessTypePerDpb->Write();
1378 // fhMuchSysMessTypePerDpb->Write();
1379 // fhStatusMessType->Write();
1380 fhMsStatusFieldType->Write();
1381 fhMuchHitsElinkPerDpb->Write();
1382 // fhMuchFebChanAdcRaw_combined->Write();
1383 fhDpbMsErrors->Write();
1384 gDirectory->cd("..");
1385 /***************************/
1386
1387 /***************************/
1388 gDirectory->mkdir("Much_Feb");
1389 gDirectory->cd("Much_Feb");
1390 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
1391 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
1392 fhMuchFebChanCntRaw[uFebIdx]->Write();
1393 fhMuchFebSpill[uFebIdx]->Write();
1394 fhMuchChannelTime[uFebIdx]->Write();
1395 fhMuchFebADC[uFebIdx]->Write();
1396 //fhMuchFebChanCntRawGood[ uFebIdx ]->Write();
1397 // fhMuchFebChanAdcRaw[ uFebIdx ]->Write();
1398 // fhMuchFebChanAdcRawProf[ uFebIdx ]->Write();
1399 //fhMuchFebChanAdcCal[ uFebIdx ]->Write();
1400 //fhMuchFebChanAdcCalProf[ uFebIdx ]->Write();
1401 // fhMuchFebChanRawTs[ uFebIdx ]->Write();
1402 // fhMuchFebChanHitRateProf[ uFebIdx ]->Write();
1403 //fhMuchFebAsicHitRateEvo[ uFebIdx ]->Write();
1404 // fhMuchFebHitRateEvo[ uFebIdx ]->Write();
1405 // fhMuchFebHitRateEvo_mskch[ uFebIdx ]->Write();
1406 // fhMuchFebHitRateEvo_mskch_adccut[ uFebIdx ]->Write();
1407 // fhMuchFebHitRateEvo_WithoutDupli[ uFebIdx ]->Write();
1408 /*fhMuchFebChanHitRateEvoLong[ uFebIdx ]->Write();
1409 fhMuchFebAsicHitRateEvoLong[ uFebIdx ]->Write();
1410 fhMuchFebHitRateEvoLong[ uFebIdx ]->Write();
1411 fhMuchFebChanDistT[ uFebIdx ]->Write();
1412 for( UInt_t uFebIdxB = uFebIdx; uFebIdxB < fuNbFebs; ++uFebIdxB )
1413 {
1414 fhMuchFebChanDtCoinc[ uFebIdx ][ uFebIdxB ]->Write();
1415 fhMuchFebChanCoinc[ uFebIdx ][ uFebIdxB ]->Write();
1416 } // for( UInt_t uFebIdxB = uFebIdx; uFebIdxB < fuNbFebs; ++uFebIdxB )*/
1417 } // if( kTRUE == fUnpackParMuch->IsFebActive( uFebIdx ) )
1418 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
1419 gDirectory->cd("..");
1420 /***************************/
1421
1422 /***************************/
1423 // Flib Histos
1424 gDirectory->mkdir("Flib_Raw");
1425 gDirectory->cd("Flib_Raw");
1426 for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks++) {
1427 TString sMsSzName = Form("MsSz_link_%02u", uLinks);
1428 if (fHM->Exists(sMsSzName.Data())) fHM->H1(sMsSzName.Data())->Write();
1429
1430 sMsSzName = Form("MsSzTime_link_%02u", uLinks);
1431 if (fHM->Exists(sMsSzName.Data())) fHM->P1(sMsSzName.Data())->Write();
1432 } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++)
1433
1434 /***************************/
1435
1436 if ("" != sFileName) {
1437 // Restore original directory position
1438 histoFile->Close();
1439 } // if( "" != sFileName )
1440
1442 gFile = oldFile;
1443 gDirectory = oldDir;
1444}
1445
1447{
1448 LOG(info) << "Reseting all Much histograms.";
1449
1450 for (UInt_t uModuleId = 0; uModuleId < 2; ++uModuleId) {
1451 //fHistPadDistr[uModuleId]->Reset();
1452 //fRealHistPadDistr[uModuleId]->Reset();
1453 fhMuchFebDuplicateHitProf[uModuleId]->Reset();
1454 }
1455 // fhRate->Reset();
1456 // fhRateAdcCut->Reset();
1457 fhFEBcount->Reset();
1458 // fhMuchMessType->Reset();
1459 // fhMuchSysMessType->Reset();
1460 // fhMuchMessTypePerDpb->Reset();
1461 // fhMuchSysMessTypePerDpb->Reset();
1462 // fhStatusMessType->Reset();
1463 fhMsStatusFieldType->Reset();
1464 fhMuchHitsElinkPerDpb->Reset();
1465 // fhMuchFebChanAdcRaw_combined->Reset();
1466 fhDpbMsErrors->Reset();
1467
1468 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
1469 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
1470 fhMuchFebChanCntRaw[uFebIdx]->Reset();
1471 fhMuchFebSpill[uFebIdx]->Reset();
1472 fhMuchChannelTime[uFebIdx]->Reset();
1473 fhMuchFebADC[uFebIdx]->Reset();
1474 //fhMuchFebChanCntRawGood[ uFebIdx ]->Reset();
1476 //fhMuchFebChanAdcRawProf[ uFebIdx ]->Reset();
1477 //fhMuchFebChanAdcCal[ uFebIdx ]->Reset();
1478 //fhMuchFebChanAdcCalProf[ uFebIdx ]->Reset();
1480 // fhMuchFebChanHitRateEvo[ uFebIdx ]->Reset();
1481 // fhMuchFebChanHitRateProf[ uFebIdx ]->Reset();
1482 //fhMuchFebAsicHitRateEvo[ uFebIdx ]->Reset();
1484 // fhMuchFebHitRateEvo_mskch[ uFebIdx ]->Reset();
1485 // fhMuchFebHitRateEvo_mskch_adccut[ uFebIdx ]->Reset();
1486 // fhMuchFebHitRateEvo_WithoutDupli[ uFebIdx ]->Reset();
1487 /*fhMuchFebChanHitRateEvoLong[ uFebIdx ]->Reset();
1488 fhMuchFebAsicHitRateEvoLong[ uFebIdx ]->Reset();
1489 fhMuchFebHitRateEvoLong[ uFebIdx ]->Reset();
1490 fhMuchFebChanDistT[ uFebIdx ]->Reset();
1491 for( UInt_t uFebIdxB = uFebIdx; uFebIdxB < fuNbFebs; ++uFebIdxB )
1492 {
1493 fhMuchFebChanDtCoinc[ uFebIdx ][ uFebIdxB ]->Reset();
1494 fhMuchFebChanCoinc[ uFebIdx ][ uFebIdxB ]->Reset();
1495 } // for( UInt_t uFebIdxB = uFebIdx; uFebIdxB < fuNbFebs; ++uFebIdxB )*/
1496 } // if( kTRUE == fUnpackParMuch->IsFebActive( uFebIdx ) )
1497 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
1498
1499 for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks) {
1500 TString sMsSzName = Form("MsSz_link_%02u", uLinks);
1501 if (fHM->Exists(sMsSzName.Data())) fHM->H1(sMsSzName.Data())->Reset();
1502
1503 sMsSzName = Form("MsSzTime_link_%02u", uLinks);
1504 if (fHM->Exists(sMsSzName.Data())) fHM->P1(sMsSzName.Data())->Reset();
1505 } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks )
1506
1507 fdStartTime = -1;
1508 fdStartTimeMsSz = -1;
1509}
1510
1511void CbmMcbm2018MonitorAlgoMuchLite::SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize)
1512{
1513 TDatime* fRunStartDateTime = new TDatime(dateIn, timeIn);
1514 fiRunStartDateTimeSec = fRunStartDateTime->Convert();
1515 fiBinSizeDatePlots = iBinSize;
1516
1517 LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString();
1518}
1519
1522{
1523 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
1524 if (kTRUE == fUnpackParMuch->IsFebActive(uFebIdx)) {
1525 LOG(info) << Form(" ------------------ Noisy channels scan for FEB %2d ------------", uFebIdx);
1526 for (UInt_t uAsicIdx = 0; uAsicIdx < fUnpackParMuch->GetNbAsicsPerFeb(); ++uAsicIdx)
1527 for (UInt_t uChanIdx = 0; uChanIdx < fUnpackParMuch->GetNbChanPerAsic(); ++uChanIdx) {
1528 UInt_t uChanInFeb = uAsicIdx * fUnpackParMuch->GetNbChanPerAsic() + uChanIdx;
1529 if (dNoiseThreshold < fhMuchFebChanHitRateProf[uFebIdx]->GetBinContent(1 + uChanInFeb))
1530 LOG(info) << Form("Noisy Channel ASIC %d channel %3d (%4d) level %6.0f", uAsicIdx, uChanIdx, uChanInFeb,
1531 fhMuchFebChanHitRateProf[uFebIdx]->GetBinContent(1 + uChanInFeb));
1532
1533 } // for( UInt_t uChanIdx = 0; uChanIdx < fUnpackParMuch->GetNbChanPerAsic(); ++uChanIdx )
1534
1535 LOG(info) << " ---------------------------------------------------------------";
1536 } // if( kTRUE == fUnpackParMuch->IsFebActive( uFebIdx ) )
1537 } // for( UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx )
1538 return kTRUE;
1539}
1540
1541//-----------------------------------------------------------------//
1542
ClassImp(CbmConverterManager)
std::string FormatMsHeaderPrintout(const fles::MicrosliceDescriptor &msDescriptor)
Histogram manager.
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.
Bool_t ProcessTs(const fles::Timeslice &ts)
void FillHitInfo(stsxyter::Message mess, const UShort_t &usElinkIdx, const UInt_t &uAsicIdx, const UInt_t &uMsIdx)
Long64_t prevtime_new
Starting state book-keeping.
std::vector< UInt_t > fvuInitialHeaderDone
Current TS MSB cycle for DPB.
Int_t fiTimeIntervalRateUpdate
Mean Rate per channel plots.
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
UInt_t fuNbFebs
Array to hold the active flag for all CROBs, [ NbDpb ][ NbCrobPerDpb ].
std::map< UInt_t, UInt_t > fDpbIdIndexMap
Total number of STS DPBs in system.
void FillTsMsbInfo(stsxyter::Message mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
TH1 * fhElinkIdxHit
Number of hits in each MS for each Channel.
UInt_t fuCurrentEquipmentId
Current data properties.
UInt_t fuNbStsXyters
Number of StsXyter ASICs.
std::vector< std::vector< Double_t > > fvdChanLastHitTime
Last hit time in bins for each Channel.
static const Int_t kiMaxNbFlibLinks
/‍** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **‍/
std::vector< Double_t > fvdPrevMsTime
Last hit time in ns for each Channel.
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
std::vector< stsxyter::FinalHit > fvmHitsInMs
Hits time-sorting.
Bool_t fbMuchMode
Switch ON the filling of a minimal set of histograms.
Int_t fiBinSizeDatePlots
Start of run time since "epoch" in s, for the plots with date as X axis.
std::vector< std::vector< stsxyter::FinalHit > > fvmAsicHitsInMs
Last hit ADC in bins in each MS for each Channel.
std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs
Last hit time in bins in each MS for each Channel.
std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs
std::vector< ULong64_t > fvulCurrentTsMsb
Bin size in s for the plots with date as X axis.
Int_t fiRunStartDateTimeSec
Index of the DPB from which the MS currently unpacked is coming.
Bool_t ScanForNoisyChannels(Double_t dNoiseThreshold=1e3)
---------------------------------------------------------------—///
std::vector< UInt_t > fvuElinkLastTsHit
TS MSB cycle from MS header in 1st MS for DPB.
UInt_t fuMsIndex
End Time in ns of current TS Core from the index of the first MS first component.
CbmHistManager * fHM
Coincidences in sorted hits.
std::vector< TH2 * > fHistPadDistr
Plots per FEB-8.
std::vector< UInt_t > fvuInitialTsMsbCycleHeader
Flag set after seeing MS header in 1st MS for DPB.
std::vector< std::vector< Double_t > > fvdFebChanCountsSinceLastRateUpdate
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
Number of StsXyter ASICs.
Bool_t fbBinningFw
=> Quick and dirty hack for binning FW!!!
std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs
Header time of each MS.
std::vector< std::vector< ULong64_t > > fvulChanLastHitTime
std::vector< Double_t > fvdMsTime
Header time of previous MS per link.
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
void SetRunStart(Int_t dateIn, Int_t timeIn, Int_t iBinSize=5)
std::vector< UInt_t > fvuCurrentTsMsbCycle
Current TS MSB for each DPB.
std::vector< std::vector< Double_t > > fdMuchFebChanLastTimeForDist
std::vector< std::vector< stsxyter::FinalHit > > fvmFebHitsInMs
All hits (time in bins, ADC in bins, asic, channel) in last TS, per ASIC, sorted with "<" operator.
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
Bool_t fbPrintMessages
Task configuration values.
std::vector< std::vector< Bool_t > > fvbCrobActiveFlag
Map of DPB Identifier to DPB index.
std::vector< TProfile * > fhMuchFebDuplicateHitProf
Int_t ElinkIdxToFebIdx(UInt_t uElink)
static constexpr UInt_t GetNbElinkPerCrob()
static constexpr UInt_t GetNbChanPerAsic()
static constexpr UInt_t GetNbAsicsPerCrob()
static constexpr UInt_t GetNbChanPerFeb()
UInt_t GetDpbId(UInt_t uDpbIdx)
UInt_t ElinkIdxToAsicIdx(UInt_t uElink)
Bool_t IsCrobActive(UInt_t uDpbIdx, UInt_t uCrobIdx)
Bool_t IsFebActive(UInt_t uFebInSystIdx)
static constexpr UInt_t GetNbFebsPerDpb()
static constexpr UInt_t GetNbCrobsPerDpb()
static constexpr UInt_t GetNbAsicsPerFeb()
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
void AddCanvasToVector(TCanvas *pointer, std::string sFolder="")
Data class with information on a STS local track.
XPU_D uint32_t GetTsMsbValBinning() const
For TS MSB data: Returns the TS MSB 29 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 GetLinkIndexHitBinning() const
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 GetHitTimeBinning() const
XPU_D uint16_t GetMsErrorType() const
For End of MS data: Returns the MS error type field (2 bit field)
XPU_D bool IsMsErrorFlagOn() const
For End of MS data: Returns the MS error flag (1 bit field)
static constexpr uint32_t kuHitNbTsBinsBinning
static constexpr uint64_t kulTsCycleNbBins
static constexpr uint64_t kulTsCycleNbBinsBinning
static constexpr uint32_t kuHitNbTsBins
static constexpr uint32_t kuHitNbAdcBins
Status/properties constants.
static constexpr double kdClockCycleNs
MessType
Message types.