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