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