Project
Loading...
Searching...
No Matches
RawToCellConverterSpec.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_EMCAL_RAWTOCELLCONVERTER_SPEC
13#define O2_EMCAL_RAWTOCELLCONVERTER_SPEC
14
15#include <chrono>
16#include <exception>
17#include <vector>
18
21#include "Framework/Task.h"
25#include "Headers/DataHeader.h"
26#include "EMCALBase/Geometry.h"
27#include "EMCALBase/Mapper.h"
35
36namespace o2
37{
38
39namespace emcal
40{
41
42class AltroDecoderError;
43class Channel;
44class MinorAltroDecodingError;
45class RawDecodingError;
46class FastORIndexException;
47class TRUIndexException;
48class FastOrStartTimeInvalidException;
49
50namespace reco_workflow
51{
52
121{
122 public:
128 RawToCellConverterSpec(int subspecification, bool hasDecodingErrors, bool hasTriggerReconstruction, std::shared_ptr<CalibLoader> calibhandler) : framework::Task(), mSubspecification(subspecification), mCreateRawDataErrors(hasDecodingErrors), mDoTriggerReconstruction(hasTriggerReconstruction), mCalibHandler(calibhandler){};
129
131 ~RawToCellConverterSpec() override;
132
135 void init(framework::InitContext& ctx) final;
136
144 void run(framework::ProcessingContext& ctx) final;
145
149 void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
150
155 void setMaxErrorMessages(int maxMessages)
156 {
157 mMaxErrorMessages = maxMessages;
158 }
159
162 void setNoiseThreshold(int threshold) { mNoiseThreshold = threshold; }
163
166 int getNoiseThreshold() const { return mNoiseThreshold; }
167
173 void setSubspecification(header::DataHeader::SubSpecificationType subspecification) { mSubspecification = subspecification; }
174
181
182 private:
185 class ModuleIndexException : public std::exception
186 {
187 public:
190 enum class ModuleType_t {
191 CELL_MODULE,
192 LEDMON_MODULE
193 };
194
201 ModuleIndexException(int moduleIndex, int column, int row, int columnshifted, int rowshifted);
202
205 ModuleIndexException(int moduleIndex);
206
208 ~ModuleIndexException() noexcept final = default;
209
212 const char* what() const noexcept final { return "Invalid cell / LEDMON index"; }
213
216 ModuleType_t getModuleType() const { return mModuleType; }
217
220 int getIndex() const { return mIndex; }
221
224 int getColumn() const { return mColumn; }
225
228 int getRow() const { return mRow; }
229
232 int getColumnShifted() const { return mColumnShifted; }
233
236 int getRowShifted() const { return mRowShifted; }
237
238 private:
239 ModuleType_t mModuleType;
240 int mIndex = -1;
241 int mColumn = -1;
242 int mRow = -1;
243 int mColumnShifted = -1;
244 int mRowShifted = -1;
245 };
246
249 struct CellTimeCorrection {
250 double mTimeShift;
251 int mBcMod4;
252
258 double getCorrectedTime(double rawtime) const { return rawtime - mTimeShift - 25. * mBcMod4; }
259 };
260
263 struct LocalPosition {
264 uint16_t mSupermoduleID;
265 uint16_t mFeeID;
266 uint8_t mColumn;
267 uint8_t mRow;
268 };
269
270 using TRUContainer = std::vector<o2::emcal::CompressedTRU>;
271 using PatchContainer = std::vector<o2::emcal::CompressedTriggerPatch>;
272
280 bool isLostTimeframe(framework::ProcessingContext& ctx) const;
281
283 void updateCalibrationObjects();
284
293 int bookEventCells(const gsl::span<const o2::emcal::RecCellInfo>& cells, bool isLELDMON);
294
301 void sendData(framework::ProcessingContext& ctx) const;
302
309 int getCellAbsID(int supermoduleID, int column, int row);
310
316 int geLEDMONAbsID(int supermoduleID, int module);
317
327 void addFEEChannelToEvent(o2::emcal::EventContainer& currentEvent, const o2::emcal::Channel& currentchannel, const CellTimeCorrection& timeCorrector, const LocalPosition& position, ChannelType_t chantype);
328
340 void addTRUChannelToEvent(o2::emcal::EventContainer& currentEvent, const o2::emcal::Channel& currentchannel, const LocalPosition& position);
341
349 std::tuple<TRUContainer, PatchContainer> buildL0Patches(const EventContainer& currentevent) const;
350
355 std::vector<o2::emcal::CompressedL0TimeSum> buildL0Timesums(const o2::emcal::EventContainer& currentevent, uint8_t l0time) const;
356
364 std::tuple<uint16_t, uint8_t> reconstructTriggerPatch(const gsl::span<const FastORTimeSeries*> fastors) const;
365
375 void handleAddressError(const Mapper::AddressNotFoundException& error, int ddlID, int hwaddress);
376
386 void handleAltroError(const o2::emcal::AltroDecoderError& altroerror, int ddlID);
387
396 void handleMinorAltroError(const o2::emcal::MinorAltroDecodingError& altroerror, int ddlID);
397
406 void handleDDLError(const MappingHandler::DDLInvalid& error, int feeID);
407
419 void handleGeometryError(const ModuleIndexException& error, int supermoduleID, int cellID, int hwaddress, ChannelType_t chantype);
420
429 void handleFitError(const o2::emcal::CaloRawFitter::RawFitterError_t& fiterror, int ddlID, int cellID, int hwaddress);
430
440 void handleGainError(const o2::emcal::reconstructionerrors::GainError_t& errortype, int ddlID, int hwaddress);
441
449 void handlePageError(const RawDecodingError& error);
450
458 void handleMinorPageError(const RawReaderMemory::MinorError& error);
459
469 void handleFastORErrors(const FastORIndexException& error, unsigned int linkID, unsigned int indexTRU);
470
480 void handleFastORStartTimeErrors(const FastOrStartTimeInvalidException& e, unsigned int linkID, unsigned int indexTRU);
481
491 void handlePatchError(const TRUDataHandler::PatchIndexException& error, unsigned int linkID, unsigned int indexTRU);
492
502 void handleTRUIndexError(const TRUIndexException& error, unsigned int linkID, unsigned int hwaddress);
503
504 header::DataHeader::SubSpecificationType mSubspecification = 0;
505 int mNoiseThreshold = 0;
506 int mNumErrorMessages = 0;
507 int mErrorMessagesSuppressed = 0;
508 int mMaxErrorMessages = 100;
509 bool mMergeLGHG = true;
510 bool mActiveLinkCheck = true;
511 bool mPrintTrailer = false;
512 bool mDisablePedestalEvaluation = false;
513 bool mCreateRawDataErrors = false;
514 bool mDoTriggerReconstruction = false;
515 std::chrono::time_point<std::chrono::system_clock> mReferenceTime;
516 Geometry* mGeometry = nullptr;
517 RecoContainer mCellHandler;
518 std::shared_ptr<CalibLoader> mCalibHandler;
519 std::unique_ptr<MappingHandler> mMapper = nullptr;
520 std::unique_ptr<TriggerMappingV2> mTriggerMapping;
521 std::unique_ptr<CaloRawFitter> mRawFitter;
522 std::vector<Cell> mOutputCells;
523 std::vector<TriggerRecord> mOutputTriggerRecords;
524 std::vector<ErrorTypeFEE> mOutputDecoderErrors;
525 std::vector<CompressedTRU> mOutputTRUs;
526 std::vector<TriggerRecord> mOutputTRUTriggerRecords;
527 std::vector<CompressedTriggerPatch> mOutputPatches;
528 std::vector<TriggerRecord> mOutputPatchTriggerRecords;
529 std::vector<CompressedL0TimeSum> mOutputTimesums;
530 std::vector<TriggerRecord> mOutputTimesumTriggerRecords;
531};
532
540framework::DataProcessorSpec getRawToCellConverterSpec(bool askDISTSTF, bool disableDecodingError, bool disableTriggerReconstruction, int subspecification);
541
542} // namespace reco_workflow
543
544} // namespace emcal
545
546} // namespace o2
547
548#endif // O2_EMCAL_RAWTOCELLCONVERTER_SPEC
Reconstruction container for EMCAL Cells and LEDMONs.
o2::mid::ColumnData & getColumn(std::vector< o2::mid::ColumnData > &patterns, uint8_t icolumn, uint8_t deId)
Error handling of the ALTRO Decoder.
RawFitterError_t
Error codes for failures in raw fitter procedure.
ALTRO channel representation.
Definition Channel.h:46
Containter of cells for a given event.
Error handling for the ALTRO decoder for non-crashing errors.
Coverter task for Raw data to EMCAL cells and trigger objects.
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj) final
Handle objects obtained from the CCDB.
RawToCellConverterSpec(int subspecification, bool hasDecodingErrors, bool hasTriggerReconstruction, std::shared_ptr< CalibLoader > calibhandler)
Constructor.
void run(framework::ProcessingContext &ctx) final
Run conversion of raw data to cells.
header::DataHeader::SubSpecificationType getSubspecification() const
Get ID of the subspecification.
void setNoiseThreshold(int threshold)
Set noise threshold for gain type errors.
void setMaxErrorMessages(int maxMessages)
Set max number of error messages printed.
void init(framework::InitContext &ctx) final
Initializing the RawToCellConverterSpec.
void setSubspecification(header::DataHeader::SubSpecificationType subspecification)
Set ID of the subspecification.
int getNoiseThreshold() const
Get the noise threshold for gain type errors.
uint8_t itsSharedClusterMap uint8_t
framework::DataProcessorSpec getRawToCellConverterSpec(bool askDISTSTF, bool disableDecodingError, bool disableTriggerReconstruction, int subspecification)
Creating DataProcessorSpec for the EMCAL Cell Converter Spec.
ChannelType_t
Type of a raw data channel.
Definition Constants.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t SubSpecificationType
Definition DataHeader.h:620
std::vector< Cell > cells
std::vector< int > row