diff --git a/Detectors/EMCAL/reconstruction/CMakeLists.txt b/Detectors/EMCAL/reconstruction/CMakeLists.txt index 62f66b7b613fe..32aa4ccca67a5 100644 --- a/Detectors/EMCAL/reconstruction/CMakeLists.txt +++ b/Detectors/EMCAL/reconstruction/CMakeLists.txt @@ -63,6 +63,7 @@ o2_target_root_dictionary( include/EMCALReconstruction/RecoParam.h include/EMCALReconstruction/StuDecoder.h include/EMCALReconstruction/TRUDataHandler.h + include/EMCALReconstruction/TRUDecodingErrors.h ) o2_add_executable(rawreader-file diff --git a/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RecoContainer.h b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RecoContainer.h index 36ce04267a47f..dc3821810c4a5 100644 --- a/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RecoContainer.h +++ b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RecoContainer.h @@ -30,6 +30,9 @@ #include #include +#ifndef ALICEO2_EMCAL_RECOCONTAINER_H +#define ALICEO2_EMCAL_RECOCONTAINER_H + namespace o2::emcal { /// \struct RecCellInfo @@ -372,3 +375,5 @@ class RecoContainerReader }; } // namespace o2::emcal + +#endif \ No newline at end of file diff --git a/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/ReconstructionErrors.h b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/ReconstructionErrors.h index 2f09c83140ec0..c46ef63b6f3ac 100644 --- a/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/ReconstructionErrors.h +++ b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/ReconstructionErrors.h @@ -222,10 +222,11 @@ const char* getGainErrorDescription(unsigned int errorcode); /// FastOR index or TRU index is called, or by the TRU data handler if /// the patch index is outside range. enum class TRUDecodingError_t { - TRU_INDEX_INVALID, ///< TRU index invalid - PATCH_INDEX_INVALID, ///< Patch index outside range - FASTOR_INDEX_INVALID, ///< FastOR index unknown - UNKNOWN_ERROR ///< Unknown error type + TRU_INDEX_INVALID, ///< TRU index invalid + PATCH_INDEX_INVALID, ///< Patch index outside range + FASTOR_INDEX_INVALID, ///< FastOR index unknown + FASTOR_STARTTIME_INVALID, ///< FastOr stattime is larger than 14 + UNKNOWN_ERROR ///< Unknown error type }; /// \brief Get the number of TRU error codes @@ -253,6 +254,8 @@ constexpr int getErrorCodeFromTRUDecodingError(TRUDecodingError_t error) return 1; case TRUDecodingError_t::FASTOR_INDEX_INVALID: return 2; + case TRUDecodingError_t::FASTOR_STARTTIME_INVALID: + return 3; case TRUDecodingError_t::UNKNOWN_ERROR: return -1; } diff --git a/Detectors/EMCAL/base/include/EMCALBase/TRUDecodingErrors.h b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/TRUDecodingErrors.h similarity index 90% rename from Detectors/EMCAL/base/include/EMCALBase/TRUDecodingErrors.h rename to Detectors/EMCAL/reconstruction/include/EMCALReconstruction/TRUDecodingErrors.h index a4a0d5d4d8584..084465f84944f 100644 --- a/Detectors/EMCAL/base/include/EMCALBase/TRUDecodingErrors.h +++ b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/TRUDecodingErrors.h @@ -29,7 +29,7 @@ class FastOrStartTimeInvalidException : public std::exception public: /// \brief Constructor /// \param l0size Size of the L0 patch - FastOrStartTimeInvalidException(unsigned int time) : std::exception(), mErrorMessage(), mStartTime(time) + FastOrStartTimeInvalidException(int time) : std::exception(), mErrorMessage(), mStartTime(time) { mErrorMessage = "FastOr starttime invalid: " + std::to_string(time); } @@ -46,7 +46,7 @@ class FastOrStartTimeInvalidException : public std::exception /// \brief Get the size of the L0 patch /// \return Size of the L0 patch - unsigned int getStartTime() const noexcept { return mStartTime; } + int getStartTime() const noexcept { return mStartTime; } private: std::string mErrorMessage; ///< Buffer for error message diff --git a/Detectors/EMCAL/reconstruction/src/FastORTimeSeries.cxx b/Detectors/EMCAL/reconstruction/src/FastORTimeSeries.cxx index 9146d9ed92b96..67ada70d6008c 100644 --- a/Detectors/EMCAL/reconstruction/src/FastORTimeSeries.cxx +++ b/Detectors/EMCAL/reconstruction/src/FastORTimeSeries.cxx @@ -12,7 +12,7 @@ #include #include #include "EMCALReconstruction/FastORTimeSeries.h" -#include "EMCALBase/TRUDecodingErrors.h" +#include "EMCALReconstruction/TRUDecodingErrors.h" using namespace o2::emcal; @@ -21,6 +21,9 @@ void FastORTimeSeries::fillReversed(const gsl::span samples, uin if (starttime >= 14) { throw FastOrStartTimeInvalidException(starttime); } + if (starttime + 1 < samples.size()) { + throw FastOrStartTimeInvalidException(static_cast(starttime) - static_cast(samples.size()) + 1); + } for (std::size_t isample = 0; isample < samples.size(); isample++) { mTimeSamples[starttime - isample] = samples[isample]; } diff --git a/Detectors/EMCAL/reconstruction/src/ReconstructionErrors.cxx b/Detectors/EMCAL/reconstruction/src/ReconstructionErrors.cxx index d2e5ea6d92a6f..6f1a5f5bd4f2d 100644 --- a/Detectors/EMCAL/reconstruction/src/ReconstructionErrors.cxx +++ b/Detectors/EMCAL/reconstruction/src/ReconstructionErrors.cxx @@ -156,6 +156,8 @@ TRUDecodingError_t getTRUDecodingErrorFromErrorCode(unsigned int errorcode) return TRUDecodingError_t::PATCH_INDEX_INVALID; case 2: return TRUDecodingError_t::FASTOR_INDEX_INVALID; + case 3: + return TRUDecodingError_t::FASTOR_STARTTIME_INVALID; default: return TRUDecodingError_t::UNKNOWN_ERROR; } @@ -170,6 +172,8 @@ const char* getTRUDecodingErrorName(TRUDecodingError_t errortype) return "PatchIndexInvalid"; case TRUDecodingError_t::FASTOR_INDEX_INVALID: return "FastORIndexInvalid"; + case TRUDecodingError_t::FASTOR_STARTTIME_INVALID: + return "FastORStartTimeInvalid"; default: return "UnknownError"; } @@ -189,6 +193,8 @@ const char* getTRUDecodingErrorTitle(TRUDecodingError_t errortype) return "Patch index invalid"; case TRUDecodingError_t::FASTOR_INDEX_INVALID: return "FastOR index invalid"; + case TRUDecodingError_t::FASTOR_STARTTIME_INVALID: + return "FastOR starttime invalid"; default: return "Unknown error"; } @@ -208,6 +214,8 @@ const char* getTRUDecodingErrorErrorDescription(TRUDecodingError_t errortype) return "Patch index is invalid"; case TRUDecodingError_t::FASTOR_INDEX_INVALID: return "FastOR index is invalid"; + case TRUDecodingError_t::FASTOR_STARTTIME_INVALID: + return "FastOR starttime is invalid"; default: return "Unknown error"; } diff --git a/Detectors/EMCAL/reconstruction/test/testFastORTimeSeries.cxx b/Detectors/EMCAL/reconstruction/test/testFastORTimeSeries.cxx index 5f512fc287967..4144273e1eb31 100644 --- a/Detectors/EMCAL/reconstruction/test/testFastORTimeSeries.cxx +++ b/Detectors/EMCAL/reconstruction/test/testFastORTimeSeries.cxx @@ -16,7 +16,7 @@ #include #include #include -#include "EMCALBase/TRUDecodingErrors.h" +#include "EMCALReconstruction/TRUDecodingErrors.h" namespace o2 { diff --git a/Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h b/Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h index 78436eedfd522..00eb030e470d9 100644 --- a/Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h +++ b/Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h @@ -30,6 +30,7 @@ #include "EMCALReconstruction/RawReaderMemory.h" #include "EMCALReconstruction/RecoContainer.h" #include "EMCALReconstruction/ReconstructionErrors.h" +#include "EMCALReconstruction/TRUDecodingErrors.h" #include "EMCALWorkflow/CalibLoader.h" namespace o2 @@ -44,6 +45,7 @@ class MinorAltroDecodingError; class RawDecodingError; class FastORIndexException; class TRUIndexException; +class FastOrStartTimeInvalidException; namespace reco_workflow { @@ -466,6 +468,17 @@ class RawToCellConverterSpec : public framework::Task /// produced. void handleFastORErrors(const FastORIndexException& error, unsigned int linkID, unsigned int indexTRU); + /// \brief Handler function for FastOR start time errors + /// \param error FastOR index error + /// \param linkID DDL raising the exception + /// \param indexTRU TRU raising the exception + /// + /// Errors are printed to the infoLogger until a user-defiened + /// threshold is reached. In case the export of decoder errors + /// is activated an error object with additional information is + /// produced. + void handleFastORStartTimeErrors(const FastOrStartTimeInvalidException& e, unsigned int linkID, unsigned int indexTRU); + /// \brief Handler function patch index exception /// \param error Patch index error /// \param linkID DDL raising the exception diff --git a/Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx b/Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx index 55f464644ab73..f2acc370a1bdc 100644 --- a/Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx +++ b/Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx @@ -456,6 +456,7 @@ void RawToCellConverterSpec::addFEEChannelToEvent(o2::emcal::EventContainer& cur if (chantype == o2::emcal::ChannelType_t::HIGH_GAIN || chantype == o2::emcal::ChannelType_t::LOW_GAIN) { // high- / low-gain cell CellID = getCellAbsID(position.mSupermoduleID, position.mColumn, position.mRow); + isLowGain = chantype == o2::emcal::ChannelType_t::LOW_GAIN; } else { CellID = geLEDMONAbsID(position.mSupermoduleID, position.mColumn); // Module index encoded in colum for LEDMONs @@ -562,7 +563,12 @@ void RawToCellConverterSpec::addTRUChannelToEvent(o2::emcal::EventContainer& cur // std::cout << adc << ", "; //} // std::cout << std::endl; - currentEvent.setFastOR(absFastOR, bunch.getStartTime(), bunch.getADC()); + + try { + currentEvent.setFastOR(absFastOR, bunch.getStartTime(), bunch.getADC()); + } catch (FastOrStartTimeInvalidException& e) { + handleFastORStartTimeErrors(e, position.mFeeID, tru); + } } } catch (FastORIndexException& e) { handleFastORErrors(e, position.mFeeID, tru); @@ -941,6 +947,22 @@ void RawToCellConverterSpec::handleFastORErrors(const FastORIndexException& e, u } } +void RawToCellConverterSpec::handleFastORStartTimeErrors(const FastOrStartTimeInvalidException& e, unsigned int linkID, unsigned int indexTRU) +{ + if (mCreateRawDataErrors) { + mOutputDecoderErrors.emplace_back(linkID, ErrorTypeFEE::ErrorSource_t::TRU_ERROR, reconstructionerrors::getErrorCodeFromTRUDecodingError(reconstructionerrors::TRUDecodingError_t::FASTOR_STARTTIME_INVALID), indexTRU, -1); + } + if (mNumErrorMessages < mMaxErrorMessages) { + LOG(warning) << " TRU decoding: " << e.what() << " in FEE ID " << linkID << ", TRU " << indexTRU; + mNumErrorMessages++; + if (mNumErrorMessages == mMaxErrorMessages) { + LOG(warning) << "Max. amount of error messages (" << mMaxErrorMessages << " reached, further messages will be suppressed"; + } + } else { + mErrorMessagesSuppressed++; + } +} + void RawToCellConverterSpec::handlePatchError(const TRUDataHandler::PatchIndexException& e, unsigned int linkID, unsigned int indexTRU) { if (mCreateRawDataErrors) {