]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROCalibData.cxx
Correction to the previous commit
[u/mrichter/AliRoot.git] / VZERO / AliVZEROCalibData.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: AliVZEROCalibData.cxx,                                            */
17
18 /////////////////////////////////////////////////////////////////////////////
19 //                                                                         //
20 // class for VZERO calibration                                             //
21 //                                                                         //
22 /////////////////////////////////////////////////////////////////////////////
23
24 #include <TMath.h>
25 #include <TObjString.h>
26 #include <TMap.h>
27
28 #include "AliDCSValue.h"
29 #include "AliVZEROCalibData.h"
30 #include "AliVZERODataDCS.h"
31 #include "AliLog.h"
32
33 ClassImp(AliVZEROCalibData)
34
35 //________________________________________________________________
36 AliVZEROCalibData::AliVZEROCalibData()
37 {
38   // default constructor
39   
40     for(int t=0; t<64; t++) {
41         fMeanHV[t]      = 100.0;
42         fWidthHV[t]     = 0.0; 
43         fTimeOffset[t]  = 5.0;
44         fTimeGain[t]    = 1.0;
45         fDeadChannel[t]= kFALSE;
46         fDiscriThr[t]  = 2.5;
47     }
48     for(int t=0; t<128; t++) {
49         fPedestal[t]    = 0.0;     
50         fSigma[t]       = 0.0;        
51         fADCmean[t]     = 0.0;      
52         fADCsigma[t]    = 0.0;
53     }
54     for(int i=0; i<kNCIUBoards ;i++) {
55         fTimeResolution[i]  = 25./256.;     // Default time resolution
56         fWidthResolution[i] = 25./64.;     // Default time width resolution
57         fMatchWindow[i] = 4;
58         fSearchWindow[i] = 16;
59         fTriggerCountOffset[i] = 3247;
60         fRollOver[i] = 3563;
61     }
62
63 }
64
65 //________________________________________________________________
66 void AliVZEROCalibData::Reset()
67 {
68   // reset 
69 }
70
71 //________________________________________________________________
72 AliVZEROCalibData::AliVZEROCalibData(const char* name)
73 {
74   // Constructor
75    TString namst = "Calib_";
76    namst += name;
77    SetName(namst.Data());
78    SetTitle(namst.Data());
79    for(int t=0; t<64; t++) {
80        fMeanHV[t]      = 100.0;
81        fWidthHV[t]     = 0.0; 
82        fTimeOffset[t]  = 5.0;
83        fTimeGain[t]    = 1.0;
84        fDeadChannel[t]= kFALSE;
85        fDiscriThr[t]  = 2.5;
86     }
87    for(int t=0; t<128; t++) {
88        fPedestal[t]    = 0.0;     
89        fSigma[t]       = 0.0;        
90        fADCmean[t]     = 0.0;      
91        fADCsigma[t]    = 0.0;
92    }
93    for(int i=0; i<kNCIUBoards ;i++) {
94        fTimeResolution[i]  = 25./256.;    // Default time resolution in ns / channel
95        fWidthResolution[i] = 25./64.;     // Default time width resolution in ns / channel
96        fMatchWindow[i] = 4;
97        fSearchWindow[i] = 16;
98        fTriggerCountOffset[i] = 3247;
99        fRollOver[i] = 3563;
100    }
101
102 }
103
104 //________________________________________________________________
105 AliVZEROCalibData::AliVZEROCalibData(const AliVZEROCalibData& calibda) :
106   TNamed(calibda)
107 {
108 // copy constructor
109
110   SetName(calibda.GetName());
111   SetTitle(calibda.GetName());
112   
113   for(int t=0; t<128; t++) { 
114       fPedestal[t] = calibda.GetPedestal(t);
115       fSigma[t]    = calibda.GetSigma(t);
116       fADCmean[t]  = calibda.GetADCmean(t);
117       fADCsigma[t] = calibda.GetADCsigma(t); }
118       
119   for(int t=0; t<64; t++) { 
120       fMeanHV[t]       = calibda.GetMeanHV(t);
121       fWidthHV[t]      = calibda.GetWidthHV(t);        
122       fTimeOffset[t]   = calibda.GetTimeOffset(t);
123       fTimeGain[t]     = calibda.GetTimeGain(t); 
124       fDeadChannel[t]  = calibda.IsChannelDead(t);
125       fDiscriThr[t]    = calibda.GetDiscriThr(t);
126   }  
127   
128   for(int i=0; i<kNCIUBoards ;i++) {
129       fTimeResolution[i]  = calibda.GetTimeResolution(i);
130       fWidthResolution[i] = calibda.GetWidthResolution(i);        
131       fMatchWindow[i] = calibda.GetMatchWindow(i);
132       fSearchWindow[i] = calibda.GetSearchWindow(i);
133       fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
134       fRollOver[i] = calibda.GetRollOver(i);
135   }
136   
137 }
138
139 //________________________________________________________________
140 AliVZEROCalibData &AliVZEROCalibData::operator =(const AliVZEROCalibData& calibda)
141 {
142 // assignment operator
143
144   SetName(calibda.GetName());
145   SetTitle(calibda.GetName());
146   
147   for(int t=0; t<128; t++) {
148       fPedestal[t] = calibda.GetPedestal(t);
149       fSigma[t]    = calibda.GetSigma(t);
150       fADCmean[t]  = calibda.GetADCmean(t);
151       fADCsigma[t] = calibda.GetADCsigma(t); }
152       
153   for(int t=0; t<64; t++) {
154       fMeanHV[t]       = calibda.GetMeanHV(t);
155       fWidthHV[t]      = calibda.GetWidthHV(t);        
156       fTimeOffset[t]   = calibda.GetTimeOffset(t);
157       fTimeGain[t]     = calibda.GetTimeGain(t); 
158       fDeadChannel[t]  = calibda.IsChannelDead(t);
159       fDiscriThr[t]    = calibda.GetDiscriThr(t);
160   }   
161   for(int i=0; i<kNCIUBoards ;i++) {
162       fTimeResolution[i]  = calibda.GetTimeResolution(i);
163       fWidthResolution[i] = calibda.GetWidthResolution(i);        
164       fMatchWindow[i] = calibda.GetMatchWindow(i);
165       fSearchWindow[i] = calibda.GetSearchWindow(i);
166       fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
167       fRollOver[i] = calibda.GetRollOver(i);
168   }
169    
170   return *this;
171   
172 }
173
174 //________________________________________________________________
175 AliVZEROCalibData::~AliVZEROCalibData()
176 {
177   // destructor
178 }
179 //_____________________________________________________________________________
180 void AliVZEROCalibData::FillDCSData(AliVZERODataDCS * data){
181         // Set all parameters from the data get by the shuttle
182         TMap * params = data->GetFEEParameters();
183         TIter iter(params);     
184         TObjString* aliasName;
185         
186         while ((  aliasName = (TObjString*) iter.Next() ))  {
187                 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
188                 Int_t val;
189                 if(aValue) {
190                         val = aValue->GetUInt();
191                         AliInfo(Form("%s : %d",aliasName->String().Data(), val));
192                         SetParameter(aliasName->String(),val);
193                 }
194         }       
195         
196         SetMeanHV(data->GetMeanHV());
197         SetWidthHV(data->GetWidthHV());
198         SetDeadMap(data->GetDeadMap());
199
200 }
201 //_____________________________________________________________________________
202 void AliVZEROCalibData::SetParameter(TString name, Int_t val){
203         // Set given parameter
204         
205         Int_t iBoard = -1;
206         Int_t iChannel = -1;
207
208         TSeqCollection* nameSplit = name.Tokenize("/");
209         TObjString * boardName = (TObjString *)nameSplit->At(2);
210         sscanf(boardName->String().Data(),"CIU%d",&iBoard);
211
212         TString paramName = ((TObjString *)nameSplit->At(3))->String();
213         Char_t channel[2] ; channel[1] = '\0';
214         channel[0] = paramName[paramName.Sizeof()-2];
215         sscanf(channel,"%d",&iChannel);
216                 
217         if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
218         else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
219         else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard);
220         else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard);
221         else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard);
222         else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard);
223         else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1));
224         else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,iBoard,(iChannel-1));
225         else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
226 }
227
228 //________________________________________________________________
229 void AliVZEROCalibData::SetPedestal(const Float_t* Pedestal)
230 {
231   if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t];
232   else for(int t=0; t<128; t++) fPedestal[t] = 0.0;
233 }
234
235 //________________________________________________________________
236 void AliVZEROCalibData::SetSigma(const Float_t* Sigma)
237 {
238   if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t];
239   else for(int t=0; t<128; t++) fSigma[t] = 0.0;
240 }
241
242 //________________________________________________________________
243 void AliVZEROCalibData::SetADCmean(const Float_t* ADCmean) 
244 {
245   if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t];
246   else for(int t=0; t<128; t++) fADCmean[t] = 0.0;
247 }
248
249 //________________________________________________________________
250 void AliVZEROCalibData::SetADCsigma(const Float_t* ADCsigma) 
251 {
252   if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t];
253   else for(int t=0; t<128; t++) fADCsigma[t] = 0.0;
254 }
255
256 //________________________________________________________________
257 void AliVZEROCalibData::SetMeanHV(const Float_t* MeanHV) 
258 {
259   if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t];
260   else for(int t=0; t<64; t++) fMeanHV[t] = 0.0;
261 }
262
263 //________________________________________________________________
264 void AliVZEROCalibData::SetWidthHV(const Float_t* WidthHV) 
265 {
266   if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t];
267   else for(int t=0; t<64; t++) fWidthHV[t] = 0.0;
268 }
269
270 //________________________________________________________________
271 void AliVZEROCalibData::SetDeadMap(const Bool_t* deadMap) 
272 {
273   if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t];
274   else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE;
275 }
276
277 //________________________________________________________________
278 void AliVZEROCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel)
279 {
280   Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel);
281   if(ch >= 0){
282     fTimeOffset[ch]=val;
283     AliInfo(Form("Time offset for channel %d set to %f",ch,fTimeOffset[ch]));
284   }
285   else
286     AliError("Board/Channel numbers are not valid");
287 }
288
289 //________________________________________________________________
290 void AliVZEROCalibData::SetTimeOffset(const Float_t* TimeOffset) 
291 {
292   if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t];
293   else for(int t=0; t<64; t++) fTimeOffset[t] = 5.0;
294 }
295
296 //________________________________________________________________
297 void AliVZEROCalibData::SetTimeGain(const Float_t* TimeGain) 
298 {
299   if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t];
300   else for(int t=0; t<64; t++) fTimeGain[t] = 0.0;
301 }
302
303 //_____________________________________________________________________________
304 Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) const {
305         
306         // Computes the MIP conversion factor - MIP per ADC channel - 
307         // Argument passed is the PM number (aliroot numbering)
308         
309         Float_t p0[64] = {
310                 7.094891, 7.124938, 7.089708, 7.098169, 7.094482, 7.147250, 7.170978, 7.183392, 
311                 7.145760, 7.148096, 7.153840, 7.143544, 7.186069, 7.194580, 7.203516, 7.195176, 
312                 7.188333, 7.198607, 7.209412, 7.226565, 7.221695, 7.205132, 7.191238, 7.227724, 
313                 7.232810, 7.252655, 7.230309, 7.140891, 7.273518, 7.242969, 7.252859, 7.252655, 
314                 7.026802, 7.079913, 7.134147, 7.092387, 7.079561, 7.072848, 7.123192, 7.003141, 
315                 7.024667, 7.124784, 7.123442, 7.129744, 7.110671, 7.143031, 7.139439, 7.178109, 
316                 7.247803, 7.139396, 7.293809, 7.094454, 6.992198, 7.206448, 7.244765, 7.056197, 
317                 7.263595, 7.138569, 7.089582, 7.215683, 7.266183, 7.165123, 7.243276, 7.235135 };
318         Float_t p1[64] = {
319                 0.135569, 0.146405, 0.142425, 0.144278, 0.142307, 0.141648, 0.128477, 0.138239, 
320                 0.144173, 0.143419, 0.143572, 0.144482, 0.138024, 0.136542, 0.135955, 0.138537, 
321                 0.148521, 0.141999, 0.139627, 0.130014, 0.134970, 0.135635, 0.139094, 0.140634, 
322                 0.137971, 0.142080, 0.142793, 0.136054, 0.142778, 0.146045, 0.139133, 0.142080, 
323                 0.144121, 0.142311, 0.136564, 0.142686, 0.138792, 0.166285, 0.136387, 0.155391, 
324                 0.176082, 0.140408, 0.164738, 0.144270, 0.142766, 0.147486, 0.141951, 0.138012, 
325                 0.132394, 0.142849, 0.140477, 0.144592, 0.141558, 0.157646, 0.143758, 0.173385, 
326                 0.146489, 0.143279, 0.145230, 0.147203, 0.147333, 0.144979, 0.148597, 0.138985 };
327         
328         // High Voltage retrieval from Calibration Data Base:  
329         Float_t  hv = fMeanHV[channel];  
330         Float_t mip = -1;
331         if (hv>0)
332           mip = 0.6/TMath::Exp((TMath::Log(hv) - p0[channel] )/p1[channel]);
333         return mip; 
334         
335 }
336
337 //________________________________________________________________
338 Float_t AliVZEROCalibData::GetGain(Int_t channel) const
339 {
340   // Computes the PM gain factors
341   // Argument passed is the PM number (aliroot numbering)
342   Float_t a[64] = {-39.68,-35.83,-36.92,-36.42,-37.02,-37.50,-43.05,-39.39,
343                    -36.62,-36.93,-37.30,-36.46,-39.51,-40.32,-39.92,-39.20,
344                    -35.39,-37.95,-38.85,-42.76,-40.68,-40.32,-39.00,-37.36,
345                    -39.64,-38.86,-37.59,-39.59,-37.97,-36.32,-38.88,-41.35,
346                    -36.01,-36.82,-39.48,-36.86,-38.22,-32.55,-39.44,-35.08,
347                    -29.91,-37.88,-33.25,-36.49,-37.25,-35.89,-40.31,-39.15,
348                    -41.71,-37.07,-38.94,-36.04,-36.62,-32.96,-36.99,-30.71,
349                    -36.66,-37.23,-35.98,-36.56,-35.64,-36.97,-35.88,-38.78};
350   Float_t b[64] = {  7.40,  6.83,  7.02,  6.94,  7.03,  7.04,  7.79,  7.27,
351                      6.92,  6.96,  7.01,  6.90,  7.28,  7.38,  7.33,  7.23,
352                      6.71,  7.05,  7.17,  7.69,  7.41,  7.38,  7.21,  7.11,
353                      7.26,  7.12,  6.98,  7.35,  6.99,  6.79,  7.13,  7.58,
354                      6.95,  7.01,  7.33,  7.01,  7.21,  6.01,  7.34,  6.44,
355                      5.68,  7.12,  6.07,  6.92,  7.04,  6.82,  7.04,  7.24,
356                      7.53,  6.99,  7.10,  6.89,  7.07,  6.35,  6.88,  5.77,
357                      6.81,  7.01,  6.89,  6.84,  6.68,  6.95,  6.73,  7.14};
358
359   // High Voltage retrieval from Calibration Data Base:  
360   Float_t hv = fMeanHV[channel];
361   Float_t gain = 0;
362   if (hv>0)
363     gain = TMath::Exp(a[channel]+b[channel]*TMath::Log(hv));
364   return gain;
365 }
366
367 //________________________________________________________________
368 void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){
369         // Set Time Resolution of the TDC
370         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
371         else AliError("Time Resolution not defined.");
372         
373 }
374 //________________________________________________________________
375 void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board)
376 {
377         // Set Time Resolution of the TDC
378         if((board>=0) && (board<kNCIUBoards)) {
379                 switch(resol){
380                         case 0:
381                                 fTimeResolution[board] = 25./256.;
382                                 break;
383                         case 1:
384                                 fTimeResolution[board] = 25./128.;
385                                 break;
386                         case 2:
387                                 fTimeResolution[board] = 25./64.;
388                                 break;
389                         case 3:
390                                 fTimeResolution[board] = 25./32.;
391                                 break;
392                         case 4:
393                                 fTimeResolution[board] = 25./16.;
394                                 break;
395                         case 5:
396                                 fTimeResolution[board] = 25./8.;
397                                 break;
398                         case 6:
399                                 fTimeResolution[board] = 6.25;
400                                 break;
401                         case 7:
402                                 fTimeResolution[board] = 12.5;
403                                 break;
404                 }
405                 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
406         } else AliError(Form("Board %d is not valid",board));
407 }
408 //________________________________________________________________
409 void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){
410         // Set Time Width Resolution of the TDC
411         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
412         else AliError("Width Resolution not defined.");
413         
414 }
415 //________________________________________________________________
416 void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board)
417 {
418         // Set Time Width Resolution of the TDC
419         if((board>=0) && (board<kNCIUBoards)){
420                 switch(resol){
421                         case 0:
422                                 fWidthResolution[board] = 25./256.;
423                                 break;
424                         case 1:
425                                 fWidthResolution[board] = 25./128.;
426                                 break;
427                         case 2:
428                                 fWidthResolution[board] = 25./64.;
429                                 break;
430                         case 3:
431                                 fWidthResolution[board] = 25./32.;
432                                 break;
433                         case 4:
434                                 fWidthResolution[board] = 25./16.;
435                                 break;
436                         case 5:
437                                 fWidthResolution[board] = 25./8.;
438                                 break;
439                         case 6:
440                                 fWidthResolution[board] = 6.25;
441                                 break;
442                         case 7:
443                                 fWidthResolution[board] = 12.5;
444                                 break;
445                         case 8:
446                                 fWidthResolution[board] = 25.;
447                                 break;
448                         case 9:
449                                 fWidthResolution[board] = 50.;
450                                 break;
451                         case 10:
452                                 fWidthResolution[board] = 100.;
453                                 break;
454                         case 11:
455                                 fWidthResolution[board] = 200.;
456                                 break;
457                         case 12:
458                                 fWidthResolution[board] = 400.;
459                                 break;
460                         case 13:
461                                 fWidthResolution[board] = 800.;
462                                 break;
463                                 
464                 }
465                 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
466         }else AliError(Form("Board %d is not valid",board));
467 }
468
469 //________________________________________________________________
470 void AliVZEROCalibData::SetMatchWindow(UInt_t *windows)
471 {
472   // Set Match window of the HPTDC
473   // The units are 25ns
474   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
475   else AliError("Match windows not defined.");
476 }
477
478 //________________________________________________________________
479 void AliVZEROCalibData::SetMatchWindow(UInt_t window, Int_t board)
480 {
481   // Set Match window of the HPTDC
482   // The units are 25ns
483   if((board>=0) && (board<kNCIUBoards)){
484     fMatchWindow[board] = window;
485     AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
486   }
487   else
488     AliError(Form("Board %d is not valid",board));
489 }
490
491 //________________________________________________________________
492 void AliVZEROCalibData::SetSearchWindow(UInt_t *windows)
493 {
494   // Set Search window of the HPTDC
495   // The units are 25ns
496   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
497   else AliError("Search windows not defined.");
498 }
499
500 //________________________________________________________________
501 void  AliVZEROCalibData::SetSearchWindow(UInt_t window, Int_t board)
502 {
503   // Set Search window of the HPTDC
504   // The units are 25ns
505   if((board>=0) && (board<kNCIUBoards)){
506     fSearchWindow[board] = window;
507     AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
508   }
509   else
510     AliError(Form("Board %d is not valid",board));
511 }
512
513 //________________________________________________________________
514 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t *offsets)
515 {
516   // Set trigger-count offset of the HPTDC
517   // The units are 25ns
518   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
519   else AliError("Trigger count offsets not defined.");
520 }
521
522 //________________________________________________________________
523 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
524 {
525   // Set trigger-count offsets of the HPTDC
526   // The units are 25ns
527   if((board>=0) && (board<kNCIUBoards)){
528     fTriggerCountOffset[board] = offset;
529     AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
530   }
531   else
532     AliError(Form("Board %d is not valid",board));
533 }
534
535 //________________________________________________________________
536 void AliVZEROCalibData::SetRollOver(UInt_t *offsets)
537 {
538   // Set Roll-over of the HPTDC
539   // The units are 25ns
540   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
541   else AliError("Roll-over offsets not defined.");
542 }
543
544 //________________________________________________________________
545 void AliVZEROCalibData::SetRollOver(UInt_t offset, Int_t board)
546 {
547   // Set Roll-over of the HPTDC
548   // The units are 25ns
549   if((board>=0) && (board<kNCIUBoards)){
550     fRollOver[board] = offset;
551     AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
552   }
553   else
554     AliError(Form("Board %d is not valid",board));
555 }
556
557 //________________________________________________________________
558 void AliVZEROCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel)
559 {
560   // Set the TDC discriminator
561   // threshold values expressed in units of ADC
562   Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel);
563   if(ch >= 0){
564     if (thr > 0) {
565       fDiscriThr[ch]=thr;
566       AliInfo(Form("Discriminator threshold for channel %d set to %f",ch,fDiscriThr[ch]));
567     }
568     else {
569       AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,ch));
570     }
571   }
572   else
573     AliError("Board/Channel numbers are not valid");
574 }
575
576 //________________________________________________________________
577 void AliVZEROCalibData::SetDiscriThr(const Float_t* thresholds) 
578 {
579   // Set the TDC discriminator
580   // threshold values expressed in units of ADC
581   if(thresholds) for(int t=0; t<64; t++) fDiscriThr[t] = thresholds[t];
582   else for(int t=0; t<64; t++) fDiscriThr[t] = 2.5;
583 }
584
585 Int_t AliVZEROCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel)
586 {
587   // Get the offline channel number from
588   // the FEE board and channel indexes
589
590   if (board < 0 || board >= 8) {
591     AliErrorClass(Form("Wrong FEE board number: %d",board));
592     return -1;
593   }
594   if (channel < 0 || channel >= 8) {
595     AliErrorClass(Form("Wrong FEE channel number: %d",channel));
596     return -1;
597   }
598
599   Int_t offCh = (board < 4) ? (8 * board + 32) : (8 * board -32);
600   offCh += (7 - channel);
601
602   return offCh;
603 }
604
605 Int_t AliVZEROCalibData::GetBoardNumber(Int_t channel)
606 {
607   // Get FEE board number
608   // from offline channel index
609   if (channel >= 0 && channel < 32) return (channel / 8 + 4);
610   if (channel >=32 && channel < 64) return (channel / 8 - 4);
611
612   AliErrorClass(Form("Wrong channel index: %d",channel));
613   return -1;
614 }