Project
Loading...
Searching...
No Matches
Pedestal.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
12#include "EMCALBase/Geometry.h"
14#include "EMCALCalib/Pedestal.h"
15
16#include <fairlogger/Logger.h>
17
18#include <TH1.h>
19#include <TH2.h>
20
21#include <iostream>
22
23#include <gsl/span>
24
25using namespace o2::emcal;
26
27void Pedestal::addPedestalValue(unsigned short cellID, short pedestal, bool isLowGain, bool isLEDMON)
28{
29 if (cellID >= mPedestalValuesHG.size()) {
30 throw CalibContainerIndexException(cellID);
31 }
32 if (isLEDMON) {
33 if (isLowGain) {
34 mPedestalValuesLEDMONLG[cellID] = pedestal;
35 } else {
36 mPedestalValuesLEDMONHG[cellID] = pedestal;
37 }
38 } else {
39 if (isLowGain) {
40 mPedestalValuesLG[cellID] = pedestal;
41 } else {
42 mPedestalValuesHG[cellID] = pedestal;
43 }
44 }
45}
46
47short Pedestal::getPedestalValue(unsigned short cellID, bool isLowGain, bool isLEDMON) const
48{
49 if (cellID >= mPedestalValuesHG.size()) {
50 throw CalibContainerIndexException(cellID);
51 }
52 if (isLEDMON) {
53 if (isLowGain) {
54 return mPedestalValuesLEDMONLG[cellID];
55 } else {
56 return mPedestalValuesLEDMONHG[cellID];
57 }
58 } else {
59 if (isLowGain) {
60 return mPedestalValuesLG[cellID];
61 } else {
62 return mPedestalValuesHG[cellID];
63 }
64 }
65}
66
67TH1* Pedestal::getHistogramRepresentation(bool isLowGain, bool isLEDMON) const
68{
69 gsl::span<const short> data;
70 std::string histname, histtitle;
71 if (isLEDMON) {
72 if (isLowGain) {
73 histname = "PedestalLG_LEDMON";
74 histtitle = "LEDMON Pedestal values Params low Gain";
75 data = gsl::span<const short>(mPedestalValuesLEDMONLG);
76 } else {
77 histname = "PedestalHG_LEDMON";
78 histtitle = "LEDMON Pedestal values Params high Gain";
79 data = gsl::span<const short>(mPedestalValuesLEDMONHG);
80 }
81 } else {
82 if (isLowGain) {
83 histname = "PedestalLG";
84 histtitle = "Pedestal values Params low Gain";
85 data = gsl::span<const short>(mPedestalValuesLG);
86 } else {
87 histname = "PedestalHG";
88 histtitle = "Pedestal values Params high Gain";
89 data = gsl::span<const short>(mPedestalValuesHG);
90 }
91 }
92
93 auto hist = new TH1S(histname.data(), histtitle.data(), data.size(), -0.5, data.size() - 0.5);
94 hist->SetDirectory(nullptr);
95 for (std::size_t icell{0}; icell < data.size(); ++icell) {
96 hist->SetBinContent(icell + 1, data[icell]);
97 }
98 return hist;
99}
100
101TH2* Pedestal::getHistogramRepresentation2D(bool isLowGain, bool isLEDMON) const
102{
103 gsl::span<const short> data;
104 std::string histname, histtitle;
105 if (isLEDMON) {
106 if (isLowGain) {
107 histname = "PedestalLG_LEDMON";
108 histtitle = "LEDMON Pedestal values Params low Gain";
109 data = gsl::span<const short>(mPedestalValuesLEDMONLG);
110 } else {
111 histname = "PedestalHG_LEDMON";
112 histtitle = "LEDMON Pedestal values Params high Gain";
113 data = gsl::span<const short>(mPedestalValuesLEDMONHG);
114 }
115 } else {
116 if (isLowGain) {
117 histname = "PedestalLG";
118 histtitle = "Pedestal values Params low Gain";
119 data = gsl::span<const short>(mPedestalValuesLG);
120 } else {
121 histname = "PedestalHG";
122 histtitle = "Pedestal values Params high Gain";
123 data = gsl::span<const short>(mPedestalValuesHG);
124 }
125 }
126
127 const int MAXROWS = isLEDMON ? 10 : 208,
128 MAXCOLS = isLEDMON ? 48 : 96;
129
130 auto hist = new TH2S(histname.data(), histtitle.data(), MAXCOLS, -0.5, double(MAXCOLS) - 0.5, MAXROWS, -0.5, double(MAXROWS) - 0.5);
131 hist->SetDirectory(nullptr);
132 try {
133 auto geo = Geometry::GetInstance();
134 for (size_t ichan = 0; ichan < data.size(); ichan++) {
135 if (isLEDMON) {
136 int col = ichan % 48,
137 row = ichan / 48;
138 hist->Fill(col, row, data[ichan]);
139 } else {
140 auto position = geo->GlobalRowColFromIndex(ichan);
141 hist->Fill(std::get<1>(position), std::get<0>(position), data[ichan]);
142 }
143 }
145 LOG(error) << "Geometry needs to be initialized";
146 }
147 return hist;
148}
149
151{
152 return mPedestalValuesHG == other.mPedestalValuesHG && mPedestalValuesLG == other.mPedestalValuesLG && mPedestalValuesLEDMONHG == other.mPedestalValuesLEDMONHG && mPedestalValuesLEDMONLG == other.mPedestalValuesLEDMONLG;
153}
uint32_t col
Definition RawData.h:4
Error handling for invalid index in calibration request.
Error handling access to non-initialized geometry.
static Geometry * GetInstance()
Get geometry instance. It should have been set before.
Definition Geometry.cxx:190
CCDB container for pedestal values.
Definition Pedestal.h:48
short getPedestalValue(unsigned short cellID, bool isLowGain, bool isLEDMON) const
Get the time calibration coefficient for a certain cell.
Definition Pedestal.cxx:47
bool operator==(const Pedestal &other) const
Comparison of two pedestal containers.
Definition Pedestal.cxx:150
void addPedestalValue(unsigned short cellID, short pedestal, bool isLowGain, bool isLEDMON)
Add pedestal to the container.
Definition Pedestal.cxx:27
TH1 * getHistogramRepresentation(bool isLowGain, bool isLEDMON) const
Convert the pedestal container to a histogram.
Definition Pedestal.cxx:67
TH2 * getHistogramRepresentation2D(bool isLowGain, bool isLEDMON) const
Convert the pedestal container to a 2D histogram.
Definition Pedestal.cxx:101
GLboolean * data
Definition glcorearb.h:298
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row