Project
Loading...
Searching...
No Matches
NonlinearityHandler.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_EMCAL_NONLINEARITYHANDLER__H
12#define ALICEO2_EMCAL_NONLINEARITYHANDLER__H
13
14#include <exception>
15#include <iosfwd>
16#include <unordered_map>
17#include <string>
18#include <Rtypes.h>
20
21namespace o2::emcal
22{
23
43{
44 public:
47 class UninitException : public std::exception
48 {
49 public:
51 UninitException() = default;
52
54 ~UninitException() noexcept final = default;
55
58 const char* what() const noexcept final
59 {
60 return "Nonlinearity handler not initialized";
61 }
62 };
63
81
85 static NonlinType_t getNonlinType(const std::string_view name);
86
90 static const char* getNonlinName(NonlinType_t nonlin);
91
98
106
109
115 {
116 mNonlinearyFunction = nonlintype;
117 initParams();
118 }
119
124 double getCorrectedClusterEnergy(double energy) const;
125
130 double getCorrectedClusterEnergy(const AnalysisCluster& cluster) const { return getCorrectedClusterEnergy(cluster.E()); }
131
135 static double evaluateShaperCorrectionCellEnergy(double energy, double ecalibHG = 1);
136
139 void printStream(std::ostream& stream) const;
140
141 private:
142 NonlinType_t mNonlinearyFunction = NonlinType_t::UNKNOWN;
143 bool mApplyScaleCorrection = false;
144 std::array<double, 11> mNonlinearityParam;
145
149 double evaluateTestbeamCorrected(double energy) const;
150
154 double evaluateTestbeamShaper(double energy) const;
155
159 double evaluatePi0MC(double energy) const;
160
164 double evaluatePi0MCv2(double energy) const;
165
170 void initParams();
171
172 ClassDefNV(NonlinearityHandler, 1)
173};
174
187{
188 public:
191 class FunctionNotFoundExcpetion : public std::exception
192 {
193 public:
196 FunctionNotFoundExcpetion(const std::string_view name) : mName(name), mMessage()
197 {
198 mMessage = "Nonlinearity funciton " + mName + " not found";
199 }
200
202 ~FunctionNotFoundExcpetion() noexcept final = default;
203
206 const char* what() const noexcept final
207 {
208 return mMessage.data();
209 }
210
213 const std::string_view getNonlinName() const noexcept { return mName.data(); }
214
215 private:
216 std::string mName;
217 std::string mMessage;
218 };
219
222 class NonlinInitError : public std::exception
223 {
224 public:
227
229 ~NonlinInitError() noexcept final = default;
230
233 const char* what() const noexcept final
234 {
235 return "Failed constructing nonlinearity handler";
236 }
237 };
238
242 {
243 static NonlinearityFactory currentInstance;
244 return currentInstance;
245 }
246
254
262 NonlinearityHandler& getNonlinearity(const std::string_view nonlintype);
263
264 private:
268 NonlinearityFactory() { initNonlinNames(); }
269
271 ~NonlinearityFactory() = default;
272
274 void initNonlinNames();
275
280 NonlinearityHandler::NonlinType_t getNonlinType(const std::string_view nonlinName) const;
281
282 std::unordered_map<NonlinearityHandler::NonlinType_t, NonlinearityHandler> mHandlers;
283 std::unordered_map<std::string, NonlinearityHandler::NonlinType_t> mNonlinNames;
284
285 ClassDefNV(NonlinearityFactory, 1)
286};
287
292std::ostream& operator<<(std::ostream& in, const NonlinearityHandler& handler);
293
294} // namespace o2::emcal
295
296#endif // ALICEO2_EMCAL_NONLINEARITYHANDLER__H
Cluster class for kinematic cluster parametersported from AliVCluster in AliRoot.
Handling request of non-exisiting nonlinearity functions.
~FunctionNotFoundExcpetion() noexcept final=default
Destructor.
const std::string_view getNonlinName() const noexcept
Getting the name of the function raising the exception.
const char * what() const noexcept final
Provide error message.
FunctionNotFoundExcpetion(const std::string_view name)
Constructor.
Handling errors of initialisation of a certain nonlinearity function.
~NonlinInitError() noexcept final=default
Destructor.
const char * what() const noexcept final
Provide error message.
Creator and handler class of nonlinearity parameterizations.
NonlinearityHandler & getNonlinearity(NonlinearityHandler::NonlinType_t nonlintype)
Get nonlinearity handler for the given nonlinearty type.
static NonlinearityFactory & getInstance()
Get instance of the nonlinearity factory.
Handling missing initialisation of the NonlinearityHanlder.
const char * what() const noexcept final
Provide error message.
~UninitException() noexcept final=default
Destructor.
Nonlinearity functions for energy correction.
NonlinType_t
Types of nonlinearity functions available.
@ MC_PI0
MC, function corresponding to inital testbeam nonlin without shaper correction.
@ MC_PI0_V5
MC, function corresponding to inital testbeam nonlin without shaper correction, version 5.
@ DATA_TESTBEAM_SHAPER_WOSCALE
Data, testbeam nonlin for shaper correction, without energy rescaling.
@ DATA_TESTBEAM_CORRECTED_V4
Data, inital testbeam nonlin without shaper correction, version 4.
@ MC_PI0_V6
MC, function corresponding to inital testbeam nonlin without shaper correction, version 6.
@ MC_TESTBEAM_FINAL
MC, function corresponding to data testbeam nonlin for shaper correction, with energy rescaling.
@ MC_PI0_V3
MC, function corresponding to inital testbeam nonlin without shaper correction, version 3.
@ DATA_TESTBEAM_CORRECTED
Data, inital testbeam nonlin without shaper correction.
@ DATA_TESTBEAM_CORRECTED_V3
Data, inital testbeam nonlin without shaper correction, version 3.
@ DATA_TESTBEAM_CORRECTED_V2
Data, inital testbeam nonlin without shaper correction, version 2.
@ DATA_TESTBEAM_SHAPER
Data, testbeam nonlin for shaper correction, with energy rescaling.
@ MC_PI0_V2
MC, function corresponding to inital testbeam nonlin without shaper correction, version 2.
double getCorrectedClusterEnergy(double energy) const
Get corrected cluster energy for the selected nonlinearity parameterization.
static double evaluateShaperCorrectionCellEnergy(double energy, double ecalibHG=1)
Get corrected energy at cell level for the shaper saturation at high energy.
~NonlinearityHandler()=default
Destructor.
static NonlinType_t getNonlinType(const std::string_view name)
Get type of a nonlinearity function from its name.
void setNonlinType(NonlinType_t nonlintype)
Set type of nonlinearity function.
NonlinearityHandler()=default
Dummy constructor.
double getCorrectedClusterEnergy(const AnalysisCluster &cluster) const
Get corrected cluster energy for the selected nonlinearity parameterization.
void printStream(std::ostream &stream) const
Print information about the nonlinearity function.
static const char * getNonlinName(NonlinType_t nonlin)
Get name of the nonlinearity function from the function type.
GLuint const GLchar * name
Definition glcorearb.h:781
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355