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