Project
Loading...
Searching...
No Matches
CalOnlineGainTables.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// //
14// TRD calibration class for online gain tables. //
15// 2019 - Ported from various bits of AliRoot (SHTM) //
16// Most things were stored in AliTRDOnlineGainTable{,ROC,MCM}.h //
18
20#include "TRDBase/Geometry.h"
21#include "TRDBase/FeeParam.h"
23
24using namespace o2::trd;
25using namespace o2::trd::constants;
26using namespace std;
27
29
30int CalOnlineGainTables::getArrayOffset(int det, int row, int col) const
31{
32 FeeParam* mFeeParam = FeeParam::instance();
33 int rob = mFeeParam->getROBfromPad(row, col);
34 int mcm = mFeeParam->getMCMfromPad(row, col);
35 int detoffset = det * 128; //TODO find this constant from somewhere else max rob=8, max mcm=16, so 7x16+15=127
36 int mcmoffset = rob * NMCMROB + mcm;
37 return detoffset + mcmoffset;
38}
39
41{
42 return 19 - (col % 18); //TODO find both of these constants from somewhere else.
43}
44
45int CalOnlineGainTables::getArrayOffsetrm(int det, int rob, int mcm) const
46{
47 return det * 128 + rob * NMCMROB + mcm;
48}
49
51{
52 //notes for my sanity ...
53 //det gives us the [0-540]
54 //row and col give us the [0-128] 16*rob+mcm
55 int arrayoffset = getArrayOffset(det, row, col);
56 int channel = getChannel(col);
57 float GainCorrectionFactor = 0.0;
58 if (mGainTable[arrayoffset].mAdcdac == 0) {
59 if (mGainTable[arrayoffset].mFGFN[channel] < 0) {
60 GainCorrectionFactor = -1.0;
61 } else if (mGainTable[arrayoffset].mFGFN[channel] > 511) {
62 GainCorrectionFactor = CalOnlineGainTables::UnDef;
63 } else {
64 GainCorrectionFactor = (mGainTable[arrayoffset].mFGFN[channel] / 2048.) + 0.875;
65 }
66 } else {
67 float ADCCorrection = (1. / (1. + ((float)mGainTable[arrayoffset].mAdcdac / 31.) * 0.4 / 1.05));
68 GainCorrectionFactor = ADCCorrection * (((mGainTable[arrayoffset].mFGFN[channel]) / 2048.) + 0.875);
69 }
70 return GainCorrectionFactor;
71}
72
73short CalOnlineGainTables::getAdcdacrm(int det, int rob, int mcm) const
74{
75 return mGainTable[getArrayOffsetrm(det, rob, mcm)].mAdcdac;
76}
77
78short CalOnlineGainTables::getAdcdac(int det, int row, int col) const
79{
80 int arrayoffset = getArrayOffset(det, row, col);
81 return mGainTable[arrayoffset].mAdcdac;
82};
83
84float CalOnlineGainTables::getMCMGainrm(int det, int rob, int mcm) const
85{
86 return mGainTable[getArrayOffsetrm(det, rob, mcm)].mMCMGain;
87}
88
89float CalOnlineGainTables::getMCMGain(int det, int row, int col) const
90{
91 int arrayoffset = getArrayOffset(det, row, col);
92 return mGainTable[arrayoffset].mMCMGain;
93}
94
95short CalOnlineGainTables::getFGANrm(int det, int rob, int mcm, int channel) const
96{
97 return mGainTable[getArrayOffsetrm(det, rob, mcm)].mFGAN[channel];
98}
99
100short CalOnlineGainTables::getFGAN(int det, int row, int col) const
101{
102 int arrayoffset = getArrayOffset(det, row, col);
103 int channel = getChannel(col);
104 return mGainTable[arrayoffset].mFGAN[channel];
105}
106
107short CalOnlineGainTables::getFGFNrm(int det, int rob, int mcm, int channel) const
108{
109 return mGainTable[getArrayOffsetrm(det, rob, mcm)].mFGFN[channel];
110}
111
112short CalOnlineGainTables::getFGFN(int det, int row, int col) const
113{
114 int arrayoffset = getArrayOffset(det, row, col);
115 int channel = getChannel(col);
116 return mGainTable[arrayoffset].mFGFN[channel];
117}
118
119void CalOnlineGainTables::setAdcdacrm(int det, int rob, int mcm, short adcdac)
120{
121 mGainTable[getArrayOffsetrm(det, rob, mcm)].mAdcdac = adcdac;
122}
123
124void CalOnlineGainTables::setAdcdac(int det, int row, int col, short adcdac)
125{
126 int arrayoffset = getArrayOffset(det, row, col);
127 mGainTable[arrayoffset].mAdcdac = adcdac;
128}
129
130void CalOnlineGainTables::setMCMGainrm(int det, int rob, int mcm, float gain)
131{
132 mGainTable[getArrayOffsetrm(det, rob, mcm)].mMCMGain = gain;
133}
134
135void CalOnlineGainTables::setMCMGain(int det, int row, int col, float gain)
136{
137 int arrayoffset = getArrayOffset(det, row, col);
138 mGainTable[arrayoffset].mMCMGain = gain;
139}
140
141void CalOnlineGainTables::setFGANrm(int det, int rob, int mcm, int channel, short gain)
142{
143 mGainTable[getArrayOffsetrm(det, rob, mcm)].mFGAN[channel] = gain;
144}
145
146void CalOnlineGainTables::setFGAN(int det, int row, int col, short gain)
147{
148 int arrayoffset = getArrayOffset(det, row, col);
149 int channel = getChannel(col);
150 mGainTable[arrayoffset].mFGAN[channel] = gain;
151}
152
153void CalOnlineGainTables::setFGFNrm(int det, int rob, int mcm, int channel, short gain)
154{
155 mGainTable[getArrayOffsetrm(det, rob, mcm)].mFGFN[channel] = gain;
156}
157
158void CalOnlineGainTables::setFGFN(int det, int row, int col, short gain)
159{
160 int arrayoffset = getArrayOffset(det, row, col);
161 int channel = getChannel(col);
162 mGainTable[arrayoffset].mFGFN[channel] = gain;
163}
uint16_t mcm
uint16_t rob
Global TRD definitions and constants.
uint32_t col
Definition RawData.h:4
void setAdcdacrm(int det, int rob, int mcm, short gain)
short getAdcdac(int det, int row, int col) const
short getFGFN(int det, int row, int col) const
void setFGFN(int det, int row, int col, short gain)
float getMCMGain(int det, int row, int col) const
void setFGFNrm(int det, int rob, int mcm, int channel, short gain)
std::array< MCMGain, 540 *128 > mGainTable
void setFGANrm(int det, int rob, int mcm, int channel, short gain)
void setMCMGainrm(int det, int rob, int mcm, float gain)
int getArrayOffset(int det, int row, int col) const
void setFGAN(int det, int row, int col, short gain)
float getMCMGainrm(int det, int rob, int mcm) const
int getArrayOffsetrm(int det, int row, int col) const
void setMCMGain(int det, int row, int col, float gain)
short getFGFNrm(int det, int rob, int mcm, int channel) const
void setAdcdac(int det, int row, int col, short gain)
short getAdcdacrm(int det, int rob, int mcm) const
short getFGANrm(int det, int rob, int mcm, int channel) const
short getFGAN(int det, int row, int col) const
float getGainCorrectionFactor(int det, int row, int col) const
static int getROBfromPad(int irow, int icol)
Definition FeeParam.cxx:184
static FeeParam * instance()
Definition FeeParam.cxx:58
static int getMCMfromPad(int irow, int icol)
Definition FeeParam.cxx:142
constexpr int NMCMROB
the number of MCMs per ROB
Definition Constants.h:46
Defining DataPointCompositeObject explicitly as copiable.
std::vector< int > row