New base class
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibData.cxx
CommitLineData
f565d89d 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/* $Id$ */
17
63b315c5 18//_________________________________________________________________________
19///*-- Author: Yves Schutz (SUBATECH)
20// : Aleksei Pavlinov (WSU); Jun 30, 2006 - ALICE numbering scheme
df5cea6b 21// : Add decalibration and time calibration arrays: Jul 21, 2011 (GCB)
f565d89d 22///////////////////////////////////////////////////////////////////////////////
23// //
24// class for EMCAL calibration //
25// //
26///////////////////////////////////////////////////////////////////////////////
27
090026bf 28#include <TMath.h>
29
f565d89d 30#include "AliEMCALCalibData.h"
31
32ClassImp(AliEMCALCalibData)
33
34//________________________________________________________________
35AliEMCALCalibData::AliEMCALCalibData()
36{
37 // Default constructor
38 Reset();
39}
40
41//________________________________________________________________
42AliEMCALCalibData::AliEMCALCalibData(const char* name)
43{
44 // Constructor
45 TString namst = "Calib_";
46 namst += name;
47 SetName(namst.Data());
48 SetTitle(namst.Data());
49 Reset();
50}
51
52//________________________________________________________________
53AliEMCALCalibData::AliEMCALCalibData(const AliEMCALCalibData& calibda) :
54 TNamed(calibda)
55{
56 // copy constructor
57 SetName(calibda.GetName());
58 SetTitle(calibda.GetName());
59 Reset();
60
0c5b726e 61 Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
62 Int_t nCol = AliEMCALGeoParams::fgkEMCALCols; //48
63 Int_t nRow = AliEMCALGeoParams::fgkEMCALRows; //24
64 Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows; //12 - Modules 11 and 12 are half modules
f565d89d 65
df5cea6b 66 for(Int_t supermodule = 0; supermodule < nSMod; supermodule++) {
67
9219ceb6 68 if(supermodule >= 10)
beb28b95 69 nRow = nRow2;
df5cea6b 70
71 for(Int_t column = 0; column<nCol; column++) {
72
73 for(Int_t row = 0; row<nRow; row++) {
74
75 fADCchannel[supermodule][column][row] =
76 calibda.GetADCchannel(supermodule,column,row);
77
78 fADCchannelDecal[supermodule][column][row] =
79 calibda.GetADCchannelDecal(supermodule,column,row);
80
81 fADCpedestal[supermodule][column][row] =
82 calibda.GetADCpedestal(supermodule,column,row);
83
84 fTimeChannel[supermodule][column][row] =
85 calibda.GetTimeChannel(supermodule,column,row);
86
87 fTimeChannelDecal[supermodule][column][row] =
88 calibda.GetTimeChannelDecal(supermodule,column,row);
89
90
f565d89d 91 }
92 }
93 }
94}
95
96
97//________________________________________________________________
98AliEMCALCalibData &AliEMCALCalibData::operator =(const AliEMCALCalibData& calibda)
99{
100 // assignment operator
101 SetName(calibda.GetName());
102 SetTitle(calibda.GetName());
103 Reset();
104
0c5b726e 105 Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
106 Int_t nCol = AliEMCALGeoParams::fgkEMCALCols; //48
107 Int_t nRow = AliEMCALGeoParams::fgkEMCALRows; //24
108 Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2; //12 - Modules 11 and 12 are half modules
f565d89d 109
df5cea6b 110 for(Int_t supermodule = 0; supermodule < nSMod; supermodule++) {
111
9219ceb6 112 if(supermodule >= 10)
beb28b95 113 nRow = nRow2;
df5cea6b 114
115 for(Int_t column = 0; column<nCol; column++) {
116
117 for(Int_t row = 0; row<nRow; row++) {
118
119 fADCchannel[supermodule][column][row] =
120 calibda.GetADCchannel(supermodule,column,row);
121
122 fADCchannelDecal[supermodule][column][row] =
123 calibda.GetADCchannelDecal(supermodule,column,row);
124
125 fADCpedestal[supermodule][column][row] =
126 calibda.GetADCpedestal(supermodule,column,row);
127
128 fTimeChannel[supermodule][column][row] =
129 calibda.GetTimeChannel(supermodule,column,row);
130
131 fTimeChannelDecal[supermodule][column][row] =
132 calibda.GetTimeChannelDecal(supermodule,column,row);
133
f565d89d 134 }
135 }
136 }
137 return *this;
138}
139
140//________________________________________________________________
141AliEMCALCalibData::~AliEMCALCalibData()
142{
143 // Destructor
144}
145
146//________________________________________________________________
147void AliEMCALCalibData::Reset()
148{
149 // Set all pedestals to 0 and all ADC channels widths to 1
0c5b726e 150 //memset(fADCchannel ,1,12*48*24*sizeof(Float_t));
151 //memset(fADCpedestal,0,12*48*24*sizeof(Float_t));
0e76a7bf 152
153 Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
154 Int_t nCol = AliEMCALGeoParams::fgkEMCALCols; //48
155 Int_t nRow = AliEMCALGeoParams::fgkEMCALRows; //24
156 Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2; //12 - Modules 11 and 12 are half modules
157 for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
158 if(supermodule >= 10)
159 nRow = nRow2;
df5cea6b 160 for (Int_t column=0; column < nCol; column++){
161
162 for (Int_t row = 0; row < nRow; row++){
163
164 fADCpedestal [supermodule][column][row]=0.;
165
166 fADCchannelDecal [supermodule][column][row]=1.;
167 fADCchannel [supermodule][column][row]=1.;
168
169 fTimeChannel [supermodule][column][row]=0.;
170 fTimeChannelDecal[supermodule][column][row]=0.;
171
0e76a7bf 172 }
173 }
63c22917 174 }
175
176 fADCchannelRef = .0162;
f565d89d 177}
178
179//________________________________________________________________
180void AliEMCALCalibData::Print(Option_t *option) const
181{
182 // Print tables of pedestals and ADC channels widths
df5cea6b 183 // options are: "gain", "ped", "decal", "time", "all"
184
0c5b726e 185 Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
186 Int_t nCol = AliEMCALGeoParams::fgkEMCALCols; //48
187 Int_t nRow = AliEMCALGeoParams::fgkEMCALRows; //24
188 Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2; //12 - Modules 11 and 12 are half modules
df5cea6b 189 if (strstr(option,"ped") || strstr(option,"all")) {
f565d89d 190 printf("\n ---- Pedestal values ----\n\n");
191 for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
9219ceb6 192 if(supermodule >= 10)
df5cea6b 193 nRow = nRow2;
f565d89d 194 printf("============== Supermodule %d\n",supermodule+1);
195 for (Int_t column=0; column<nCol; column++){
df5cea6b 196 for (Int_t row=0; row<nRow; row++){
197 printf(" %2.4f ",fADCpedestal[supermodule][column][row]);
198 }
199 printf("\n");
f565d89d 200 }
201 }
202 }
df5cea6b 203
204 if (strstr(option,"gain") || strstr(option,"all")) {
f565d89d 205 printf("\n ---- ADC channel values ----\n\n");
206 for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
9219ceb6 207 if(supermodule >= 10)
df5cea6b 208 nRow = nRow2;
f565d89d 209 printf("============== Supermodule %d\n",supermodule+1);
210 for (Int_t column=0; column<nCol; column++){
df5cea6b 211 for (Int_t row=0; row<nRow; row++){
212 printf(" %2.4f ",fADCchannel[supermodule][column][row]);
213 }
214 printf("\n");
f565d89d 215 }
216 }
217 }
df5cea6b 218
219 if (strstr(option,"adcdecal") || strstr(option,"all")) {
220 printf("\n ---- ADC decalibration channel values ----\n\n");
221 for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
222 if(supermodule >= 10)
223 nRow = nRow2;
224 printf("============== Supermodule %d\n",supermodule+1);
225 for (Int_t column=0; column<nCol; column++){
226 for (Int_t row=0; row<nRow; row++){
227 printf(" %2.4f ",fADCchannelDecal[supermodule][column][row]);
228 }
229 printf("\n");
230 }
231 }
232 }
233
234 if (strstr(option,"time") || strstr(option,"all")) {
235 printf("\n ---- time channel values ----\n\n");
236 for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
237 if(supermodule >= 10)
238 nRow = nRow2;
239 printf("============== Supermodule %d\n",supermodule+1);
240 for (Int_t column=0; column<nCol; column++){
241 for (Int_t row=0; row<nRow; row++){
242 printf(" %2.4f ",fTimeChannel[supermodule][column][row]);
243 }
244 printf("\n");
245 }
246 }
247 }
248
249
250 if (strstr(option,"time") || strstr(option,"all")) {
251 printf("\n ---- time decalibration channel values ----\n\n");
252 for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
253 if(supermodule >= 10)
254 nRow = nRow2;
255 printf("============== Supermodule %d\n",supermodule+1);
256 for (Int_t column=0; column<nCol; column++){
257 for (Int_t row=0; row<nRow; row++){
258 printf(" %2.4f ",fTimeChannelDecal[supermodule][column][row]);
259 }
260 printf("\n");
261 }
262 }
263 }
264
265
f565d89d 266}
267
268//________________________________________________________________
269Float_t AliEMCALCalibData::GetADCchannel(Int_t supermodule, Int_t column, Int_t row) const
270{
271 // Set ADC channel witdth values
63b315c5 272 // All indexes start from 0!
273 // Supermodule, column,raw should follow the ALICE convention:
274 // supermodule 0:11, column 0:47, row 0:23
f565d89d 275
63b315c5 276 return fADCchannel[supermodule][column][row];
f565d89d 277}
278
df5cea6b 279//________________________________________________________________
280Float_t AliEMCALCalibData::GetADCchannelDecal(Int_t supermodule, Int_t column, Int_t row) const
281{
282 // Set ADC channel decalibration witdth values
283 // All indexes start from 0!
284 // Supermodule, column,raw should follow the ALICE convention:
285 // supermodule 0:11, column 0:47, row 0:23
286
287 return fADCchannelDecal[supermodule][column][row];
288}
289
f565d89d 290//________________________________________________________________
291Float_t AliEMCALCalibData::GetADCpedestal(Int_t supermodule, Int_t column, Int_t row) const
292{
293 // Get ADC pedestal values
63b315c5 294 return fADCpedestal[supermodule][column][row];
f565d89d 295}
296
df5cea6b 297//________________________________________________________________
298Float_t AliEMCALCalibData::GetTimeChannel(Int_t supermodule, Int_t column, Int_t row) const
299{
300 // Set channel time witdth values
301 return fTimeChannel[supermodule][column][row];
302}
303
304//________________________________________________________________
305Float_t AliEMCALCalibData::GetTimeChannelDecal(Int_t supermodule, Int_t column, Int_t row) const
306{
307 // Set channel time witdth values
308 return fTimeChannelDecal[supermodule][column][row];
309}
310
f565d89d 311//________________________________________________________________
312void AliEMCALCalibData::SetADCchannel(Int_t supermodule, Int_t column, Int_t row, Float_t value)
313{
314 // Set ADC channel width values
63b315c5 315 fADCchannel[supermodule][column][row] = value;
f565d89d 316}
317
df5cea6b 318//________________________________________________________________
319void AliEMCALCalibData::SetADCchannelDecal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
320{
321 // Set ADC channel width values
322 fADCchannelDecal[supermodule][column][row] = value;
323}
324
f565d89d 325//________________________________________________________________
326void AliEMCALCalibData::SetADCpedestal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
327{
328 // Set ADC pedestal values
63b315c5 329 fADCpedestal[supermodule][column][row] = value;
f565d89d 330}
0e76a7bf 331
df5cea6b 332//________________________________________________________________
333void AliEMCALCalibData::SetTimeChannel(Int_t supermodule, Int_t column, Int_t row, Float_t value)
334{
335 // Set ADC pedestal values
336 fTimeChannel[supermodule][column][row] = value;
337}
338
339//________________________________________________________________
340void AliEMCALCalibData::SetTimeChannelDecal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
341{
342 // Set ADC pedestal values
343 fTimeChannelDecal[supermodule][column][row] = value;
344}
345
346
0e76a7bf 347//________________________________________________________________
348void AliEMCALCalibData::Fill(const AliEMCALCalibData *cd1, const AliEMCALCalibData *cd2, Bool_t print)
349{
350 // Fill for (relative) recalibration to undo calibration
351 // from 1 and apply calibration from 2.
352
353 Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
354 Int_t nCol = AliEMCALGeoParams::fgkEMCALCols; //48
355 Int_t nRow = AliEMCALGeoParams::fgkEMCALRows; //24
356 Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2; //12 - Modules 11 and 12 are half modules
357 for (Int_t supermodule=0; supermodule<nSMod; supermodule++) {
358 if(supermodule >= 10)
359 nRow = nRow2;
360 for (Int_t column=0; column<nCol; column++) {
361 for (Int_t row=0; row<nRow; row++){
362 Double_t adc1 = cd1->GetADCchannel(supermodule, column, row);
363 Double_t ped1 = cd1->GetADCpedestal(supermodule, column, row);
364 Double_t adc2 = cd2->GetADCchannel(supermodule, column, row);
365 Double_t ped2 = cd2->GetADCpedestal(supermodule, column, row);
366 Double_t adc = adc2/adc1;
367 Double_t ped = ped2-adc*ped1;
368 if (print)
369 printf("%d %d %d: %f %f %f %f -> %f %f\n",supermodule,column,row,adc1,ped1,adc2,ped2,adc,ped);
370 fADCchannel [supermodule][column][row]=adc;
371 fADCpedestal[supermodule][column][row]=ped;
372 }
373 }
374 }
375}
376