11#ifndef __O2_EMCAL_MAPPER_H__
12#define __O2_EMCAL_MAPPER_H__
19#include <unordered_map>
22#include <boost/container_hash/hash.hpp>
24#include "fmt/format.h"
25#include "RStringView.h"
69 boost::hash_combine(seed, s.mRow);
70 boost::hash_combine(seed, s.mColumn);
93 std::stringstream msgbuilder;
94 msgbuilder <<
"Hardware address " <<
address <<
"(0x" << std::hex <<
address << std::dec <<
") not found";
95 mMessage = msgbuilder.str();
103 const
char*
what() const noexcept
override {
return mMessage.data(); }
111 std::string mMessage;
124 mMaxAddress(maxaddress),
125 mMessage(
"Hardware (ALTRO) address (" +
std::
to_string(mAddress) +
" outside the range (0 -> " +
std::
to_string(mMaxAddress) +
") !")
134 const
char*
what() const noexcept
override {
return mMessage.data(); }
147 std::string mMessage;
161 std::stringstream msgbuilder;
162 msgbuilder <<
"Channel with " << mChannelID <<
" not found.";
163 mMessage = msgbuilder.str();
171 const
char*
what() const noexcept
override
173 return mMessage.data();
182 std::string mMessage;
193 mMessage(
std::
string(
"Failure reading input file: ") + errormessage.
data())
202 const
char*
what() const noexcept
override
204 return mMessage.data();
208 std::string mMessage;
224 const
char*
what() const noexcept
override {
return "Mapping not properly initialized"; }
235 Mapper(
const std::string_view inputfile);
250 uint8_t
getRow(
unsigned int hardawareaddress)
const
286 void setMapping(
const std::string_view inputfile);
294 void init(
const std::string_view inputfile);
296 std::unordered_map<unsigned int, ChannelID> mMapping;
297 std::unordered_map<ChannelID, unsigned int, ChannelIDHasher> mInverseMapping;
298 bool mInitStatus =
false;
323 DDLInvalid(
int ddlID) : mDDL(ddlID) { mMessage = fmt::format(
"DDL {0} not existing for EMCAL", mDDL); };
330 const
char*
what() const noexcept final {
return mMessage.data(); }
337 std::string mMessage;
360 std::array<Mapper, 4> mMappings;
Error handling requests for unknown hardware addresses.
const char * what() const noexcept override
Access to error message.
~AddressNotFoundException() noexcept override=default
Destructor.
AddressNotFoundException(int address)
Constructor initializing the exception.
int getAddress() const noexcept
Access to hardware address raising the exception.
int getAddress() const noexcept
Access to hardware address raising the exception.
int getMaxAddress() const noexcept
Access to max hardware address in mapping.
~AddressRangeException() noexcept override=default
Destructor.
const char * what() const noexcept override
Access to error message of the exception.
AddressRangeException(int address, int maxaddress)
Constructor initializing the exception.
Exception handling invalid channel ID.
const char * what() const noexcept override
Access to error message of the exception.
const ChannelID & getChannel() const
Access to channel ID raising the exception.
~ChannelNotFoundException() noexcept override=default
Destructor.
ChannelNotFoundException(ChannelID id)
Constructor initializing the exception.
Error handling requests to not properly initialized mapping object.
const char * what() const noexcept override
Access to error message of the exception.
~InitStatusException() noexcept override=default
Destructor.
InitStatusException()=default
Constructor.
ALTRO mapping for calorimeters.
uint8_t getRow(unsigned int hardawareaddress) const
Get channel row for a given hardware address.
~Mapper()=default
Destructor.
Mapper()=default
Default constructor.
void setMapping(const std::string_view inputfile)
Initialize with new.
ChannelType_t getChannelType(unsigned int hardawareaddress) const
Get channel type for a given hardware address.
uint8_t getColumn(unsigned int hardawareaddress) const
Get channel column for a given hardware address.
ChannelID getChannelID(unsigned int hardawareaddress) const
Get channel ID params for a given hardware address.
unsigned int getHardwareAddress(uint8_t row, uint8_t col, ChannelType_t channeltype) const
Get the hardware address for a channel.
Error handling for invalid DDL IDs (not in range for EMCAL)
~DDLInvalid() noexcept final=default
Destructor.
const char * what() const noexcept final
Access to the error message of the exception.
int getDDDL() const
Access to DDL ID responsible for the exception.
Handler providing the correct mapping for the given DDL.
int getFEEForChannelInDDL(unsigned int dll, unsigned int channelFEC, unsigned int branch)
Get FEC index for channel based on DDL and information in the channel header.
Mapper & getMappingForDDL(unsigned int ddl)
Get Mapping for given DDL.
~MappingHandler()=default
Destructor.
MappingHandler()
Constructor.
GLsizei const GLchar *const * string
GLuint GLuint64EXT address
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
ChannelType_t
Type of a raw data channel.
int channelTypeToInt(ChannelType_t chantype)
integer representation of the channel type object
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
std::string to_string(gsl::span< T, Size > span)
Hash functor for channel ID.
size_t operator()(const ChannelID &s) const
Functor implementation.
Mapped information of a channel.
uint8_t mColumn
Column of the channel in module.
ChannelType_t mChannelType
Type of the channel (see o2::emcal::ChannelType for channel type definitions)
uint8_t mRow
Row of the channel in module.
friend std::ostream & operator<<(std::ostream &stream, const Mapper::ChannelID &channel)
stream operator for Mapper::Channel
bool operator==(const ChannelID &other) const
VectorOfTObjectPtrs other