Project
Loading...
Searching...
No Matches
PadMapper.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#ifndef ALICEO2_FOCAL_PADMAPPER_H
12#define ALICEO2_FOCAL_PADMAPPER_H
13
14#include <array>
15#include <exception>
16#include <iosfwd>
17#include <string>
18#include <tuple>
19
20namespace o2::focal
21{
22
24{
25 public:
26 static constexpr std::size_t NCOLUMN = 8;
27 static constexpr std::size_t NROW = 9;
28 static constexpr std::size_t NCHANNELS = NCOLUMN * NROW;
29
30 class PositionException : public std::exception
31 {
32 public:
33 PositionException(unsigned int column, unsigned int row) : mColumn(column), mRow(row), mMessage()
34 {
35 mMessage = "Invalid pad position: col (" + std::to_string(mColumn) + "), row (" + std::to_string(mRow);
36 }
37 ~PositionException() noexcept final = default;
38
39 const char* what() const noexcept final
40 {
41 return mMessage.data();
42 }
43
44 unsigned int getColumn() const noexcept { return mColumn; }
45 unsigned int getRow() const noexcept { return mRow; }
46 void print(std::ostream& stream) const;
47
48 private:
49 unsigned int mColumn;
50 unsigned int mRow;
51 std::string mMessage;
52 };
53
54 class ChannelIDException : public std::exception
55 {
56 public:
57 ChannelIDException(unsigned int channelID) : mChannelID(channelID), mMessage()
58 {
59 mMessage = "Invalid channelID: " + std::to_string(mChannelID);
60 }
61 ~ChannelIDException() noexcept final = default;
62
63 const char* what() const noexcept final
64 {
65 return mMessage.data();
66 }
67
68 unsigned int getChannelID() const { return mChannelID; }
69 void print(std::ostream& stream) const;
70
71 private:
72 unsigned int mChannelID;
73 std::string mMessage;
74 };
75 PadMapper();
76 ~PadMapper() = default;
77
78 std::tuple<unsigned int, unsigned int> getRowColFromChannelID(unsigned int channelID) const;
79 unsigned int getRow(unsigned int channelID) const;
80 unsigned int getColumn(unsigned int channelID) const;
81
82 unsigned int getChannelID(unsigned int col, unsigned int row) const;
83
84 private:
85 static constexpr unsigned int mMapping[NCOLUMN][NROW] = { // map of channels in XY
86 {43, 41, 53, 49, 58, 54, 66, 68, 69},
87 {39, 37, 47, 51, 56, 62, 60, 64, 70},
88 {38, 42, 45, 46, 50, 59, 55, 65, 71},
89 {44, 40, 36, 48, 52, 61, 57, 67, 63},
90 {8, 4, 0, 14, 16, 19, 23, 31, 27},
91 {2, 6, 11, 10, 17, 21, 25, 33, 35},
92 {1, 3, 9, 15, 22, 24, 26, 28, 34},
93 {7, 5, 12, 13, 18, 20, 29, 30, 32}};
94
95 void initInverseMapping();
96
97 std::array<std::tuple<unsigned int, unsigned int>, NCHANNELS> mInverseMapping;
98};
99
100std::ostream& operator<<(std::ostream& stream, const PadMapper::PositionException& except);
101std::ostream& operator<<(std::ostream& stream, const PadMapper::ChannelIDException& except);
102
103} // namespace o2::focal
104
105#endif // ALICEO2_FOCAL_PADMAPPER_H
uint8_t channelID
Definition RawEventData.h:8
void print() const
uint32_t col
Definition RawData.h:4
const char * what() const noexcept final
Definition PadMapper.h:63
~ChannelIDException() noexcept final=default
ChannelIDException(unsigned int channelID)
Definition PadMapper.h:57
const char * what() const noexcept final
Definition PadMapper.h:39
~PositionException() noexcept final=default
unsigned int getColumn() const noexcept
Definition PadMapper.h:44
unsigned int getRow() const noexcept
Definition PadMapper.h:45
PositionException(unsigned int column, unsigned int row)
Definition PadMapper.h:33
static constexpr std::size_t NCHANNELS
Definition PadMapper.h:28
unsigned int getRow(unsigned int channelID) const
Definition PadMapper.cxx:29
static constexpr std::size_t NCOLUMN
Definition PadMapper.h:26
unsigned int getChannelID(unsigned int col, unsigned int row) const
Definition PadMapper.cxx:38
unsigned int getColumn(unsigned int channelID) const
Definition PadMapper.cxx:33
std::tuple< unsigned int, unsigned int > getRowColFromChannelID(unsigned int channelID) const
Definition PadMapper.cxx:22
static constexpr std::size_t NROW
Definition PadMapper.h:27
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &in, const IndexExceptionEvent &error)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
std::vector< int > row