CbmRoot
Loading...
Searching...
No Matches
CbmCosy2019UnpackerAlgoHodo.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Florian Uhlig [committer] */
4
5// -----------------------------------------------------------------------------
6// ----- -----
7// ----- CbmCosy2019UnpackerAlgoHodo -----
8// ----- Created 31/07/19 by P.-A. Loizeau -----
9// ----- -----
10// -----------------------------------------------------------------------------
11
13
14#include "CbmCosy2019HodoPar.h"
16#include "TCanvas.h"
17#include "TH1.h"
18#include "TH2.h"
19#include "TList.h"
20#include "TProfile.h"
21#include "TROOT.h"
22#include "TString.h"
23
24#include <Logger.h>
25
26#include <cstdint>
27#include <fstream>
28#include <iomanip>
29#include <iostream>
30
31// -------------------------------------------------------------------------
34 ,
36 fbMonitorMode(kFALSE)
37 , fbDebugMonitorMode(kFALSE)
39 , fUnpackPar(nullptr)
40 , fuNbModules(0)
42 , fuNrOfDpbs(0)
45 , fuNbFebs(0)
46 , fuNbStsXyters(0)
51 , fviFebModule()
52 , fdTimeOffsetNs(0.0)
56 , fdTsStartTime(-1.0)
57 , fdTsStopTimeCore(-1.0)
58 , fdMsTime(-1.0)
59 , fuMsIndex(0)
60 , fmMsgCounter()
62 , fuCurrDpbId(0)
63 , fuCurrDpbIdx(0)
67 , fdStartTime(0.0)
68 , fdStartTimeMsSz(0.0)
69 , ftStartTimeUnix(std::chrono::steady_clock::now())
70 , fvmHitsInMs()
71 , fhDigisTimeInRun(nullptr)
72/*
73 fvhHitsTimeToTriggerRaw(),
74 fvhMessDistributionInMs(),
75 fhEventNbPerTs( nullptr ),
76 fcTimeToTrigRaw( nullptr )
77*/
78{
79}
81{
83 fvmHitsInMs.clear();
84 /*
85 for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
86 {
87 fvmHitsInMs[ uDpb ].clear();
88 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
89*/
90}
91
92// -------------------------------------------------------------------------
94{
95 LOG(info) << "Initializing mCBM STS 2019 unpacker algo";
96
97 return kTRUE;
98}
106
107// -------------------------------------------------------------------------
109{
110 LOG(info) << "Init parameter containers for CbmCosy2019UnpackerAlgoHodo";
111 Bool_t initOK = ReInitContainers();
112
113 return initOK;
114}
116{
117 LOG(info) << "**********************************************";
118 LOG(info) << "ReInit parameter containers for CbmCosy2019UnpackerAlgoHodo";
119
120 fUnpackPar = (CbmCosy2019HodoPar*) fParCList->FindObject("CbmCosy2019HodoPar");
121 if (nullptr == fUnpackPar) return kFALSE;
122
123 Bool_t initOK = InitParameters();
124
125 return initOK;
126}
128{
129 if (nullptr == fParCList) fParCList = new TList();
130 fUnpackPar = new CbmCosy2019HodoPar("CbmCosy2019HodoPar");
131 fParCList->Add(fUnpackPar);
132
133 return fParCList;
134}
136{
137 fuNbModules = fUnpackPar->GetNbOfModules();
138 LOG(info) << "Nr. of STS Modules: " << fuNbModules;
139
141 for (UInt_t uModIdx = 0; uModIdx < fuNbModules; ++uModIdx) {
142 fviModAddress[uModIdx] = fUnpackPar->GetModuleAddress(uModIdx);
143 LOG(info) << "Module #" << std::setw(2) << uModIdx << " Address 0x" << std::setw(8) << std::hex
144 << fviModAddress[uModIdx] << std::dec;
145 } // for( UInt_t uModIdx = 0; uModIdx < fuNbModules; ++uModIdx)
146
147 fuNrOfDpbs = fUnpackPar->GetNrOfDpbs();
148 LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs;
149
150 fDpbIdIndexMap.clear();
151 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
152 fDpbIdIndexMap[fUnpackPar->GetDpbId(uDpb)] = uDpb;
153 LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = 0x" << std::setw(4) << std::hex
154 << fUnpackPar->GetDpbId(uDpb) << std::dec << " => " << fDpbIdIndexMap[fUnpackPar->GetDpbId(uDpb)];
155 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
156
157 fuNbFebs = fUnpackPar->GetNrOfFebs();
158 LOG(info) << "Nr. of FEBs: " << fuNbFebs;
159
160 fuNbStsXyters = fUnpackPar->GetNrOfAsics();
161 LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters;
162
163 if (fvdTimeOffsetNsAsics.size() < fuNbStsXyters) {
165 } // if( fvdTimeOffsetNsAsics.size() < fuNbStsXyters )
166
171 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
172 fvbCrobActiveFlag[uDpb].resize(fUnpackPar->GetNbCrobsPerDpb());
173 fviFebModuleIdx[uDpb].resize(fUnpackPar->GetNbCrobsPerDpb());
174 fvdFebAdcGain[uDpb].resize(fUnpackPar->GetNbCrobsPerDpb());
175 fvdFebAdcOffs[uDpb].resize(fUnpackPar->GetNbCrobsPerDpb());
176 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx) {
177 fvbCrobActiveFlag[uDpb][uCrobIdx] = fUnpackPar->IsCrobActive(uDpb, uCrobIdx);
178
179 fviFebModuleIdx[uDpb][uCrobIdx].resize(fUnpackPar->GetNbFebsPerCrob());
180 fvdFebAdcGain[uDpb][uCrobIdx].resize(fUnpackPar->GetNbFebsPerCrob(), 0.0);
181 fvdFebAdcOffs[uDpb][uCrobIdx].resize(fUnpackPar->GetNbFebsPerCrob(), 0.0);
182 for (UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++uFebIdx) {
183 fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx] = fUnpackPar->GetFebModuleIdx(uDpb, uCrobIdx, uFebIdx);
184 fvdFebAdcGain[uDpb][uCrobIdx][uFebIdx] = fUnpackPar->GetFebAdcGain(uDpb, uCrobIdx, uFebIdx);
185 fvdFebAdcOffs[uDpb][uCrobIdx][uFebIdx] = fUnpackPar->GetFebAdcOffset(uDpb, uCrobIdx, uFebIdx);
186
187 if (0 <= fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]
188 && static_cast<UInt_t>(fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]) < fuNbModules) {
189
196 fviFebAddress.push_back(fviModAddress[fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]]);
197 fviFebModule.push_back(fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]);
198 } // FEB active and module index OK
199 else if (-1 == fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]) {
200 fviFebAddress.push_back(0);
201 fviFebModule.push_back(-1);
202 } // Module index or type is set to inactive
203 else {
204 LOG(fatal) << Form("Bad module Index for DPB #%02u CROB #%u FEB %02u: %d", uDpb, uCrobIdx, uFebIdx,
205 fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx]);
206 } // Bad module index or type for this FEB
207 } // for( UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++ uFebIdx )
208 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx )
209 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
210
211 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
212 TString sPrintoutLine = Form("DPB #%02u CROB Active ?: ", uDpb);
213 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx) {
214 sPrintoutLine += Form("%1u", (fvbCrobActiveFlag[uDpb][uCrobIdx] == kTRUE));
215 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx )
216 LOG(info) << sPrintoutLine;
217 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
218
219 UInt_t uGlobalFebIdx = 0;
220 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
221 for (UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx) {
222 LOG(info) << Form("DPB #%02u CROB #%u: ", uDpb, uCrobIdx);
223 for (UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++uFebIdx) {
224 if (0 <= fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx])
225 LOG(info) << Form(" FEB #%02u (%02u): Mod. Idx = %03d (Addr. "
226 "0x%08x) ADC gain %4.0f e- ADC Offs %5.0f e-",
227 uFebIdx, uGlobalFebIdx, fviFebModuleIdx[uDpb][uCrobIdx][uFebIdx],
228 fviFebAddress[uGlobalFebIdx], fvdFebAdcGain[uDpb][uCrobIdx][uFebIdx],
229 fvdFebAdcOffs[uDpb][uCrobIdx][uFebIdx]);
230 uGlobalFebIdx++;
231 } // for( UInt_t uFebIdx = 0; uFebIdx < fUnpackPar->GetNbFebsPerCrob(); ++ uFebIdx )
232 } // for( UInt_t uCrobIdx = 0; uCrobIdx < fUnpackPar->GetNbCrobsPerDpb(); ++uCrobIdx )
233 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
234
235 // Internal status initialization
238 for (UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb) {
239 fvulCurrentTsMsb[uDpb] = 0;
240 fvuCurrentTsMsbCycle[uDpb] = 0;
241 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
242
243 return kTRUE;
244}
245// -------------------------------------------------------------------------
246
247void CbmCosy2019UnpackerAlgoHodo::AddMsComponentToList(size_t component, UShort_t usDetectorId)
248{
250 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
251 if (component == fvMsComponentsList[uCompIdx]) return;
252
254 fvMsComponentsList.push_back(component);
255
256 LOG(info) << "CbmCosy2019UnpackerAlgoHodo::AddMsComponentToList => Component " << component << " with detector ID 0x"
257 << std::hex << usDetectorId << std::dec << " added to list";
258}
259// -------------------------------------------------------------------------
260
262{
263 fulCurrentTsIdx = ts.index();
264 fdTsStartTime = static_cast<Double_t>(ts.descriptor(0, 0).idx);
265
267 if (0 == fulCurrentTsIdx) { return kTRUE; } // if( 0 == fulCurrentTsIdx )
268
270 if (-1.0 == fdTsCoreSizeInNs) {
271 fuNbCoreMsPerTs = ts.num_core_microslices();
272 fuNbOverMsPerTs = ts.num_microslices(0) - ts.num_core_microslices();
275 LOG(info) << "Timeslice parameters: each TS has " << fuNbCoreMsPerTs << " Core MS and " << fuNbOverMsPerTs
276 << " Overlap MS, for a core duration of " << fdTsCoreSizeInNs << " ns and a full duration of "
277 << fdTsFullSizeInNs << " ns";
278
282 LOG(info) << "In each TS " << fuNbMsLoop << " MS will be looped over";
283 } // if( -1.0 == fdTsCoreSizeInNs )
284
287 // LOG(info) << Form( "TS %5d Start %12f Stop %12f", fulCurrentTsIdx, fdTsStartTime, fdTsStopTimeCore );
288
290 for (fuMsIndex = 0; fuMsIndex < fuNbMsLoop; fuMsIndex++) {
292 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
293 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
294
295 if (kFALSE == ProcessMs(ts, uMsComp, fuMsIndex)) {
296 LOG(error) << "Failed to process ts " << fulCurrentTsIdx << " MS " << fuMsIndex << " for component " << uMsComp;
297 return kFALSE;
298 } // if( kFALSE == ProcessMs( ts, uMsCompIdx, fuMsIndex ) )
299 } // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
300
302 std::sort(fvmHitsInMs.begin(), fvmHitsInMs.end());
303
305 for (auto itHitIn = fvmHitsInMs.begin(); itHitIn < fvmHitsInMs.end(); ++itHitIn) {
306 UInt_t uAsicIdx = itHitIn->GetAsic();
307 UInt_t uFebIdx = itHitIn->GetAsic() / fUnpackPar->GetNbAsicsPerFeb();
308
310 if (-1 == fviFebModule[uFebIdx]) continue;
311
312 UInt_t uChanInMod =
313 fUnpackPar->GetChannelInModule(fviFebModule[uFebIdx], itHitIn->GetChan()); // 0-63 = X, 64-127 = Y
314
315 Double_t dTimeInNs = itHitIn->GetTs() * stsxyter::kdClockCycleNs - fdTimeOffsetNs;
316 if (uAsicIdx < fvdTimeOffsetNsAsics.size()) dTimeInNs -= fvdTimeOffsetNsAsics[uAsicIdx];
317 ULong64_t ulTimeInNs = static_cast<ULong64_t>(dTimeInNs);
318 /*
319 LOG(info) << Form("Hit in ASIC %2u FEB %2u (Address %08x) Chan %3u Time %12u ",
320 uAsicIdx, uFebIdx, fviFebAddress[ uFebIdx ], uChanInMod, ulTimeInNs );
321*/
322 fDigiVect.emplace_back(fviFebAddress[uFebIdx], uChanInMod, ulTimeInNs, itHitIn->GetAdc());
323 } // for( auto itHitIn = fvmHitsInMs.begin(); itHitIn < fvmHitsInMs.end(); ++itHitIn )
324
326 fvmHitsInMs.clear();
327 } // for( fuMsIndex = 0; fuMsIndex < uNbMsLoop; fuMsIndex ++ )
328
330 fvmHitsInMs.clear();
331 /*
332 for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
333 {
334 fvmHitsInMs[ uDpb ].clear();
335 } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb )
336*/
338 if (fbMonitorMode) {
339 if (kFALSE == FillHistograms()) {
340 LOG(error) << "Failed to fill histos in ts " << fulCurrentTsIdx;
341 return kFALSE;
342 } // if( kFALSE == FillHistograms() )
343
345 fhVectorCapacity->Fill(fulCurrentTsIdx, fDigiVect.capacity());
346 } // if( fbMonitorMode )
347
348 if (fuTsMaxVectorSize < fDigiVect.size()) {
350 fDigiVect.shrink_to_fit();
352 } // if( fuTsMaxVectorSize < fDigiVect.size() )
353
354 return kTRUE;
355}
356
357Bool_t CbmCosy2019UnpackerAlgoHodo::ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx)
358{
359 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
360 fuCurrentEquipmentId = msDescriptor.eq_id;
361 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsCompIdx, uMsIdx));
362
363 uint32_t uSize = msDescriptor.size;
364 fulCurrentMsIdx = msDescriptor.idx;
365 // Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
366 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
367 << " has size: " << uSize;
368
369 if (0 == fvbMaskedComponents.size()) fvbMaskedComponents.resize(ts.num_components(), kFALSE);
370
371 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
372 // fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ];
373
375 auto it = fDpbIdIndexMap.find(fuCurrDpbId);
376 if (it == fDpbIdIndexMap.end()) {
377 if (kFALSE == fvbMaskedComponents[uMsCompIdx]) {
378 LOG(info) << "---------------------------------------------------------------";
379 /*
380 LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
381 LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
382 static_cast<unsigned int>(msDescriptor.hdr_id),
383 static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
384 static_cast<unsigned int>(msDescriptor.sys_id),
385 static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
386 msDescriptor.size, msDescriptor.offset );
387*/
388 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
389 // LOG(info) << msDescriptor;
390 LOG(warning) << "Could not find the sDPB index for AFCK id 0x" << std::hex << fuCurrDpbId << std::dec
391 << " in timeslice " << fulCurrentTsIdx << " in microslice " << uMsIdx << " component " << uMsCompIdx
392 << "\n"
393 << "If valid this index has to be added in the HODO "
394 "parameter file in the DbpIdArray field";
395 fvbMaskedComponents[uMsCompIdx] = kTRUE;
396
399 if (1 == fulCurrentTsIdx) return kTRUE;
400 } // if( kFALSE == fvbMaskedComponents[ uMsComp ] )
401 else
402 return kTRUE;
403
404 return kFALSE;
405 } // if( it == fDpbIdIndexMap.end() )
406 else
408
410 UInt_t uTsMsbCycleHeader = std::floor(fulCurrentMsIdx / (stsxyter::kulTsCycleNbBins * stsxyter::kdClockCycleNs));
411
412 if (0 == uMsIdx) {
413 fvuCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
415 } // if( 0 == uMsIdx )
416 else if (uTsMsbCycleHeader != fvuCurrentTsMsbCycle[fuCurrDpbIdx] && 4194303 != fvulCurrentTsMsb[fuCurrDpbIdx]) {
417 LOG(warning) << "TS MSB cycle from MS header does not match current cycle from data "
418 << "for TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx
419 << " MsInTs " << std::setw(3) << uMsIdx << " ====> " << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " VS "
420 << uTsMsbCycleHeader;
421 fvuCurrentTsMsbCycle[fuCurrDpbIdx] = uTsMsbCycleHeader;
422 }
423
424 // If not integer number of message in input buffer, print warning/error
425 if (0 != (uSize % sizeof(stsxyter::Message)))
426 LOG(error) << "The input microslice buffer does NOT "
427 << "contain only complete sDPB messages!";
428
429 // Compute the number of complete messages in the input microslice buffer
430 uint32_t uNbMessages = (uSize - (uSize % sizeof(stsxyter::Message))) / sizeof(stsxyter::Message);
431
432 // Prepare variables for the loop on contents
433 const stsxyter::Message* pMess = reinterpret_cast<const stsxyter::Message*>(msContent);
434 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
435
437 stsxyter::MessType typeMess = pMess[uIdx].GetMessType();
438 fmMsgCounter[typeMess]++;
439 // fhStsMessType->Fill( static_cast< uint16_t > (typeMess) );
440 // fhStsMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) );
441
442 switch (typeMess) {
444 // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific!
445 UShort_t usElinkIdx = pMess[uIdx].GetLinkIndex();
446 // fhStsMessTypePerElink->Fill( usElinkIdx, static_cast< uint16_t > (typeMess) );
447 // fhStsHitsElinkPerDpb->Fill( fuCurrDpbIdx, usElinkIdx );
448
449 UInt_t uCrobIdx = usElinkIdx / fUnpackPar->GetNbElinkPerCrob();
450 Int_t uFebIdx = fUnpackPar->ElinkIdxToFebIdx(usElinkIdx);
451
452 if (-1 == uFebIdx) {
453 LOG(warning) << "CbmCosy2019UnpackerAlgoHodo::DoUnpack => "
454 << "Wrong elink Idx! Elink raw " << Form("%d remap %d", usElinkIdx, uFebIdx);
455 continue;
456 } // if( -1 == uFebIdx )
457
458 UInt_t uAsicIdx = (fuCurrDpbIdx * fUnpackPar->GetNbCrobsPerDpb() + uCrobIdx) * fUnpackPar->GetNbAsicsPerCrob()
459 + fUnpackPar->ElinkIdxToAsicIdx(usElinkIdx);
460
461 ProcessHitInfo(pMess[uIdx], usElinkIdx, uAsicIdx, uMsIdx);
462 break;
463 } // case stsxyter::MessType::Hit :
465 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
466
467 ProcessTsMsbInfo(pMess[uIdx], uIdx, uMsIdx);
468 break;
469 } // case stsxyter::MessType::TsMsb :
471 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
472
473 // The first message in the TS is a special ones: EPOCH
474 ProcessEpochInfo(pMess[uIdx]);
475
476 if (0 < uIdx)
477 LOG(info) << "CbmCosy2019UnpackerAlgoHodo::DoUnpack => "
478 << "EPOCH message at unexpected position in MS: message " << uIdx << " VS message 0 expected!";
479 break;
480 } // case stsxyter::MessType::TsMsb :
482 // UShort_t usElinkIdx = pMess[uIdx].GetStatusLink();
483 // fhStsMessTypePerElink->Fill( usElinkIdx, static_cast< uint16_t > (typeMess) );
484 ProcessStatusInfo(pMess[uIdx]);
485 break;
486 } // case stsxyter::MessType::Status
488 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
489 // FillTsMsbInfo( pMess[uIdx] );
490 break;
491 } // case stsxyter::MessType::Empty :
493 // fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fUnpackPar->GetNbElinkPerDpb(), static_cast< uint16_t > (typeMess) );
494 break;
495 } // case stsxyter::MessType::Dummy / ReadDataAck / Ack :
496 default: {
497 LOG(fatal) << "CbmCosy2019UnpackerAlgoHodo::DoUnpack => "
498 << "Unknown message type, should never happen, stopping "
499 "here! Type found was: "
500 << static_cast<int>(typeMess);
501 }
502 } // switch( typeMess )
503 } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++)
504
505 return kTRUE;
506}
507
508// -------------------------------------------------------------------------
509void CbmCosy2019UnpackerAlgoHodo::ProcessHitInfo(const stsxyter::Message& mess, const UShort_t& usElinkIdx,
510 const UInt_t& uAsicIdx, const UInt_t& /*uMsIdx*/)
511{
512 UShort_t usChan = mess.GetHitChannel();
513 UShort_t usRawAdc = mess.GetHitAdc();
514 // UShort_t usFullTs = mess.GetHitTimeFull();
515 // UShort_t usTsOver = mess.GetHitTimeOver();
516 UShort_t usRawTs = mess.GetHitTime();
517
519 // usChan = 127 - usChan;
520
521 /*
522 fhStsChanCntRaw[ uAsicIdx ]->Fill( usChan );
523 fhStsChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc );
524 fhStsChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc );
525 fhStsChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs );
526 fhStsChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() );
527*/
528 UInt_t uCrobIdx = usElinkIdx / fUnpackPar->GetNbElinkPerCrob();
529 // UInt_t uFebIdx = uAsicIdx / fUnpackPar->GetNbAsicsPerFeb();
530 // UInt_t uAsicInFeb = uAsicIdx % fUnpackPar->GetNbAsicsPerFeb();
531 // UInt_t uChanInFeb = usChan + fUnpackPar->GetNbChanPerAsic() * (uAsicIdx % fUnpackPar->GetNbAsicsPerFeb());
532
533 /*
534 Double_t dCalAdc = fvdFebAdcOffs[ fuCurrDpbIdx ][ uCrobIdx ][ uFebIdx ]
535 + (usRawAdc - 1)* fvdFebAdcGain[ fuCurrDpbIdx ][ uCrobIdx ][ uFebIdx ];
536*/
537 /*
538 fhStsFebChanCntRaw[ uFebIdx ]->Fill( uChanInFeb );
539 fhStsFebChanAdcRaw[ uFebIdx ]->Fill( uChanInFeb, usRawAdc );
540 fhStsFebChanAdcRawProf[ uFebIdx ]->Fill( uChanInFeb, usRawAdc );
541 fhStsFebChanAdcCal[ uFebIdx ]->Fill( uChanInFeb, dCalAdc );
542 fhStsFebChanAdcCalProf[ uFebIdx ]->Fill( uChanInFeb, dCalAdc );
543 fhStsFebChanRawTs[ uFebIdx ]->Fill( usChan, usRawTs );
544 fhStsFebChanMissEvt[ uFebIdx ]->Fill( usChan, mess.IsHitMissedEvts() );
545*/
546
547 // Compute the Full time stamp
548 // Use TS w/o overlap bits as they will anyway come from the TS_MSB
549 Long64_t ulHitTime = usRawTs;
550 ulHitTime +=
551 static_cast<ULong64_t>(stsxyter::kuHitNbTsBins) * static_cast<ULong64_t>(fvulCurrentTsMsb[fuCurrDpbIdx])
552 + static_cast<ULong64_t>(stsxyter::kulTsCycleNbBins) * static_cast<ULong64_t>(fvuCurrentTsMsbCycle[fuCurrDpbIdx]);
553
554 // Convert the Hit time in bins to Hit time in ns
555 Double_t dHitTimeNs = ulHitTime * stsxyter::kdClockCycleNs;
556
557 fvmHitsInMs.push_back(stsxyter::FinalHit(ulHitTime, usRawAdc, uAsicIdx, usChan, fuCurrDpbIdx, uCrobIdx));
558
559 // Check Starting point of histos with time as X axis
560 if (-1 == fdStartTime) fdStartTime = dHitTimeNs;
561 /*
562 // Fill histos with time as X axis
563 Double_t dTimeSinceStartSec = (dHitTimeNs - fdStartTime)* 1e-9;
564 Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0;
565
566 fviFebCountsSinceLastRateUpdate[uFebIdx]++;
567 fvdFebChanCountsSinceLastRateUpdate[uFebIdx][uChanInFeb] += 1;
568
569 fhStsFebChanHitRateEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uChanInFeb );
570 fhStsFebAsicHitRateEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uAsicInFeb );
571 fhStsFebHitRateEvo[ uFebIdx ]->Fill( dTimeSinceStartSec );
572 fhStsFebChanHitRateEvoLong[ uFebIdx ]->Fill( dTimeSinceStartMin, uChanInFeb, 1.0/60.0 );
573 fhStsFebAsicHitRateEvoLong[ uFebIdx ]->Fill( dTimeSinceStartMin, uAsicInFeb, 1.0/60.0 );
574 fhStsFebHitRateEvoLong[ uFebIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 );
575 if( mess.IsHitMissedEvts() )
576 {
577 fhStsFebChanMissEvtEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uChanInFeb );
578 fhStsFebAsicMissEvtEvo[ uFebIdx ]->Fill( dTimeSinceStartSec, uAsicInFeb );
579 fhStsFebMissEvtEvo[ uFebIdx ]->Fill( dTimeSinceStartSec );
580 } // if( mess.IsHitMissedEvts() )
581*/
582 /*
583 if( kTRUE == fbLongHistoEnable )
584 {
585 std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now();
586 Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count();
587 fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec );
588 fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec );
589 } // if( kTRUE == fbLongHistoEnable )
590*/
591}
592
593void CbmCosy2019UnpackerAlgoHodo::ProcessTsMsbInfo(const stsxyter::Message& mess, UInt_t uMessIdx, UInt_t uMsIdx)
594{
595 UInt_t uVal = mess.GetTsMsbVal();
596
597 /*
598 if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal &&
599 !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS!
600 {
601 LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx
602 << " MS " << std::setw( 12 ) << fulCurrentMsIdx
603 << " MsInTs " << std::setw( 3 ) << uMsIdx
604 << " DPB " << std::setw( 2 ) << fuCurrDpbIdx
605 << " Mess " << std::setw( 5 ) << uMessIdx
606 << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx]
607 << " new TsMsb " << std::setw( 5 ) << uVal
608 << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx]
609 << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx];
610 } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal )
611*/
612
613 // Update Status counters
614 if (uVal < fvulCurrentTsMsb[fuCurrDpbIdx]) {
615
616 LOG(info) << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
617 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
618 << fuCurrDpbIdx << " Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " Old MsbCy "
619 << std::setw(5) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] << " new TsMsb " << std::setw(5) << uVal;
620
622 } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
623 if (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1 && 0 != uVal && 4194303 != fvulCurrentTsMsb[fuCurrDpbIdx]
624 && 1 != uMessIdx) {
625 LOG(info) << "TS MSb Jump in "
626 << " TS " << std::setw(12) << fulCurrentTsIdx << " MS " << std::setw(12) << fulCurrentMsIdx << " MS Idx "
627 << std::setw(4) << uMsIdx << " Msg Idx " << std::setw(5) << uMessIdx << " DPB " << std::setw(2)
628 << fuCurrDpbIdx << " => Old TsMsb " << std::setw(5) << fvulCurrentTsMsb[fuCurrDpbIdx] << " new TsMsb "
629 << std::setw(5) << uVal;
630 } // if( uVal + 1 != fvulCurrentTsMsb[fuCurrDpbIdx] && 4194303 != uVal && 0 != fvulCurrentTsMsb[fuCurrDpbIdx] )
632 /*
633 if( 1 < uMessIdx )
634 {
635 fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] );
636 fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) );
637 fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) );
638 } // if( 0 < uMessIdx )
639*/
640 // fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
641 /*
642 ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins )
643 * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx])
644 + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins )
645 * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] );
646*/
647}
648
650{
651 // UInt_t uVal = mess.GetEpochVal();
652 // UInt_t uCurrentCycle = uVal % stsxyter::kulTsCycleNbBins;
653
654 /*
655 // Update Status counters
656 if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] )
657 fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++;
658 fvulCurrentTsMsb[fuCurrDpbIdx] = usVal;
659
660// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx );
661*/
662}
663
665{
666 /*
667 UInt_t uCrobIdx = usElinkIdx / fUnpackPar->GetNbElinkPerCrob();
668 Int_t uFebIdx = fUnpackPar->ElinkIdxToFebIdx( usElinkIdx );
669 UInt_t uAsicIdx = ( fuCurrDpbIdx * fUnpackPar->GetNbCrobsPerDpb() + uCrobIdx
670 ) * fUnpackPar->GetNbAsicsPerCrob()
671 + fUnpackPar->ElinkIdxToAsicIdx( usElinkIdx );
672
673 UShort_t usStatusField = mess.GetStatusStatus();
674
675 fhPulserStatusMessType->Fill( uAsicIdx, usStatusField );
677 if( fbPrintMessages )
678 {
679 std::cout << Form("DPB %2u TS %12u MS %12u mess %5u ", fuCurrDpbIdx, fulCurrentTsIdx, fulCurrentMsIdx, uIdx );
680 mess.PrintMess( std::cout, fPrintMessCtrl );
681 } // if( fbPrintMessages )
682*/
683}
684
685// -------------------------------------------------------------------------
686
687// -------------------------------------------------------------------------
688
690{
693 new TH1I("hStsDigisTimeInRun", "Digis Nb vs Time in Run; Time in run [s]; Digis Nb []", 36000, 0, 3600);
695
696 fhVectorSize = new TH1I("fhVectorSize", "Size of the vector VS TS index; TS index; Size [bytes]", 10000, 0., 10000.);
698 new TH1I("fhVectorCapacity", "Size of the vector VS TS index; TS index; Size [bytes]", 10000, 0., 10000.);
701 /*
703 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
704 {
705 UInt_t uSector = fUnpackPar->GetGdpbToSectorOffset() + uGdpb;
706 std::string sFolder = Form( "sector%2u", uSector);
707
708 LOG(info) << "gDPB " << uGdpb << " is " << sFolder;
709
710 fvhHitsTimeToTriggerRaw.push_back( new TH1D(
711 Form( "hHitsTimeToTriggerRawSect%2u", uSector ),
712 Form( "Time to trigger for all neighboring hits in sector %2u; t - Ttrigg [ns]; Hits []", uSector ),
713 2000, -5000, 5000 ) );
714
715 UInt_t uNbBinsDtSel = fdStarTriggerWinSize[ uGdpb ];
716 Double_t dMaxDtSel = fdStarTriggerDelay[ uGdpb ] + fdStarTriggerWinSize[ uGdpb ];
717 fvhHitsTimeToTriggerSel.push_back( new TH1D(
718 Form( "hHitsTimeToTriggerSelSect%2u", uSector ),
719 Form( "Time to trigger for all selected hits in sector %2u; t - Ttrigg [ns]; Hits []", uSector ),
720 uNbBinsDtSel, fdStarTriggerDelay[ uGdpb ], dMaxDtSel ) );
721
723 AddHistoToVector( fvhHitsTimeToTriggerRaw[ uGdpb ], sFolder );
724 AddHistoToVector( fvhHitsTimeToTriggerSel[ uGdpb ], sFolder );
725
726 if( kTRUE == fbDebugMonitorMode )
727 {
728 fvhHitsTimeToTriggerSelVsDaq.push_back( new TH2D(
729 Form( "hHitsTimeToTriggerSelVsDaqSect%2u", uSector ),
730 Form( "Time to trigger for all selected hits vs DAQ CMD in sector %2u; t - Ttrigg [ns]; DAQ CMD []; Hits []", uSector ),
731 uNbBinsDtSel, fdStarTriggerDelay[ uGdpb ], dMaxDtSel,
732 16, 0., 16. ) );
733
734 fvhHitsTimeToTriggerSelVsTrig.push_back( new TH2D(
735 Form( "hHitsTimeToTriggerSelVsTrigSect%2u", uSector ),
736 Form( "Time to trigger for all selected hits vs TRIG CMD in sector %2u; t - Ttrigg [ns]; TRIG CMD []; Hits []", uSector ),
737 uNbBinsDtSel, fdStarTriggerDelay[ uGdpb ], dMaxDtSel,
738 16, 0., 16. ) );
739
740 fvhTriggerDt.push_back( new TH1I(
741 Form( "hTriggerDtSect%2u", uSector ),
742 Form( "Trigger time difference between sector %2u and the first sector, full events only; Ttrigg%2u - TtriggRef [Clk]; events []",
743 uSector, uSector ),
744 200, -100, 100 ) );
745
748 UInt_t uNbBinsInTs = fdMsSizeInNs * 111 / 1000. / 10.;
749 UInt_t uNbBinsInMs = fdMsSizeInNs * 20 / 1000. / 10.;
750
751 fvhTriggerDistributionInTs.push_back( new TH1I( Form( "hTriggerDistInTsSect%2u", uSector ),
752 Form( "Trigger distribution inside TS in sector %2u; Time in TS [us]; Trigger [];", uSector ),
753 uNbBinsInTs, -0.5 - fdMsSizeInNs * 10 / 1000., fdMsSizeInNs * 101 / 1000. - 0.5 ) );
754
755 fvhTriggerDistributionInMs.push_back( new TH1I( Form( "hTriggerDistInMsSect%2u", uSector ),
756 Form( "Trigger distribution inside MS in sector %2u; Time in MS [us]; Trigger [];", uSector ),
757 uNbBinsInMs, -0.5 - fdMsSizeInNs * 10 / 1000., fdMsSizeInNs * 10 / 1000. - 0.5 ) );
758
759 fvhMessDistributionInMs.push_back( new TH1I( Form( "hMessDistInMsSect%2u", uSector ),
760 Form( "Messages distribution inside MS in sector %2u; Time in MS [us]; Trigger [];", uSector ),
761 uNbBinsInMs, -0.5 - fdMsSizeInNs * 10 / 1000., fdMsSizeInNs * 10 / 1000. - 0.5 ) );
762
764 AddHistoToVector( fvhHitsTimeToTriggerSelVsDaq[ uGdpb ], sFolder );
765 AddHistoToVector( fvhHitsTimeToTriggerSelVsTrig[ uGdpb ], sFolder );
766 AddHistoToVector( fvhTriggerDt[ uGdpb ], sFolder );
767 AddHistoToVector( fvhTriggerDistributionInTs[ uGdpb ], sFolder );
768 AddHistoToVector( fvhTriggerDistributionInMs[ uGdpb ], sFolder );
769 AddHistoToVector( fvhMessDistributionInMs[ uGdpb ], sFolder );
770 } // if( kTRUE == fbDebugMonitorMode )
771 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
772
774 fhEventNbPerTs = new TH1I( "hEventNbPerTs",
775 "Number of Events per TS; Events []; TS []",
776 1000 , 0, 1000 );
777
778 fhEventSizeDistribution = new TH1I( "hEventSizeDistribution",
779 "Event size distribution; Event size [byte]; Events []",
780 CbmTofStarSubevent2019::GetMaxOutputSize()/8 , 0, CbmTofStarSubevent2019::GetMaxOutputSize() );
781
782 fhEventSizeEvolution = new TProfile( "hEventSizeEvolution",
783 "Event size evolution; Time in run [min]; mean Event size [byte];",
784 14400, 0, 14400 );
785
786 fhEventNbEvolution = new TH1I( "hEventNbEvolution",
787 "Event number evolution; Time in run [min]; Events [];",
788 14400, 0, 14400 );
789
791 AddHistoToVector( fhEventNbPerTs, "eventbuilder" );
792 AddHistoToVector( fhEventSizeDistribution, "eventbuilder" );
793 AddHistoToVector( fhEventSizeEvolution, "eventbuilder" );
794 AddHistoToVector( fhEventNbEvolution, "eventbuilder" );
795
796 if( kTRUE == fbDebugMonitorMode )
797 {
800 UInt_t uNbBinsInTs = fdMsSizeInNs * 101 / 1000. / 10.;
801
802 fhEventNbDistributionInTs = new TH1I( "hEventNbDistributionInTs",
803 "Event number distribution inside TS; Time in TS [us]; Events [];",
804 uNbBinsInTs, -0.5, fdMsSizeInNs * 101 / 1000. - 0.5 );
805
806 fhEventSizeDistributionInTs = new TProfile( "hEventSizeDistributionInTs",
807 "Event size distribution inside TS; Time in TS [us]; mean Event size [Byte];",
808 uNbBinsInTs, -0.5, fdMsSizeInNs * 101 / 1000. - 0.5 );
809
810 fhRawTriggersStats = new TH2I(
811 "hRawTriggersStats",
812 "Raw triggers statistics per sector; ; Sector []; Messages []",
813 5, 0, 5,
814 12, 13, 25 );
815 fhRawTriggersStats->GetXaxis()->SetBinLabel( 1, "A");
816 fhRawTriggersStats->GetXaxis()->SetBinLabel( 2, "B");
817 fhRawTriggersStats->GetXaxis()->SetBinLabel( 3, "C");
818 fhRawTriggersStats->GetXaxis()->SetBinLabel( 4, "D");
819 fhRawTriggersStats->GetXaxis()->SetBinLabel( 5, "F");
820
821 fhMissingTriggersEvolution = new TH2I(
822 "hMissingTriggersEvolution",
823 "Missing trigger counts per sector vs time in run; Time in run [min]; Sector []; Missing triggers []",
824 14400, 0, 14400,
825 12, 13, 25 );
826
828 AddHistoToVector( fhEventNbDistributionInTs, "eventbuilder" );
829 AddHistoToVector( fhEventSizeDistributionInTs, "eventbuilder" );
830 AddHistoToVector( fhRawTriggersStats, "eventbuilder" );
831 AddHistoToVector( fhMissingTriggersEvolution, "eventbuilder" );
832 } // if( kTRUE == fbDebugMonitorMode )
833
835 Double_t w = 10;
836 Double_t h = 10;
837
839 fcTimeToTrigRaw = new TCanvas( "cTimeToTrigRaw", "Raw Time to trig for all sectors", w, h);
840 fcTimeToTrigRaw->Divide( 2, fuNrOfGdpbs / 2 );
841 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
842 {
843 fcTimeToTrigRaw->cd( 1 + uGdpb );
844 gPad->SetGridx();
845 gPad->SetGridy();
846 gPad->SetLogy();
847 fvhHitsTimeToTriggerRaw[ uGdpb ]->Draw();
848 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
849
851 fcTimeToTrigSel = new TCanvas( "cTimeToTrigSel", "Selected Time to trig for all sectors", w, h);
852 fcTimeToTrigSel->Divide( 2, fuNrOfGdpbs / 2 );
853 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
854 {
855 fcTimeToTrigSel->cd( 1 + uGdpb );
856 gPad->SetGridx();
857 gPad->SetGridy();
858 gPad->SetLogy();
859 fvhHitsTimeToTriggerSel[ uGdpb ]->Draw();
860 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
861
862 if( kTRUE == fbDebugMonitorMode )
863 {
865 fcTrigDistMs = new TCanvas( "cTrigDistMs", "Trigger time to MS start for all sectors", w, h);
866 fcTrigDistMs->Divide( 2, fuNrOfGdpbs / 2 );
867 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
868 {
869 fcTrigDistMs->cd( 1 + uGdpb );
870 gPad->SetGridx();
871 gPad->SetGridy();
872 gPad->SetLogy();
873 fvhTriggerDistributionInMs[ uGdpb ]->Draw();
874 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
875
877 fcMessDistMs = new TCanvas( "cMessDistMs", "Message time to MS start for all sectors", w, h);
878 fcMessDistMs->Divide( 2, fuNrOfGdpbs / 2 );
879 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
880 {
881 fcMessDistMs->cd( 1 + uGdpb );
882 gPad->SetGridx();
883 gPad->SetGridy();
884 gPad->SetLogy();
885 fvhMessDistributionInMs[ uGdpb ]->Draw();
886 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
887 } // if( kTRUE == fbDebugMonitorMode )
888
890 fcEventBuildStats = new TCanvas( "cEvtBuildStats", "Event building statistics", w, h);
891 if( kTRUE == fbDebugMonitorMode )
892 fcEventBuildStats->Divide( 2, 3 );
893 else fcEventBuildStats->Divide( 2, 2 );
894
895 fcEventBuildStats->cd( 1 );
896 gPad->SetGridx();
897 gPad->SetGridy();
898 gPad->SetLogy();
899 fhEventNbPerTs->Draw();
900
901 fcEventBuildStats->cd( 2 );
902 gPad->SetGridx();
903 gPad->SetGridy();
904 gPad->SetLogy();
905 fhEventSizeDistribution->Draw();
906
907 fcEventBuildStats->cd( 3 );
908 gPad->SetGridx();
909 gPad->SetGridy();
910 gPad->SetLogy();
911 fhEventSizeEvolution->Draw();
912
913 fcEventBuildStats->cd( 4 );
914 gPad->SetGridx();
915 gPad->SetGridy();
916 gPad->SetLogy();
917 fhEventNbEvolution->Draw();
918
919 if( kTRUE == fbDebugMonitorMode )
920 {
921 fcEventBuildStats->cd( 5 );
922 gPad->SetGridx();
923 gPad->SetGridy();
924 gPad->SetLogy();
925 fhEventNbDistributionInTs->Draw();
926
927 fcEventBuildStats->cd( 6 );
928 gPad->SetGridx();
929 gPad->SetGridy();
930 gPad->SetLogy();
931 fhEventSizeDistributionInTs->Draw();
932 } // if( kTRUE == fbDebugMonitorMode )
933
934 AddCanvasToVector( fcEventBuildStats, "canvases" );
935*/
936 return kTRUE;
937}
939{
940 for (auto itHit = fDigiVect.begin(); itHit != fDigiVect.end(); ++itHit) {
941 fhDigisTimeInRun->Fill(itHit->GetTime() * 1e-9);
942 } // for( auto itHit = fDigiVect.begin(); itHit != fDigiVect.end(); ++itHit)
943 return kTRUE;
944}
946{
947 fhDigisTimeInRun->Reset();
948 /*
949 for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
950 {
951 fvhHitsTimeToTriggerRaw[ uGdpb ]->Reset();
952 fvhHitsTimeToTriggerSel[ uGdpb ]->Reset();
953
954 if( kTRUE == fbDebugMonitorMode )
955 {
956 fvhHitsTimeToTriggerSelVsDaq[ uGdpb ]->Reset();
957 fvhHitsTimeToTriggerSelVsTrig[ uGdpb ]->Reset();
958 fvhTriggerDt[ uGdpb ]->Reset();
959 fvhTriggerDistributionInTs[ uGdpb ]->Reset();
960 fvhTriggerDistributionInMs[ uGdpb ]->Reset();
961 fvhMessDistributionInMs[ uGdpb ]->Reset();
962 } // if( kTRUE == fbDebugMonitorMode )
963 } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb )
964
966 fhEventNbPerTs->Reset();
967 fhEventSizeDistribution->Reset();
968 fhEventSizeEvolution->Reset();
969 fhEventNbEvolution->Reset();
970
971 if( kTRUE == fbDebugMonitorMode )
972 {
973 fhEventNbDistributionInTs->Reset();
974 fhEventSizeDistributionInTs->Reset();
975 fhRawTriggersStats->Reset();
976 fhMissingTriggersEvolution->Reset();
977 } // if( kTRUE == fbDebugMonitorMode )
978*/
979 return kTRUE;
980}
981// -------------------------------------------------------------------------
982
983void CbmCosy2019UnpackerAlgoHodo::SetTimeOffsetNsAsic(UInt_t uAsicIdx, Double_t dOffsetIn)
984{
985 if (uAsicIdx >= fvdTimeOffsetNsAsics.size()) {
986 fvdTimeOffsetNsAsics.resize(uAsicIdx + 1, 0.0);
987 } // if( uAsicIdx < fvdTimeOffsetNsAsics.size() )
988
989 fvdTimeOffsetNsAsics[uAsicIdx] = dOffsetIn;
990}
991// -------------------------------------------------------------------------
std::string FormatMsHeaderPrintout(const fles::MicrosliceDescriptor &msDescriptor)
int Int_t
bool Bool_t
std::chrono::steady_clock::time_point ftStartTimeUnix
std::vector< std::vector< std::vector< Double_t > > > fvdFebAdcGain
Idx of the STS module for each FEB, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ], -1 if inactive.
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
std::map< UInt_t, UInt_t > fDpbIdIndexMap
Total number of STS DPBs in system.
void ProcessStatusInfo(const stsxyter::Message &mess)
std::vector< std::vector< std::vector< Double_t > > > fvdFebAdcOffs
ADC gain in e-/b, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ].
std::vector< ULong64_t > fvulCurrentTsMsb
std::vector< Double_t > fvdTimeOffsetNsAsics
std::vector< std::vector< Bool_t > > fvbCrobActiveFlag
Map of DPB Identifier to DPB index.
void SetTimeOffsetNsAsic(UInt_t uAsicIdx, Double_t dOffsetIn=0.0)
void ProcessTsMsbInfo(const stsxyter::Message &mess, UInt_t uMessIdx=0, UInt_t uMsIdx=0)
CbmCosy2019HodoPar * fUnpackPar
Settings from parameter file.
void ProcessEpochInfo(const stsxyter::Message &mess)
std::vector< stsxyter::FinalHit > fvmHitsInMs
Hits time-sorting.
Double_t fdTimeOffsetNs
Module for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
std::vector< Int_t > fviFebAddress
ADC offset in e-, [ NbDpb ][ NbCrobPerDpb ][ NbFebsPerCrob ].
UInt_t fuNrOfDpbs
STS address for the first strip of each module.
std::vector< Int_t > fviFebModule
STS address for each FEB, [ NbDpb * NbCrobPerDpb * NbFebsPerCrob ].
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
std::vector< Bool_t > fvbMaskedComponents
Switch ON the filling of a additional set of histograms.
Bool_t fbDebugMonitorMode
Switch ON the filling of a minimal set of histograms.
std::vector< std::vector< std::vector< Int_t > > > fviFebModuleIdx
Number of StsXyter ASICs.
Int_t fiRunStartDateTimeSec
Index of the DPB from which the MS currently unpacked is coming.
std::map< stsxyter::MessType, UInt_t > fmMsgCounter
UInt_t fuMsIndex
Start Time in ns of current MS from its index field in header.
TH1 * fhDigisTimeInRun
All hits (time in bins, ADC in bins, asic, channel) in last MS, sorted with "<" operator.
Int_t fiBinSizeDatePlots
Start of run time since "epoch" in s, for the plots with date as X axis.
std::vector< UInt_t > fvuCurrentTsMsbCycle
Current TS MSB for each DPB.
Double_t fdMsTime
End Time in ns of current TS Core from the index of the first MS first component.
UInt_t fuNbFebs
Array to hold the active flag for all CROBs, [ NbDpb ][ NbCrobPerDpb ].
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
std::vector< Int_t > fviModAddress
Total number of STS modules in the setup.
UInt_t fuNbStsXyters
Number of FEBs with StsXyter ASICs.
Bool_t ProcessTs(const fles::Timeslice &ts)
void ProcessHitInfo(const stsxyter::Message &mess, const UShort_t &usElinkIdx, const UInt_t &uAsicIdx, const UInt_t &uMsIdx)
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
std::vector< size_t > fvMsComponentsList
std::vector< CbmStsDigi > fDigiVect
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 MessType GetMessType() const
Returns the message type, see enum MessType.
XPU_D uint16_t GetHitTime() const
For Hit data: Returns timestamp (8 bit field, 2 MSB bits overlap removed)
XPU_D uint32_t GetTsMsbVal() const
For TS MSB data: Returns the TS MSB 22 bit field)
Hash for CbmL1LinkKey.
static constexpr uint64_t kulTsCycleNbBins
static constexpr uint32_t kuHitNbTsBins
static constexpr double kdClockCycleNs
MessType
Message types.