]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROCalibData.cxx
Coding conv viols fixed (Raphael)
[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         fGain[t]        = 1.0;
54     }
55     for(int i=0; i<kNCIUBoards ;i++) {
56         fTimeResolution[i]  = 25./256.;     // Default time resolution
57         fWidthResolution[i] = 25./64.;     // Default time width resolution
58         fMatchWindow[i] = 4;
59         fSearchWindow[i] = 16;
60         fTriggerCountOffset[i] = 3247;
61         fRollOver[i] = 3563;
62     }
63
64 }
65
66 //________________________________________________________________
67 void AliVZEROCalibData::Reset()
68 {
69   // reset 
70 }
71
72 //________________________________________________________________
73 AliVZEROCalibData::AliVZEROCalibData(const char* name)
74 {
75   // Constructor
76    TString namst = "Calib_";
77    namst += name;
78    SetName(namst.Data());
79    SetTitle(namst.Data());
80    for(int t=0; t<64; t++) {
81        fMeanHV[t]      = 100.0;
82        fWidthHV[t]     = 0.0; 
83        fTimeOffset[t]  = 5.0;
84        fTimeGain[t]    = 1.0;
85        fDeadChannel[t]= kFALSE;
86        fDiscriThr[t]  = 2.5;
87     }
88    for(int t=0; t<128; t++) {
89        fPedestal[t]    = 0.0;     
90        fSigma[t]       = 0.0;        
91        fADCmean[t]     = 0.0;      
92        fADCsigma[t]    = 0.0;
93        fGain[t]        = 1.0;
94    }
95    for(int i=0; i<kNCIUBoards ;i++) {
96        fTimeResolution[i]  = 25./256.;    // Default time resolution in ns / channel
97        fWidthResolution[i] = 25./64.;     // Default time width resolution in ns / channel
98        fMatchWindow[i] = 4;
99        fSearchWindow[i] = 16;
100        fTriggerCountOffset[i] = 3247;
101        fRollOver[i] = 3563;
102    }
103
104 }
105
106 //________________________________________________________________
107 AliVZEROCalibData::AliVZEROCalibData(const AliVZEROCalibData& calibda) :
108   TNamed(calibda)
109 {
110 // copy constructor
111
112   SetName(calibda.GetName());
113   SetTitle(calibda.GetName());
114   
115   for(int t=0; t<128; t++) { 
116       fPedestal[t] = calibda.GetPedestal(t);
117       fSigma[t]    = calibda.GetSigma(t);
118       fADCmean[t]  = calibda.GetADCmean(t);
119       fADCsigma[t] = calibda.GetADCsigma(t);
120       fGain[t]     = calibda.GetGain(t); }
121       
122   for(int t=0; t<64; t++) { 
123       fMeanHV[t]       = calibda.GetMeanHV(t);
124       fWidthHV[t]      = calibda.GetWidthHV(t);        
125       fTimeOffset[t]   = calibda.GetTimeOffset(t);
126       fTimeGain[t]     = calibda.GetTimeGain(t); 
127       fDeadChannel[t]  = calibda.IsChannelDead(t);
128       fDiscriThr[t]    = calibda.GetDiscriThr(t);
129   }  
130   
131   for(int i=0; i<kNCIUBoards ;i++) {
132       fTimeResolution[i]  = calibda.GetTimeResolution(i);
133       fWidthResolution[i] = calibda.GetWidthResolution(i);        
134       fMatchWindow[i] = calibda.GetMatchWindow(i);
135       fSearchWindow[i] = calibda.GetSearchWindow(i);
136       fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
137       fRollOver[i] = calibda.GetRollOver(i);
138   }
139   
140 }
141
142 //________________________________________________________________
143 AliVZEROCalibData &AliVZEROCalibData::operator =(const AliVZEROCalibData& calibda)
144 {
145 // assignment operator
146
147   SetName(calibda.GetName());
148   SetTitle(calibda.GetName());
149   
150   for(int t=0; t<128; t++) {
151       fPedestal[t] = calibda.GetPedestal(t);
152       fSigma[t]    = calibda.GetSigma(t);
153       fADCmean[t]  = calibda.GetADCmean(t);
154       fADCsigma[t] = calibda.GetADCsigma(t);
155       fGain[t]     = calibda.GetGain(t); }
156       
157   for(int t=0; t<64; t++) {
158       fMeanHV[t]       = calibda.GetMeanHV(t);
159       fWidthHV[t]      = calibda.GetWidthHV(t);        
160       fTimeOffset[t]   = calibda.GetTimeOffset(t);
161       fTimeGain[t]     = calibda.GetTimeGain(t); 
162       fDeadChannel[t]  = calibda.IsChannelDead(t);
163       fDiscriThr[t]    = calibda.GetDiscriThr(t);
164   }   
165   for(int i=0; i<kNCIUBoards ;i++) {
166       fTimeResolution[i]  = calibda.GetTimeResolution(i);
167       fWidthResolution[i] = calibda.GetWidthResolution(i);        
168       fMatchWindow[i] = calibda.GetMatchWindow(i);
169       fSearchWindow[i] = calibda.GetSearchWindow(i);
170       fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
171       fRollOver[i] = calibda.GetRollOver(i);
172   }
173    
174   return *this;
175   
176 }
177
178 //________________________________________________________________
179 AliVZEROCalibData::~AliVZEROCalibData()
180 {
181   // destructor
182 }
183 //_____________________________________________________________________________
184 void AliVZEROCalibData::FillDCSData(AliVZERODataDCS * data){
185         // Set all parameters from the data get by the shuttle
186         TMap * params = data->GetFEEParameters();
187         TIter iter(params);     
188         TObjString* aliasName;
189         
190         while ((  aliasName = (TObjString*) iter.Next() ))  {
191                 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
192                 Int_t val;
193                 if(aValue) {
194                         val = aValue->GetUInt();
195                         AliInfo(Form("%s : %d",aliasName->String().Data(), val));
196                         SetParameter(aliasName->String(),val);
197                 }
198         }       
199         
200         SetMeanHV(data->GetMeanHV());
201         SetWidthHV(data->GetWidthHV());
202         SetDeadMap(data->GetDeadMap());
203
204 }
205 //_____________________________________________________________________________
206 void AliVZEROCalibData::SetParameter(TString name, Int_t val){
207         // Set given parameter
208         
209         Int_t iBoard = -1;
210         Int_t iChannel = -1;
211
212         TSeqCollection* nameSplit = name.Tokenize("/");
213         TObjString * boardName = (TObjString *)nameSplit->At(2);
214         sscanf(boardName->String().Data(),"CIU%d",&iBoard);
215
216         TString paramName = ((TObjString *)nameSplit->At(3))->String();
217         Char_t channel[2] ; channel[1] = '\0';
218         channel[0] = paramName[paramName.Sizeof()-2];
219         sscanf(channel,"%d",&iChannel);
220                 
221         if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
222         else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
223         else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard);
224         else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard);
225         else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard);
226         else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard);
227         else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,8*iBoard+(iChannel-1));
228         else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,8*iBoard+(iChannel-1));
229         else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
230 }
231
232 //________________________________________________________________
233 void AliVZEROCalibData::SetPedestal(const Float_t* Pedestal)
234 {
235   if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t];
236   else for(int t=0; t<128; t++) fPedestal[t] = 0.0;
237 }
238
239 //________________________________________________________________
240 void AliVZEROCalibData::SetSigma(const Float_t* Sigma)
241 {
242   if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t];
243   else for(int t=0; t<128; t++) fSigma[t] = 0.0;
244 }
245
246 //________________________________________________________________
247 void AliVZEROCalibData::SetADCmean(const Float_t* ADCmean) 
248 {
249   if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t];
250   else for(int t=0; t<128; t++) fADCmean[t] = 0.0;
251 }
252
253 //________________________________________________________________
254 void AliVZEROCalibData::SetADCsigma(const Float_t* ADCsigma) 
255 {
256   if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t];
257   else for(int t=0; t<128; t++) fADCsigma[t] = 0.0;
258 }
259
260 //________________________________________________________________
261 void AliVZEROCalibData::SetMeanHV(const Float_t* MeanHV) 
262 {
263   if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t];
264   else for(int t=0; t<64; t++) fMeanHV[t] = 0.0;
265 }
266
267 //________________________________________________________________
268 void AliVZEROCalibData::SetWidthHV(const Float_t* WidthHV) 
269 {
270   if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t];
271   else for(int t=0; t<64; t++) fWidthHV[t] = 0.0;
272 }
273
274 //________________________________________________________________
275 void AliVZEROCalibData::SetDeadMap(const Bool_t* deadMap) 
276 {
277   if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t];
278   else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE;
279 }
280
281 //________________________________________________________________
282 void AliVZEROCalibData::SetGain(const Float_t* Gain) 
283 {
284   if(Gain) for(int t=0; t<128; t++) fGain[t] = Gain[t];
285   else for(int t=0; t<128; t++) fGain[t] = 0.0;
286 }
287
288 //________________________________________________________________
289 void AliVZEROCalibData::SetTimeOffset(Float_t val, Int_t channel)
290 {
291   if((channel>=0) && (channel<64)){
292     fTimeOffset[channel]=val;
293     AliInfo(Form("Time offset for channel %d set to %f",channel,fTimeOffset[channel]));
294   }
295   else
296     AliError(Form("Channel %d is not valid",channel));
297 }
298
299 //________________________________________________________________
300 void AliVZEROCalibData::SetTimeOffset(const Float_t* TimeOffset) 
301 {
302   if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t];
303   else for(int t=0; t<64; t++) fTimeOffset[t] = 5.0;
304 }
305
306 //________________________________________________________________
307 void AliVZEROCalibData::SetTimeGain(const Float_t* TimeGain) 
308 {
309   if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t];
310   else for(int t=0; t<64; t++) fTimeGain[t] = 0.0;
311 }
312
313 //_____________________________________________________________________________
314 Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) const {
315         
316         // Computes the MIP conversion factor - MIP per ADC channel - 
317         // Argument passed is the PM number (aliroot numbering)
318         
319         Float_t p0[64] = {
320                 7.094891, 7.124938, 7.089708, 7.098169, 7.094482, 7.147250, 7.170978, 7.183392, 
321                 7.145760, 7.148096, 7.153840, 7.143544, 7.186069, 7.194580, 7.203516, 7.195176, 
322                 7.188333, 7.198607, 7.209412, 7.226565, 7.221695, 7.205132, 7.191238, 7.227724, 
323                 7.232810, 7.252655, 7.230309, 7.273518, 7.273518, 7.242969, 7.252859, 7.252655, 
324                 7.026802, 7.079913, 7.134147, 7.092387, 7.079561, 7.072848, 7.123192, 7.003141, 
325                 7.024667, 7.124784, 7.123442, 7.129744, 7.110671, 7.143031, 7.139439, 7.178109, 
326                 7.247803, 7.139396, 7.293809, 7.094454, 6.992198, 7.206448, 7.244765, 7.056197, 
327                 7.263595, 7.138569, 7.089582, 7.215683, 7.266183, 7.165123, 7.243276, 7.235135 };
328         Float_t p1[64] = {
329                 0.135569, 0.146405, 0.142425, 0.144278, 0.142307, 0.141648, 0.128477, 0.138239, 
330                 0.144173, 0.143419, 0.143572, 0.144482, 0.138024, 0.136542, 0.135955, 0.138537, 
331                 0.148521, 0.141999, 0.139627, 0.130014, 0.134970, 0.135635, 0.139094, 0.140634, 
332                 0.137971, 0.142080, 0.142793, 0.142778, 0.142778, 0.146045, 0.139133, 0.142080, 
333                 0.144121, 0.142311, 0.136564, 0.142686, 0.138792, 0.166285, 0.136387, 0.155391, 
334                 0.176082, 0.140408, 0.164738, 0.144270, 0.142766, 0.147486, 0.141951, 0.138012, 
335                 0.132394, 0.142849, 0.140477, 0.144592, 0.141558, 0.157646, 0.143758, 0.173385, 
336                 0.146489, 0.143279, 0.145230, 0.147203, 0.147333, 0.144979, 0.148597, 0.138985 };
337         
338         // High Voltage retrieval from Calibration Data Base:  
339         Float_t  hv = fMeanHV[channel];  
340         Float_t mip = -1;
341         if (hv>0)
342           mip = 0.6/TMath::Exp((TMath::Log(hv) - p0[channel] )/p1[channel]);
343         return mip; 
344         
345 }
346 //________________________________________________________________
347 void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){
348         // Set Time Resolution of the TDC
349         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
350         else AliError("Time Resolution not defined.");
351         
352 }
353 //________________________________________________________________
354 void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board)
355 {
356         // Set Time Resolution of the TDC
357         if((board>=0) && (board<kNCIUBoards)) {
358                 switch(resol){
359                         case 0:
360                                 fTimeResolution[board] = 25./256.;
361                                 break;
362                         case 1:
363                                 fTimeResolution[board] = 25./128.;
364                                 break;
365                         case 2:
366                                 fTimeResolution[board] = 25./64.;
367                                 break;
368                         case 3:
369                                 fTimeResolution[board] = 25./32.;
370                                 break;
371                         case 4:
372                                 fTimeResolution[board] = 25./16.;
373                                 break;
374                         case 5:
375                                 fTimeResolution[board] = 25./8.;
376                                 break;
377                         case 6:
378                                 fTimeResolution[board] = 6.25;
379                                 break;
380                         case 7:
381                                 fTimeResolution[board] = 12.5;
382                                 break;
383                 }
384                 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
385         } else AliError(Form("Board %d is not valid",board));
386 }
387 //________________________________________________________________
388 void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){
389         // Set Time Width Resolution of the TDC
390         if(resols)  for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
391         else AliError("Width Resolution not defined.");
392         
393 }
394 //________________________________________________________________
395 void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board)
396 {
397         // Set Time Width Resolution of the TDC
398         if((board>=0) && (board<kNCIUBoards)){
399                 switch(resol){
400                         case 0:
401                                 fWidthResolution[board] = 25./256.;
402                                 break;
403                         case 1:
404                                 fWidthResolution[board] = 25./128.;
405                                 break;
406                         case 2:
407                                 fWidthResolution[board] = 25./64.;
408                                 break;
409                         case 3:
410                                 fWidthResolution[board] = 25./32.;
411                                 break;
412                         case 4:
413                                 fWidthResolution[board] = 25./16.;
414                                 break;
415                         case 5:
416                                 fWidthResolution[board] = 25./8.;
417                                 break;
418                         case 6:
419                                 fWidthResolution[board] = 6.25;
420                                 break;
421                         case 7:
422                                 fWidthResolution[board] = 12.5;
423                                 break;
424                         case 8:
425                                 fWidthResolution[board] = 25.;
426                                 break;
427                         case 9:
428                                 fWidthResolution[board] = 50.;
429                                 break;
430                         case 10:
431                                 fWidthResolution[board] = 100.;
432                                 break;
433                         case 11:
434                                 fWidthResolution[board] = 200.;
435                                 break;
436                         case 12:
437                                 fWidthResolution[board] = 400.;
438                                 break;
439                         case 13:
440                                 fWidthResolution[board] = 800.;
441                                 break;
442                                 
443                 }
444                 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
445         }else AliError(Form("Board %d is not valid",board));
446 }
447
448 //________________________________________________________________
449 void AliVZEROCalibData::SetMatchWindow(UInt_t *windows)
450 {
451   // Set Match window of the HPTDC
452   // The units are 25ns
453   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
454   else AliError("Match windows not defined.");
455 }
456
457 //________________________________________________________________
458 void AliVZEROCalibData::SetMatchWindow(UInt_t window, Int_t board)
459 {
460   // Set Match window of the HPTDC
461   // The units are 25ns
462   if((board>=0) && (board<kNCIUBoards)){
463     fMatchWindow[board] = window;
464     AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
465   }
466   else
467     AliError(Form("Board %d is not valid",board));
468 }
469
470 //________________________________________________________________
471 void AliVZEROCalibData::SetSearchWindow(UInt_t *windows)
472 {
473   // Set Search window of the HPTDC
474   // The units are 25ns
475   if(windows)  for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
476   else AliError("Search windows not defined.");
477 }
478
479 //________________________________________________________________
480 void  AliVZEROCalibData::SetSearchWindow(UInt_t window, Int_t board)
481 {
482   // Set Search window of the HPTDC
483   // The units are 25ns
484   if((board>=0) && (board<kNCIUBoards)){
485     fSearchWindow[board] = window;
486     AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
487   }
488   else
489     AliError(Form("Board %d is not valid",board));
490 }
491
492 //________________________________________________________________
493 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t *offsets)
494 {
495   // Set trigger-count offset of the HPTDC
496   // The units are 25ns
497   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
498   else AliError("Trigger count offsets not defined.");
499 }
500
501 //________________________________________________________________
502 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
503 {
504   // Set trigger-count offsets of the HPTDC
505   // The units are 25ns
506   if((board>=0) && (board<kNCIUBoards)){
507     fTriggerCountOffset[board] = offset;
508     AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
509   }
510   else
511     AliError(Form("Board %d is not valid",board));
512 }
513
514 //________________________________________________________________
515 void AliVZEROCalibData::SetRollOver(UInt_t *offsets)
516 {
517   // Set Roll-over of the HPTDC
518   // The units are 25ns
519   if(offsets)  for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
520   else AliError("Roll-over offsets not defined.");
521 }
522
523 //________________________________________________________________
524 void AliVZEROCalibData::SetRollOver(UInt_t offset, Int_t board)
525 {
526   // Set Roll-over of the HPTDC
527   // The units are 25ns
528   if((board>=0) && (board<kNCIUBoards)){
529     fRollOver[board] = offset;
530     AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
531   }
532   else
533     AliError(Form("Board %d is not valid",board));
534 }
535
536 //________________________________________________________________
537 void AliVZEROCalibData::SetDiscriThr(Float_t thr, Int_t channel)
538 {
539   // Set the TDC discriminator
540   // threshold values expressed in units of ADC
541   if((channel>=0) && (channel<64)){
542     if (thr > 0) {
543       fDiscriThr[channel]=thr;
544       AliInfo(Form("Discriminator threshold for channel %d set to %f",channel,fDiscriThr[channel]));
545     }
546     else {
547       AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,channel));
548     }
549   }
550   else
551     AliError(Form("Channel %d is not valid",channel));
552 }
553
554 //________________________________________________________________
555 void AliVZEROCalibData::SetDiscriThr(const Float_t* thresholds) 
556 {
557   // Set the TDC discriminator
558   // threshold values expressed in units of ADC
559   if(thresholds) for(int t=0; t<64; t++) fDiscriThr[t] = thresholds[t];
560   else for(int t=0; t<64; t++) fDiscriThr[t] = 2.5;
561 }