Project
Loading...
Searching...
No Matches
PadPedestal.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_PADPEDESTAL_H
12#define ALICEO2_FOCAL_PADPEDESTAL_H
13
14#include <array>
15#include <exception>
16#include <string>
17#include <unordered_map>
18
19#include <boost/container_hash/hash.hpp>
20
21#include "TH1.h"
22#include "Rtypes.h"
23
24namespace o2::focal
25{
26
28{
29 public:
30 struct ChannelID {
31 std::size_t mLayer;
32 std::size_t mChannel;
33
34 bool operator==(const ChannelID& other) const
35 {
36 return mLayer == other.mLayer && mChannel == other.mChannel;
37 }
38 };
39
41
45 size_t operator()(const ChannelID& s) const
46 {
47 std::size_t seed = 0;
48 boost::hash_combine(seed, s.mLayer);
49 boost::hash_combine(seed, s.mChannel);
50 return seed;
51 }
52 };
53
54 class InvalidChannelException final : public std::exception
55 {
56 public:
57 InvalidChannelException(std::size_t layer, std::size_t channel) : mLayer(layer), mChannel(channel)
58 {
59 mMessage = "Invalid channel: Layer " + std::to_string(mLayer) + ", channel " + std::to_string(mChannel);
60 }
61 ~InvalidChannelException() noexcept final = default;
62
63 const char* what() const noexcept final { return mMessage.data(); }
64
65 std::size_t getLayer() const noexcept { return mLayer; }
66 std::size_t getChannel() const noexcept { return mChannel; }
67
68 private:
69 std::size_t mLayer;
70 std::size_t mChannel;
71 std::string mMessage;
72 };
73
74 class InvalidLayerException final : public std::exception
75 {
76 public:
77 InvalidLayerException(std::size_t layer) : mLayer(layer)
78 {
79 mMessage = "Access to invalid layer " + std::to_string(layer);
80 }
81 ~InvalidLayerException() noexcept final = default;
82
83 const char* what() const noexcept final { return mMessage.data(); }
84 std::size_t getLayer() const noexcept { return mLayer; }
85
86 private:
87 std::size_t mLayer = 0;
88 std::string mMessage;
89 };
90
91 PadPedestal() = default;
92 ~PadPedestal() = default;
93
94 bool operator==(const PadPedestal& rhs) const;
95
96 void clear();
97 void setPedestal(std::size_t layer, std::size_t channel, double pedestal);
98 double getPedestal(std::size_t layer, std::size_t channel) const;
99
100 TH1* getHistogramRepresentation(int layer) const;
101 std::array<TH1*, 18> getLayerHistogramRepresentations() const;
102 int getNumberOfChannels() const { return mPedestalValues.size(); }
103
104 private:
105 std::unordered_map<ChannelID, double, ChannelIDHasher> mPedestalValues;
106 ClassDefNV(PadPedestal, 1);
107};
108
109} // namespace o2::focal
110#endif // ALICEO2_FOCAL_PADPEDESTAL_H
const char * what() const noexcept final
Definition PadPedestal.h:63
InvalidChannelException(std::size_t layer, std::size_t channel)
Definition PadPedestal.h:57
~InvalidChannelException() noexcept final=default
std::size_t getChannel() const noexcept
Definition PadPedestal.h:66
const char * what() const noexcept final
Definition PadPedestal.h:83
~InvalidLayerException() noexcept final=default
std::size_t getLayer() const noexcept
Definition PadPedestal.h:84
void setPedestal(std::size_t layer, std::size_t channel, double pedestal)
int getNumberOfChannels() const
TH1 * getHistogramRepresentation(int layer) const
double getPedestal(std::size_t layer, std::size_t channel) const
bool operator==(const PadPedestal &rhs) const
std::array< TH1 *, 18 > getLayerHistogramRepresentations() const
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
size_t operator()(const ChannelID &s) const
Functor implementation.
Definition PadPedestal.h:45
bool operator==(const ChannelID &other) const
Definition PadPedestal.h:34
VectorOfTObjectPtrs other