Modifying build files according to recent changes
[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"
30
31ClassImp(AliVZEROCalibData)
32
33//________________________________________________________________
34AliVZEROCalibData::AliVZEROCalibData()
35{
2f09013f 36 // default constructor
37
38 for(int t=0; t<64; t++) {
39 fMeanHV[t] = 100.0;
40 fWidthHV[t] = 0.0;
41 fTimeOffset[t] = 0.0;
42 fTimeGain[t] = 1.0;
43 fDeadChannel[t]= kFALSE;
44 }
45 for(int t=0; t<128; t++) {
46 fPedestal[t] = 0.0;
47 fSigma[t] = 0.0;
48 fADCmean[t] = 0.0;
49 fADCsigma[t] = 0.0;
50 fGain[t] = 1.0;
51 }
52 for(int i=0; i<kNCIUBoards ;i++) {
53 fTimeResolution[i] = 25./256.; // Default time resolution
54 fWidthResolution[i] = 25./64.; // Default time width resolution
55 }
d5deaaa5 56
3191f471 57}
58
a3c86e1f 59//________________________________________________________________
60void AliVZEROCalibData::Reset()
61{
d7a5c700 62 // reset
a3c86e1f 63}
64
3191f471 65//________________________________________________________________
66AliVZEROCalibData::AliVZEROCalibData(const char* name)
67{
2f09013f 68 TString namst = "Calib_";
69 namst += name;
70 SetName(namst.Data());
71 SetTitle(namst.Data());
72 for(int t=0; t<64; t++) {
73 fMeanHV[t] = 100.0;
74 fWidthHV[t] = 0.0;
75 fTimeOffset[t] = 0.0;
76 fTimeGain[t] = 1.0;
77 fDeadChannel[t]= kFALSE;
78 }
79 for(int t=0; t<128; t++) {
80 fPedestal[t] = 0.0;
81 fSigma[t] = 0.0;
82 fADCmean[t] = 0.0;
83 fADCsigma[t] = 0.0;
84 fGain[t] = 1.0;
85 }
86 for(int i=0; i<kNCIUBoards ;i++) {
87 fTimeResolution[i] = 25./256.; // Default time resolution in ns / channel
88 fWidthResolution[i] = 25./64.; // Default time width resolution in ns / channel
89 }
3191f471 90
91}
92
93//________________________________________________________________
94AliVZEROCalibData::AliVZEROCalibData(const AliVZEROCalibData& calibda) :
95 TNamed(calibda)
96{
97// copy constructor
98
99 SetName(calibda.GetName());
100 SetTitle(calibda.GetName());
101
fae0e0c0 102 for(int t=0; t<128; t++) {
3191f471 103 fPedestal[t] = calibda.GetPedestal(t);
fae0e0c0 104 fSigma[t] = calibda.GetSigma(t);
2a25ea57 105 fADCmean[t] = calibda.GetADCmean(t);
106 fADCsigma[t] = calibda.GetADCsigma(t);
107 fGain[t] = calibda.GetGain(t); }
fae0e0c0 108
109 for(int t=0; t<64; t++) {
d7a5c700 110 fMeanHV[t] = calibda.GetMeanHV(t);
2a25ea57 111 fWidthHV[t] = calibda.GetWidthHV(t);
112 fTimeOffset[t] = calibda.GetTimeOffset(t);
d5deaaa5 113 fTimeGain[t] = calibda.GetTimeGain(t);
2f09013f 114 fDeadChannel[t] = calibda.IsChannelDead(t);
d5deaaa5 115 }
116
2f09013f 117 for(int i=0; i<kNCIUBoards ;i++) {
118 fTimeResolution[i] = calibda.GetTimeResolution(i);
119 fWidthResolution[i] = calibda.GetWidthResolution(i);
120 }
3191f471 121
122}
123
124//________________________________________________________________
125AliVZEROCalibData &AliVZEROCalibData::operator =(const AliVZEROCalibData& calibda)
126{
127// assignment operator
128
129 SetName(calibda.GetName());
130 SetTitle(calibda.GetName());
131
fae0e0c0 132 for(int t=0; t<128; t++) {
3191f471 133 fPedestal[t] = calibda.GetPedestal(t);
fae0e0c0 134 fSigma[t] = calibda.GetSigma(t);
2a25ea57 135 fADCmean[t] = calibda.GetADCmean(t);
40b6a179 136 fADCsigma[t] = calibda.GetADCsigma(t);
2a25ea57 137 fGain[t] = calibda.GetGain(t); }
fae0e0c0 138
2a25ea57 139 for(int t=0; t<64; t++) {
d7a5c700 140 fMeanHV[t] = calibda.GetMeanHV(t);
2a25ea57 141 fWidthHV[t] = calibda.GetWidthHV(t);
142 fTimeOffset[t] = calibda.GetTimeOffset(t);
d5deaaa5 143 fTimeGain[t] = calibda.GetTimeGain(t);
2f09013f 144 fDeadChannel[t] = calibda.IsChannelDead(t);
d5deaaa5 145 }
2f09013f 146 for(int i=0; i<kNCIUBoards ;i++) {
147 fTimeResolution[i] = calibda.GetTimeResolution(i);
148 fWidthResolution[i] = calibda.GetWidthResolution(i);
149 }
2a25ea57 150
3191f471 151 return *this;
152
153}
154
155//________________________________________________________________
156AliVZEROCalibData::~AliVZEROCalibData()
157{
d7a5c700 158 // destructor
3191f471 159}
d5deaaa5 160//_____________________________________________________________________________
161void AliVZEROCalibData::FillDCSData(AliVZERODataDCS * data){
162 // Set all parameters from the data get by the shuttle
163 TMap * params = data->GetFEEParameters();
164 TIter iter(params);
165 TObjString* aliasName;
166
167 while (( aliasName = (TObjString*) iter.Next() )) {
168 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
5978520a 169 Int_t val;
d5deaaa5 170 if(aValue) {
692e31a4 171 val = aValue->GetUInt();
5978520a 172 AliInfo(Form("%s : %d",aliasName->String().Data(), val));
d5deaaa5 173 SetParameter(aliasName->String(),val);
174 }
175 }
176
177 SetMeanHV(data->GetMeanHV());
178 SetWidthHV(data->GetWidthHV());
179 SetDeadMap(data->GetDeadMap());
180
181}
182//_____________________________________________________________________________
5978520a 183void AliVZEROCalibData::SetParameter(TString name, Int_t val){
d5deaaa5 184 // Set given parameter
185
186 Int_t iBoard = -1;
187
188 TSeqCollection* nameSplit = name.Tokenize("/");
189 TObjString * boardName = (TObjString *)nameSplit->At(2);
190 sscanf(boardName->String().Data(),"CIU%d",&iBoard);
191
4bc15c46 192 if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
193 else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
d5deaaa5 194 else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
195}
3191f471 196
3191f471 197//________________________________________________________________
198void AliVZEROCalibData::SetPedestal(Float_t* Pedestal)
199{
fae0e0c0 200 if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t];
201 else for(int t=0; t<128; t++) fPedestal[t] = 0.0;
202}
203
204//________________________________________________________________
205void AliVZEROCalibData::SetSigma(Float_t* Sigma)
206{
207 if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t];
208 else for(int t=0; t<128; t++) fSigma[t] = 0.0;
3191f471 209}
210
211//________________________________________________________________
2a25ea57 212void AliVZEROCalibData::SetADCmean(Float_t* ADCmean)
3191f471 213{
2a25ea57 214 if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t];
215 else for(int t=0; t<128; t++) fADCmean[t] = 0.0;
3191f471 216}
217
40b6a179 218//________________________________________________________________
219void AliVZEROCalibData::SetADCsigma(Float_t* ADCsigma)
220{
221 if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t];
222 else for(int t=0; t<128; t++) fADCsigma[t] = 0.0;
223}
224
fae0e0c0 225//________________________________________________________________
2a25ea57 226void AliVZEROCalibData::SetMeanHV(Float_t* MeanHV)
fae0e0c0 227{
2a25ea57 228 if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t];
229 else for(int t=0; t<64; t++) fMeanHV[t] = 0.0;
fae0e0c0 230}
231
232//________________________________________________________________
2a25ea57 233void AliVZEROCalibData::SetWidthHV(Float_t* WidthHV)
fae0e0c0 234{
2a25ea57 235 if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t];
236 else for(int t=0; t<64; t++) fWidthHV[t] = 0.0;
fae0e0c0 237}
d7a5c700 238
7495d2be 239//________________________________________________________________
240void AliVZEROCalibData::SetDeadMap(Bool_t* deadMap)
241{
242 if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t];
243 else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE;
244}
245
d7a5c700 246//________________________________________________________________
2a25ea57 247void AliVZEROCalibData::SetGain(Float_t* Gain)
d7a5c700 248{
2a25ea57 249 if(Gain) for(int t=0; t<128; t++) fGain[t] = Gain[t];
250 else for(int t=0; t<128; t++) fGain[t] = 0.0;
d7a5c700 251}
252
253//________________________________________________________________
2a25ea57 254void AliVZEROCalibData::SetTimeOffset(Float_t* TimeOffset)
d7a5c700 255{
2a25ea57 256 if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t];
257 else for(int t=0; t<64; t++) fTimeOffset[t] = 0.0;
d7a5c700 258}
2a25ea57 259
260//________________________________________________________________
261void AliVZEROCalibData::SetTimeGain(Float_t* TimeGain)
262{
263 if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t];
264 else for(int t=0; t<64; t++) fTimeGain[t] = 0.0;
265}
266
706506da 267//_____________________________________________________________________________
268Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) const {
269
270 // Computes the MIP conversion factor - MIP per ADC channel -
271 // Argument passed is the PM number (aliroot numbering)
272
273 Float_t P0[64] = {
274 7.094891, 7.124938, 7.089708, 7.098169, 7.094482, 7.147250, 7.170978, 7.183392,
275 7.145760, 7.148096, 7.153840, 7.143544, 7.186069, 7.194580, 7.203516, 7.195176,
276 7.188333, 7.198607, 7.209412, 7.226565, 7.221695, 7.205132, 7.191238, 7.227724,
277 7.232810, 7.252655, 7.230309, 7.273518, 7.273518, 7.242969, 7.252859, 7.252655,
278 7.026802, 7.079913, 7.134147, 7.092387, 7.079561, 7.072848, 7.123192, 7.003141,
279 7.024667, 7.124784, 7.123442, 7.129744, 7.110671, 7.143031, 7.139439, 7.178109,
280 7.247803, 7.139396, 7.293809, 7.094454, 6.992198, 7.206448, 7.244765, 7.056197,
281 7.263595, 7.138569, 7.089582, 7.215683, 7.266183, 7.165123, 7.243276, 7.235135 };
282 Float_t P1[64] = {
283 0.135569, 0.146405, 0.142425, 0.144278, 0.142307, 0.141648, 0.128477, 0.138239,
284 0.144173, 0.143419, 0.143572, 0.144482, 0.138024, 0.136542, 0.135955, 0.138537,
285 0.148521, 0.141999, 0.139627, 0.130014, 0.134970, 0.135635, 0.139094, 0.140634,
286 0.137971, 0.142080, 0.142793, 0.142778, 0.142778, 0.146045, 0.139133, 0.142080,
287 0.144121, 0.142311, 0.136564, 0.142686, 0.138792, 0.166285, 0.136387, 0.155391,
288 0.176082, 0.140408, 0.164738, 0.144270, 0.142766, 0.147486, 0.141951, 0.138012,
289 0.132394, 0.142849, 0.140477, 0.144592, 0.141558, 0.157646, 0.143758, 0.173385,
290 0.146489, 0.143279, 0.145230, 0.147203, 0.147333, 0.144979, 0.148597, 0.138985 };
291
292 // High Voltage retrieval from Calibration Data Base:
293 Float_t HV = fMeanHV[channel];
2f52e327 294 Float_t MIP = -1;
295 if (HV>0)
b8d9ff2a 296 MIP = 0.6/TMath::Exp((TMath::Log(HV) - P0[channel] )/P1[channel]);
706506da 297 return MIP;
298
299}
d5deaaa5 300//________________________________________________________________
301void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){
302 // Set Time Resolution of the TDC
303 if(resols) for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
4bc15c46 304 else AliError("Time Resolution not defined.");
d5deaaa5 305
306}
307//________________________________________________________________
308void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board)
309{
310 // Set Time Resolution of the TDC
4bc15c46 311 if((board>=0) && (board<kNCIUBoards)) {
d5deaaa5 312 switch(resol){
313 case 0:
314 fTimeResolution[board] = 25./256.;
315 break;
316 case 1:
317 fTimeResolution[board] = 25./128.;
318 break;
319 case 2:
320 fTimeResolution[board] = 25./64.;
321 break;
322 case 3:
323 fTimeResolution[board] = 25./32.;
324 break;
325 case 4:
326 fTimeResolution[board] = 25./16.;
327 break;
328 case 5:
329 fTimeResolution[board] = 25./8.;
330 break;
331 case 6:
332 fTimeResolution[board] = 6.25;
333 break;
334 case 7:
335 fTimeResolution[board] = 12.5;
336 break;
337 }
4bc15c46 338 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
d5deaaa5 339 } else AliError(Form("Board %d is not valid",board));
340}
341//________________________________________________________________
342void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){
343 // Set Time Width Resolution of the TDC
344 if(resols) for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
4bc15c46 345 else AliError("Width Resolution not defined.");
d5deaaa5 346
347}
348//________________________________________________________________
349void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board)
350{
351 // Set Time Width Resolution of the TDC
4bc15c46 352 if((board>=0) && (board<kNCIUBoards)){
d5deaaa5 353 switch(resol){
354 case 0:
355 fWidthResolution[board] = 25./256.;
356 break;
357 case 1:
358 fWidthResolution[board] = 25./128.;
359 break;
360 case 2:
361 fWidthResolution[board] = 25./64.;
362 break;
363 case 3:
364 fWidthResolution[board] = 25./32.;
365 break;
366 case 4:
367 fWidthResolution[board] = 25./16.;
368 break;
369 case 5:
370 fWidthResolution[board] = 25./8.;
371 break;
372 case 6:
373 fWidthResolution[board] = 6.25;
374 break;
375 case 7:
376 fWidthResolution[board] = 12.5;
377 break;
378 case 8:
379 fWidthResolution[board] = 25.;
380 break;
381 case 9:
382 fWidthResolution[board] = 50.;
383 break;
384 case 10:
385 fWidthResolution[board] = 100.;
386 break;
387 case 11:
388 fWidthResolution[board] = 200.;
389 break;
390 case 12:
391 fWidthResolution[board] = 400.;
392 break;
393 case 13:
394 fWidthResolution[board] = 800.;
395 break;
396
397 }
4bc15c46 398 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
d5deaaa5 399 }else AliError(Form("Board %d is not valid",board));
400}
706506da 401