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