Project
Loading...
Searching...
No Matches
GeometryBase.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 ALICEO2_EMCAL_GEOMETRYBASE_H
13#define ALICEO2_EMCAL_GEOMETRYBASE_H
14
15#include <string>
16
17namespace o2::emcal
18{
25 DCAL_EXT = 4
26}; // possible SM Type
27
31
32const std::string DEFAULT_GEOMETRY = "EMCAL_COMPLETE12SMV1_DCAL_8SM";
33
37class GeometryNotInitializedException final : public std::exception
38{
39 public:
42
44 ~GeometryNotInitializedException() noexcept final = default;
45
48 [[nodiscard]] const char* what() const noexcept override { return "Geometry not initialized"; }
49};
50
54class InvalidModuleException final : public std::exception
55{
56 public:
60 InvalidModuleException(int nModule, int nMax) : mModule(nModule),
61 mMax(nMax),
62 mMessage("Invalid Module [ " + std::to_string(mModule) + "|" + std::to_string(mMax) + "]")
63 {
64 }
65
67 ~InvalidModuleException() noexcept final = default;
68
71 [[nodiscard]] int GetModuleID() const noexcept { return mModule; }
72
75 [[nodiscard]] int GetMaxNumberOfModules() const noexcept { return mMax; }
76
79 [[nodiscard]] const char* what() const noexcept final { return mMessage.c_str(); }
80
81 private:
82 int mModule;
83 int mMax;
84 std::string mMessage;
85};
86
90class InvalidPositionException final : public std::exception
91{
92 public:
96 InvalidPositionException(double eta, double phi) : mEta(eta),
97 mPhi(phi),
98 mMessage("Position phi (" + std::to_string(mPhi) + "), eta(" + std::to_string(mEta) + ") not im EMCAL")
99 {
100 }
101
103 ~InvalidPositionException() noexcept final = default;
104
107 [[nodiscard]] double getEta() const noexcept { return mEta; }
108
111 [[nodiscard]] double getPhi() const noexcept { return mPhi; }
112
115 [[nodiscard]] const char* what() const noexcept final { return mMessage.data(); }
116
117 private:
118 double mEta = 0.;
119 double mPhi = 0.;
120 std::string mMessage;
121};
122
126class InvalidCellIDException final : public std::exception
127{
128 public:
131 InvalidCellIDException(int cellID) : mCellID(cellID),
132 mMessage("Cell ID " + std::to_string(mCellID) + " outside limits.")
133 {
134 }
135
137 ~InvalidCellIDException() noexcept final = default;
138
141 [[nodiscard]] int getCellID() const noexcept { return mCellID; }
142
145 [[nodiscard]] const char* what() const noexcept final { return mMessage.data(); }
146
147 private:
148 int mCellID;
149 std::string mMessage;
150};
151
155class InvalidSupermoduleTypeException final : public std::exception
156{
157 public:
160
162 ~InvalidSupermoduleTypeException() noexcept final = default;
163
165 [[nodiscard]] const char* what() const noexcept final { return "Uknown SuperModule Type !!"; }
166};
167
171class SupermoduleIndexException final : public std::exception
172{
173 public:
177 SupermoduleIndexException(int supermodule, int maxSupermodules) : mSupermoduleIndex(supermodule),
178 mMaxSupermodules(maxSupermodules)
179 {
180 mMessage = "Invalid supermodule ID " + std::to_string(mSupermoduleIndex) + ", max " + std::to_string(mMaxSupermodules);
181 }
182
184 ~SupermoduleIndexException() noexcept final = default;
185
188 [[nodiscard]] int getSupermodule() const noexcept { return mSupermoduleIndex; }
189
192 [[nodiscard]] int getMaxSupermodule() const noexcept { return mMaxSupermodules; }
193
196 [[nodiscard]] const char* what() const noexcept final { return mMessage.data(); }
197
198 private:
199 int mSupermoduleIndex;
200 int mMaxSupermodules;
201 std::string mMessage;
202};
203
207class RowColException final : public std::exception
208{
209 public:
213 RowColException(int row, int col) : mRow(row), mCol(col)
214 {
215 mMessage = "Invalid position: row " + std::to_string(mRow) + ", col " + std::to_string(mCol);
216 }
217
219 ~RowColException() noexcept final = default;
220
223 [[nodiscard]] int getRow() const noexcept { return mRow; }
224
227 [[nodiscard]] int getCol() const noexcept { return mCol; }
228
231 [[nodiscard]] const char* what() const noexcept final { return mMessage.data(); }
232
233 private:
234 int mRow, mCol;
235 std::string mMessage;
236};
237
238} // namespace o2
239
240#endif
uint32_t supermodule
Definition RawData.h:3
uint32_t col
Definition RawData.h:4
Error handling access to non-initialized geometry.
~GeometryNotInitializedException() noexcept final=default
Destructor.
const char * what() const noexcept override
Access to error message.
GeometryNotInitializedException()=default
Constructor.
Exception handling non-existing cell IDs.
InvalidCellIDException(int cellID)
Constructor, setting cell ID raising the exception.
int getCellID() const noexcept
Access to cell ID raising the exception.
~InvalidCellIDException() noexcept final=default
Destructor.
const char * what() const noexcept final
Access to error message of the exception.
Error Handling when an invalid module ID (outside the limits) is called.
int GetMaxNumberOfModules() const noexcept
Get number of modules.
InvalidModuleException(int nModule, int nMax)
Constructor.
~InvalidModuleException() noexcept final=default
Destructor.
const char * what() const noexcept final
Access to error message.
int GetModuleID() const noexcept
Get ID of the module raising the exception.
Exception handling errors due to positions not in the EMCAL area.
double getEta() const noexcept
Access to eta coordinate raising the exception.
const char * what() const noexcept final
Access to error message of the exception.
~InvalidPositionException() noexcept final=default
Destructor.
double getPhi() const noexcept
Access to phi corrdinate raising the exception.
InvalidPositionException(double eta, double phi)
Constructor, setting the position raising the exception.
Exception handling improper or uninitialized supermodule types.
InvalidSupermoduleTypeException()=default
constructor
~InvalidSupermoduleTypeException() noexcept final=default
Destructor.
const char * what() const noexcept final
Access to error message of the exception.
Handling error for invalid positions in row-column space.
~RowColException() noexcept final=default
Destructor.
const char * what() const noexcept final
Access tp error message of the exception.
int getRow() const noexcept
Get row of the position raising the exception.
RowColException(int row, int col)
Constructor, initializing the exception with invalid row-column position.
int getCol() const noexcept
Get column of the position raising the exception.
Handling error due to invalid supermodule.
SupermoduleIndexException(int supermodule, int maxSupermodules)
Constructor, initializing the exception.
int getMaxSupermodule() const noexcept
Access to maximum number of supermodules.
~SupermoduleIndexException() noexcept final=default
Destructor.
const char * what() const noexcept final
Access to error message of the exception.
int getSupermodule() const noexcept
Access to supermodule index raising the exception.
const std::string DEFAULT_GEOMETRY
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
std::vector< int > row