CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018UnpackerAlgoPsd.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: Nikolay Karpushkin, David Emschermann [committer], Pierre-Alain Loizeau */
4
5// -----------------------------------------------------------------------------
6// ----- -----
7// ----- CbmMcbm2018UnpackerAlgoPsd -----
8// ----- Created 09.10.2019 by N.Karpushkin -----
9// ----- based on CbmMcbm2018UnpackerAlgoTof by P.-A. Loizeau -----
10// ----- -----
11// -----------------------------------------------------------------------------
12
14
16#include "CbmMcbm2018PsdPar.h"
17#include "CbmPsdAddress.h"
18#include "TCanvas.h"
19#include "TH1.h"
20#include "TH2.h"
21#include "TList.h"
22#include "TProfile.h"
23#include "TROOT.h"
24#include "TString.h"
25
26#include <Logger.h>
27
28#include <cstdint>
29#include <fstream>
30#include <iomanip>
31#include <iostream>
32
33// -------------------------------------------------------------------------
38
40{
41 if (nullptr != fPsdDigiVector) {
42 fPsdDigiVector->clear();
43 delete fPsdDigiVector;
44 }
45 if (nullptr != fPsdDspVector) {
46 fPsdDspVector->clear();
47 delete fPsdDspVector;
48 }
49}
50
51// -------------------------------------------------------------------------
53{
54 LOG(info) << "Initializing mCBM PSD 2019 unpacker algo";
55
56 return kTRUE;
57}
64
65// -------------------------------------------------------------------------
67{
68 LOG(info) << "Init parameter containers for CbmMcbm2018UnpackerAlgoPsd";
69 Bool_t initOK = ReInitContainers();
70
71 return initOK;
72}
74{
75 LOG(info) << "**********************************************";
76 LOG(info) << "ReInit parameter containers for CbmMcbm2018UnpackerAlgoPsd";
77
78 fUnpackPar = (CbmMcbm2018PsdPar*) fParCList->FindObject("CbmMcbm2018PsdPar");
79 if (nullptr == fUnpackPar) return kFALSE;
80
81 Bool_t initOK = InitParameters();
82
83 return initOK;
84}
86{
87 if (nullptr == fParCList) fParCList = new TList();
88 fUnpackPar = new CbmMcbm2018PsdPar("CbmMcbm2018PsdPar");
90
91 return fParCList;
92}
94{
95 fuRawDataVersion = fUnpackPar->GetDataVersion();
96 LOG(info) << "Data Version: " << fuRawDataVersion;
97
98 fuNrOfGdpbs = fUnpackPar->GetNrOfGdpbs();
99 LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs;
100
101 fuNrOfFeePerGdpb = fUnpackPar->GetNrOfFeesPerGdpb();
102 LOG(info) << "Nr. of FEEs per Psd GDPB: " << fuNrOfFeePerGdpb;
103
104 fuNrOfChannelsPerFee = fUnpackPar->GetNrOfChannelsPerFee();
105 LOG(info) << "Nr. of channels per FEE: " << fuNrOfChannelsPerFee;
106
108 LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb;
109
110 fGdpbIdIndexMap.clear();
111 for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
112 fGdpbIdIndexMap[fUnpackPar->GetGdpbId(i)] = i;
113 LOG(info) << "GDPB Id of PSD " << i << " : " << std::hex << fUnpackPar->GetGdpbId(i) << std::dec;
114 } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
115
116 fuNrOfGbtx = fUnpackPar->GetNrOfGbtx();
117 LOG(info) << "Nr. of GBTx: " << fuNrOfGbtx;
118
119 //Temporary until creation of full psd map
120 UInt_t uNrOfModules = 1;
121 UInt_t uNrOfSections = 32;
122 UInt_t uNrOfChannels = uNrOfModules * uNrOfSections;
123 LOG(info) << "Nr. of possible Psd channels: " << uNrOfChannels;
124 fviPsdChUId.resize(uNrOfChannels);
125
126 UInt_t iCh = 0;
127 for (UInt_t iModule = 0; iModule < uNrOfModules; ++iModule) {
128 for (UInt_t iSection = 0; iSection < uNrOfSections; ++iSection) {
129 iCh = iModule * uNrOfSections + iSection;
130 fviPsdChUId[iCh] = CbmPsdAddress::GetAddress(iModule, iSection);
131 }
132 }
133
134 return kTRUE;
135}
136// -------------------------------------------------------------------------
137
138void CbmMcbm2018UnpackerAlgoPsd::AddMsComponentToList(size_t component, UShort_t usDetectorId)
139{
141 for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
142 if (component == fvMsComponentsList[uCompIdx]) return;
143
145 fvMsComponentsList.push_back(component);
146
147 LOG(info) << "CbmMcbm2018UnpackerAlgoPsd::AddMsComponentToList => Component " << component << " with detector ID 0x"
148 << std::hex << usDetectorId << std::dec << " added to list";
149}
150// -------------------------------------------------------------------------
151
153{
154
155 fulCurrentTsIdx = ts.index();
156 fdTsStartTime = static_cast<Double_t>(ts.start_time());
157
159 if (0 == fulCurrentTsIdx) { return kTRUE; } // if( 0 == fulCurrentTsIdx )
160
162 if (-1.0 == fdTsCoreSizeInNs) {
163 fuNbCoreMsPerTs = ts.num_core_microslices();
164 fuNbOverMsPerTs = ts.num_microslices(0) - ts.num_core_microslices();
167 LOG(info) << "Timeslice parameters: each TS has " << fuNbCoreMsPerTs << " Core MS and " << fuNbOverMsPerTs
168 << " Overlap MS, for a core duration of " << fdTsCoreSizeInNs << " ns and a full duration of "
169 << fdTsFullSizeInNs << " ns";
170
174 LOG(info) << "In each TS " << fuNbMsLoop << " MS will be looped over";
175 } // if( -1.0 == fdTsCoreSizeInNs )
176
179 // LOG(info) << Form( "TS %5d Start %12f Stop %12f", fulCurrentTsIdx, fdTsStartTime, fdTsStopTimeCore );
180
181 fDigiVect.clear();
183 for (fuMsIndex = 0; fuMsIndex < fuNbMsLoop; fuMsIndex++) {
185 for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
186 UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
187 if (kFALSE == ProcessMs(ts, uMsComp, fuMsIndex)) {
188 LOG(error) << "Failed to process ts " << fulCurrentTsIdx << " MS " << fuMsIndex << " for component " << uMsComp;
189 return kFALSE;
190 } // if( kFALSE == ProcessMs( ts, uMsCompIdx, fuMsIndex ) )
191 } // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
192 } // for( fuMsIndex = 0; fuMsIndex < uNbMsLoop; fuMsIndex ++ )
193
195 //std::sort(fDigiVect.begin(), fDigiVect.end(),
196 // [](const CbmPsdDigi& a, const CbmPsdDigi& b) -> bool { return a.GetTime() < b.GetTime(); });
197
198 std::sort(fPsdDigiVector->begin(), fPsdDigiVector->end(),
199 [](const CbmPsdDigi& a, const CbmPsdDigi& b) -> bool { return a.GetTime() < b.GetTime(); });
200
201 if (fbDebugWriteOutput && (fPsdDspVector != nullptr)) {
202 std::sort(fPsdDspVector->begin(), fPsdDspVector->end(),
203 [](const CbmPsdDsp& a, const CbmPsdDsp& b) -> bool { return a.GetTime() < b.GetTime(); });
204 }
205
206 return kTRUE;
207}
208
209
210Bool_t CbmMcbm2018UnpackerAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx)
211{
212 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
213 fuCurrentEquipmentId = msDescriptor.eq_id;
214 const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsCompIdx, uMsIdx));
215
216 uint32_t uSize = msDescriptor.size;
217 fulCurrentMsIdx = msDescriptor.idx;
218
219 fdMsTime = static_cast<double>(fulCurrentMsIdx);
220
221 LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
222 << " has size: " << uSize;
223
224 if (0 == fvbMaskedComponents.size()) fvbMaskedComponents.resize(ts.num_components(), kFALSE);
225
226 fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
227
229 auto it = fGdpbIdIndexMap.find(fuCurrDpbId);
230 if (it == fGdpbIdIndexMap.end()) {
231 if (kFALSE == fvbMaskedComponents[uMsCompIdx]) {
232 LOG(info) << "---------------------------------------------------------------";
233
234 LOG(info) << FormatMsHeaderPrintout(msDescriptor);
235 LOG(warning) << "Could not find the gDPB index for AFCK id 0x" << std::hex << fuCurrDpbId << std::dec
236 << " in timeslice " << fulCurrentTsIdx << " in microslice " << uMsIdx << " component " << uMsCompIdx
237 << "\n"
238 << "If valid this index has to be added in the PSD "
239 "parameter file in the DbpIdArray field";
240 fvbMaskedComponents[uMsCompIdx] = kTRUE;
241 } // if( kFALSE == fvbMaskedComponents[ uMsComp ] )
242 else
243 return kTRUE;
244
247
248
249 return kFALSE;
250
251 } // if( it == fGdpbIdIndexMap.end() )
252 else
254
255 fuCurrentMsSysId = static_cast<unsigned int>(msDescriptor.sys_id);
256
257 // If not integer number of message in input buffer, print warning/error
258 if (0 != (uSize % kuBytesPerMessage))
259 LOG(error) << "The input microslice buffer does NOT "
260 << "contain only complete nDPB messages!";
261
264 Double_t dMsRelativeTime = fdMsTime - fdTsStartTime;
265
266 // If MS time is less than start time print error and return
267 if (fdMsTime - fdStartTime < 0) {
268 LOG(error) << "CbmMcbm2018UnpackerAlgoPsd:: Negative time! MS time = " << fdMsTime
269 << "; Start time = " << fdStartTime;
270 //return kFALSE;
271 }
272
273 // Compute the number of complete messages in the input microslice buffer
274 uint32_t uNbMessages = (uSize - (uSize % kuBytesPerMessage)) / kuBytesPerMessage;
275
276 // Prepare variables for the loop on contents
277 const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent);
278
279 /*
280 if (uSize != 0) {
281 printf("%u = %u 64bit messages\n", uSize, uNbMessages);
282 for(uint32_t line_iter = 0; line_iter<uNbMessages; line_iter++){
283 printf("%016lx\n", (pInBuff[line_iter]));
284 }
285 }
286*/
287
288 if ((fair::Logger::Logging(fair::Severity::debug)) && (uNbMessages > 1)) {
289 printf("%u = %u 64bit messages\n", uSize, uNbMessages);
290 for (uint32_t line_iter = 0; line_iter < uNbMessages - 2; line_iter += 2) {
291 printf("%010llx", static_cast<unsigned long long int>(pInBuff[line_iter] & 0xffffffffff));
292 printf("%010llx", static_cast<unsigned long long int>(pInBuff[line_iter + 1] & 0xffffffffff));
293 printf(" %u - %u", line_iter + 1, line_iter + 2);
294 printf("\n");
295 }
296 printf("%020llx %u\n", static_cast<unsigned long long int>(pInBuff[uNbMessages - 1]), uNbMessages);
297 }
298
299 // every 80bit gbt word is decomposed into two 64bit words
300 if (uNbMessages > 1) { //more than one 64 bit word
301
302 switch (fuRawDataVersion) {
303 // --------------------------------------------------------------------------------------------------
304 case 100: {
305
306 PsdDataV100::PsdGbtReader PsdReader(pInBuff);
307 if (fair::Logger::Logging(fair::Severity::debug)) PsdReader.SetPrintOutMode(true);
308
309 while (PsdReader.GetTotalGbtWordsRead() < uNbMessages) {
310 int ReadResult = PsdReader.ReadMs();
311 if (fair::Logger::Logging(fair::Severity::debug)) {
312 printf("\nMicroslice idx: %llu\n", fulCurrentMsIdx);
313 PsdReader.PrintOut(); /*PsdReader.PrintSaveBuff();*/
314 }
315 if (ReadResult == 0) {
316
317 double prev_hit_time =
318 dMsRelativeTime + (double) PsdReader.VectPackHdr.at(0).uAdcTime * 12.5 - fdTimeOffsetNs; //in ns
319
320 //hit loop
321 for (uint64_t hit_iter = 0; hit_iter < PsdReader.VectHitHdr.size(); hit_iter++) {
322 if (PsdReader.VectPackHdr.size() != PsdReader.VectHitHdr.size()) {
323 LOG(error) << "Different vector headers sizes!"
324 << " in VectPackHdr " << PsdReader.VectPackHdr.size() << " in VectHitHdr "
325 << PsdReader.VectHitHdr.size() << "\n";
326 break;
327 }
328
329 uint8_t uHitChannel = PsdReader.VectHitHdr.at(hit_iter).uHitChannel;
330 //uint8_t uLinkIndex = PsdReader.VectPackHdr.at(hit_iter).uLinkIndex;
331 if (uHitChannel >= fviPsdChUId.size()) {
332 LOG(error) << "hit channel number out of range! channel index: " << uHitChannel
333 << " max: " << fviPsdChUId.size();
334 break;
335 }
336 UInt_t uChanUId = fviPsdChUId[uHitChannel]; //unique ID
337
338 UInt_t fuAddress = uChanUId;
339 Double_t fdTime = dMsRelativeTime + (double) PsdReader.VectPackHdr.at(hit_iter).uAdcTime * 12.5
341 Double_t fdTsTime =
343 Double_t fdEdep = (double) PsdReader.VectHitHdr.at(hit_iter).uSignalCharge
344 / fUnpackPar->GetMipCalibration(uHitChannel);
345 UInt_t fuZL = PsdReader.VectHitHdr.at(hit_iter).uZeroLevel;
346 Double_t fdAccum = (double) PsdReader.VectHitHdr.at(hit_iter).uFeeAccum;
347 Double_t fdAdcTime = (double) PsdReader.VectPackHdr.at(hit_iter).uAdcTime;
348
349 Double_t fdEdepWfm = 0.;
350 Double_t fdAmpl = 0.;
351 UInt_t fuMinimum = 0;
352 UInt_t fuTimeMax = 0;
353 std::vector<uint16_t> fuWfm = PsdReader.VectHitData.at(hit_iter).uWfm;
354
355 Double_t fdFitAmpl = 0.;
356 Double_t fdFitZL = 0.;
357 Double_t fdFitEdep = 0.;
358 Double_t fdFitR2 = 999.;
359 Double_t fdFitTimeMax = -1.;
360 std::vector<uint16_t> fuFitWfm;
361
362 if (!fuWfm.empty()) {
363
364 int32_t iHitChargeWfm = std::accumulate(fuWfm.begin(), fuWfm.end(), -fuZL * fuWfm.size());
365 auto const max_iter = std::max_element(fuWfm.begin(), fuWfm.end());
366 assert(max_iter != fuWfm.end());
367 if (max_iter == fuWfm.end()) break;
368 uint8_t uHitTimeMax = std::distance(fuWfm.begin(), max_iter);
369 int32_t iHitAmlpitude = *max_iter - fuZL;
370 auto const min_iter = std::min_element(fuWfm.begin(), fuWfm.end());
371 uint32_t uHitMinimum = *min_iter;
372
373 fdEdepWfm = (double) iHitChargeWfm / fUnpackPar->GetMipCalibration(uHitChannel); // ->now in MeV
374 fdAmpl = (double) iHitAmlpitude / 16.5; // -> now in mV
375 fuTimeMax = uHitTimeMax;
376 fuMinimum = uHitMinimum;
377
378 int gate_beg = 0;
379 int gate_end = (int) fuWfm.size() - 1;
380 PsdSignalFitting::PronyFitter Pfitter(2, 2, gate_beg, gate_end);
381 Pfitter.SetDebugMode(0);
382 //std::vector<int> iWfm(fuWfm.begin(), fuWfm.end());
383 Pfitter.SetWaveform(fuWfm, fuZL);
384 int SignalBeg = 4;
385 //0.6, 0.2 // 0.72 0.38
386 std::complex<float> first_fit_harmonic = {0.72, 0.0};
387 std::complex<float> second_fit_harmonic = {0.38, -0.0};
388 Pfitter.SetExternalHarmonics(first_fit_harmonic, second_fit_harmonic);
389 Int_t best_signal_begin = Pfitter.ChooseBestSignalBegin(SignalBeg - 1, SignalBeg + 1);
390 Pfitter.SetSignalBegin(best_signal_begin);
391 Pfitter.CalculateFitAmplitudes();
392
393 fdFitEdep =
394 Pfitter.GetIntegral(gate_beg, gate_end) / fUnpackPar->GetMipCalibration(uHitChannel); // ->now in MeV
395 fdFitAmpl = (Pfitter.GetMaxAmplitude() - Pfitter.GetZeroLevel()) / 16.5; // ->now in mV
396 fdFitR2 = Pfitter.GetRSquare(gate_beg, gate_end);
397 fdFitZL = Pfitter.GetZeroLevel();
398 fdFitTimeMax = Pfitter.GetSignalMaxTime();
399 fuFitWfm = Pfitter.GetFitWfm();
400 }
401
402 CbmPsdDsp dsp = CbmPsdDsp(fuAddress, fdTime, fdTsTime, fdEdep, fuZL, fdAccum, fdAdcTime,
403
404 fdEdepWfm, fdAmpl, fuMinimum, fuTimeMax, fuWfm,
405
406 fdFitAmpl, fdFitZL, fdFitEdep, fdFitR2, fdFitTimeMax, fuFitWfm);
407
408 std::unique_ptr<CbmPsdDigi> digi = MakeDigi(dsp);
409 if (digi) fPsdDigiVector->emplace_back(*digi);
410
411 if (fbDebugWriteOutput && (fPsdDspVector != nullptr)) { fPsdDspVector->emplace_back(dsp); }
412
413 //DEBUG
414 if (fdTime < prev_hit_time) printf("negative time btw hits! %f after %f \n", fdTime, prev_hit_time);
415 //DEBUG END
416 prev_hit_time = fdTime;
417 //DEBUG
418
419 } // for (uint64_t hit_iter = 0; hit_iter < PsdReader.VectHitHdr.size(); hit_iter++) {
420 }
421 else if (ReadResult == 1) {
422 LOG(error) << "no pack headers in message!";
423 break;
424 }
425 else if (ReadResult == 2) {
426 LOG(error) << "wrong channel! In header: " << PsdReader.HitHdr.uHitChannel;
427 break;
428 }
429 else if (ReadResult == 3) {
430 LOG(error) << "check number of waveform points! In header: " << PsdReader.HitHdr.uWfmWords - 1;
431 break;
432 }
433 else {
434 LOG(error) << "PsdGbtReader.ReadEventFles() didn't return expected values";
435 break;
436 }
437
438
439 } // while(PsdReader.GetTotalGbtWordsRead()<uNbMessages)
440
441 if (uNbMessages != PsdReader.GetTotalGbtWordsRead())
442 LOG(error) << "Wrong amount of messages read!"
443 << " in microslice " << uNbMessages << " by PsdReader " << PsdReader.GetTotalGbtWordsRead()
444 << "\n";
445
446 break;
447 } // case 100
448 // --------------------------------------------------------------------------------------------------
449 // --------------------------------------------------------------------------------------------------
450 case 000: {
451
452 PsdDataV000::PsdGbtReader PsdReader(pInBuff);
453 //PsdReader.SetPrintOutMode(true);
454
455 while (PsdReader.GetTotalGbtWordsRead() < uNbMessages) {
456 int ReadResult = PsdReader.ReadEventFles();
457 if (PsdReader.EvHdrAb.uHitsNumber > fviPsdChUId.size()) {
458 LOG(error) << "too many triggered channels! In header: " << PsdReader.EvHdrAb.uHitsNumber
459 << " in PSD: " << fviPsdChUId.size();
460 break;
461 }
462
463 if (ReadResult == 0) {
464 //hit loop
465 for (int hit_iter = 0; hit_iter < PsdReader.EvHdrAb.uHitsNumber; hit_iter++) {
466 UInt_t uHitChannel = PsdReader.VectHitHdr.at(hit_iter).uHitChannel;
467 UInt_t uSignalCharge = PsdReader.VectHitHdr.at(hit_iter).uSignalCharge;
468 //UInt_t uZeroLevel = PsdReader.VectHitHdr.at(hit_iter).uZeroLevel;
469 Double_t dHitTime =
470 (double) PsdReader.EvHdrAb.ulMicroSlice + (double) PsdReader.EvHdrAc.uAdcTime * 12.5 - fdTimeOffsetNs;
471
472 if (uHitChannel >= fviPsdChUId.size()) {
473 LOG(error) << "hit channel number out of range! channel index: " << uHitChannel
474 << " max: " << fviPsdChUId.size();
475 break;
476 }
477 UInt_t uChanUId = fviPsdChUId[uHitChannel]; //unique ID
478
479 LOG(debug) << Form("Insert 0x%08x digi with charge ", uChanUId) << uSignalCharge
480 << Form(", at %u,", PsdReader.EvHdrAc.uAdcTime)
481 << " epoch: " << PsdReader.EvHdrAb.ulMicroSlice;
482
483 fPsdDigiVector->emplace_back(uChanUId, dHitTime, (double) uSignalCharge);
484
485 } // for(int hit_iter = 0; hit_iter < PsdReader.EvHdrAb.uHitsNumber; hit_iter++)
486 }
487 else if (ReadResult == 1) {
488 LOG(error) << "no event headers in message!";
489 break;
490 }
491 else if (ReadResult == 2) {
492 LOG(error) << "check number of waveform points! In header: " << PsdReader.HitHdr.uWfmPoints
493 << " should be: " << 8;
494 break;
495 }
496 else if (ReadResult == 3) {
497 LOG(error) << "wrong amount of hits read! In header: " << PsdReader.EvHdrAb.uHitsNumber
498 << " in hit vector: " << PsdReader.VectHitHdr.size();
499 break;
500 }
501 else {
502 LOG(error) << "PsdGbtReader.ReadEventFles() didn't return expected values";
503 break;
504 }
505
506 } // while(PsdReader.GetTotalGbtWordsRead()<uNbMessages)
507
508 if (uNbMessages != PsdReader.GetTotalGbtWordsRead())
509 LOG(error) << "Wrong amount of messages read!"
510 << " in microslice " << uNbMessages << " by PsdReader " << PsdReader.GetTotalGbtWordsRead()
511 << "\n";
512
513 if (fulCurrentMsIdx != PsdReader.EvHdrAb.ulMicroSlice)
514 LOG(error) << "Wrong MS index!"
515 << " in microslice " << fulCurrentMsIdx << " by PsdReader " << PsdReader.EvHdrAb.ulMicroSlice
516 << "\n";
517 break;
518 } //case 000
519 // --------------------------------------------------------------------------------------------------
520
521 } // switch
522
523 } //if(uNbMessages > 1)
524
525
526 return kTRUE;
527}
528
529std::pair<std::vector<CbmPsdDigi>*, std::vector<CbmPsdDsp>*>
530CbmMcbm2018UnpackerAlgoPsd::unpack(const fles::Timeslice* ts, uint16_t icomp)
531{
532 AddMsComponentToList(icomp, 0x80);
533 Reset();
534 ProcessTs(*ts);
535
536 return std::make_pair(fPsdDigiVector, fPsdDspVector);
537}
538
539Bool_t CbmMcbm2018UnpackerAlgoPsd::SetDigiOutputPointer(std::vector<CbmPsdDigi>* const pVector)
540{
541 if (nullptr == fPsdDigiVector) {
542 fPsdDigiVector = pVector;
543 return kTRUE;
544 }
545 else {
546 return kFALSE;
547 }
548}
549
550Bool_t CbmMcbm2018UnpackerAlgoPsd::SetDspOutputPointer(std::vector<CbmPsdDsp>* const pVector)
551{
552 if (nullptr == fPsdDspVector) {
553 fPsdDspVector = pVector;
554 return kTRUE;
555 }
556 else {
557 return kFALSE;
558 }
559}
560
561std::unique_ptr<CbmPsdDigi> CbmMcbm2018UnpackerAlgoPsd::MakeDigi(CbmPsdDsp dsp)
562{
563 std::unique_ptr<CbmPsdDigi> digi(new CbmPsdDigi(dsp.GetAddress(), dsp.GetTime(), dsp.fdFitEdep));
564
565 return digi;
566}
567
571// -------------------------------------------------------------------------
std::string FormatMsHeaderPrintout(const fles::MicrosliceDescriptor &msDescriptor)
int Int_t
bool Bool_t
Bool_t ProcessTs(const fles::Timeslice &ts)
UInt_t fuMsIndex
Start Time in ns of current MS from its index field in header.
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
std::pair< std::vector< CbmPsdDigi > *, std::vector< CbmPsdDsp > * > unpack(const fles::Timeslice *ts, uint16_t icomp)
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
UInt_t fuCurrentEquipmentId
Index of current MS within the TS.
std::map< UInt_t, UInt_t > fGdpbIdIndexMap
Total number of GDPBs in the system.
Double_t fdTimeOffsetNs
User settings: Data correction parameters.
UInt_t fuNrOfGbtx
Number of channels per GDPB.
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
Bool_t SetDigiOutputPointer(std::vector< CbmPsdDigi > *const pVector)
UInt_t fuNrOfChannelsPerFee
Number of FEBs per GDPB.
std::vector< Bool_t > fvbMaskedComponents
Output Dsp vector /* TODO CHECK The exclamation mark signals the transientness *‍/.
UInt_t fuNrOfChannelsPerGdpb
Number of channels in each FEE.
Double_t fdMsTime
End Time in ns of current TS Core from the index of the first MS first component.
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
Double_t fdTsStartTime
SysId of the current MS in TS (0 to fuTotalMsNb)
std::unique_ptr< CbmPsdDigi > MakeDigi(CbmPsdDsp dsp)
UInt_t fuNrOfFeePerGdpb
gDPB ID to index map
Bool_t fbDebugWriteOutput
Switch ON the filling of a additional set of histograms.
std::vector< CbmPsdDigi > * fPsdDigiVector
If ON the output vector of dsp debug information is written to disk.
ULong64_t fulCurrentMsIdx
Idx of the current TS.
Double_t fdStartTime
Index of the DPB from which the MS currently unpacked is coming.
size_t fuCurrentMsSysId
Idx of the current MS in TS (0 to fuTotalMsNb)
CbmMcbm2018PsdPar * fUnpackPar
Settings from parameter file.
Bool_t SetDspOutputPointer(std::vector< CbmPsdDsp > *const pVector)
std::vector< CbmPsdDsp > * fPsdDspVector
Output Digi vector /* TODO CHECK The exclamation mark signals the transientness *‍/.
static uint32_t GetAddress(int32_t moduleId, int32_t sectionId)
Return address from system ID, module, Section.
Data class for PSD digital information.
Definition CbmPsdDigi.h:36
Data class for PSD digital signal processing (DSP)
Definition CbmPsdDsp.h:30
double GetTime() const
Time.
Definition CbmPsdDsp.h:81
uint32_t GetAddress() const
Address.
Definition CbmPsdDsp.h:75
double fdFitEdep
ZeroLevel from fit of waveform [adc counts].
Definition CbmPsdDsp.h:136
std::vector< size_t > fvMsComponentsList
std::vector< CbmPsdDigi > fDigiVect
std::vector< PsdHitHeader > VectHitHdr
std::vector< struct PsdPackHeader > VectPackHdr
std::vector< struct PsdHitData > VectHitData
std::vector< struct PsdHitHeader > VectHitHdr
void SetSignalBegin(int SignalBeg)
void SetExternalHarmonics(std::complex< float > z1, std::complex< float > z2)
std::vector< uint16_t > GetFitWfm()
Definition PronyFitter.h:73
float GetRSquare(int gate_beg, int gate_end)
void SetDebugMode(bool IsDebug)
Definition PronyFitter.h:49
void SetWaveform(std::vector< uint16_t > &uWfm, uint16_t uZeroLevel)
int ChooseBestSignalBegin(int first_sample, int last_sample)
float GetIntegral(int gate_beg, int gate_end)
uint64_t ulMicroSlice
Total number of hits.