Adding macros to create Calibration objects
[u/mrichter/AliRoot.git] / TRD / TRDbase / AliTRDCalOnlineGainTableMCM.cxx
CommitLineData
dbadb4c4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16#include "AliTRDCalOnlineGainTableMCM.h"
17#include "AliTRDCalOnlineGainTable.h"
18
19//////////////////////////////////////////////////////////////////////////////////////////////
20//
21// Data structure to store gaintables of the online calibration in the OCDB
22// consisting of three classes:
23// AliTRDCalOnlineGainTable
24// AliTRDCalOnlineGainTableROC
25// AliTRDCalOnlineGainTableMCM
26//
27// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
28// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
29// contain the gaintables on ROC level and on the MCM level respectively.
30//
31// The online calibration is used to compensate gain deviations on the pad level.
32// For the offline reconstruction the online calibration has to be undone.
33// The corresponding gain correction factor that was used by the online gain filter can be accessed
34// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col)
35// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
36//
37// With the class AliTRDCalOnlineGainTablesMCM all values used for the
38// online calibration can be set and accessed on the MCM/channel level
39//
40//////////////////////////////////////////////////////////////////////////////////////////////
41
42ClassImp(AliTRDCalOnlineGainTableMCM);
43
44//_____________________________________________________________________________
45AliTRDCalOnlineGainTableMCM::AliTRDCalOnlineGainTableMCM()
46 :TObject()
47 ,fAdcdac(0)
48 ,fMCMGain(0.0)
49{
50 //
51 // constructor
52 //
53
54 fAdcdac = -1;
55 fMCMGain = AliTRDCalOnlineGainTable::UnDef;
56
57 for (int i=0; i<21;i++) {
58
59 fFGFN[i] = -1;
60 fFGAN[i] = -1;
61 }
62
63}
64
65//_____________________________________________________________________________
66AliTRDCalOnlineGainTableMCM::~AliTRDCalOnlineGainTableMCM()
67{
68 //
69 // destructor
70 //
71
72}
73
74//_____________________________________________________________________________
75Float_t AliTRDCalOnlineGainTableMCM::GetGainCorrectionFactor(Int_t channel)
76{
77 //
78 // returns the Gain Correction Factor of the given channel that was used by the online gain filter
79 // 1.0 means no correction
80 // 0.9 means a correction of -10%
81 // 1.1 means a correction of +10% etc.
82 //
83
84 if (fAdcdac == 0){
85 if (fFGFN[channel] < 0){
86 return -1.;
87 }
88 else if(fFGFN[channel] > 511){
89 return -999.;
90 }
91 else{
92 return (fFGFN[channel]/2048.)+0.875;
93
94 }
95 }
96 else{
97 // if the reference voltage of the ADC is not the default value
98 // this taken into account for the Gain Correction Factor
99 Float_t fAdcdac_Correction = ( 1./(1.+((Float_t)fAdcdac/31.)*(0.4/1.05)));
100 return (fAdcdac_Correction*((fFGFN[channel]/2048.)+0.875));
101 }
102
103}
104
105//_____________________________________________________________________________
106Short_t AliTRDCalOnlineGainTableMCM::GetAdcdac()
107{
108 //
109 // returns an integer between 0 and 31 which corresponds to an ADC reference voltage between 1.05V and 1.45V
110 // U_Ref = (1.05V + (fAdcdac/31)*0.4V
111 // fAdcdac is the same value for all ADCs within one MCM
112 //
113
114 return fAdcdac;
115
116}
117
118//_____________________________________________________________________________
119Float_t AliTRDCalOnlineGainTableMCM::GetMCMGain()
120{
121 //
122 // returns the Gain Factor which would lead to a Gain Correction Factor of 1.0
123 // this value is the same for all channels within one MCM
124 // this value is used for the online PID
125 //
126
127 return fMCMGain;
128
129}
130
131//_____________________________________________________________________________
132Short_t AliTRDCalOnlineGainTableMCM::GetFGAN(Int_t channel)
133{
134 //
135 // returns the Gain Correction Filter Additive as an interger between 0 and 15
136 // as it is loaded into the TRAP
137 //
138
139 if (fFGAN[channel] < 0){
140 return -1;
141 }
142 else if(fFGAN[channel] > 511){
143 return -999;
144 }
145 else{
146 return fFGAN[channel];
147
148 }
149
150}
151
152//_____________________________________________________________________________
153Short_t AliTRDCalOnlineGainTableMCM::GetFGFN(Int_t channel)
154{
155 //
156 // returns the Gain Correction Filter Factors as an interger between 0 and 511
157 // as it is loaded into the TRAP
158 //
159
160 if (fFGFN[channel] < 0){
161 return -1;
162 }
163 else if(fFGFN[channel] > 511){
164 return -999;
165 }
166 else{
167 return fFGFN[channel];
168
169 }
170
171}
172