CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018UnpackerAlgoSts.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2020 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5// -----------------------------------------------------------------------------
6// ----- -----
7// ----- CbmMcbm2018UnpackerAlgoSts -----
8// ----- Created 26.01.2019 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
13
15#include "CbmMcbm2018StsPar.h"
16
17#include <Logger.h>
18
19#include "TCanvas.h"
20#include "TH1.h"
21#include "TH2.h"
22#include "TList.h"
23#include "TProfile.h"
24#include "TROOT.h"
25#include "TString.h"
26
27#include <fstream>
28#include <iomanip>
29#include <iostream>
30
31#include <stdint.h>
32
33// -------------------------------------------------------------------------
36 ,
38 fbMonitorMode(kFALSE)
39 , fbDebugMonitorMode(kFALSE)
40 , fvbMaskedComponents()
41 , fUnpackPar(nullptr)
42 , fuNbModules(0)
43 , fviModuleType()
44 , fviModAddress()
45 , fuNrOfDpbs(0)
46 , fDpbIdIndexMap()
47 , fvbCrobActiveFlag()
48 , fuNbFebs(0)
49 , fuNbStsXyters(0)
50 , fviFebModuleIdx()
51 , fviFebModuleSide()
52 , fviFebType()
53 , fviFebAddress()
54 , fviFebSide()
55 , fvdFebAdcGain()
56 , fvdFebAdcOffs()
57 , fdTimeOffsetNs(0.0)
58 , fvdTimeOffsetNsAsics()
59 , fbUseChannelMask(kFALSE)
60 , fvvbMaskedChannels()
61 , fdAdcCut(0)
62 , fulCurrentTsIdx(0)
63 , fulCurrentMsIdx(0)
64 , fdTsStartTime(-1.0)
65 , fdTsStopTimeCore(-1.0)
66 , fdMsTime(-1.0)
67 , fuMsIndex(0)
68 , fmMsgCounter()
69 , fuCurrentEquipmentId(0)
70 , fuCurrDpbId(0)
71 , fuCurrDpbIdx(0)
72 , fiRunStartDateTimeSec(-1)
73 , fiBinSizeDatePlots(-1)
74 , fvulCurrentTsMsb()
75 , fdStartTime(0.0)
76 , fdStartTimeMsSz(0.0)
77 , ftStartTimeUnix(std::chrono::steady_clock::now())
78 , fvmHitsInMs()
79 , fvvusLastTsChan()
80 , fvvusLastAdcChan()
81 , fvvusLastTsMsbChan()
82 , fvvusLastTsMsbCycleChan()
83 , fhDigisTimeInRun(nullptr)
84/*
85 fvhHitsTimeToTriggerRaw(),
86 fvhMessDistributionInMs(),
87 fhEventNbPerTs( nullptr ),
88 fcTimeToTrigRaw( nullptr )
89*/
90{
91}
93{
95 fvmHitsInMs.clear();
96 /*
97 for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
98 {
99 fvmHitsInMs[ uDpb ].clear();
100 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
101*/
102 if (nullptr != fParCList) delete fParCList;
103 if (nullptr != fUnpackPar) delete fUnpackPar;
104}
105
106// -------------------------------------------------------------------------
108{
109 LOG(info) << "Initializing mCBM STS 2019 unpacker algo";
110
111 return kTRUE;
112}
120
121// -------------------------------------------------------------------------
123{
124 LOG(info) << "Init parameter containers for CbmMcbm2018UnpackerAlgoSts";
125 Bool_t initOK = ReInitContainers();
126
127 return initOK;
128}
130{
131 LOG(info) << "**********************************************";
132 LOG(info) << "ReInit parameter containers for CbmMcbm2018UnpackerAlgoSts";
133
134 fUnpackPar = (CbmMcbm2018StsPar*) fParCList->FindObject("CbmMcbm2018StsPar");
135 if (nullptr == fUnpackPar) return kFALSE;
136
137 Bool_t initOK = InitParameters();
138
139 return initOK;
140}
142{
143 if (nullptr == fParCList) fParCList = new TList();
144 fUnpackPar = new CbmMcbm2018StsPar("CbmMcbm2018StsPar");
145 fParCList->Add(fUnpackPar);
146
147 return fParCList;
148}
150{
152 LOG(info) << "Nr. of STS Modules: " << fuNbModules;
153
156 for (UInt_t uModIdx = 0; uModIdx < fuNbModules; ++uModIdx) {
157 fviModuleType[uModIdx] = fUnpackPar->GetModuleType(uModIdx);
158 fviModAddress[uModIdx] = fUnpackPar->GetModuleAddress(uModIdx);
159 LOG(info) << "Module #" << std::setw(2) << uModIdx << " Type " << std::setw(4) << fviModuleType[uModIdx]
160 << " Address 0x" << std::setw(8) << std::hex << fviModAddress[uModIdx] << std::dec;
161 } // for( UInt_t uModIdx = 0; uModIdx < fuNbModules; ++uModIdx)
162
164 LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs;
165
166 fDpbIdIndexMap.clear();
167 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
168 fDpbIdIndexMap[fUnpackPar->GetDpbId(uDpb)] = uDpb;
169 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = 0x" << std::setw(4) << std::hex
170 << fUnpackPar->GetDpbId(uDpb) << std::dec << " => " << fDpbIdIndexMap[fUnpackPar->GetDpbId(uDpb)];
171 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
172
174 LOG(info) << "Nr. of FEBs: " << fuNbFebs;
175
177 LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters;
178
179 if (fvdTimeOffsetNsAsics.size() < fuNbStsXyters) {
181 } // if( fvdTimeOffsetNsAsics.size() < fuNbStsXyters )
182
186 fviFebType.resize(fuNrOfDpbs);
187 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
191 fviFebType[uDpb].resize(fUnpackPar->GetNbCrobsPerDpb());
192 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx) {
193 fvbCrobActiveFlag[uDpb][uCrobIdx] = fUnpackPar->IsCrobActive(uDpb, uCrobIdx);
194
195 fviFebModuleIdx[uDpb][uCrobIdx].resize(fUnpackPar->GetNbFebsPerCrob());
196 fviFebModuleSide[uDpb][uCrobIdx].resize(fUnpackPar->GetNbFebsPerCrob());
197 fviFebType[uDpb][uCrobIdx].resize(fUnpackPar->GetNbFebsPerCrob(), -1);
198 for (UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++uFebIdx) {
199 fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx] = fUnpackPar->GetFebModuleIdx(uDpb, uCrobIdx, uFebIdx);
200 fviFebModuleSide[uDpb][uCrobIdx][uFebIdx] = fUnpackPar->GetFebModuleSide(uDpb, uCrobIdx, uFebIdx);
201
202 fvbFebPulser.push_back(fUnpackPar->IsFebPulser(uDpb, uCrobIdx, uFebIdx));
203 fvdFebAdcGain.push_back(fUnpackPar->GetFebAdcGain(uDpb, uCrobIdx, uFebIdx));
204 fvdFebAdcOffs.push_back(fUnpackPar->GetFebAdcOffset(uDpb, uCrobIdx, uFebIdx));
205
206 if (0 <= fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]
207 && static_cast<UInt_t>(fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]) < fuNbModules
208 && 0 <= fviFebModuleSide[uDpb][uCrobIdx][uFebIdx] && fviFebModuleSide[uDpb][uCrobIdx][uFebIdx] < 2) {
209 switch (fviModuleType[fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]]) {
210 case 0: // FEB-8-1 with ZIF connector on the right
211 {
212 // P side (0) has type A (0)
213 // N side (1) has type B (1)
214 fviFebType[uDpb][uCrobIdx][uFebIdx] = fviFebModuleSide[uDpb][uCrobIdx][uFebIdx];
215
222 fviFebAddress.push_back(fviModAddress[fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]]
223 + (fviFebModuleSide[uDpb][uCrobIdx][uFebIdx] << 25));
224 fviFebSide.push_back(fviFebModuleSide[uDpb][uCrobIdx][uFebIdx]);
225 break;
226 } // case 0: // FEB-8-1 with ZIF connector on the right
227 case 1: // FEB-8-1 with ZIF connector on the left
228 {
229 // P side (0) has type B (1)
230 // N side (1) has type A (0)
231 fviFebType[uDpb][uCrobIdx][uFebIdx] = !(fviFebModuleSide[uDpb][uCrobIdx][uFebIdx]);
232
239 fviFebAddress.push_back(fviModAddress[fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]]
240 + ((!fviFebModuleSide[uDpb][uCrobIdx][uFebIdx]) << 25));
241 fviFebSide.push_back(fviFebModuleSide[uDpb][uCrobIdx][uFebIdx]);
242 break;
243 } // case 1: // FEB-8-1 with ZIF connector on the left
244 default:
245 LOG(fatal) << Form("Bad module type for DPB #%02u CROB #%u FEB %02u: %d", uDpb, uCrobIdx, uFebIdx,
246 fviModuleType[fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]]);
247 break;
248 } // switch( fviModuleType[ fviFebModuleIdx[ uDpb ][ uCrobIdx ][ uFebIdx ] ] )
249 } // FEB active and module index OK
250 else if (-1 == fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx] || -1 == fviFebModuleSide[uDpb][uCrobIdx][uFebIdx]) {
251 fviFebAddress.push_back(0);
252 fviFebSide.push_back(-1);
253 } // Module index or type is set to inactive
254 else {
255 LOG(fatal) << Form("Bad module Index and/or Side for DPB #%02u CROB "
256 "#%u FEB %02u: %d %d",
257 uDpb, uCrobIdx, uFebIdx, fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx],
258 fviFebModuleSide[uDpb][uCrobIdx][uFebIdx]);
259 } // Bad module index or type for this FEB
260 } // for( UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++ uFebIdx )
261 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx )
262 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
263
264 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
265 TString sPrintoutLine = Form("DPB #%02u CROB Active ?: ", uDpb);
266 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx) {
267 sPrintoutLine += Form("%1u", (fvbCrobActiveFlag[uDpb][uCrobIdx] == kTRUE));
268 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx )
269 LOG(info) << sPrintoutLine;
270 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
271
272 UInt_t uGlobalFebIdx = 0;
273 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
274 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx) {
275 LOG(info) << Form("DPB #%02u CROB #%u: ", uDpb, uCrobIdx);
276 for (UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++uFebIdx) {
277 if (0 <= fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx])
278 LOG(info) << Form(" FEB #%02u (%02u): Mod. Idx = %03d Side %c (%2d) Type %c "
279 "(%2d) (Addr. 0x%08x) ADC gain %4.0f e- ADC Offs %5.0f e-",
280 uFebIdx, uGlobalFebIdx, fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx],
281 1 == fviFebModuleSide[uDpb][uCrobIdx][uFebIdx] ? 'N' : 'P',
282 fviFebModuleSide[uDpb][uCrobIdx][uFebIdx],
283 1 == fviFebType[uDpb][uCrobIdx][uFebIdx] ? 'B' : 'A', fviFebType[uDpb][uCrobIdx][uFebIdx],
284 fviFebAddress[uGlobalFebIdx], fvdFebAdcGain[uGlobalFebIdx], fvdFebAdcOffs[uGlobalFebIdx]);
285 else
286 LOG(info) << Form("Disabled FEB #%02u (%02u): Mod. Idx = %03d Side %c (%2d) Type %c "
287 "(%2d) (Addr. 0x%08x) ADC gain %4.0f e- ADC Offs %5.0f e-",
288 uFebIdx, uGlobalFebIdx, fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx],
289 1 == fviFebModuleSide[uDpb][uCrobIdx][uFebIdx] ? 'N' : 'P',
290 fviFebModuleSide[uDpb][uCrobIdx][uFebIdx],
291 1 == fviFebType[uDpb][uCrobIdx][uFebIdx] ? 'B' : 'A', fviFebType[uDpb][uCrobIdx][uFebIdx],
292 fviFebAddress[uGlobalFebIdx], fvdFebAdcGain[uGlobalFebIdx], fvdFebAdcOffs[uGlobalFebIdx]);
293 uGlobalFebIdx++;
294 } // for( UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++ uFebIdx )
295 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx )
296 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
297
298 if (fbBinningFw) LOG(info) << "Unpacking data in bin sorter FW mode";
299 else
300 LOG(info) << "Unpacking data in full time sorter FW mode (legacy)";
301
302 // Internal status initialization
305 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
306 fvulCurrentTsMsb[uDpb] = 0;
307 fvuCurrentTsMsbCycle[uDpb] = 0;
308 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
309
314 for (UInt_t uAsicIdx = 0; uAsicIdx < fuNbStsXyters; ++uAsicIdx) {
315 fvvusLastTsChan[uAsicIdx].resize(fUnpackPar->GetNbChanPerAsic(), 0);
316 fvvusLastAdcChan[uAsicIdx].resize(fUnpackPar->GetNbChanPerAsic(), 0);
317 fvvusLastTsMsbChan[uAsicIdx].resize(fUnpackPar->GetNbChanPerAsic(), 0);
319 } // for( UInt_t uAsicIdx = 0; uAsicIdx < fuNbStsXyters; ++ uAsicIdx )
320
321 return kTRUE;
322}
323// -------------------------------------------------------------------------
324
325void CbmMcbm2018UnpackerAlgoSts::AddMsComponentToList(size_t component, UShort_t usDetectorId)
326{
328 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
329 if (component == fvMsComponentsList[uCompIdx]) return;
330
332 fvMsComponentsList.push_back(component);
333
334 LOG(info) << "CbmMcbm2018UnpackerAlgoSts::AddMsComponentToList => Component " << component << " with detector ID 0x"
335 << std::hex << usDetectorId << std::dec << " added to list";
336}
337// -------------------------------------------------------------------------
338
339Bool_t CbmMcbm2018UnpackerAlgoSts::ProcessTs(const fles::Timeslice& ts)
340{
341 fulCurrentTsIdx = ts.index();
342 fdTsStartTime = static_cast<Double_t>(ts.descriptor(0, 0).idx);
343
345 if (0 == fulCurrentTsIdx) { return kTRUE; } // if( 0 == fulCurrentTsIdx )
346
348 if (-1.0 == fdTsCoreSizeInNs) {
349 fuNbCoreMsPerTs = ts.num_core_microslices();
350 fuNbOverMsPerTs = ts.num_microslices(0) - ts.num_core_microslices();
353 LOG(info) << "Timeslice parameters: each TS has " << fuNbCoreMsPerTs << " Core MS and " << fuNbOverMsPerTs
354 << " Overlap MS, for a core duration of " << fdTsCoreSizeInNs << " ns and a full duration of "
355 << fdTsFullSizeInNs << " ns";
356
360 LOG(info) << "In each TS " << fuNbMsLoop << " MS will be looped over";
361 } // if( -1.0 == fdTsCoreSizeInNs )
362
365 // LOG(info) << Form( "TS %5d Start %12f Stop %12f", fulCurrentTsIdx, fdTsStartTime, fdTsStopTimeCore );
366
368 for (fuMsIndex = 0; fuMsIndex < fuNbMsLoop; fuMsIndex++) {
370 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
371 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
372
373 if (kFALSE == ProcessMs(ts, uMsComp, fuMsIndex)) {
374 LOG(error) << "Failed to process ts " << fulCurrentTsIdx << " MS " << fuMsIndex << " for component " << uMsComp;
375 return kFALSE;
376 } // if( kFALSE == ProcessMs( ts, uMsCompIdx, fuMsIndex ) )
377 } // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
378
381 // std::sort( fvmHitsInMs.begin(), fvmHitsInMs.end() );
382
384 for (auto itHitIn = fvmHitsInMs.begin(); itHitIn < fvmHitsInMs.end(); ++itHitIn) {
385 /*
386 UInt_t uFebIdx = itHitIn->GetAsic() / fUnpackPar->GetNbAsicsPerFeb()
387 + ( itHitIn->GetDpb() * fUnpackPar->GetNbCrobsPerDpb() + itHitIn->GetCrob() )
388 * fUnpackPar->GetNbFebsPerCrob();
389*/
390 UInt_t uAsicIdx = itHitIn->GetAsic();
391 UInt_t uFebIdx = itHitIn->GetAsic() / fUnpackPar->GetNbAsicsPerFeb();
392 UInt_t uChanInMod =
393 itHitIn->GetChan() + fUnpackPar->GetNbChanPerAsic() * (itHitIn->GetAsic() % fUnpackPar->GetNbAsicsPerFeb());
397 if (0 == fviFebSide[uFebIdx])
398 uChanInMod = fUnpackPar->GetNbChanPerFeb() - uChanInMod - 1 // Invert channel order
399 + fUnpackPar->GetNbChanPerFeb(); // Offset for P (back) side
400
401 Double_t dTimeInNs = itHitIn->GetTs() * stsxyter::kdClockCycleNs - fdTimeOffsetNs;
402 if (uAsicIdx < fvdTimeOffsetNsAsics.size()) dTimeInNs -= fvdTimeOffsetNsAsics[uAsicIdx];
403 ULong64_t ulTimeInNs = static_cast<ULong64_t>(dTimeInNs);
404
405 Double_t dCalAdc = fvdFebAdcOffs[uFebIdx] + (itHitIn->GetAdc() - 1) * fvdFebAdcGain[uFebIdx];
406
407 if (0 == fviFebAddress[uFebIdx] || -1 == fviFebSide[uFebIdx]) {
408 LOG(error) << Form("Digi on disabled FEB %02u has address 0x%08x and side %d", uFebIdx, fviFebAddress[uFebIdx],
409 fviFebSide[uFebIdx]);
410 } // if( 0 == fviFebAddress[ uFebIdx ] || -1 == fviFebSide[ uFebIdx ] )
411
412
414 if (fbPulserOutput && fvbFebPulser[uFebIdx]) {
415 fPulserDigiVect.emplace_back(CbmStsDigi(fviFebAddress[uFebIdx], uChanInMod, ulTimeInNs, dCalAdc));
416 } // if (fvbFebPulser[uFebIdx])
417 else {
418 fDigiVect.emplace_back(fviFebAddress[uFebIdx], uChanInMod, ulTimeInNs, dCalAdc);
419 } // else of if (fvbFebPulser[uFebIdx])
420 } // for( auto itHitIn = fvmHitsInMs.begin(); itHitIn < fvmHitsInMs.end(); ++itHitIn )
421
423 fvmHitsInMs.clear();
424 } // for( fuMsIndex = 0; fuMsIndex < uNbMsLoop; fuMsIndex ++ )
425
427 fvmHitsInMs.clear();
428 /*
429 for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
430 {
431 fvmHitsInMs[ uDpb ].clear();
432 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
433*/
434
436 std::sort(fDigiVect.begin(), fDigiVect.end(),
437 [](const CbmStsDigi& a, const CbmStsDigi& b) -> bool { return a.GetTime() < b.GetTime(); });
438
440 if (fbPulserOutput) {
441 std::sort(fPulserDigiVect.begin(), fPulserDigiVect.end(),
442 [](const CbmStsDigi& a, const CbmStsDigi& b) -> bool { return a.GetTime() < b.GetTime(); });
443 }
444
446 if (fbMonitorMode) {
447 if (kFALSE == FillHistograms()) {
448 LOG(error) << "Failed to fill histos in ts " << fulCurrentTsIdx;
449 return kFALSE;
450 } // if( kFALSE == FillHistograms() )
451
453 fhVectorCapacity->Fill(fulCurrentTsIdx, fDigiVect.capacity());
454 } // if( fbMonitorMode )
455
456 if (fuTsMaxVectorSize < fDigiVect.size()) {
458 fDigiVect.shrink_to_fit();
460 } // if( fuTsMaxVectorSize < fDigiVect.size() )
461
462 return kTRUE;
463}
464
465Bool_t CbmMcbm2018UnpackerAlgoSts::ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx)
466{
467 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
468 fuCurrentEquipmentId = msDescriptor.eq_id;
469 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsCompIdx, uMsIdx));
470
471 uint32_t uSize = msDescriptor.size;
472 fulCurrentMsIdx = msDescriptor.idx;
473 // Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
474 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
475 << " has size: " << uSize;
476
477 if (0 == fvbMaskedComponents.size()) fvbMaskedComponents.resize(ts.num_components(), kFALSE);
478
479 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
480 // fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ];
481
483 auto it = fDpbIdIndexMap.find(fuCurrDpbId);
484 if (it == fDpbIdIndexMap.end()) {
485 if (kFALSE == fvbMaskedComponents[uMsCompIdx]) {
486 LOG(info) << "---------------------------------------------------------------";
487 /*
488 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
489 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
490 static_cast<unsigned int>(msDescriptor.hdr_id),
491 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
492 static_cast<unsigned int>(msDescriptor.sys_id),
493 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
494 msDescriptor.size, msDescriptor.offset );
495*/
496 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
497 LOG(warning) << "Could not find the sDPB index for AFCK id 0x" << std::hex << fuCurrDpbId << std::dec
498 << " in timeslice " << fulCurrentTsIdx << " in microslice " << uMsIdx << " component " << uMsCompIdx
499 << "\n"
500 << "If valid this index has to be added in the STS "
501 "parameter file in the DbpIdArray field";
502 fvbMaskedComponents[uMsCompIdx] = kTRUE;
503
506 if (1 == fulCurrentTsIdx) return kTRUE;
507 } // if( kFALSE == fvbMaskedComponents[ uMsComp ] )
508 else
509 return kTRUE;
510
511 return kFALSE;
512 } // if( it == fDpbIdIndexMap.end() )
513 else
515
517
519 UInt_t uTsMsbCycleHeader = std::floor(fulCurrentMsIdx / (stsxyter::kulTsCycleNbBins * stsxyter::kdClockCycleNs));
520
522 if (kTRUE == fbBinningFw)
524
525 if (0 == uMsIdx) {
526 if (uTsMsbCycleHeader != fvuCurrentTsMsbCycle[fuCurrDpbIdx])
527 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
528 << " MS Idx " << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << 0 << " DPB " << std::setw(2)
529 << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " Old MsbCy "
530 << std::setw(5) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " New MsbCy " << uTsMsbCycleHeader;
531 fvuCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
533 } // if( 0 == uMsIdx )
534 else if (uTsMsbCycleHeader != fvuCurrentTsMsbCycle[fuCurrDpbIdx]) {
535 if (4194303 == fvulCurrentTsMsb[fuCurrDpbIdx]) {
536 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
537 << " MS Idx " << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << 0 << " DPB " << std::setw(2)
538 << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " Old MsbCy "
539 << std::setw(5) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " New MsbCy " << uTsMsbCycleHeader;
540 }
541 else {
542 LOG(warning) << "TS MSB cycle from MS header does not match current cycle from data "
543 << "for TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
544 << " MsInTs " << std::setw(3) << uMsIdx << " ====> " << fvuCurrentTsMsbCycle[fuCurrDpbIdx]
545 << " (cnt) VS " << uTsMsbCycleHeader << " (header)";
546 } // else of if( 4194303 == fvulCurrentTsMsb[fuCurrDpbIdx] )
547 fvuCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
548 } // else if( uTsMsbCycleHeader != fvuCurrentTsMsbCycle[ fuCurrDpbIdx ] )
549
550 // If not integer number of message in input buffer, print warning/error
551 if (0 != (uSize % sizeof(stsxyter::Message)))
552 LOG(error) << "The input microslice buffer does NOT "
553 << "contain only complete sDPB messages!";
554
555 // Compute the number of complete messages in the input microslice buffer
556 uint32_t uNbMessages = (uSize - (uSize % sizeof(stsxyter::Message))) / sizeof(stsxyter::Message);
557
558 // std::vector< uint32_t > vNbMessType( 7, 0 );
559 // std::string sMessPatt = "";
560 // bool bError = false;
561
562 // Prepare variables for the loop on contents
563 const stsxyter::Message* pMess = reinterpret_cast<const stsxyter::Message*>(msContent);
564 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
566 stsxyter::MessType typeMess = pMess[uIdx].GetMessType();
567 fmMsgCounter[typeMess]++;
568 // fhStsMessType->Fill( static_cast< uint16_t > (typeMess) );
569 // fhStsMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) );
570
571 switch (typeMess) {
573 // ++vNbMessType[0];
574 // sMessPatt += " H ";
575 // sMessPatt += ".";
576
577 // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific!
578 UShort_t usElinkIdx = pMess[uIdx].GetLinkIndex();
580 if (kTRUE == fbBinningFw) usElinkIdx = pMess[uIdx].GetLinkIndexHitBinning();
581 // fhStsMessTypePerElink->Fill( usElinkIdx, static_cast< uint16_t > (typeMess) );
582 // fhStsHitsElinkPerDpb->Fill( fuCurrDpbIdx, usElinkIdx );
583
584 UInt_t uCrobIdx = usElinkIdx / fUnpackPar->GetNbElinkPerCrob();
585 Int_t uFebIdx = fUnpackPar->ElinkIdxToFebIdx(usElinkIdx);
586
587 if (-1 == uFebIdx) {
588 LOG(warning) << "CbmMcbm2018UnpackerAlgoSts::DoUnpack => "
589 << "Wrong elink Idx! Elink raw " << Form("%d remap %d", usElinkIdx, uFebIdx);
590 continue;
591 } // if( -1 == uFebIdx )
592
593 UInt_t uAsicIdx = (fuCurrDpbIdx * fUnpackPar->GetNbCrobsPerDpb() + uCrobIdx) * fUnpackPar->GetNbAsicsPerCrob()
594 + fUnpackPar->ElinkIdxToAsicIdx(1 == fviFebType[fuCurrDpbIdx][uCrobIdx][uFebIdx], usElinkIdx);
595
596 ProcessHitInfo(pMess[uIdx], usElinkIdx, uAsicIdx, uMsIdx);
597 break;
598 } // case stsxyter::MessType::Hit :
600 // ++vNbMessType[1];
601 // sMessPatt += " T ";
602
603 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
604
605 ProcessTsMsbInfo(pMess[uIdx], uIdx, uMsIdx);
606 break;
607 } // case stsxyter::MessType::TsMsb :
609 // ++vNbMessType[2];
610 // sMessPatt += " E ";
611
612 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
613
614 // The first message in the TS is a special ones: EPOCH
615 ProcessEpochInfo(pMess[uIdx]);
616
617 if (0 < uIdx)
618 LOG(info) << "CbmMcbm2018UnpackerAlgoSts::DoUnpack => "
619 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
620 break;
621 } // case stsxyter::MessType::TsMsb :
623 // ++vNbMessType[3];
624 // sMessPatt += " S ";
625
626 // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific!
627 UShort_t usElinkIdx = pMess[uIdx].GetStatusLink();
628
629 UInt_t uCrobIdx = usElinkIdx / fUnpackPar->GetNbElinkPerCrob();
630 Int_t uFebIdx = fUnpackPar->ElinkIdxToFebIdx(usElinkIdx);
631
632 if (-1 == uFebIdx) {
633 LOG(warning) << "CbmMcbm2018UnpackerAlgoSts::DoUnpack => "
634 << "Wrong elink Idx! Elink raw " << Form("%d remap %d", usElinkIdx, uFebIdx);
635 continue;
636 } // if( -1 == uFebIdx )
637 UInt_t uAsicIdx = (fuCurrDpbIdx * fUnpackPar->GetNbCrobsPerDpb() + uCrobIdx) * fUnpackPar->GetNbAsicsPerCrob()
638 + fUnpackPar->ElinkIdxToAsicIdx(1 == fviFebType[fuCurrDpbIdx][uCrobIdx][uFebIdx], usElinkIdx);
639
640 ProcessStatusInfo(pMess[uIdx], uAsicIdx);
641 break;
642 } // case stsxyter::MessType::Status
644 // ++vNbMessType[4];
645 // sMessPatt += " Em";
646
647 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
648 // FillTsMsbInfo( pMess[uIdx] );
649 break;
650 } // case stsxyter::MessType::Empty :
652 // ++vNbMessType[5];
653 // sMessPatt += " En";
654 // bError = pMess[uIdx].IsMsErrorFlagOn();
655
656 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
657 // FillTsMsbInfo( pMess[uIdx] );
658 if (pMess[uIdx].IsMsErrorFlagOn()) {
660 fhMsErrorsEvo->Fill(1e-9 * fulCurrentMsIdx, pMess[uIdx].GetMsErrorType());
661 fErrVect.push_back(
662 CbmErrorMessage(ECbmModuleId::kSts, fulCurrentMsIdx, fuCurrDpbIdx, 0x20, pMess[uIdx].GetMsErrorType()));
663 } // if( pMess[uIdx].IsMsErrorFlagOn() )
664 break;
665 } // case stsxyter::MessType::EndOfMs :
667 // ++vNbMessType[6];
668 // sMessPatt += " D ";
669
670 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
671 break;
672 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
673 default: {
674 LOG(fatal) << "CbmMcbm2018UnpackerAlgoSts::DoUnpack => "
675 << "Unknown message type, should never happen, stopping "
676 "here! Type found was: "
677 << static_cast<int>(typeMess);
678 }
679 } // switch( typeMess )
680 } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
681
682 // if( 18967040000 == fulCurrentMsIdx || 18968320000 == fulCurrentMsIdx )
683 // LOG( info ) << sMessPatt;
684
685 /*
686 if( static_cast< uint16_t >( fles::MicrosliceFlags::CrcValid ) != msDescriptor.flags )
687 {
688 LOG(info) << "STS unp "
689 << " TS " << std::setw( 12 ) << fulCurrentTsIdx
690 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
691 << " MS flags 0x" << std::setw( 4 ) << std::hex << msDescriptor.flags << std::dec
692 << " Size " << std::setw( 8 ) << uSize << " bytes "
693 << " H " << std::setw( 5 ) << vNbMessType[0]
694 << " T " << std::setw( 5 ) << vNbMessType[1]
695 << " E " << std::setw( 5 ) << vNbMessType[2]
696 << " S " << std::setw( 5 ) << vNbMessType[3]
697 << " Em " << std::setw( 5 ) << vNbMessType[4]
698 << " En " << std::setw( 5 ) << vNbMessType[5]
699 << " D " << std::setw( 5 ) << vNbMessType[6]
700 << " Err " << bError
701 << " Undet. bad " << ( !bError && 400 != vNbMessType[1] );
702 } // if( MicrosliceFlags::CrcValid != msDescriptor.flags )
703*/
704 return kTRUE;
705}
706
707// -------------------------------------------------------------------------
708void CbmMcbm2018UnpackerAlgoSts::ProcessHitInfo(const stsxyter::Message& mess, const UShort_t& usElinkIdx,
709 const UInt_t& uAsicIdx, const UInt_t& /*uMsIdx*/)
710{
711 UShort_t usChan = mess.GetHitChannel();
712 UShort_t usRawAdc = mess.GetHitAdc();
713 // UShort_t usFullTs = mess.GetHitTimeFull();
714 // UShort_t usTsOver = mess.GetHitTimeOver();
715 UShort_t usRawTs = mess.GetHitTime();
716
718 if (kTRUE == fbBinningFw) usRawTs = mess.GetHitTimeBinning();
719
721 // usChan = 127 - usChan;
722
723 /*
724 fhStsChanCntRaw[ uAsicIdx ]->Fill( usChan );
725 fhStsChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc );
726 fhStsChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc );
727 fhStsChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs );
728 fhStsChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() );
729*/
730 UInt_t uCrobIdx = usElinkIdx / fUnpackPar->GetNbElinkPerCrob();
731 UInt_t uFebIdx = uAsicIdx / fUnpackPar->GetNbAsicsPerFeb();
732 // UInt_t uAsicInFeb = uAsicIdx % fUnpackPar->GetNbAsicsPerFeb();
733 UInt_t uChanInFeb = usChan + fUnpackPar->GetNbChanPerAsic() * (uAsicIdx % fUnpackPar->GetNbAsicsPerFeb());
734
736 if (usRawTs == fvvusLastTsChan[uAsicIdx][usChan] &&
737 // usRawAdc == fvvusLastAdcChan[ uAsicIdx ][ usChan ] &&
741 return;
742 } // if SMX 2.0 DPB and same TS, ADC, TS MSB, TS MSB cycle!
743 fvvusLastTsChan[uAsicIdx][usChan] = usRawTs;
744 fvvusLastAdcChan[uAsicIdx][usChan] = usRawAdc;
747
748 /*
749 fhStsFebChanCntRaw[ uFebIdx ]->Fill( uChanInFeb );
750 fhStsFebChanAdcRaw[ uFebIdx ]->Fill( uChanInFeb, usRawAdc );
751 fhStsFebChanAdcRawProf[ uFebIdx ]->Fill( uChanInFeb, usRawAdc );
752 fhStsFebChanAdcCal[ uFebIdx ]->Fill( uChanInFeb, dCalAdc );
753 fhStsFebChanAdcCalProf[ uFebIdx ]->Fill( uChanInFeb, dCalAdc );
754 fhStsFebChanRawTs[ uFebIdx ]->Fill( usChan, usRawTs );
755 fhStsFebChanMissEvt[ uFebIdx ]->Fill( usChan, mess.IsHitMissedEvts() );
756*/
757
758 // Compute the Full time stamp
759 // Use TS w/o overlap bits as they will anyway come from the TS_MSB
760 Long64_t ulHitTime = usRawTs;
761 ulHitTime +=
762 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
763 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
764
766 if (kTRUE == fbBinningFw)
767 ulHitTime =
768 usRawTs
769 + static_cast<ULong64_t>(stsxyter::kuHitNbTsBinsBinning) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
770 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBinsBinning)
771 * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
772
773 // Convert the Hit time in bins to Hit time in ns
774 Double_t dHitTimeNs = ulHitTime * stsxyter::kdClockCycleNs;
775 /*
776 if( 3 == uAsicIdx && 32 == usChan && 10 < usRawAdc )
777 {
778
779 LOG(info) << "; TS; " << std::setw( 12 ) << fulCurrentTsIdx
780 << "; MS; " << std::setw( 12 ) << fulCurrentMsIdx
781 << "; time; " << std::setw( 12 ) << dHitTimeNs
782 << "; time to MS; " << std::setw( 12 ) << (dHitTimeNs / fulCurrentMsIdx)
783 << "; time; " << std::setw( 12 ) << ulHitTime
784 << "; TS; " << std::setw( 4 ) << usRawTs
785 << "; MSB; " << std::setw( 12 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
786 << "; Cy; " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]
787 << "; dt; " << std::setw( 12 ) << dHitTimeNs - fdTimeA - 20971600;
788
789 if( 0.0 < fdTimeA )
790 fhPulserVsTsAB->Fill( fusTsA, usRawTs, dHitTimeNs - fdTimeA - 20971600 );
791
792 fusTsA = usRawTs;
793 fdTimeA = dHitTimeNs;
794 } // if( 3 == uAsicIdx && 32 == usChan && 10 < usRawAdc )
795*/
797 if (0 != fviFebAddress[uFebIdx] && fdAdcCut < usRawAdc) {
800 if (kFALSE == fbUseChannelMask || false == fvvbMaskedChannels[uFebIdx][uChanInFeb])
801 fvmHitsInMs.push_back(stsxyter::FinalHit(ulHitTime, usRawAdc, uAsicIdx, usChan, fuCurrDpbIdx, uCrobIdx));
802 } // if( 0 != fviFebAddress[ uFebIdx ] )
803
805 if (mess.IsHitMissedEvts())
806 fErrVect.push_back(
807 CbmErrorMessage(ECbmModuleId::kSts, dHitTimeNs, uAsicIdx, 1 << stsxyter::kusLenStatStatus, usChan));
808
809 // Check Starting point of histos with time as X axis
810 if (-1 == fdStartTime) fdStartTime = dHitTimeNs;
811 /*
812 // Fill histos with time as X axis
813 Double_t dTimeSinceStartSec = (dHitTimeNs - fdStartTime)* 1e-9;
814 Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0;
815
816 fviFebCountsSinceLastRateUpdate[uFebIdx]++;
817 fvdFebChanCountsSinceLastRateUpdate[uFebIdx][uChanInFeb] += 1;
818
819 fhStsFebChanHitRateEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uChanInFeb );
820 fhStsFebAsicHitRateEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uAsicInFeb );
821 fhStsFebHitRateEvo[ uFebIdx ]->Fill( dTimeSinceStartSec );
822 fhStsFebChanHitRateEvoLong[ uFebIdx ]->Fill( dTimeSinceStartMin, uChanInFeb, 1.0/60.0 );
823 fhStsFebAsicHitRateEvoLong[ uFebIdx ]->Fill( dTimeSinceStartMin, uAsicInFeb, 1.0/60.0 );
824 fhStsFebHitRateEvoLong[ uFebIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 );
825 if( mess.IsHitMissedEvts() )
826 {
827 fhStsFebChanMissEvtEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uChanInFeb );
828 fhStsFebAsicMissEvtEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uAsicInFeb );
829 fhStsFebMissEvtEvo[ uFebIdx ]->Fill( dTimeSinceStartSec );
830 } // if( mess.IsHitMissedEvts() )
831*/
832 /*
833 if( kTRUE == fbLongHistoEnable )
834 {
835 std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now();
836 Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count();
837 fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec );
838 fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec );
839 } // if( kTRUE == fbLongHistoEnable )
840*/
841}
842
843void CbmMcbm2018UnpackerAlgoSts::ProcessTsMsbInfo(const stsxyter::Message& mess, UInt_t uMessIdx, UInt_t uMsIdx)
844{
845 UInt_t uVal = mess.GetTsMsbVal();
846
848 if (kTRUE == fbBinningFw) uVal = mess.GetTsMsbValBinning();
849
850 /*
851 if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal &&
852 !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS!
853 {
854 LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx
855 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
856 << " MsInTs " << std::setw( 3 ) << uMsIdx
857 << " DPB " << std::setw( 2 ) << fuCurrDpbIdx
858 << " Mess " << std::setw( 5 ) << uMessIdx
859 << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
860 << " new TsMsb " << std::setw( 5 ) << uVal
861 << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx]
862 << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx];
863 } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal )
864*/
865
866 // Update Status counters
867 if (uVal < fvulCurrentTsMsb[fuCurrDpbIdx]) {
868
869 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
870 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
871 << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " Old MsbCy "
872 << std::setw(5) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " new TsMsb " << std::setw(5) << uVal;
873
875 } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
876 if (
877 uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1 && !(0 == uVal && 4194303 == fvulCurrentTsMsb[fuCurrDpbIdx])
878 &&
879 1 != uMessIdx &&
880 !(0 == uVal && 0 == fvulCurrentTsMsb[fuCurrDpbIdx] && 2 == uMessIdx) &&
881 !(uVal == fvulCurrentTsMsb[fuCurrDpbIdx] && 2 == uMessIdx)
882 &&
883 uVal < fvulCurrentTsMsb
884 [fuCurrDpbIdx]
885 ) {
886 LOG(info) << "TS MSb Jump in "
887 << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
888 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
889 << fuCurrDpbIdx << " => Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " new TsMsb "
890 << std::setw(5) << uVal;
891 } // if( uVal + 1 != fvulCurrentTsMsb[fuCurrDpbIdx] && 4194303 != uVal && 0 != fvulCurrentTsMsb[fuCurrDpbIdx] )
892
895 if (4194303 == uVal && 1 == uMessIdx) fvulCurrentTsMsb[fuCurrDpbIdx] = 0;
896 else
898 /*
899 if( 1 < uMessIdx )
900 {
901 fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] );
902 fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) );
903 fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) );
904 } // if( 0 < uMessIdx )
905*/
906 // fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
907 /*
908 ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins )
909 * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx])
910 + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins )
911 * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] );
912*/
913}
914
916{
917 // UInt_t uVal = mess.GetEpochVal();
918 // UInt_t uCurrentCycle = uVal % stsxyter::kulTsCycleNbBins;
919
920 /*
921 // Update Status counters
922 if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
923 fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++;
924 fvulCurrentTsMsb[fuCurrDpbIdx] = usVal;
925
926// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
927*/
928}
929
931{
932 /*
933 UShort_t usStatusField = mess.GetStatusStatus();
934
935 fhPulserStatusMessType->Fill( uAsicIdx, usStatusField );
937 if( fbPrintMessages )
938 {
939 std::cout << Form("DPB %2u TS %12u MS %12u mess %5u ", fuCurrDpbIdx, fulCurrentTsIdx, fulCurrentMsIdx, uIdx );
940 mess.PrintMess( std::cout, fPrintMessCtrl );
941 } // if( fbPrintMessages )
942*/
945 Long64_t ulTime =
946 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
947 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
948
950 if (kTRUE == fbBinningFw)
951 ulTime =
952 static_cast<ULong64_t>(stsxyter::kuHitNbTsBinsBinning) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
953 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBinsBinning)
954 * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
955
957 Double_t dTimeNs = ulTime * stsxyter::kdClockCycleNs;
958
959 fErrVect.push_back(CbmErrorMessage(ECbmModuleId::kSts, dTimeNs, uAsicIdx, mess.GetStatusStatus(), mess.GetData()));
960}
961
962// -------------------------------------------------------------------------
963
964// -------------------------------------------------------------------------
965
967{
970 new TH1I("hStsDigisTimeInRun", "Digis Nb vs Time in Run; Time in run [s]; Digis Nb []", 36000, 0, 3600);
972
973 fhVectorSize = new TH1I("fhVectorSize", "Size of the vector VS TS index; TS index; Size [bytes]", 10000, 0., 10000.);
975 new TH1I("fhVectorCapacity", "Size of the vector VS TS index; TS index; Size [bytes]", 10000, 0., 10000.);
978
979
980 fhMsCntEvo = new TH1I("fhMsCntEvo", "; MS index [s]; Counts []", 600, 0.0, 600.0);
982
983 fhMsErrorsEvo = new TH2I("fhMsErrorsEvo", "; MS index [s]; Error type []; Counts []", 600, 0.0, 600.0, 4, -0.5, 3.5);
985
986 /*
987 fhPulserVsTsAB = new TProfile2D( "fhPulserVsTsAB", "; TS A [bin]; TS B [bin]; dT B - A [ns]",
988 1024, -0.5, 1023.5,
989 1024, -0.5, 1023.5 );
990 AddHistoToVector( fhPulserVsTsAB, "" );
991*/
992 /*
994 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
995 {
996 UInt_t uSector = fUnpackPar->GetGdpbToSectorOffset() + uGdpb;
997 std::string sFolder = Form( "sector%2u", uSector);
998
999 LOG(info) << "gDPB " << uGdpb << " is " << sFolder;
1000
1001 fvhHitsTimeToTriggerRaw.push_back( new TH1D(
1002 Form( "hHitsTimeToTriggerRawSect%2u", uSector ),
1003 Form( "Time to trigger for all neighboring hits in sector %2u; t - Ttrigg [ns]; Hits []", uSector ),
1004 2000, -5000, 5000 ) );
1005
1006 UInt_t uNbBinsDtSel = fdStarTriggerWinSize[ uGdpb ];
1007 Double_t dMaxDtSel = fdStarTriggerDelay[ uGdpb ] + fdStarTriggerWinSize[ uGdpb ];
1008 fvhHitsTimeToTriggerSel.push_back( new TH1D(
1009 Form( "hHitsTimeToTriggerSelSect%2u", uSector ),
1010 Form( "Time to trigger for all selected hits in sector %2u; t - Ttrigg [ns]; Hits []", uSector ),
1011 uNbBinsDtSel, fdStarTriggerDelay[ uGdpb ], dMaxDtSel ) );
1012
1014 AddHistoToVector( fvhHitsTimeToTriggerRaw[ uGdpb ], sFolder );
1015 AddHistoToVector( fvhHitsTimeToTriggerSel[ uGdpb ], sFolder );
1016
1017 if( kTRUE == fbDebugMonitorMode )
1018 {
1019 fvhHitsTimeToTriggerSelVsDaq.push_back( new TH2D(
1020 Form( "hHitsTimeToTriggerSelVsDaqSect%2u", uSector ),
1021 Form( "Time to trigger for all selected hits vs DAQ CMD in sector %2u; t - Ttrigg [ns]; DAQ CMD []; Hits []", uSector ),
1022 uNbBinsDtSel, fdStarTriggerDelay[ uGdpb ], dMaxDtSel,
1023 16, 0., 16. ) );
1024
1025 fvhHitsTimeToTriggerSelVsTrig.push_back( new TH2D(
1026 Form( "hHitsTimeToTriggerSelVsTrigSect%2u", uSector ),
1027 Form( "Time to trigger for all selected hits vs TRIG CMD in sector %2u; t - Ttrigg [ns]; TRIG CMD []; Hits []", uSector ),
1028 uNbBinsDtSel, fdStarTriggerDelay[ uGdpb ], dMaxDtSel,
1029 16, 0., 16. ) );
1030
1031 fvhTriggerDt.push_back( new TH1I(
1032 Form( "hTriggerDtSect%2u", uSector ),
1033 Form( "Trigger time difference between sector %2u and the first sector, full events only; Ttrigg%2u - TtriggRef [Clk]; events []",
1034 uSector, uSector ),
1035 200, -100, 100 ) );
1036
1039 UInt_t uNbBinsInTs = fdMsSizeInNs * 111 / 1000. / 10.;
1040 UInt_t uNbBinsInMs = fdMsSizeInNs * 20 / 1000. / 10.;
1041
1042 fvhTriggerDistributionInTs.push_back( new TH1I( Form( "hTriggerDistInTsSect%2u", uSector ),
1043 Form( "Trigger distribution inside TS in sector %2u; Time in TS [us]; Trigger [];", uSector ),
1044 uNbBinsInTs, -0.5 - fdMsSizeInNs * 10 / 1000., fdMsSizeInNs * 101 / 1000. - 0.5 ) );
1045
1046 fvhTriggerDistributionInMs.push_back( new TH1I( Form( "hTriggerDistInMsSect%2u", uSector ),
1047 Form( "Trigger distribution inside MS in sector %2u; Time in MS [us]; Trigger [];", uSector ),
1048 uNbBinsInMs, -0.5 - fdMsSizeInNs * 10 / 1000., fdMsSizeInNs * 10 / 1000. - 0.5 ) );
1049
1050 fvhMessDistributionInMs.push_back( new TH1I( Form( "hMessDistInMsSect%2u", uSector ),
1051 Form( "Messages distribution inside MS in sector %2u; Time in MS [us]; Trigger [];", uSector ),
1052 uNbBinsInMs, -0.5 - fdMsSizeInNs * 10 / 1000., fdMsSizeInNs * 10 / 1000. - 0.5 ) );
1053
1055 AddHistoToVector( fvhHitsTimeToTriggerSelVsDaq[ uGdpb ], sFolder );
1056 AddHistoToVector( fvhHitsTimeToTriggerSelVsTrig[ uGdpb ], sFolder );
1057 AddHistoToVector( fvhTriggerDt[ uGdpb ], sFolder );
1058 AddHistoToVector( fvhTriggerDistributionInTs[ uGdpb ], sFolder );
1059 AddHistoToVector( fvhTriggerDistributionInMs[ uGdpb ], sFolder );
1060 AddHistoToVector( fvhMessDistributionInMs[ uGdpb ], sFolder );
1061 } // if( kTRUE == fbDebugMonitorMode )
1062 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1063
1065 fhEventNbPerTs = new TH1I( "hEventNbPerTs",
1066 "Number of Events per TS; Events []; TS []",
1067 1000 , 0, 1000 );
1068
1069 fhEventSizeDistribution = new TH1I( "hEventSizeDistribution",
1070 "Event size distribution; Event size [byte]; Events []",
1071 CbmTofStarSubevent2019::GetMaxOutputSize()/8 , 0, CbmTofStarSubevent2019::GetMaxOutputSize() );
1072
1073 fhEventSizeEvolution = new TProfile( "hEventSizeEvolution",
1074 "Event size evolution; Time in run [min]; mean Event size [byte];",
1075 14400, 0, 14400 );
1076
1077 fhEventNbEvolution = new TH1I( "hEventNbEvolution",
1078 "Event number evolution; Time in run [min]; Events [];",
1079 14400, 0, 14400 );
1080
1082 AddHistoToVector( fhEventNbPerTs, "eventbuilder" );
1083 AddHistoToVector( fhEventSizeDistribution, "eventbuilder" );
1084 AddHistoToVector( fhEventSizeEvolution, "eventbuilder" );
1085 AddHistoToVector( fhEventNbEvolution, "eventbuilder" );
1086
1087 if( kTRUE == fbDebugMonitorMode )
1088 {
1091 UInt_t uNbBinsInTs = fdMsSizeInNs * 101 / 1000. / 10.;
1092
1093 fhEventNbDistributionInTs = new TH1I( "hEventNbDistributionInTs",
1094 "Event number distribution inside TS; Time in TS [us]; Events [];",
1095 uNbBinsInTs, -0.5, fdMsSizeInNs * 101 / 1000. - 0.5 );
1096
1097 fhEventSizeDistributionInTs = new TProfile( "hEventSizeDistributionInTs",
1098 "Event size distribution inside TS; Time in TS [us]; mean Event size [Byte];",
1099 uNbBinsInTs, -0.5, fdMsSizeInNs * 101 / 1000. - 0.5 );
1100
1101 fhRawTriggersStats = new TH2I(
1102 "hRawTriggersStats",
1103 "Raw triggers statistics per sector; ; Sector []; Messages []",
1104 5, 0, 5,
1105 12, 13, 25 );
1106 fhRawTriggersStats->GetXaxis()->SetBinLabel( 1, "A");
1107 fhRawTriggersStats->GetXaxis()->SetBinLabel( 2, "B");
1108 fhRawTriggersStats->GetXaxis()->SetBinLabel( 3, "C");
1109 fhRawTriggersStats->GetXaxis()->SetBinLabel( 4, "D");
1110 fhRawTriggersStats->GetXaxis()->SetBinLabel( 5, "F");
1111
1112 fhMissingTriggersEvolution = new TH2I(
1113 "hMissingTriggersEvolution",
1114 "Missing trigger counts per sector vs time in run; Time in run [min]; Sector []; Missing triggers []",
1115 14400, 0, 14400,
1116 12, 13, 25 );
1117
1119 AddHistoToVector( fhEventNbDistributionInTs, "eventbuilder" );
1120 AddHistoToVector( fhEventSizeDistributionInTs, "eventbuilder" );
1121 AddHistoToVector( fhRawTriggersStats, "eventbuilder" );
1122 AddHistoToVector( fhMissingTriggersEvolution, "eventbuilder" );
1123 } // if( kTRUE == fbDebugMonitorMode )
1124
1126 Double_t w = 10;
1127 Double_t h = 10;
1128
1130 fcTimeToTrigRaw = new TCanvas( "cTimeToTrigRaw", "Raw Time to trig for all sectors", w, h);
1131 fcTimeToTrigRaw->Divide( 2, fuNrOfGdpbs / 2 );
1132 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1133 {
1134 fcTimeToTrigRaw->cd( 1 + uGdpb );
1135 gPad->SetGridx();
1136 gPad->SetGridy();
1137 gPad->SetLogy();
1138 fvhHitsTimeToTriggerRaw[ uGdpb ]->Draw();
1139 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1140
1142 fcTimeToTrigSel = new TCanvas( "cTimeToTrigSel", "Selected Time to trig for all sectors", w, h);
1143 fcTimeToTrigSel->Divide( 2, fuNrOfGdpbs / 2 );
1144 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1145 {
1146 fcTimeToTrigSel->cd( 1 + uGdpb );
1147 gPad->SetGridx();
1148 gPad->SetGridy();
1149 gPad->SetLogy();
1150 fvhHitsTimeToTriggerSel[ uGdpb ]->Draw();
1151 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1152
1153 if( kTRUE == fbDebugMonitorMode )
1154 {
1156 fcTrigDistMs = new TCanvas( "cTrigDistMs", "Trigger time to MS start for all sectors", w, h);
1157 fcTrigDistMs->Divide( 2, fuNrOfGdpbs / 2 );
1158 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1159 {
1160 fcTrigDistMs->cd( 1 + uGdpb );
1161 gPad->SetGridx();
1162 gPad->SetGridy();
1163 gPad->SetLogy();
1164 fvhTriggerDistributionInMs[ uGdpb ]->Draw();
1165 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1166
1168 fcMessDistMs = new TCanvas( "cMessDistMs", "Message time to MS start for all sectors", w, h);
1169 fcMessDistMs->Divide( 2, fuNrOfGdpbs / 2 );
1170 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1171 {
1172 fcMessDistMs->cd( 1 + uGdpb );
1173 gPad->SetGridx();
1174 gPad->SetGridy();
1175 gPad->SetLogy();
1176 fvhMessDistributionInMs[ uGdpb ]->Draw();
1177 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1178 } // if( kTRUE == fbDebugMonitorMode )
1179
1181 fcEventBuildStats = new TCanvas( "cEvtBuildStats", "Event building statistics", w, h);
1182 if( kTRUE == fbDebugMonitorMode )
1183 fcEventBuildStats->Divide( 2, 3 );
1184 else fcEventBuildStats->Divide( 2, 2 );
1185
1186 fcEventBuildStats->cd( 1 );
1187 gPad->SetGridx();
1188 gPad->SetGridy();
1189 gPad->SetLogy();
1190 fhEventNbPerTs->Draw();
1191
1192 fcEventBuildStats->cd( 2 );
1193 gPad->SetGridx();
1194 gPad->SetGridy();
1195 gPad->SetLogy();
1196 fhEventSizeDistribution->Draw();
1197
1198 fcEventBuildStats->cd( 3 );
1199 gPad->SetGridx();
1200 gPad->SetGridy();
1201 gPad->SetLogy();
1202 fhEventSizeEvolution->Draw();
1203
1204 fcEventBuildStats->cd( 4 );
1205 gPad->SetGridx();
1206 gPad->SetGridy();
1207 gPad->SetLogy();
1208 fhEventNbEvolution->Draw();
1209
1210 if( kTRUE == fbDebugMonitorMode )
1211 {
1212 fcEventBuildStats->cd( 5 );
1213 gPad->SetGridx();
1214 gPad->SetGridy();
1215 gPad->SetLogy();
1216 fhEventNbDistributionInTs->Draw();
1217
1218 fcEventBuildStats->cd( 6 );
1219 gPad->SetGridx();
1220 gPad->SetGridy();
1221 gPad->SetLogy();
1222 fhEventSizeDistributionInTs->Draw();
1223 } // if( kTRUE == fbDebugMonitorMode )
1224
1225 AddCanvasToVector( fcEventBuildStats, "canvases" );
1226*/
1227 return kTRUE;
1228}
1230{
1231 for (auto itHit = fDigiVect.begin(); itHit != fDigiVect.end(); ++itHit) {
1232 fhDigisTimeInRun->Fill(itHit->GetTime() * 1e-9);
1233 } // for( auto itHit = fDigiVect.begin(); itHit != fDigiVect.end(); ++itHit)
1234 if (fbPulserOutput) {
1235 for (auto itHit = fPulserDigiVect.begin(); itHit != fPulserDigiVect.end(); ++itHit) {
1236 fhDigisTimeInRun->Fill(itHit->GetTime() * 1e-9);
1237 } // for( auto itHit = fPulserDigiVect.begin(); itHit != fPulserDigiVect.end(); ++itHit)
1238 }
1239 return kTRUE;
1240}
1242{
1243 fhDigisTimeInRun->Reset();
1244 /*
1245 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1246 {
1247 fvhHitsTimeToTriggerRaw[ uGdpb ]->Reset();
1248 fvhHitsTimeToTriggerSel[ uGdpb ]->Reset();
1249
1250 if( kTRUE == fbDebugMonitorMode )
1251 {
1252 fvhHitsTimeToTriggerSelVsDaq[ uGdpb ]->Reset();
1253 fvhHitsTimeToTriggerSelVsTrig[ uGdpb ]->Reset();
1254 fvhTriggerDt[ uGdpb ]->Reset();
1255 fvhTriggerDistributionInTs[ uGdpb ]->Reset();
1256 fvhTriggerDistributionInMs[ uGdpb ]->Reset();
1257 fvhMessDistributionInMs[ uGdpb ]->Reset();
1258 } // if( kTRUE == fbDebugMonitorMode )
1259 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
1260
1262 fhEventNbPerTs->Reset();
1263 fhEventSizeDistribution->Reset();
1264 fhEventSizeEvolution->Reset();
1265 fhEventNbEvolution->Reset();
1266
1267 if( kTRUE == fbDebugMonitorMode )
1268 {
1269 fhEventNbDistributionInTs->Reset();
1270 fhEventSizeDistributionInTs->Reset();
1271 fhRawTriggersStats->Reset();
1272 fhMissingTriggersEvolution->Reset();
1273 } // if( kTRUE == fbDebugMonitorMode )
1274*/
1275 return kTRUE;
1276}
1277// -------------------------------------------------------------------------
1278
1279void CbmMcbm2018UnpackerAlgoSts::SetTimeOffsetNsAsic(UInt_t uAsicIdx, Double_t dOffsetIn)
1280{
1281 if (uAsicIdx >= fvdTimeOffsetNsAsics.size()) {
1282 fvdTimeOffsetNsAsics.resize(uAsicIdx + 1, 0.0);
1283 } // if( uAsicIdx < fvdTimeOffsetNsAsics.size() )
1284
1285 fvdTimeOffsetNsAsics[uAsicIdx] = dOffsetIn;
1286}
1287// -------------------------------------------------------------------------
1288void CbmMcbm2018UnpackerAlgoSts::MaskNoisyChannel(UInt_t uFeb, UInt_t uChan, Bool_t bMasked)
1289{
1290 if (kFALSE == fbUseChannelMask) {
1291 fbUseChannelMask = kTRUE;
1293 for (UInt_t uFebIdx = 0; uFebIdx < fuNbFebs; ++uFebIdx) {
1294 fvvbMaskedChannels[uFebIdx].resize(fUnpackPar->GetNbChanPerFeb(), false);
1295 } // for( UInt_t uFeb = 0; uFeb < fuNbFebs; ++uFeb )
1296 } // if( kFALSE == fbUseChannelMask )
1297
1298 if (uFeb < fuNbFebs && uChan < fUnpackPar->GetNbChanPerFeb()) fvvbMaskedChannels[uFeb][uChan] = bMasked;
1299 else
1300 LOG(fatal) << "CbmMcbm2018UnpackerAlgoSts::MaskNoisyChannel => Invalid FEB "
1301 "and/or CHAN index:"
1302 << Form(" %u vs %u and %u vs %u", uFeb, fuNbFebs, uChan, fUnpackPar->GetNbChanPerFeb());
1303}
1304// -------------------------------------------------------------------------
@ kSts
Silicon Tracking System.
std::string FormatMsHeaderPrintout(const fles::MicrosliceDescriptor &msDescriptor)
CbmRoot (+externals) headers.
Double_t GetFebAdcGain(UInt_t uDpbIdx, UInt_t uCrobIdx, UInt_t uFebIdx)
UInt_t GetDpbId(UInt_t uDpbIdx)
Int_t ElinkIdxToFebIdx(UInt_t uElink)
Int_t GetFebModuleIdx(UInt_t uDpbIdx, UInt_t uCrobIdx, UInt_t uFebIdx)
UInt_t GetModuleType(UInt_t uModuleIdx)
static constexpr UInt_t GetNbFebsPerCrob()
static constexpr UInt_t GetNbAsicsPerFeb()
static constexpr UInt_t GetNbElinkPerCrob()
Double_t GetFebAdcOffset(UInt_t uDpbIdx, UInt_t uCrobIdx, UInt_t uFebIdx)
static constexpr UInt_t GetNbAsicsPerCrob()
Bool_t IsCrobActive(UInt_t uDpbIdx, UInt_t uCrobIdx)
static constexpr UInt_t GetNbCrobsPerDpb()
UInt_t GetModuleAddress(UInt_t uModuleIdx)
UInt_t ElinkIdxToAsicIdx(Bool_t bFebType, UInt_t uElink)
Bool_t IsFebPulser(UInt_t uFebInSystIdx)
Int_t GetFebModuleSide(UInt_t uDpbIdx, UInt_t uCrobIdx, UInt_t uFebIdx)
static constexpr UInt_t GetNbChanPerAsic()
static constexpr UInt_t GetNbChanPerFeb()
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
std::vector< stsxyter::FinalHit > fvmHitsInMs
Hits time-sorting.
std::vector< std::vector< UShort_t > > fvvusLastTsChan
std::vector< Bool_t > fvbMaskedComponents
Switch ON the filling of a additional set of histograms.
Bool_t fbBinningFw
=> Quick and dirty hack for binning FW!!!
std::vector< Double_t > fvdFebAdcOffs
ADC gain in e-/b, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::vector< Int_t > fviFebAddress
Pulser flag for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::vector< CbmStsDigi > fPulserDigiVect
All hits (time in bins, ADC in bins, asic, channel) in last MS, sorted with "<" operator.
UInt_t fuNbFebs
Array to hold the active flag for all CROBs, [ NbDpb ][ NbCrobPerDpb ].
std::vector< Double_t > fvdFebAdcGain
Module side for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
TH1 * fhDigisTimeInRun
TS MSB cycle of last hit message for each channel, [ AsicIdx ][ Chan ].
std::vector< Int_t > fviModuleType
Total number of STS modules in the setup.
std::vector< UInt_t > fvuCurrentTsMsbCycle
Current TS MSB for each DPB.
void ProcessEpochInfo(const stsxyter::Message &mess)
UInt_t fuMsIndex
Start Time in ns of current MS from its index field in header.
std::vector< Int_t > fviFebSide
STS address for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::vector< std::vector< std::vector< Int_t > > > fviFebModuleIdx
Number of StsXyter ASICs.
std::vector< Int_t > fviModAddress
Type of each module: 0 for connectors on the right, 1 for connectors on the left.
UInt_t fuNbStsXyters
Number of FEBs with StsXyter ASICs.
std::vector< std::vector< UShort_t > > fvvusLastTsMsbCycleChan
TS MSB of last hit message for each channel, [ AsicIdx ][ Chan ].
void ProcessHitInfo(const stsxyter::Message &mess, const UShort_t &usElinkIdx, const UInt_t &uAsicIdx, const UInt_t &uMsIdx)
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
std::vector< std::vector< Bool_t > > fvbCrobActiveFlag
Map of DPB Identifier to DPB index.
Bool_t fbDebugMonitorMode
Switch ON the filling of a minimal set of histograms.
void ProcessStatusInfo(const stsxyter::Message &mess, const UInt_t &uAsicIdx)
void ProcessTsMsbInfo(const stsxyter::Message &mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
std::vector< std::vector< UShort_t > > fvvusLastTsMsbChan
ADC of last hit message for each channel, [ AsicIdx ][ Chan ].
std::vector< std::vector< std::vector< Int_t > > > fviFebType
STS module side for each FEB, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ], 0 = P, 1 = N,...
std::vector< ULong64_t > fvulCurrentTsMsb
std::map< UInt_t, UInt_t > fDpbIdIndexMap
Total number of STS DPBs in system.
static const UInt_t kuMaxTsMsbDiffDuplicates
Duplicate hits suppression.
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
std::vector< std::vector< bool > > fvvbMaskedChannels
UInt_t fuNrOfDpbs
STS address for the first strip of each module.
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
CbmMcbm2018StsPar * fUnpackPar
If ON a separate output vector of digi is used for the pulser.
UInt_t fdAdcCut
Vector of channel masks, [ NbFeb ][ NbCHanInFeb ], used only if fbUseChannelMask is true.
std::vector< bool > fvbFebPulser
FEB type, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ], 0 = A, 1 = B, -1 if inactive.
std::vector< Double_t > fvdTimeOffsetNsAsics
Double_t fdTimeOffsetNs
ADC offset in e-, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
void SetTimeOffsetNsAsic(UInt_t uAsicIdx, Double_t dOffsetIn=0.0)
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
std::vector< std::vector< UShort_t > > fvvusLastAdcChan
TS of last hit message for each channel, [ AsicIdx ][ Chan ].
Bool_t ProcessTs(const fles::Timeslice &ts)
std::vector< std::vector< std::vector< Int_t > > > fviFebModuleSide
Idx of the STS module for each FEB, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ], -1 if inactive.
void MaskNoisyChannel(UInt_t uFeb, UInt_t uChan, Bool_t bMasked=kTRUE)
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
std::vector< CbmErrorMessage > fErrVect
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
std::vector< size_t > fvMsComponentsList
std::vector< CbmStsDigi > fDigiVect
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
XPU_D bool IsHitMissedEvts() const
For Hit data: Returns Missed event flag (1 bit field)
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)
XPU_D uint16_t GetLinkIndex() const
For all data: Returns the (global) index of the eLink on which the message was received (n bit field)
XPU_D uint16_t GetStatusStatus() const
For Status data: Returns the Status field from ACK frame (4 bit field)
XPU_D MessType GetMessType() const
Returns the message type, see enum MessType.
XPU_D uint16_t GetLinkIndexHitBinning() const
XPU_D uint32_t GetData() 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 GetStatusLink() const
For Status data: Returns the Link Inedx (9 bit field)
Hash for CbmL1LinkKey.
static constexpr uint32_t kuHitNbTsBinsBinning
static constexpr uint64_t kulTsCycleNbBins
static constexpr uint64_t kulTsCycleNbBinsBinning
static constexpr uint32_t kuHitNbTsBins
static constexpr double kdClockCycleNs
MessType
Message types.
static constexpr uint16_t kusLenStatStatus