Project
Loading...
Searching...
No Matches
EMCALChannelScaleFactors.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
17
18#ifndef EMCAL_CHANNEL_SCALE_FACTORS_H_
19#define EMCAL_CHANNEL_SCALE_FACTORS_H_
20
21#include <cfloat>
22#include "Framework/Logger.h"
23#include "EMCALBase/Geometry.h"
24
25namespace o2
26{
27namespace emcal
28{
29
30class InvalidEnergyIntervalException final : public std::exception
31{
32
33 public:
36 InvalidEnergyIntervalException(float E, unsigned int cellID) : std::exception(),
37 mE(E),
38 mCellID(cellID),
39 mMessage("Invalid energy " + std::to_string(mE) + "for cell " + std::to_string(mCellID) + "]")
40 {
41 }
42
44 ~InvalidEnergyIntervalException() noexcept final = default;
45
48 const char* what() const noexcept final { return mMessage.c_str(); }
49
50 private:
51 float mE;
52 unsigned int mCellID;
53 std::string mMessage;
54};
55
57{
58 public:
59 EnergyIntervals() = default;
60 EnergyIntervals(float min, float max)
61 {
62 Elow = min;
63 Ehigh = max;
64 }
65 ~EnergyIntervals() = default;
66
70 void setEnergy(float min, float max)
71 {
72 Elow = min;
73 Ehigh = max;
74 }
78 bool isInInterval(float E) const
79 {
80 LOG(debug) << "EMCALChannelScaleFactors::EnergyIntervals::IsInInterval: Checking if " << E << " is in the interval " << Elow << " - " << Ehigh;
81 if (E >= Elow && E < Ehigh) {
82 return true;
83 } else {
84 return false;
85 }
86 }
87
89 bool operator==(const EnergyIntervals& other) const
90 {
91 if (std::abs(Elow - other.Elow) < FLT_EPSILON && std::abs(Ehigh - other.Ehigh) < FLT_EPSILON) {
92 return true;
93 } else {
94 return false;
95 }
96 }
97 bool operator!=(const EnergyIntervals& other) const
98 {
99 if (std::abs(Elow - other.Elow) < FLT_EPSILON && std::abs(Ehigh - other.Ehigh) < FLT_EPSILON) {
100 return false;
101 } else {
102 return true;
103 }
104 }
105 bool operator<(const EnergyIntervals& other) const
106 {
107 if (Elow < other.Elow) {
108 return true;
109 } else {
110 return false;
111 }
112 }
113 bool operator>(const EnergyIntervals& other) const
114 {
115 if (Elow > other.Elow) {
116 return true;
117 } else {
118 return false;
119 }
120 }
121
122 private:
124 float Elow;
125 float Ehigh;
126
127 ClassDefNV(EnergyIntervals, 1);
128};
129
131{
132
133 public:
140 void insertVal(unsigned int cellID, float E_min, float E_max, float scale);
141
148 float getScaleVal(unsigned int cellID, float E) const;
149
150 private:
151 static constexpr int NCells = 17664;
152 std::array<std::map<EnergyIntervals, float>, NCells> ScaleFactors;
153
154 ClassDefNV(EMCALChannelScaleFactors, 1);
155};
156
157} // end namespace emcal
158
159} // end namespace o2
160
161#endif
std::ostringstream debug
void insertVal(unsigned int cellID, float E_min, float E_max, float scale)
float getScaleVal(unsigned int cellID, float E) const
EnergyIntervals(float min, float max)
bool operator==(const EnergyIntervals &other) const
declare operator ==, !=, <, >
bool operator<(const EnergyIntervals &other) const
bool operator>(const EnergyIntervals &other) const
bool operator!=(const EnergyIntervals &other) const
void setEnergy(float min, float max)
InvalidEnergyIntervalException(float E, unsigned int cellID)
Constructor.
const char * what() const noexcept final
Access to error message.
~InvalidEnergyIntervalException() noexcept final=default
Destructor.
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)
Definition common.h:52
constexpr size_t min
constexpr size_t max
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"