214 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
216 const uint8_t* msContent =
reinterpret_cast<const uint8_t*
>(ts.content(uMsCompIdx, uMsIdx));
218 uint32_t uSize = msDescriptor.size;
224 <<
" has size: " << uSize;
234 LOG(info) <<
"---------------------------------------------------------------";
237 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x" << std::hex <<
fuCurrDpbId << std::dec
238 <<
" in timeslice " <<
fulCurrentTsIdx <<
" in microslice " << uMsIdx <<
" component " << uMsCompIdx
240 <<
"If valid this index has to be added in the PSD "
241 "parameter file in the DbpIdArray field";
261 LOG(error) <<
"The input microslice buffer does NOT "
262 <<
"contain only complete nDPB messages!";
270 LOG(error) <<
"CbmMcbm2018UnpackerAlgoPsd:: Negative time! MS time = " <<
fdMsTime
279 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
290 if ((fair::Logger::Logging(fair::Severity::debug)) && (uNbMessages > 1)) {
291 printf(
"%u = %u 64bit messages\n", uSize, uNbMessages);
292 for (uint32_t line_iter = 0; line_iter < uNbMessages - 2; line_iter += 2) {
293 printf(
"%010llx",
static_cast<unsigned long long int>(pInBuff[line_iter] & 0xffffffffff));
294 printf(
"%010llx",
static_cast<unsigned long long int>(pInBuff[line_iter + 1] & 0xffffffffff));
295 printf(
" %u - %u", line_iter + 1, line_iter + 2);
298 printf(
"%020llx %u\n",
static_cast<unsigned long long int>(pInBuff[uNbMessages - 1]), uNbMessages);
302 if (uNbMessages > 1) {
309 if (fair::Logger::Logging(fair::Severity::debug)) PsdReader.
SetPrintOutMode(
true);
312 int ReadResult = PsdReader.
ReadMs();
313 if (fair::Logger::Logging(fair::Severity::debug)) {
317 if (ReadResult == 0) {
319 double prev_hit_time =
323 for (uint64_t hit_iter = 0; hit_iter < PsdReader.
VectHitHdr.size(); hit_iter++) {
325 LOG(error) <<
"Different vector headers sizes!"
326 <<
" in VectPackHdr " << PsdReader.
VectPackHdr.size() <<
" in VectHitHdr "
331 uint8_t uHitChannel = PsdReader.
VectHitHdr.at(hit_iter).uHitChannel;
334 LOG(error) <<
"hit channel number out of range! channel index: " << uHitChannel
340 UInt_t fuAddress = uChanUId;
341 Double_t fdTime = dMsRelativeTime + (double) PsdReader.
VectPackHdr.at(hit_iter).uAdcTime * 12.5
345 Double_t fdEdep = (double) PsdReader.
VectHitHdr.at(hit_iter).uSignalCharge
347 UInt_t fuZL = PsdReader.
VectHitHdr.at(hit_iter).uZeroLevel;
348 Double_t fdAccum = (double) PsdReader.
VectHitHdr.at(hit_iter).uFeeAccum;
349 Double_t fdAdcTime = (double) PsdReader.
VectPackHdr.at(hit_iter).uAdcTime;
351 Double_t fdEdepWfm = 0.;
352 Double_t fdAmpl = 0.;
353 UInt_t fuMinimum = 0;
354 UInt_t fuTimeMax = 0;
355 std::vector<uint16_t> fuWfm = PsdReader.
VectHitData.at(hit_iter).uWfm;
357 Double_t fdFitAmpl = 0.;
358 Double_t fdFitZL = 0.;
359 Double_t fdFitEdep = 0.;
360 Double_t fdFitR2 = 999.;
361 Double_t fdFitTimeMax = -1.;
362 std::vector<uint16_t> fuFitWfm;
364 if (!fuWfm.empty()) {
366 int32_t iHitChargeWfm = std::accumulate(fuWfm.begin(), fuWfm.end(), -fuZL * fuWfm.size());
367 auto const max_iter = std::max_element(fuWfm.begin(), fuWfm.end());
368 assert(max_iter != fuWfm.end());
369 if (max_iter == fuWfm.end())
break;
370 uint8_t uHitTimeMax = std::distance(fuWfm.begin(), max_iter);
371 int32_t iHitAmlpitude = *max_iter - fuZL;
372 auto const min_iter = std::min_element(fuWfm.begin(), fuWfm.end());
373 uint32_t uHitMinimum = *min_iter;
376 fdAmpl = (double) iHitAmlpitude / 16.5;
377 fuTimeMax = uHitTimeMax;
378 fuMinimum = uHitMinimum;
381 int gate_end = (int) fuWfm.size() - 1;
388 std::complex<float> first_fit_harmonic = {0.72, 0.0};
389 std::complex<float> second_fit_harmonic = {0.38, -0.0};
398 fdFitR2 = Pfitter.
GetRSquare(gate_beg, gate_end);
404 CbmPsdDsp dsp =
CbmPsdDsp(fuAddress, fdTime, fdTsTime, fdEdep, fuZL, fdAccum, fdAdcTime,
406 fdEdepWfm, fdAmpl, fuMinimum, fuTimeMax, fuWfm,
408 fdFitAmpl, fdFitZL, fdFitEdep, fdFitR2, fdFitTimeMax, fuFitWfm);
410 std::unique_ptr<CbmPsdDigi> digi =
MakeDigi(dsp);
416 if (fdTime < prev_hit_time) printf(
"negative time btw hits! %f after %f \n", fdTime, prev_hit_time);
418 prev_hit_time = fdTime;
423 else if (ReadResult == 1) {
424 LOG(error) <<
"no pack headers in message!";
427 else if (ReadResult == 2) {
431 else if (ReadResult == 3) {
432 LOG(error) <<
"check number of waveform points! In header: " << PsdReader.
HitHdr.
uWfmWords - 1;
436 LOG(error) <<
"PsdGbtReader.ReadEventFles() didn't return expected values";
444 LOG(error) <<
"Wrong amount of messages read!"
460 LOG(error) <<
"too many triggered channels! In header: " << PsdReader.
EvHdrAb.
uHitsNumber
465 if (ReadResult == 0) {
468 UInt_t uHitChannel = PsdReader.
VectHitHdr.at(hit_iter).uHitChannel;
469 UInt_t uSignalCharge = PsdReader.
VectHitHdr.at(hit_iter).uSignalCharge;
475 LOG(error) <<
"hit channel number out of range! channel index: " << uHitChannel
481 LOG(debug) << Form(
"Insert 0x%08x digi with charge ", uChanUId) << uSignalCharge
485 fPsdDigiVector->emplace_back(uChanUId, dHitTime, (
double) uSignalCharge);
489 else if (ReadResult == 1) {
490 LOG(error) <<
"no event headers in message!";
493 else if (ReadResult == 2) {
494 LOG(error) <<
"check number of waveform points! In header: " << PsdReader.
HitHdr.
uWfmPoints
495 <<
" should be: " << 8;
498 else if (ReadResult == 3) {
499 LOG(error) <<
"wrong amount of hits read! In header: " << PsdReader.
EvHdrAb.
uHitsNumber
500 <<
" in hit vector: " << PsdReader.
VectHitHdr.size();
504 LOG(error) <<
"PsdGbtReader.ReadEventFles() didn't return expected values";
511 LOG(error) <<
"Wrong amount of messages read!"
516 LOG(error) <<
"Wrong MS index!"