Project
Loading...
Searching...
No Matches
ZDCEnergyParam.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 "Framework/Logger.h"
14
15using namespace o2::zdc;
16
17void ZDCEnergyParam::setEnergyCalib(uint32_t ich, float val)
18{
19 bool in_list = false;
20 for (int il = 0; il < ChEnergyCalib.size(); il++) {
21 if (ich == ChEnergyCalib[il]) {
22 in_list = true;
23 break;
24 }
25 }
26 if (in_list) {
27 energy_calib[ich] = val;
28 } else {
29 LOG(fatal) << __func__ << " channel " << ich << " not in allowed range";
30 for (int il = 0; il < ChEnergyCalib.size(); il++) {
31 LOG(info) << __func__ << " channel " << ChEnergyCalib[il] << " " << ChannelNames[ChEnergyCalib[il]];
32 }
33 }
34}
35
36float ZDCEnergyParam::getEnergyCalib(uint32_t ich) const
37{
38 if (ich >= 0 && ich < NChannels) {
39 return energy_calib[ich];
40 } else {
41 LOG(fatal) << __func__ << " channel " << ich << " not in allowed range";
42 return 0;
43 }
44}
45
46void ZDCEnergyParam::setOffset(uint32_t ich, float val)
47{
48 bool in_list = false;
49 for (int il = 0; il < ChEnergyCalib.size(); il++) {
50 if (ich == ChEnergyCalib[il]) {
51 in_list = true;
52 break;
53 }
54 }
55 if (in_list) {
56 adc_offset[ich] = val;
57 } else {
58 LOG(fatal) << __func__ << " channel " << ich << " not in allowed range";
59 for (int il = 0; il < ChEnergyCalib.size(); il++) {
60 LOG(info) << __func__ << " channel " << ChEnergyCalib[il] << " " << ChannelNames[ChEnergyCalib[il]];
61 }
62 }
63}
64
65float ZDCEnergyParam::getOffset(uint32_t ich) const
66{
67 if (ich >= 0 && ich < NChannels) {
68 return adc_offset[ich];
69 } else {
70 LOG(fatal) << __func__ << " channel " << ich << " not in allowed range";
71 return 0;
72 }
73}
74
76{
77 for (Int_t ich = 0; ich < NChannels; ich++) {
78 if (energy_calib[ich] > 0) {
79 LOG(info) << ChannelNames[ich] << " calibration factor = " << energy_calib[ich];
80 }
81 if (adc_offset[ich] > 0) {
82 LOG(info) << ChannelNames[ich] << " adc offset = " << adc_offset[ich];
83 }
84 }
85}
ZDC Energy calibration.
GLuint GLfloat * val
Definition glcorearb.h:1582
constexpr std::array< int, 10 > ChEnergyCalib
Definition Constants.h:286
constexpr int NChannels
Definition Constants.h:65
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
float energy_calib[NChannels]
float getOffset(uint32_t ich) const
void setEnergyCalib(uint32_t ich, float val)
float getEnergyCalib(uint32_t ich) const
void setOffset(uint32_t ich, float val)
float adc_offset[NChannels]
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"