Skip to content

Commit d921a17

Browse files
jokonigjokonig
andauthored
[EMCAL-1135] Throw exception in case starttime is to large or small (#13369)
- This commit is an extention for PR: #13326 - Move error class from base to reconstruction - added handling of error RawToCell converter: handleFastORStartTimeErrors - add error type to TRUDecodingError to indicate invalid starttime Co-authored-by: jokonig <[email protected]>
1 parent 84ee8e1 commit d921a17

File tree

9 files changed

+64
-9
lines changed

9 files changed

+64
-9
lines changed

Detectors/EMCAL/reconstruction/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ o2_target_root_dictionary(
6363
include/EMCALReconstruction/RecoParam.h
6464
include/EMCALReconstruction/StuDecoder.h
6565
include/EMCALReconstruction/TRUDataHandler.h
66+
include/EMCALReconstruction/TRUDecodingErrors.h
6667
)
6768

6869
o2_add_executable(rawreader-file

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RecoContainer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include <EMCALReconstruction/FastORTimeSeries.h>
3131
#include <EMCALReconstruction/TRUDataHandler.h>
3232

33+
#ifndef ALICEO2_EMCAL_RECOCONTAINER_H
34+
#define ALICEO2_EMCAL_RECOCONTAINER_H
35+
3336
namespace o2::emcal
3437
{
3538
/// \struct RecCellInfo
@@ -372,3 +375,5 @@ class RecoContainerReader
372375
};
373376

374377
} // namespace o2::emcal
378+
379+
#endif

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/ReconstructionErrors.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@ const char* getGainErrorDescription(unsigned int errorcode);
222222
/// FastOR index or TRU index is called, or by the TRU data handler if
223223
/// the patch index is outside range.
224224
enum class TRUDecodingError_t {
225-
TRU_INDEX_INVALID, ///< TRU index invalid
226-
PATCH_INDEX_INVALID, ///< Patch index outside range
227-
FASTOR_INDEX_INVALID, ///< FastOR index unknown
228-
UNKNOWN_ERROR ///< Unknown error type
225+
TRU_INDEX_INVALID, ///< TRU index invalid
226+
PATCH_INDEX_INVALID, ///< Patch index outside range
227+
FASTOR_INDEX_INVALID, ///< FastOR index unknown
228+
FASTOR_STARTTIME_INVALID, ///< FastOr stattime is larger than 14
229+
UNKNOWN_ERROR ///< Unknown error type
229230
};
230231

231232
/// \brief Get the number of TRU error codes
@@ -253,6 +254,8 @@ constexpr int getErrorCodeFromTRUDecodingError(TRUDecodingError_t error)
253254
return 1;
254255
case TRUDecodingError_t::FASTOR_INDEX_INVALID:
255256
return 2;
257+
case TRUDecodingError_t::FASTOR_STARTTIME_INVALID:
258+
return 3;
256259
case TRUDecodingError_t::UNKNOWN_ERROR:
257260
return -1;
258261
}

Detectors/EMCAL/base/include/EMCALBase/TRUDecodingErrors.h renamed to Detectors/EMCAL/reconstruction/include/EMCALReconstruction/TRUDecodingErrors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class FastOrStartTimeInvalidException : public std::exception
2929
public:
3030
/// \brief Constructor
3131
/// \param l0size Size of the L0 patch
32-
FastOrStartTimeInvalidException(unsigned int time) : std::exception(), mErrorMessage(), mStartTime(time)
32+
FastOrStartTimeInvalidException(int time) : std::exception(), mErrorMessage(), mStartTime(time)
3333
{
3434
mErrorMessage = "FastOr starttime invalid: " + std::to_string(time);
3535
}
@@ -46,7 +46,7 @@ class FastOrStartTimeInvalidException : public std::exception
4646

4747
/// \brief Get the size of the L0 patch
4848
/// \return Size of the L0 patch
49-
unsigned int getStartTime() const noexcept { return mStartTime; }
49+
int getStartTime() const noexcept { return mStartTime; }
5050

5151
private:
5252
std::string mErrorMessage; ///< Buffer for error message

Detectors/EMCAL/reconstruction/src/FastORTimeSeries.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <algorithm>
1313
#include <iostream>
1414
#include "EMCALReconstruction/FastORTimeSeries.h"
15-
#include "EMCALBase/TRUDecodingErrors.h"
15+
#include "EMCALReconstruction/TRUDecodingErrors.h"
1616

1717
using namespace o2::emcal;
1818

@@ -21,6 +21,9 @@ void FastORTimeSeries::fillReversed(const gsl::span<const uint16_t> samples, uin
2121
if (starttime >= 14) {
2222
throw FastOrStartTimeInvalidException(starttime);
2323
}
24+
if (starttime + 1 < samples.size()) {
25+
throw FastOrStartTimeInvalidException(static_cast<int>(starttime) - static_cast<int>(samples.size()) + 1);
26+
}
2427
for (std::size_t isample = 0; isample < samples.size(); isample++) {
2528
mTimeSamples[starttime - isample] = samples[isample];
2629
}

Detectors/EMCAL/reconstruction/src/ReconstructionErrors.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ TRUDecodingError_t getTRUDecodingErrorFromErrorCode(unsigned int errorcode)
156156
return TRUDecodingError_t::PATCH_INDEX_INVALID;
157157
case 2:
158158
return TRUDecodingError_t::FASTOR_INDEX_INVALID;
159+
case 3:
160+
return TRUDecodingError_t::FASTOR_STARTTIME_INVALID;
159161
default:
160162
return TRUDecodingError_t::UNKNOWN_ERROR;
161163
}
@@ -170,6 +172,8 @@ const char* getTRUDecodingErrorName(TRUDecodingError_t errortype)
170172
return "PatchIndexInvalid";
171173
case TRUDecodingError_t::FASTOR_INDEX_INVALID:
172174
return "FastORIndexInvalid";
175+
case TRUDecodingError_t::FASTOR_STARTTIME_INVALID:
176+
return "FastORStartTimeInvalid";
173177
default:
174178
return "UnknownError";
175179
}
@@ -189,6 +193,8 @@ const char* getTRUDecodingErrorTitle(TRUDecodingError_t errortype)
189193
return "Patch index invalid";
190194
case TRUDecodingError_t::FASTOR_INDEX_INVALID:
191195
return "FastOR index invalid";
196+
case TRUDecodingError_t::FASTOR_STARTTIME_INVALID:
197+
return "FastOR starttime invalid";
192198
default:
193199
return "Unknown error";
194200
}
@@ -208,6 +214,8 @@ const char* getTRUDecodingErrorErrorDescription(TRUDecodingError_t errortype)
208214
return "Patch index is invalid";
209215
case TRUDecodingError_t::FASTOR_INDEX_INVALID:
210216
return "FastOR index is invalid";
217+
case TRUDecodingError_t::FASTOR_STARTTIME_INVALID:
218+
return "FastOR starttime is invalid";
211219
default:
212220
return "Unknown error";
213221
}

Detectors/EMCAL/reconstruction/test/testFastORTimeSeries.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <tuple>
1717
#include <TRandom.h>
1818
#include <EMCALReconstruction/FastORTimeSeries.h>
19-
#include "EMCALBase/TRUDecodingErrors.h"
19+
#include "EMCALReconstruction/TRUDecodingErrors.h"
2020

2121
namespace o2
2222
{

Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "EMCALReconstruction/RawReaderMemory.h"
3131
#include "EMCALReconstruction/RecoContainer.h"
3232
#include "EMCALReconstruction/ReconstructionErrors.h"
33+
#include "EMCALReconstruction/TRUDecodingErrors.h"
3334
#include "EMCALWorkflow/CalibLoader.h"
3435

3536
namespace o2
@@ -44,6 +45,7 @@ class MinorAltroDecodingError;
4445
class RawDecodingError;
4546
class FastORIndexException;
4647
class TRUIndexException;
48+
class FastOrStartTimeInvalidException;
4749

4850
namespace reco_workflow
4951
{
@@ -466,6 +468,17 @@ class RawToCellConverterSpec : public framework::Task
466468
/// produced.
467469
void handleFastORErrors(const FastORIndexException& error, unsigned int linkID, unsigned int indexTRU);
468470

471+
/// \brief Handler function for FastOR start time errors
472+
/// \param error FastOR index error
473+
/// \param linkID DDL raising the exception
474+
/// \param indexTRU TRU raising the exception
475+
///
476+
/// Errors are printed to the infoLogger until a user-defiened
477+
/// threshold is reached. In case the export of decoder errors
478+
/// is activated an error object with additional information is
479+
/// produced.
480+
void handleFastORStartTimeErrors(const FastOrStartTimeInvalidException& e, unsigned int linkID, unsigned int indexTRU);
481+
469482
/// \brief Handler function patch index exception
470483
/// \param error Patch index error
471484
/// \param linkID DDL raising the exception

Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ void RawToCellConverterSpec::addFEEChannelToEvent(o2::emcal::EventContainer& cur
456456
if (chantype == o2::emcal::ChannelType_t::HIGH_GAIN || chantype == o2::emcal::ChannelType_t::LOW_GAIN) {
457457
// high- / low-gain cell
458458
CellID = getCellAbsID(position.mSupermoduleID, position.mColumn, position.mRow);
459+
459460
isLowGain = chantype == o2::emcal::ChannelType_t::LOW_GAIN;
460461
} else {
461462
CellID = geLEDMONAbsID(position.mSupermoduleID, position.mColumn); // Module index encoded in colum for LEDMONs
@@ -562,7 +563,12 @@ void RawToCellConverterSpec::addTRUChannelToEvent(o2::emcal::EventContainer& cur
562563
// std::cout << adc << ", ";
563564
//}
564565
// std::cout << std::endl;
565-
currentEvent.setFastOR(absFastOR, bunch.getStartTime(), bunch.getADC());
566+
567+
try {
568+
currentEvent.setFastOR(absFastOR, bunch.getStartTime(), bunch.getADC());
569+
} catch (FastOrStartTimeInvalidException& e) {
570+
handleFastORStartTimeErrors(e, position.mFeeID, tru);
571+
}
566572
}
567573
} catch (FastORIndexException& e) {
568574
handleFastORErrors(e, position.mFeeID, tru);
@@ -941,6 +947,22 @@ void RawToCellConverterSpec::handleFastORErrors(const FastORIndexException& e, u
941947
}
942948
}
943949

950+
void RawToCellConverterSpec::handleFastORStartTimeErrors(const FastOrStartTimeInvalidException& e, unsigned int linkID, unsigned int indexTRU)
951+
{
952+
if (mCreateRawDataErrors) {
953+
mOutputDecoderErrors.emplace_back(linkID, ErrorTypeFEE::ErrorSource_t::TRU_ERROR, reconstructionerrors::getErrorCodeFromTRUDecodingError(reconstructionerrors::TRUDecodingError_t::FASTOR_STARTTIME_INVALID), indexTRU, -1);
954+
}
955+
if (mNumErrorMessages < mMaxErrorMessages) {
956+
LOG(warning) << " TRU decoding: " << e.what() << " in FEE ID " << linkID << ", TRU " << indexTRU;
957+
mNumErrorMessages++;
958+
if (mNumErrorMessages == mMaxErrorMessages) {
959+
LOG(warning) << "Max. amount of error messages (" << mMaxErrorMessages << " reached, further messages will be suppressed";
960+
}
961+
} else {
962+
mErrorMessagesSuppressed++;
963+
}
964+
}
965+
944966
void RawToCellConverterSpec::handlePatchError(const TRUDataHandler::PatchIndexException& e, unsigned int linkID, unsigned int indexTRU)
945967
{
946968
if (mCreateRawDataErrors) {

0 commit comments

Comments
 (0)