diff --git a/reco/detectors/sts/unpack/CbmStsUnpackAlgo.cxx b/reco/detectors/sts/unpack/CbmStsUnpackAlgo.cxx index 7eb60a6fd6f45385c57f7d308f4ac3995c9997e7..e738045445779a8cee446e8c049e1dd0b0494cbf 100644 --- a/reco/detectors/sts/unpack/CbmStsUnpackAlgo.cxx +++ b/reco/detectors/sts/unpack/CbmStsUnpackAlgo.cxx @@ -13,9 +13,6 @@ #include <cstdint> #include <iomanip> -#include "StsXyterFinalHit.h" - - CbmStsUnpackAlgo::CbmStsUnpackAlgo() : CbmRecoUnpackAlgo("CbmStsUnpackAlgo") {} CbmStsUnpackAlgo::~CbmStsUnpackAlgo() {} @@ -24,16 +21,16 @@ CbmStsUnpackAlgo::~CbmStsUnpackAlgo() {} uint32_t CbmStsUnpackAlgo::getAsicIndex(uint32_t dpbidx, uint32_t crobidx, uint16_t elinkidx) { - uint32_t asicidx = 0; - const int32_t uFebIdx = fElinkIdxToFebIdxVec.at(elinkidx); - uint32_t febtype = fviFebType[dpbidx][crobidx][uFebIdx]; + uint32_t asicidx = 0; + const int32_t uFebIdx = fElinkIdxToFebIdxVec.at(elinkidx); + const uint32_t febtype = fviFebType[dpbidx][crobidx][uFebIdx]; // Feb type a if (febtype == 0) asicidx = fElinkIdxToAsicIdxVec.at(elinkidx).first; // Feb type b if (febtype == 1) asicidx = fElinkIdxToAsicIdxVec.at(elinkidx).second; // else would be inactive feb, this was not handled in the previous implementation, this I expect it should not happen - uint32_t uAsicIdx = (dpbidx * fNrCrobPerDpb + crobidx) * fNrAsicsPerCrob + asicidx; + const uint32_t uAsicIdx = (dpbidx * fNrCrobPerDpb + crobidx) * fNrAsicsPerCrob + asicidx; return uAsicIdx; } @@ -309,8 +306,7 @@ void CbmStsUnpackAlgo::initInternalStatus(CbmMcbm2018StsPar* parset) } // ---- loopMsMessages ---- -void CbmStsUnpackAlgo::loopMsMessages(const uint8_t* msContent, const uint32_t uSize, const size_t uMsIdx, bool& bError, - std::string& sMessPatt, std::vector<uint32_t>& vNbMessType) +void CbmStsUnpackAlgo::loopMsMessages(const uint8_t* msContent, const uint32_t uSize, const size_t uMsIdx) { // If not integer number of message in input buffer, print warning/error if (0 != (uSize % sizeof(stsxyter::Message))) { @@ -327,9 +323,7 @@ void CbmStsUnpackAlgo::loopMsMessages(const uint8_t* msContent, const uint32_t u /// Get message type const stsxyter::MessType typeMess = pMess[uIdx].GetMessType(); if (fMonitor) - if (fMonitor->GetDebugMode()) { - bError = fMonitor->ProcessDebugInfo(pMess[uIdx], sMessPatt, vNbMessType, fuCurrDpbIdx); - } + if (fMonitor->GetDebugMode()) { fMonitor->ProcessDebugInfo(pMess[uIdx], fuCurrDpbIdx); } switch (typeMess) { case stsxyter::MessType::Hit: { processHitInfo(pMess[uIdx]); @@ -734,31 +728,17 @@ bool CbmStsUnpackAlgo::unpack(const fles::Timeslice* ts, std::uint16_t icomp, UI // Check the current TS_MSb cycle and correct it if wrong refreshTsMsbFields(imslice, fMsStartTime); - //Variables for debugging info - std::vector<uint32_t> vNbMessType(7, 0); - std::string sMessPatt = ""; - bool bError = false; + //Reset internal monitor variables for debugging info + if (fMonitor) { + if (fMonitor->GetDebugMode()) { fMonitor->ResetDebugInfo(); } + } //Main processing of MS content - loopMsMessages(msContent, uSize, imslice, bError, sMessPatt, vNbMessType); + loopMsMessages(msContent, uSize, imslice); //Output debugging info - /** @todo @experts this is printout debugging which depends on monitor settings. Not sure whether this is a good way. Please check and decide. (It was this way already before to be clear) */ if (fMonitor) { - if (fMonitor->GetDebugMode()) { - if (18967040000 == fMsStartTime || 18968320000 == fMsStartTime) { LOG(debug) << sMessPatt; } - if (static_cast<uint16_t>(fles::MicrosliceFlags::CrcValid) != msDescriptor.flags) { - LOG(debug) << "STS unp " - << " TS " << std::setw(12) << fNrProcessedTs << " MS " << std::setw(12) << fMsStartTime - << " MS flags 0x" << std::setw(4) << std::hex << msDescriptor.flags << std::dec << " Size " - << std::setw(8) << uSize << " bytes " - << " H " << std::setw(5) << vNbMessType[0] << " T " << std::setw(5) << vNbMessType[1] << " E " - << std::setw(5) << vNbMessType[2] << " S " << std::setw(5) << vNbMessType[3] << " Em " - << std::setw(5) << vNbMessType[4] << " En " << std::setw(5) << vNbMessType[5] << " D " - << std::setw(5) << vNbMessType[6] << " Err " << bError << " Undet. bad " - << (!bError && 400 != vNbMessType[1]); - } - } + if (fMonitor->GetDebugMode()) { fMonitor->PrintDebugInfo(fMsStartTime, fNrProcessedTs, msDescriptor.flags, uSize); } for (auto itHit = fOutputVec.begin(); itHit != fOutputVec.end(); ++itHit) { fMonitor->FillDigisTimeInRun(itHit->GetTime()); } diff --git a/reco/detectors/sts/unpack/CbmStsUnpackAlgo.h b/reco/detectors/sts/unpack/CbmStsUnpackAlgo.h index c35e3ba8260e1495cbc08c580a289f623ad906eb..9f5ffb1d27f9b13f231a5948d39e32bf67295f63 100644 --- a/reco/detectors/sts/unpack/CbmStsUnpackAlgo.h +++ b/reco/detectors/sts/unpack/CbmStsUnpackAlgo.h @@ -155,9 +155,7 @@ protected: * @param sMessPatt * @param vNbMessType */ - void loopMsMessages(const uint8_t* msContent, const uint32_t uSize, const size_t uMsIdx, bool& bError, - std::string& sMessPatt, std::vector<uint32_t>& vNbMessType); - + void loopMsMessages(const uint8_t* msContent, const uint32_t uSize, const size_t uMsIdx); /** @brief experts please add description */ void printActiveCrobs(CbmMcbm2018StsPar* parset, const std::vector<std::vector<bool>>& vbCrobActiveFlag); diff --git a/reco/detectors/sts/unpack/CbmStsUnpackMonitor.cxx b/reco/detectors/sts/unpack/CbmStsUnpackMonitor.cxx index 5c8185eb62110ddd36468e1637b62037dbefde24..24b0cb526074b200a50502c9268b07b9897868aa 100644 --- a/reco/detectors/sts/unpack/CbmStsUnpackMonitor.cxx +++ b/reco/detectors/sts/unpack/CbmStsUnpackMonitor.cxx @@ -2,6 +2,8 @@ #include "CbmQaCanvas.h" +#include "MicrosliceDescriptor.hpp" + #include <FairRun.h> #include <FairRunOnline.h> #include <Logger.h> @@ -14,6 +16,7 @@ #include <TProfile.h> #include <cstdint> +#include <iomanip> #include <iostream> #include <memory> #include <string> @@ -21,7 +24,7 @@ #include <cmath> -CbmStsUnpackMonitor::CbmStsUnpackMonitor(/* args */) : fvpAllHistoPointers() +CbmStsUnpackMonitor::CbmStsUnpackMonitor(/* args */) : vNbMessType(7, 0), fvpAllHistoPointers() { // Miscroslice component properties histos for (UInt_t component = 0; component < kiMaxNbFlibLinks; component++) { @@ -594,12 +597,17 @@ void CbmStsUnpackMonitor::FillHitEvoMonitoringHistos(const UInt_t& uFebIdx, cons */ } +// ------------------------------------------------------------------------- +void CbmStsUnpackMonitor::ResetDebugInfo() +{ + std::fill(vNbMessType.begin(), vNbMessType.end(), 0); + sMessPatt = ""; + bError = false; +} // ------------------------------------------------------------------------- -bool CbmStsUnpackMonitor::ProcessDebugInfo(const stsxyter::Message& Mess, std::string& sMessPatt, - std::vector<uint32_t>& vNbMessType, const UInt_t& uCurrDpbIdx) +void CbmStsUnpackMonitor::ProcessDebugInfo(const stsxyter::Message& Mess, const UInt_t& uCurrDpbIdx) { - bool bError = false; const stsxyter::MessType typeMess = Mess.GetMessType(); FillStsMessType(static_cast<uint16_t>(typeMess)); @@ -655,9 +663,24 @@ bool CbmStsUnpackMonitor::ProcessDebugInfo(const stsxyter::Message& Mess, std::s default: { } } - return bError; } +// ------------------------------------------------------------------------- +void CbmStsUnpackMonitor::PrintDebugInfo(const uint64_t MsStartTime, const size_t NrProcessedTs, + const uint16_t msDescriptorFlags, const uint32_t uSize) +{ + if (18967040000 == MsStartTime || 18968320000 == MsStartTime) { LOG(debug) << sMessPatt; } + if (static_cast<uint16_t>(fles::MicrosliceFlags::CrcValid) != msDescriptorFlags) { + LOG(debug) << "STS unp " + << " TS " << std::setw(12) << NrProcessedTs << " MS " << std::setw(12) << MsStartTime << " MS flags 0x" + << std::setw(4) << std::hex << msDescriptorFlags << std::dec << " Size " << std::setw(8) << uSize + << " bytes " + << " H " << std::setw(5) << vNbMessType[0] << " T " << std::setw(5) << vNbMessType[1] << " E " + << std::setw(5) << vNbMessType[2] << " S " << std::setw(5) << vNbMessType[3] << " Em " << std::setw(5) + << vNbMessType[4] << " En " << std::setw(5) << vNbMessType[5] << " D " << std::setw(5) << vNbMessType[6] + << " Err " << bError << " Undet. bad " << (!bError && 400 != vNbMessType[1]); + } +} // ---- Init ---- Bool_t CbmStsUnpackMonitor::Init(CbmMcbm2018StsPar* parset) @@ -742,6 +765,7 @@ void CbmStsUnpackMonitor::Finish() gDirectory = oldDir; histoFile->Close(); + delete histoFile; } diff --git a/reco/detectors/sts/unpack/CbmStsUnpackMonitor.h b/reco/detectors/sts/unpack/CbmStsUnpackMonitor.h index 9074210960d1ef6058cb5f44818c38cd4d425683..579b7393bea6e51850188ec094c2cfd619307134 100644 --- a/reco/detectors/sts/unpack/CbmStsUnpackMonitor.h +++ b/reco/detectors/sts/unpack/CbmStsUnpackMonitor.h @@ -27,6 +27,15 @@ public: virtual ~CbmStsUnpackMonitor(); + //Variables for debugging info + std::vector<uint32_t> vNbMessType; + std::string sMessPatt = ""; + bool bError = false; + + void ResetDebugInfo(); + void PrintDebugInfo(const uint64_t MsStartTime, const size_t NrProcessedTs, const uint16_t msDescriptorFlags, + const uint32_t uSize); + /** @brief Init all required parameter informations and histograms */ Bool_t Init(CbmMcbm2018StsPar* digiParSet); @@ -205,8 +214,7 @@ public: /** @brief Activate the debug mode */ bool GetDebugMode() { return fDebugMode; } - bool ProcessDebugInfo(const stsxyter::Message& Mess, std::string& sMessPatt, std::vector<uint32_t>& vNbMessType, - const UInt_t& uCurrDpbIdx); + void ProcessDebugInfo(const stsxyter::Message& Mess, const UInt_t& uCurrDpbIdx); /** @brief Activate the debug mode */ void SetDebugMode(bool value) { fDebugMode = value; }