]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALCalibData.cxx
Changes for #93916 EMCAL commit attached patch and port to the release
[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 {
37   // Default constructor
38   Reset();
39 }
40
41 //________________________________________________________________
42 AliEMCALCalibData::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 //________________________________________________________________
53 AliEMCALCalibData::AliEMCALCalibData(const AliEMCALCalibData& calibda) :
54   TNamed(calibda)
55 {
56   // copy constructor
57   SetName(calibda.GetName());
58   SetTitle(calibda.GetName());
59   Reset();
60
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
65
66   for(Int_t supermodule = 0; supermodule < nSMod; supermodule++) {
67     
68     if(supermodule >= 10)
69       nRow = nRow2;
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         
91       }
92     }
93   }
94 }
95
96
97 //________________________________________________________________
98 AliEMCALCalibData &AliEMCALCalibData::operator =(const AliEMCALCalibData& calibda)
99 {
100   // assignment operator
101   SetName(calibda.GetName());
102   SetTitle(calibda.GetName());
103   Reset();
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
110   for(Int_t supermodule = 0; supermodule < nSMod; supermodule++) {
111     
112     if(supermodule >= 10)
113       nRow = nRow2;
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         
134       }
135     }
136   }
137   return *this;
138 }
139
140 //________________________________________________________________
141 AliEMCALCalibData::~AliEMCALCalibData()
142 {
143   // Destructor
144 }
145
146 //________________________________________________________________
147 void AliEMCALCalibData::Reset()
148 {
149   // Set all pedestals to 0 and all ADC channels widths to 1
150   //memset(fADCchannel ,1,12*48*24*sizeof(Float_t));
151   //memset(fADCpedestal,0,12*48*24*sizeof(Float_t));
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;
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
172       }
173     }
174   }
175         
176   fADCchannelRef = .0162;       
177 }
178
179 //________________________________________________________________
180 void  AliEMCALCalibData::Print(Option_t *option) const
181 {
182   // Print tables of pedestals and ADC channels widths
183   // options are: "gain", "ped", "decal", "time", "all"
184   
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
189   if (strstr(option,"ped") || strstr(option,"all")) {
190     printf("\n  ----    Pedestal values ----\n\n");
191     for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
192       if(supermodule >= 10)
193         nRow = nRow2;
194       printf("============== Supermodule %d\n",supermodule+1);
195       for (Int_t column=0; column<nCol; column++){
196         for (Int_t row=0; row<nRow; row++){
197           printf(" %2.4f ",fADCpedestal[supermodule][column][row]);
198         }
199         printf("\n");
200       }
201     } 
202   }
203   
204   if (strstr(option,"gain") || strstr(option,"all")) {
205     printf("\n  ----    ADC channel values      ----\n\n");
206     for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
207       if(supermodule >= 10) 
208         nRow = nRow2;
209       printf("============== Supermodule %d\n",supermodule+1);
210       for (Int_t column=0; column<nCol; column++){
211         for (Int_t row=0; row<nRow; row++){
212           printf(" %2.4f ",fADCchannel[supermodule][column][row]);
213         }
214         printf("\n");
215       }
216     }   
217   }
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   
266 }
267
268 //________________________________________________________________
269 Float_t AliEMCALCalibData::GetADCchannel(Int_t supermodule, Int_t column, Int_t row) const
270 {
271   // Set ADC channel witdth values
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
275
276   return fADCchannel[supermodule][column][row];
277 }
278
279 //________________________________________________________________
280 Float_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
290 //________________________________________________________________
291 Float_t AliEMCALCalibData::GetADCpedestal(Int_t supermodule, Int_t column, Int_t row) const
292 {
293   // Get ADC pedestal values
294  return fADCpedestal[supermodule][column][row];
295 }
296
297 //________________________________________________________________
298 Float_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 //________________________________________________________________
305 Float_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
311 //________________________________________________________________
312 void AliEMCALCalibData::SetADCchannel(Int_t supermodule, Int_t column, Int_t row, Float_t value)
313
314   // Set ADC channel width values
315   fADCchannel[supermodule][column][row] = value;
316 }
317
318 //________________________________________________________________
319 void 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
325 //________________________________________________________________
326 void AliEMCALCalibData::SetADCpedestal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
327 {
328   // Set ADC pedestal values
329   fADCpedestal[supermodule][column][row] = value;
330 }
331
332 //________________________________________________________________
333 void 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 //________________________________________________________________
340 void 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
347 //________________________________________________________________
348 void 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