diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index 28aad4224354e89b579876f85627be93122ea392..6c09f31f6b9117f66478f304e54463344f728612 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -162,13 +162,17 @@ void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const cha // ------------- // ---- TOF ---- - auto tofconfig = std::make_shared<CbmTofUnpackConfig>("", runid); - // tofconfig->SetDebugState(); - tofconfig->SetDoWriteOutput(); - // tofconfig->SetDoWriteOptOutA("CbmTofErrors"); - std::string parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2021/", srcDir.Data()); - tofconfig->SetParFilesBasePath(parfilesbasepathTof); - tofconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated + std::shared_ptr<CbmTofUnpackConfig> tofconfig = nullptr; + + tofconfig = std::make_shared<CbmTofUnpackConfig>("", runid); + if (tofconfig) { + // tofconfig->SetDebugState(); + tofconfig->SetDoWriteOutput(); + // tofconfig->SetDoWriteOptOutA("CbmTofErrors"); + std::string parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2021/", srcDir.Data()); + tofconfig->SetParFilesBasePath(parfilesbasepathTof); + tofconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated + } // ------------- diff --git a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx index bb836c75e7959332e99b5d21442d6170d35b8b10..cd218e250a5da6748f18f5da3abe3558478116be 100644 --- a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx +++ b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx @@ -163,8 +163,9 @@ void CbmTrdUnpackAlgoR::finishDerived() { LOG(info) << fName << " \n " << fNrWildRda << " unexpected RDA frames,\n " << fNrWildNul << " unexpected NUL frames, \n " << fNrWildEom << " unexpected EOM frames, \n " << fNrMissingEom - << " missing EOM frames, \n " << fNrElinkMis << " SOM to RDA/EOM eLink mismatches, \n " << fNrNonMajorTsMsb - << " non-major ts_msbs and \n " << fNrUnknownWords << " unknown frames." << std::endl; + << " missing EOM frames, \n " << fNrCorruptEom << " corrupt EOM frames, \n " << fNrElinkMis + << " SOM to RDA/EOM eLink mismatches, \n " << fNrNonMajorTsMsb << " non-major ts_msbs and \n " + << fNrUnknownWords << " unknown frames." << std::endl; } // ---- getInfoType ---- @@ -456,18 +457,24 @@ bool CbmTrdUnpackAlgoR::unpack(const fles::Timeslice* ts, std::uint16_t icomp, U nn = nreqsamples % 4; } - // Now extract from the above values the number of required adc bits from the eom - std::int8_t nrequiredbits = (nreqsamples - isample) * 9 - nadcbits; - adcbuffer <<= nrequiredbits; + // There is a chance that the nsamplesindicator bits are corrupted, here we check that we do not try to extract more adcbits than actually are streamed + if (nreqsamples >= isample) { + // Now extract from the above values the number of required adc bits from the eom + std::int8_t nrequiredbits = (nreqsamples - isample) * 9 - nadcbits; + adcbuffer <<= nrequiredbits; - // The eom carries at maximum 18 adcbits - adcbuffer |= static_cast<size_t>((frame & 0x3ffff) >> (18 - nrequiredbits)); - nadcbits += nrequiredbits; + // The eom carries at maximum 18 adcbits + adcbuffer |= static_cast<size_t>((frame & 0x3ffff) >> (18 - nrequiredbits)); + nadcbits += nrequiredbits; - while (nadcbits >= 9) { - raw.IncNrSamples(); - raw.SetSample(extractSample(&adcbuffer, &nadcbits), isample); - isample++; + while (nadcbits >= 9) { + raw.IncNrSamples(); + raw.SetSample(extractSample(&adcbuffer, &nadcbits), isample); + isample++; + } + } + else { + ++fNrCorruptEom; } ++fNrCreatedRawMsgs; // the message is done and the raw message container should contain everything we need. So now we can call makeDigi() diff --git a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.h b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.h index 716e4eac30b7f6d575f815bff4f89c35bf21edf5..9783828f74200507dc6c619f005a4d3ed3cf6f8c 100644 --- a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.h +++ b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.h @@ -182,6 +182,9 @@ protected: /** @brief Number of SOM to RDA/EOM mismatches */ size_t fNrElinkMis = 0; + /** @brief Number of corrupted EOM frames */ + size_t fNrCorruptEom = 0; + /** @brief Start time of the current µSlice in Spadic CC */ size_t fMsStartTimeCC = 0;