]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROCalibData.cxx
606d03c8f29b86ebdadc2006d2aec4a2568687e2
[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]  = 0.0;
44         fTimeGain[t]    = 1.0;
45         fDeadChannel[t]= kFALSE;
46     }
47     for(int t=0; t<128; t++) {
48         fPedestal[t]    = 0.0;     
49         fSigma[t]       = 0.0;        
50         fADCmean[t]     = 0.0;      
51         fADCsigma[t]    = 0.0;
52         fGain[t]        = 1.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]  = 0.0;
83        fTimeGain[t]    = 1.0;
84        fDeadChannel[t]= kFALSE;
85     }
86    for(int t=0; t<128; t++) {
87        fPedestal[t]    = 0.0;     
88        fSigma[t]       = 0.0;        
89        fADCmean[t]     = 0.0;      
90        fADCsigma[t]    = 0.0;
91        fGain[t]        = 1.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       fGain[t]     = calibda.GetGain(t); }
119       
120   for(int t=0; t<64; t++) { 
121       fMeanHV[t]       = calibda.GetMeanHV(t);
122       fWidthHV[t]      = calibda.GetWidthHV(t);        
123       fTimeOffset[t]   = calibda.GetTimeOffset(t);
124       fTimeGain[t]     = calibda.GetTimeGain(t); 
125       fDeadChannel[t]  = calibda.IsChannelDead(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       fGain[t]     = calibda.GetGain(t); }
153       
154   for(int t=0; t<64; t++) {
155       fMeanHV[t]       = calibda.GetMeanHV(t);
156       fWidthHV[t]      = calibda.GetWidthHV(t);        
157       fTimeOffset[t]   = calibda.GetTimeOffset(t);
158       fTimeGain[t]     = calibda.GetTimeGain(t); 
159       fDeadChannel[t]  = calibda.IsChannelDead(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,8*iBoard+(iChannel-1));
224         else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
225 }
226
227 //________________________________________________________________
228 void AliVZEROCalibData::SetPedestal(const Float_t* Pedestal)
229 {
230   if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t];
231   else for(int t=0; t<128; t++) fPedestal[t] = 0.0;
232 }
233
234 //________________________________________________________________
235 void AliVZEROCalibData::SetSigma(const Float_t* Sigma)
236 {
237   if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t];
238   else for(int t=0; t<128; t++) fSigma[t] = 0.0;
239 }
240
241 //________________________________________________________________
242 void AliVZEROCalibData::SetADCmean(const Float_t* ADCmean) 
243 {
244   if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t];
245   else for(int t=0; t<128; t++) fADCmean[t] = 0.0;
246 }
247
248 //________________________________________________________________
249 void AliVZEROCalibData::SetADCsigma(const Float_t* ADCsigma) 
250 {
251   if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t];
252   else for(int t=0; t<128; t++) fADCsigma[t] = 0.0;
253 }
254
255 //________________________________________________________________
256 void AliVZEROCalibData::SetMeanHV(const Float_t* MeanHV) 
257 {
258   if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t];
259   else for(int t=0; t<64; t++) fMeanHV[t] = 0.0;
260 }
261
262 //________________________________________________________________
263 void AliVZEROCalibData::SetWidthHV(const Float_t* WidthHV) 
264 {
265   if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t];
266   else for(int t=0; t<64; t++) fWidthHV[t] = 0.0;
267 }
268
269 //________________________________________________________________
270 void AliVZEROCalibData::SetDeadMap(const Bool_t* deadMap) 
271 {
272   if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t];
273   else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE;
274 }
275
276 //________________________________________________________________
277 void AliVZEROCalibData::SetGain(const Float_t* Gain) 
278 {
279   if(Gain) for(int t=0; t<128; t++) fGain[t] = Gain[t];
280   else for(int t=0; t<128; t++) fGain[t] = 0.0;
281 }
282
283 //________________________________________________________________
284 void AliVZEROCalibData::SetTimeOffset(Float_t val, Int_t channel)
285 {
286   if((channel>=0) && (channel<64)){
287     fTimeOffset[channel]=val;
288     AliInfo(Form("Time offset for channel &d set to %f",channel,fTimeOffset[channel]));
289   }
290   else
291     AliError(Form("Channel %d is not valid",channel));
292 }
293
294 //________________________________________________________________
295 void AliVZEROCalibData::SetTimeOffset(const Float_t* TimeOffset) 
296 {
297   if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t];
298   else for(int t=0; t<64; t++) fTimeOffset[t] = 0.0;
299 }
300
301 //________________________________________________________________
302 void AliVZEROCalibData::SetTimeGain(const Float_t* TimeGain) 
303 {
304   if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t];
305   else for(int t=0; t<64; t++) fTimeGain[t] = 0.0;
306 }
307
308 //_____________________________________________________________________________
309 Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) const {
310         
311         // Computes the MIP conversion factor - MIP per ADC channel - 
312         // Argument passed is the PM number (aliroot numbering)
313         
314         Float_t p0[64] = {
315                 7.094891, 7.124938, 7.089708, 7.098169, 7.094482, 7.147250, 7.170978, 7.183392, 
316                 7.145760, 7.148096, 7.153840, 7.143544, 7.186069, 7.194580, 7.203516, 7.195176, 
317                 7.188333, 7.198607, 7.209412, 7.226565, 7.221695, 7.205132, 7.191238, 7.227724, 
318                 7.232810, 7.252655, 7.230309, 7.273518, 7.273518, 7.242969, 7.252859, 7.252655, 
319                 7.026802, 7.079913, 7.134147, 7.092387, 7.079561, 7.072848, 7.123192, 7.003141, 
320                 7.024667, 7.124784, 7.123442, 7.129744, 7.110671, 7.143031, 7.139439, 7.178109, 
321                 7.247803, 7.139396, 7.293809, 7.094454, 6.992198, 7.206448, 7.244765, 7.056197, 
322                 7.263595, 7.138569, 7.089582, 7.215683, 7.266183, 7.165123, 7.243276, 7.235135 };
323         Float_t p1[64] = {
324                 0.135569, 0.146405, 0.142425, 0.144278, 0.142307, 0.141648, 0.128477, 0.138239, 
325                 0.144173, 0.143419, 0.143572, 0.144482, 0.138024, 0.136542, 0.135955, 0.138537, 
326                 0.148521, 0.141999, 0.139627, 0.130014, 0.134970, 0.135635, 0.139094, 0.140634, 
327                 0.137971, 0.142080, 0.142793, 0.142778, 0.142778, 0.146045, 0.139133, 0.142080, 
328                 0.144121, 0.142311, 0.136564, 0.142686, 0.138792, 0.166285, 0.136387, 0.155391, 
329                 0.176082, 0.140408, 0.164738, 0.144270, 0.142766, 0.147486, 0.141951, 0.138012, 
330                 0.132394, 0.142849, 0.140477, 0.144592, 0.141558, 0.157646, 0.143758, 0.173385, 
331                 0.146489, 0.143279, 0.145230, 0.147203, 0.147333, 0.144979, 0.148597, 0.138985 };
332         
333         // High Voltage retrieval from Calibration Data Base:  
334         Float_t  hv = fMeanHV[channel];  
335         Float_t mip = -1;
336         if (hv>0)
337           mip = 0.6/TMath::Exp((TMath::Log(hv) - p0[channel] )/p1[channel]);
338         return mip; 
339         
340 }
341 //________________________________________________________________
342 void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){
343         // Set Time Resolution of the TDC
344         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
345         else AliError("Time Resolution not defined.");
346         
347 }
348 //________________________________________________________________
349 void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board)
350 {
351         // Set Time Resolution of the TDC
352         if((board>=0) && (board<kNCIUBoards)) {
353                 switch(resol){
354                         case 0:
355                                 fTimeResolution[board] = 25./256.;
356                                 break;
357                         case 1:
358                                 fTimeResolution[board] = 25./128.;
359                                 break;
360                         case 2:
361                                 fTimeResolution[board] = 25./64.;
362                                 break;
363                         case 3:
364                                 fTimeResolution[board] = 25./32.;
365                                 break;
366                         case 4:
367                                 fTimeResolution[board] = 25./16.;
368                                 break;
369                         case 5:
370                                 fTimeResolution[board] = 25./8.;
371                                 break;
372                         case 6:
373                                 fTimeResolution[board] = 6.25;
374                                 break;
375                         case 7:
376                                 fTimeResolution[board] = 12.5;
377                                 break;
378                 }
379                 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
380         } else AliError(Form("Board %d is not valid",board));
381 }
382 //________________________________________________________________
383 void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){
384         // Set Time Width Resolution of the TDC
385         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
386         else AliError("Width Resolution not defined.");
387         
388 }
389 //________________________________________________________________
390 void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board)
391 {
392         // Set Time Width Resolution of the TDC
393         if((board>=0) && (board<kNCIUBoards)){
394                 switch(resol){
395                         case 0:
396                                 fWidthResolution[board] = 25./256.;
397                                 break;
398                         case 1:
399                                 fWidthResolution[board] = 25./128.;
400                                 break;
401                         case 2:
402                                 fWidthResolution[board] = 25./64.;
403                                 break;
404                         case 3:
405                                 fWidthResolution[board] = 25./32.;
406                                 break;
407                         case 4:
408                                 fWidthResolution[board] = 25./16.;
409                                 break;
410                         case 5:
411                                 fWidthResolution[board] = 25./8.;
412                                 break;
413                         case 6:
414                                 fWidthResolution[board] = 6.25;
415                                 break;
416                         case 7:
417                                 fWidthResolution[board] = 12.5;
418                                 break;
419                         case 8:
420                                 fWidthResolution[board] = 25.;
421                                 break;
422                         case 9:
423                                 fWidthResolution[board] = 50.;
424                                 break;
425                         case 10:
426                                 fWidthResolution[board] = 100.;
427                                 break;
428                         case 11:
429                                 fWidthResolution[board] = 200.;
430                                 break;
431                         case 12:
432                                 fWidthResolution[board] = 400.;
433                                 break;
434                         case 13:
435                                 fWidthResolution[board] = 800.;
436                                 break;
437                                 
438                 }
439                 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
440         }else AliError(Form("Board %d is not valid",board));
441 }
442
443 //________________________________________________________________
444 void AliVZEROCalibData::SetMatchWindow(UInt_t *windows)
445 {
446   // Set Match window of the HPTDC
447   // The units are 25ns
448   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
449   else AliError("Match windows not defined.");
450 }
451
452 //________________________________________________________________
453 void AliVZEROCalibData::SetMatchWindow(UInt_t window, Int_t board)
454 {
455   // Set Match window of the HPTDC
456   // The units are 25ns
457   if((board>=0) && (board<kNCIUBoards)){
458     fMatchWindow[board] = window;
459     AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
460   }
461   else
462     AliError(Form("Board %d is not valid",board));
463 }
464
465 //________________________________________________________________
466 void AliVZEROCalibData::SetSearchWindow(UInt_t *windows)
467 {
468   // Set Search window of the HPTDC
469   // The units are 25ns
470   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
471   else AliError("Search windows not defined.");
472 }
473
474 //________________________________________________________________
475 void  AliVZEROCalibData::SetSearchWindow(UInt_t window, Int_t board)
476 {
477   // Set Search window of the HPTDC
478   // The units are 25ns
479   if((board>=0) && (board<kNCIUBoards)){
480     fSearchWindow[board] = window;
481     AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
482   }
483   else
484     AliError(Form("Board %d is not valid",board));
485 }
486
487 //________________________________________________________________
488 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t *offsets)
489 {
490   // Set trigger-count offset of the HPTDC
491   // The units are 25ns
492   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
493   else AliError("Trigger count offsets not defined.");
494 }
495
496 //________________________________________________________________
497 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
498 {
499   // Set trigger-count offsets of the HPTDC
500   // The units are 25ns
501   if((board>=0) && (board<kNCIUBoards)){
502     fTriggerCountOffset[board] = offset;
503     AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
504   }
505   else
506     AliError(Form("Board %d is not valid",board));
507 }
508
509 //________________________________________________________________
510 void AliVZEROCalibData::SetRollOver(UInt_t *offsets)
511 {
512   // Set Roll-over of the HPTDC
513   // The units are 25ns
514   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
515   else AliError("Roll-over offsets not defined.");
516 }
517
518 //________________________________________________________________
519 void AliVZEROCalibData::SetRollOver(UInt_t offset, Int_t board)
520 {
521   // Set Roll-over of the HPTDC
522   // The units are 25ns
523   if((board>=0) && (board<kNCIUBoards)){
524     fRollOver[board] = offset;
525     AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
526   }
527   else
528     AliError(Form("Board %d is not valid",board));
529 }