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