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