Project
Loading...
Searching...
No Matches
CalibParams.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
13#include "PHOSBase/Geometry.h"
14
15#include <fairlogger/Logger.h>
16
17#include <TH2.h>
18
19#include <iostream>
20
21using namespace o2::phos;
22
23CalibParams::CalibParams(int /*dummy*/)
24{
25 //produce reasonable objest for test purposes
26 mGainCalib.fill(0.005);
27 mHGLGRatio.fill(16.);
28 mHGTimeCalib.fill(0.);
29 mLGTimeCalib.fill(0.);
30}
31
32bool CalibParams::setGain(TH2* h, char module)
33{
34 const char MAXX = 64,
35 MAXZ = 56;
36 if (module < 1 || module > 4) {
37 LOG(error) << "module " << module << "does not exist";
38 return false;
39 }
40
41 if (!h) {
42 LOG(error) << "no input histogam";
43 return false;
44 }
45
46 if (h->GetNbinsX() != MAXX || h->GetNbinsY() != MAXZ) {
47 LOG(error) << "Wrong dimentions of input histogram:" << h->GetNbinsX() << "," << h->GetNbinsY() << " instead of " << MAXX << "," << MAXZ;
48 return false;
49 }
50
51 char relid[3] = {module, 1, 1};
52 short absId;
53 for (char ix = 1; ix <= MAXX; ix++) {
54 relid[1] = ix;
55 for (char iz = 1; iz <= MAXZ; iz++) {
56 relid[2] = iz;
57
58 if (o2::phos::Geometry::relToAbsNumbering(relid, absId)) {
59 if (absId - OFFSET < 0) { //non-existing part of a module 1
60 continue;
61 }
62 mGainCalib[absId - OFFSET] = h->GetBinContent(ix, iz);
63 }
64 }
65 }
66 return true;
67}
68
69bool CalibParams::setHGLGRatio(TH2* h, char module)
70{
71 const char MAXX = 64,
72 MAXZ = 56;
73 if (module < 1 || module > 4) {
74 LOG(error) << "module " << module << "does not exist";
75 return false;
76 }
77 if (!h) {
78 LOG(error) << "no input histogam";
79 return false;
80 }
81
82 if (h->GetNbinsX() != MAXX || h->GetNbinsY() != MAXZ) {
83 LOG(error) << "Wrong dimentions of input histogram:" << h->GetNbinsX() << "," << h->GetNbinsY() << " instead of " << MAXX << "," << MAXZ;
84 return false;
85 }
86
87 char relid[3] = {module, 1, 1};
88 short absId;
89 for (char ix = 1; ix <= MAXX; ix++) {
90 relid[1] = ix;
91 for (char iz = 1; iz <= MAXZ; iz++) {
92 relid[2] = iz;
93
94 if (o2::phos::Geometry::relToAbsNumbering(relid, absId)) {
95 if (absId - OFFSET < 0) { //non-existing part of a module 1
96 continue;
97 }
98 mHGLGRatio[absId - OFFSET] = h->GetBinContent(ix, iz);
99 }
100 }
101 }
102 return true;
103}
104
105bool CalibParams::setHGTimeCalib(TH2* h, char module)
106{
107 const char MAXX = 64,
108 MAXZ = 56;
109 if (module < 1 || module > 4) {
110 LOG(error) << "module " << module << "does not exist";
111 return false;
112 }
113 if (!h) {
114 LOG(error) << "no input histogam";
115 return false;
116 }
117
118 if (h->GetNbinsX() != MAXX || h->GetNbinsY() != MAXZ) {
119 LOG(error) << "Wrong dimentions of input histogram:" << h->GetNbinsX() << "," << h->GetNbinsY() << " instead of " << MAXX << "," << MAXZ;
120 return false;
121 }
122
123 char relid[3] = {module, 1, 1};
124 short absId;
125 for (char ix = 1; ix <= MAXX; ix++) {
126 relid[1] = ix;
127 for (char iz = 1; iz <= MAXZ; iz++) {
128 relid[2] = iz;
129
130 if (o2::phos::Geometry::relToAbsNumbering(relid, absId)) {
131 if (absId - OFFSET < 0) { //non-existing part of a module 1
132 continue;
133 }
134 mHGTimeCalib[absId - OFFSET] = h->GetBinContent(ix, iz);
135 }
136 }
137 }
138 return true;
139}
140
141bool CalibParams::setLGTimeCalib(TH2* h, char module)
142{
143 const char MAXX = 64,
144 MAXZ = 56;
145 if (module < 1 || module > 4) {
146 LOG(error) << "module " << module << "does not exist";
147 return false;
148 }
149 if (!h) {
150 LOG(error) << "no input histogam";
151 return false;
152 }
153
154 if (h->GetNbinsX() != MAXX || h->GetNbinsY() != MAXZ) {
155 LOG(error) << "Wrong dimentions of input histogram:" << h->GetNbinsX() << "," << h->GetNbinsY() << " instead of " << MAXX << "," << MAXZ;
156 return false;
157 }
158
159 char relid[3] = {module, 1, 1};
160 short absId;
161 for (char ix = 1; ix <= MAXX; ix++) {
162 relid[1] = ix;
163 for (char iz = 1; iz <= MAXZ; iz++) {
164 relid[2] = iz;
165
166 if (o2::phos::Geometry::relToAbsNumbering(relid, absId)) {
167 if (absId - OFFSET < 0) { //non-existing part of a module 1
168 continue;
169 }
170 mLGTimeCalib[absId - OFFSET] = h->GetBinContent(ix, iz);
171 }
172 }
173 }
174 return true;
175}
Class for time synchronization of RawReader instances.
void setHGLGRatio(short cellID, float r)
Set High Gain to Low Gain ratio.
Definition CalibParams.h:74
void setHGTimeCalib(short cellID, float t)
Set High Gain time calibration coefficient.
Definition CalibParams.h:90
void setGain(short cellID, float c)
Set High Gain energy calibration coefficient.
Definition CalibParams.h:58
void setLGTimeCalib(short cellID, float t)
Set time calibration coefficient.
static bool relToAbsNumbering(const char *RelId, short &AbsId)
Definition Geometry.cxx:207
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"