Project
Loading...
Searching...
No Matches
PadPedestal.cxx
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#include <cfloat>
14
15#include <fairlogger/Logger.h>
16
17using namespace o2::focal;
18
20{
21}
22
24{
25 if (mPedestalValues.size() != rhs.mPedestalValues.size()) {
26 LOG(debug) << "Error size: this " << mPedestalValues.size() << ", other " << rhs.mPedestalValues.size();
27 return false;
28 }
29 bool failure = false;
30 // check equalty of content based on other object
31 for (auto [channel, pedestal] : rhs.mPedestalValues) {
32 auto found = mPedestalValues.find(channel);
33 if (found == mPedestalValues.end()) {
34 LOG(debug) << "Key not found this: Layer " << channel.mLayer << ", channel " << channel.mChannel;
35 failure = true;
36 } else {
37 if (std::abs(found->second - pedestal) > DBL_EPSILON) {
38 LOG(debug) << "Value error channel layer " << channel.mLayer << ", channel " << channel.mChannel << " this " << found->second << ", other " << pedestal;
39 failure = true;
40 }
41 }
42 }
43 if (failure) {
44 return false;
45 }
46 // check equality of content based on this object
47 for (auto [channel, pedestal] : mPedestalValues) {
48 auto found = rhs.mPedestalValues.find(channel);
49 if (found == rhs.mPedestalValues.end()) {
50 LOG(debug) << "Key not found other: Layer " << channel.mLayer << ", channel: " << channel.mChannel;
51 failure = true;
52 } else {
53 if (std::abs(found->second - pedestal) > DBL_EPSILON) {
54 LOG(debug) << "Value error channel layer " << channel.mLayer << ", channel " << channel.mChannel << " other " << found->second << ", this " << pedestal;
55 failure = true;
56 }
57 }
58 }
59 return !failure;
60}
61
62void PadPedestal::setPedestal(std::size_t layer, std::size_t channel, double pedestal)
63{
65 throw InvalidChannelException(layer, channel);
66 }
68 throw InvalidChannelException(layer, channel);
69 }
70 auto found = mPedestalValues.find({layer, channel});
71 if (found == mPedestalValues.end()) {
72 mPedestalValues.insert({{layer, channel}, pedestal});
73 } else {
74 found->second = pedestal;
75 }
76}
77
78double PadPedestal::getPedestal(std::size_t layer, std::size_t channel) const
79{
80 auto found = mPedestalValues.find({layer, channel});
81 if (found == mPedestalValues.end()) {
82 throw InvalidChannelException(layer, channel);
83 }
84 return found->second;
85}
86
88{
89 if (layer > 18) {
91 }
92 std::string histname = "PedestalsLayer" + std::to_string(layer),
93 histtitle = "Pedestals in layer " + std::to_string(layer);
94 auto pedestalHist = new TH1F(histname.data(), histtitle.data(), constants::PADLAYER_MODULE_NCHANNELS, -0.5, constants::PADLAYER_MODULE_NCHANNELS - 0.5);
95 pedestalHist->SetDirectory(nullptr);
96 pedestalHist->SetStats(false);
97 pedestalHist->SetXTitle("Channel");
98 pedestalHist->SetYTitle("Pedestal (ADC counts)");
99 for (std::size_t channel = 0; channel < constants::PADLAYER_MODULE_NCHANNELS; channel++) {
100 double pedestal = 0;
101 try {
102 pedestal = getPedestal(layer, channel);
103 } catch (InvalidChannelException& e) {
104 LOG(error) << e.what();
105 }
106 pedestalHist->SetBinContent(channel + 1, pedestal);
107 }
108 return pedestalHist;
109}
111{
112 std::array<TH1*, 18> pedestalHistograms;
113 for (int layer = 0; layer < 18; layer++) {
114 pedestalHistograms[layer] = getHistogramRepresentation(layer);
115 }
116 return pedestalHistograms;
117}
std::ostringstream debug
const char * what() const noexcept final
Definition PadPedestal.h:63
void setPedestal(std::size_t layer, std::size_t channel, double pedestal)
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
constexpr int PADLAYER_MODULE_NCHANNELS
Definition Constants.h:16
constexpr int PADS_NLAYERS
Definition Constants.h:18
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"