]>
Commit | Line | Data |
---|---|---|
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 | #include <TH1F.h> | |
28 | #include <TH2F.h> | |
29 | ||
30 | #include "AliDCSValue.h" | |
31 | #include "AliCDBManager.h" | |
32 | #include "AliCDBEntry.h" | |
33 | #include "AliVZEROCalibData.h" | |
34 | #include "AliVZERODataDCS.h" | |
35 | #include "AliVZEROConst.h" | |
36 | #include "AliLog.h" | |
37 | ||
38 | ClassImp(AliVZEROCalibData) | |
39 | ||
40 | //________________________________________________________________ | |
41 | AliVZEROCalibData::AliVZEROCalibData(): | |
42 | fLightYields(NULL), | |
43 | fPMGainsA(NULL), | |
44 | fPMGainsB(NULL) | |
45 | { | |
46 | // default constructor | |
47 | ||
48 | for(int t=0; t<64; t++) { | |
49 | fMeanHV[t] = 100.0; | |
50 | fWidthHV[t] = 0.0; | |
51 | fTimeOffset[t] = 5.0; | |
52 | fTimeGain[t] = 1.0; | |
53 | fDeadChannel[t]= kFALSE; | |
54 | fDiscriThr[t] = 2.5; | |
55 | } | |
56 | for(int t=0; t<128; t++) { | |
57 | fPedestal[t] = 0.0; | |
58 | fSigma[t] = 0.0; | |
59 | fADCmean[t] = 0.0; | |
60 | fADCsigma[t] = 0.0; | |
61 | } | |
62 | for(int i=0; i<kNCIUBoards ;i++) { | |
63 | fTimeResolution[i] = 25./256.; // Default time resolution | |
64 | fWidthResolution[i] = 25./64.; // Default time width resolution | |
65 | fMatchWindow[i] = 4; | |
66 | fSearchWindow[i] = 16; | |
67 | fTriggerCountOffset[i] = 3247; | |
68 | fRollOver[i] = 3563; | |
69 | } | |
70 | ||
71 | } | |
72 | ||
73 | //________________________________________________________________ | |
74 | void AliVZEROCalibData::Reset() | |
75 | { | |
76 | // reset | |
77 | } | |
78 | ||
79 | //________________________________________________________________ | |
80 | AliVZEROCalibData::AliVZEROCalibData(const char* name): | |
81 | fLightYields(NULL), | |
82 | fPMGainsA(NULL), | |
83 | fPMGainsB(NULL) | |
84 | { | |
85 | // Constructor | |
86 | TString namst = "Calib_"; | |
87 | namst += name; | |
88 | SetName(namst.Data()); | |
89 | SetTitle(namst.Data()); | |
90 | for(int t=0; t<64; t++) { | |
91 | fMeanHV[t] = 100.0; | |
92 | fWidthHV[t] = 0.0; | |
93 | fTimeOffset[t] = 5.0; | |
94 | fTimeGain[t] = 1.0; | |
95 | fDeadChannel[t]= kFALSE; | |
96 | fDiscriThr[t] = 2.5; | |
97 | } | |
98 | for(int t=0; t<128; t++) { | |
99 | fPedestal[t] = 0.0; | |
100 | fSigma[t] = 0.0; | |
101 | fADCmean[t] = 0.0; | |
102 | fADCsigma[t] = 0.0; | |
103 | } | |
104 | for(int i=0; i<kNCIUBoards ;i++) { | |
105 | fTimeResolution[i] = 25./256.; // Default time resolution in ns / channel | |
106 | fWidthResolution[i] = 25./64.; // Default time width resolution in ns / channel | |
107 | fMatchWindow[i] = 4; | |
108 | fSearchWindow[i] = 16; | |
109 | fTriggerCountOffset[i] = 3247; | |
110 | fRollOver[i] = 3563; | |
111 | } | |
112 | ||
113 | } | |
114 | ||
115 | //________________________________________________________________ | |
116 | AliVZEROCalibData::AliVZEROCalibData(const AliVZEROCalibData& calibda) : | |
117 | TNamed(calibda), | |
118 | fLightYields(NULL), | |
119 | fPMGainsA(NULL), | |
120 | fPMGainsB(NULL) | |
121 | { | |
122 | // copy constructor | |
123 | ||
124 | SetName(calibda.GetName()); | |
125 | SetTitle(calibda.GetName()); | |
126 | ||
127 | for(int t=0; t<128; t++) { | |
128 | fPedestal[t] = calibda.GetPedestal(t); | |
129 | fSigma[t] = calibda.GetSigma(t); | |
130 | fADCmean[t] = calibda.GetADCmean(t); | |
131 | fADCsigma[t] = calibda.GetADCsigma(t); } | |
132 | ||
133 | for(int t=0; t<64; t++) { | |
134 | fMeanHV[t] = calibda.GetMeanHV(t); | |
135 | fWidthHV[t] = calibda.GetWidthHV(t); | |
136 | fTimeOffset[t] = calibda.GetTimeOffset(t); | |
137 | fTimeGain[t] = calibda.GetTimeGain(t); | |
138 | fDeadChannel[t] = calibda.IsChannelDead(t); | |
139 | fDiscriThr[t] = calibda.GetDiscriThr(t); | |
140 | } | |
141 | ||
142 | for(int i=0; i<kNCIUBoards ;i++) { | |
143 | fTimeResolution[i] = calibda.GetTimeResolution(i); | |
144 | fWidthResolution[i] = calibda.GetWidthResolution(i); | |
145 | fMatchWindow[i] = calibda.GetMatchWindow(i); | |
146 | fSearchWindow[i] = calibda.GetSearchWindow(i); | |
147 | fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i); | |
148 | fRollOver[i] = calibda.GetRollOver(i); | |
149 | } | |
150 | ||
151 | } | |
152 | ||
153 | //________________________________________________________________ | |
154 | AliVZEROCalibData &AliVZEROCalibData::operator =(const AliVZEROCalibData& calibda) | |
155 | { | |
156 | // assignment operator | |
157 | ||
158 | SetName(calibda.GetName()); | |
159 | SetTitle(calibda.GetName()); | |
160 | ||
161 | for(int t=0; t<128; t++) { | |
162 | fPedestal[t] = calibda.GetPedestal(t); | |
163 | fSigma[t] = calibda.GetSigma(t); | |
164 | fADCmean[t] = calibda.GetADCmean(t); | |
165 | fADCsigma[t] = calibda.GetADCsigma(t); } | |
166 | ||
167 | for(int t=0; t<64; t++) { | |
168 | fMeanHV[t] = calibda.GetMeanHV(t); | |
169 | fWidthHV[t] = calibda.GetWidthHV(t); | |
170 | fTimeOffset[t] = calibda.GetTimeOffset(t); | |
171 | fTimeGain[t] = calibda.GetTimeGain(t); | |
172 | fDeadChannel[t] = calibda.IsChannelDead(t); | |
173 | fDiscriThr[t] = calibda.GetDiscriThr(t); | |
174 | } | |
175 | for(int i=0; i<kNCIUBoards ;i++) { | |
176 | fTimeResolution[i] = calibda.GetTimeResolution(i); | |
177 | fWidthResolution[i] = calibda.GetWidthResolution(i); | |
178 | fMatchWindow[i] = calibda.GetMatchWindow(i); | |
179 | fSearchWindow[i] = calibda.GetSearchWindow(i); | |
180 | fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i); | |
181 | fRollOver[i] = calibda.GetRollOver(i); | |
182 | } | |
183 | ||
184 | return *this; | |
185 | ||
186 | } | |
187 | ||
188 | //________________________________________________________________ | |
189 | AliVZEROCalibData::~AliVZEROCalibData() | |
190 | { | |
191 | // destructor | |
192 | if (fLightYields) | |
193 | delete [] fLightYields; | |
194 | if (fPMGainsA) | |
195 | delete [] fPMGainsA; | |
196 | if (fPMGainsB) | |
197 | delete [] fPMGainsB; | |
198 | } | |
199 | //_____________________________________________________________________________ | |
200 | void AliVZEROCalibData::FillDCSData(AliVZERODataDCS * data){ | |
201 | // Set all parameters from the data get by the shuttle | |
202 | TMap * params = data->GetFEEParameters(); | |
203 | TIter iter(params); | |
204 | TObjString* aliasName; | |
205 | ||
206 | while (( aliasName = (TObjString*) iter.Next() )) { | |
207 | AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName); | |
208 | Int_t val; | |
209 | if(aValue) { | |
210 | val = aValue->GetUInt(); | |
211 | AliInfo(Form("%s : %d",aliasName->String().Data(), val)); | |
212 | SetParameter(aliasName->String(),val); | |
213 | } | |
214 | } | |
215 | ||
216 | SetMeanHV(data->GetMeanHV()); | |
217 | SetWidthHV(data->GetWidthHV()); | |
218 | SetDeadMap(data->GetDeadMap()); | |
219 | ||
220 | } | |
221 | //_____________________________________________________________________________ | |
222 | void AliVZEROCalibData::SetParameter(TString name, Int_t val){ | |
223 | // Set given parameter | |
224 | ||
225 | Int_t iBoard = -1; | |
226 | Int_t iChannel = -1; | |
227 | ||
228 | TSeqCollection* nameSplit = name.Tokenize("/"); | |
229 | TObjString * boardName = (TObjString *)nameSplit->At(2); | |
230 | sscanf(boardName->String().Data(),"CIU%d",&iBoard); | |
231 | ||
232 | TString paramName = ((TObjString *)nameSplit->At(3))->String(); | |
233 | Char_t channel[2] ; channel[1] = '\0'; | |
234 | channel[0] = paramName[paramName.Sizeof()-2]; | |
235 | sscanf(channel,"%d",&iChannel); | |
236 | ||
237 | if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard); | |
238 | else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard); | |
239 | else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard); | |
240 | else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard); | |
241 | else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard); | |
242 | else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard); | |
243 | else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1)); | |
244 | else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,iBoard,(iChannel-1)); | |
245 | else AliError(Form("No Setter found for FEE parameter : %s",name.Data())); | |
246 | // | |
247 | delete nameSplit; | |
248 | } | |
249 | ||
250 | //________________________________________________________________ | |
251 | void AliVZEROCalibData::SetPedestal(const Float_t* Pedestal) | |
252 | { | |
253 | if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t]; | |
254 | else for(int t=0; t<128; t++) fPedestal[t] = 0.0; | |
255 | } | |
256 | ||
257 | //________________________________________________________________ | |
258 | void AliVZEROCalibData::SetSigma(const Float_t* Sigma) | |
259 | { | |
260 | if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t]; | |
261 | else for(int t=0; t<128; t++) fSigma[t] = 0.0; | |
262 | } | |
263 | ||
264 | //________________________________________________________________ | |
265 | void AliVZEROCalibData::SetADCmean(const Float_t* ADCmean) | |
266 | { | |
267 | if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t]; | |
268 | else for(int t=0; t<128; t++) fADCmean[t] = 0.0; | |
269 | } | |
270 | ||
271 | //________________________________________________________________ | |
272 | void AliVZEROCalibData::SetADCsigma(const Float_t* ADCsigma) | |
273 | { | |
274 | if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t]; | |
275 | else for(int t=0; t<128; t++) fADCsigma[t] = 0.0; | |
276 | } | |
277 | ||
278 | //________________________________________________________________ | |
279 | void AliVZEROCalibData::SetMeanHV(const Float_t* MeanHV) | |
280 | { | |
281 | if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t]; | |
282 | else for(int t=0; t<64; t++) fMeanHV[t] = 0.0; | |
283 | } | |
284 | ||
285 | //________________________________________________________________ | |
286 | void AliVZEROCalibData::SetWidthHV(const Float_t* WidthHV) | |
287 | { | |
288 | if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t]; | |
289 | else for(int t=0; t<64; t++) fWidthHV[t] = 0.0; | |
290 | } | |
291 | ||
292 | //________________________________________________________________ | |
293 | void AliVZEROCalibData::SetDeadMap(const Bool_t* deadMap) | |
294 | { | |
295 | if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t]; | |
296 | else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE; | |
297 | } | |
298 | ||
299 | //________________________________________________________________ | |
300 | void AliVZEROCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel) | |
301 | { | |
302 | Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel); | |
303 | if(ch >= 0){ | |
304 | fTimeOffset[ch]=val; | |
305 | AliInfo(Form("Time offset for channel %d set to %f",ch,fTimeOffset[ch])); | |
306 | } | |
307 | else | |
308 | AliError("Board/Channel numbers are not valid"); | |
309 | } | |
310 | ||
311 | //________________________________________________________________ | |
312 | void AliVZEROCalibData::SetTimeOffset(const Float_t* TimeOffset) | |
313 | { | |
314 | if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t]; | |
315 | else for(int t=0; t<64; t++) fTimeOffset[t] = 5.0; | |
316 | } | |
317 | ||
318 | //________________________________________________________________ | |
319 | void AliVZEROCalibData::SetTimeGain(const Float_t* TimeGain) | |
320 | { | |
321 | if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t]; | |
322 | else for(int t=0; t<64; t++) fTimeGain[t] = 0.0; | |
323 | } | |
324 | ||
325 | //_____________________________________________________________________________ | |
326 | Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) { | |
327 | ||
328 | // Computes the MIP conversion factor - MIP per ADC channel - | |
329 | // Argument passed is the PM number (aliroot numbering) | |
330 | ||
331 | Float_t nPhPerMIP = (channel < 32) ? 6950 : 33690; | |
332 | return 1./(nPhPerMIP*GetLightYields(channel)*0.18*TMath::Qe()*GetGain(channel)/kChargePerADC); | |
333 | ||
334 | } | |
335 | ||
336 | //_____________________________________________________________________________ | |
337 | Float_t AliVZEROCalibData::GetHV(Int_t channel, Float_t adcPerMip) { | |
338 | ||
339 | // Computes the HV value for certain ADC per MIP value | |
340 | // Arguments passed is the PM number (aliroot numbering) and | |
341 | // required value of ADC per MIP | |
342 | if (!fPMGainsA) InitPMGains(); | |
343 | ||
344 | if (adcPerMip <= 0) return 0; | |
345 | Float_t nPhPerMIP = (channel < 32) ? 6950 : 33690; | |
346 | Float_t gain = adcPerMip/(nPhPerMIP*GetLightYields(channel)*0.18*TMath::Qe())*kChargePerADC; | |
347 | return TMath::Exp((TMath::Log(gain)-fPMGainsA[channel])/fPMGainsB[channel]); | |
348 | } | |
349 | ||
350 | //________________________________________________________________ | |
351 | Float_t AliVZEROCalibData::GetGain(Int_t channel) | |
352 | { | |
353 | // Computes the PM gains | |
354 | // Argument passed is the PM number (aliroot numbering) | |
355 | if (!fPMGainsA) InitPMGains(); | |
356 | ||
357 | // High Voltage retrieval from Calibration Data Base: | |
358 | Float_t hv = fMeanHV[channel]; | |
359 | Float_t gain = 0; | |
360 | if (hv>0) | |
361 | gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv)); | |
362 | return gain; | |
363 | } | |
364 | ||
365 | //________________________________________________________________ | |
366 | void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){ | |
367 | // Set Time Resolution of the TDC | |
368 | if(resols) for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t); | |
369 | else AliError("Time Resolution not defined."); | |
370 | ||
371 | } | |
372 | //________________________________________________________________ | |
373 | void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board) | |
374 | { | |
375 | // Set Time Resolution of the TDC | |
376 | if((board>=0) && (board<kNCIUBoards)) { | |
377 | switch(resol){ | |
378 | case 0: | |
379 | fTimeResolution[board] = 25./256.; | |
380 | break; | |
381 | case 1: | |
382 | fTimeResolution[board] = 25./128.; | |
383 | break; | |
384 | case 2: | |
385 | fTimeResolution[board] = 25./64.; | |
386 | break; | |
387 | case 3: | |
388 | fTimeResolution[board] = 25./32.; | |
389 | break; | |
390 | case 4: | |
391 | fTimeResolution[board] = 25./16.; | |
392 | break; | |
393 | case 5: | |
394 | fTimeResolution[board] = 25./8.; | |
395 | break; | |
396 | case 6: | |
397 | fTimeResolution[board] = 6.25; | |
398 | break; | |
399 | case 7: | |
400 | fTimeResolution[board] = 12.5; | |
401 | break; | |
402 | } | |
403 | AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board])); | |
404 | } else AliError(Form("Board %d is not valid",board)); | |
405 | } | |
406 | //________________________________________________________________ | |
407 | void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){ | |
408 | // Set Time Width Resolution of the TDC | |
409 | if(resols) for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t); | |
410 | else AliError("Width Resolution not defined."); | |
411 | ||
412 | } | |
413 | //________________________________________________________________ | |
414 | void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board) | |
415 | { | |
416 | // Set Time Width Resolution of the TDC | |
417 | if((board>=0) && (board<kNCIUBoards)){ | |
418 | switch(resol){ | |
419 | case 0: | |
420 | fWidthResolution[board] = 25./256.; | |
421 | break; | |
422 | case 1: | |
423 | fWidthResolution[board] = 25./128.; | |
424 | break; | |
425 | case 2: | |
426 | fWidthResolution[board] = 25./64.; | |
427 | break; | |
428 | case 3: | |
429 | fWidthResolution[board] = 25./32.; | |
430 | break; | |
431 | case 4: | |
432 | fWidthResolution[board] = 25./16.; | |
433 | break; | |
434 | case 5: | |
435 | fWidthResolution[board] = 25./8.; | |
436 | break; | |
437 | case 6: | |
438 | fWidthResolution[board] = 6.25; | |
439 | break; | |
440 | case 7: | |
441 | fWidthResolution[board] = 12.5; | |
442 | break; | |
443 | case 8: | |
444 | fWidthResolution[board] = 25.; | |
445 | break; | |
446 | case 9: | |
447 | fWidthResolution[board] = 50.; | |
448 | break; | |
449 | case 10: | |
450 | fWidthResolution[board] = 100.; | |
451 | break; | |
452 | case 11: | |
453 | fWidthResolution[board] = 200.; | |
454 | break; | |
455 | case 12: | |
456 | fWidthResolution[board] = 400.; | |
457 | break; | |
458 | case 13: | |
459 | fWidthResolution[board] = 800.; | |
460 | break; | |
461 | ||
462 | } | |
463 | AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board])); | |
464 | }else AliError(Form("Board %d is not valid",board)); | |
465 | } | |
466 | ||
467 | //________________________________________________________________ | |
468 | void AliVZEROCalibData::SetMatchWindow(UInt_t *windows) | |
469 | { | |
470 | // Set Match window of the HPTDC | |
471 | // The units are 25ns | |
472 | if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b); | |
473 | else AliError("Match windows not defined."); | |
474 | } | |
475 | ||
476 | //________________________________________________________________ | |
477 | void AliVZEROCalibData::SetMatchWindow(UInt_t window, Int_t board) | |
478 | { | |
479 | // Set Match window of the HPTDC | |
480 | // The units are 25ns | |
481 | if((board>=0) && (board<kNCIUBoards)){ | |
482 | fMatchWindow[board] = window; | |
483 | AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board])); | |
484 | } | |
485 | else | |
486 | AliError(Form("Board %d is not valid",board)); | |
487 | } | |
488 | ||
489 | //________________________________________________________________ | |
490 | void AliVZEROCalibData::SetSearchWindow(UInt_t *windows) | |
491 | { | |
492 | // Set Search window of the HPTDC | |
493 | // The units are 25ns | |
494 | if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b); | |
495 | else AliError("Search windows not defined."); | |
496 | } | |
497 | ||
498 | //________________________________________________________________ | |
499 | void AliVZEROCalibData::SetSearchWindow(UInt_t window, Int_t board) | |
500 | { | |
501 | // Set Search window of the HPTDC | |
502 | // The units are 25ns | |
503 | if((board>=0) && (board<kNCIUBoards)){ | |
504 | fSearchWindow[board] = window; | |
505 | AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board])); | |
506 | } | |
507 | else | |
508 | AliError(Form("Board %d is not valid",board)); | |
509 | } | |
510 | ||
511 | //________________________________________________________________ | |
512 | void AliVZEROCalibData::SetTriggerCountOffset(UInt_t *offsets) | |
513 | { | |
514 | // Set trigger-count offset of the HPTDC | |
515 | // The units are 25ns | |
516 | if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b); | |
517 | else AliError("Trigger count offsets not defined."); | |
518 | } | |
519 | ||
520 | //________________________________________________________________ | |
521 | void AliVZEROCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board) | |
522 | { | |
523 | // Set trigger-count offsets of the HPTDC | |
524 | // The units are 25ns | |
525 | if((board>=0) && (board<kNCIUBoards)){ | |
526 | fTriggerCountOffset[board] = offset; | |
527 | AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board])); | |
528 | } | |
529 | else | |
530 | AliError(Form("Board %d is not valid",board)); | |
531 | } | |
532 | ||
533 | //________________________________________________________________ | |
534 | void AliVZEROCalibData::SetRollOver(UInt_t *offsets) | |
535 | { | |
536 | // Set Roll-over of the HPTDC | |
537 | // The units are 25ns | |
538 | if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b); | |
539 | else AliError("Roll-over offsets not defined."); | |
540 | } | |
541 | ||
542 | //________________________________________________________________ | |
543 | void AliVZEROCalibData::SetRollOver(UInt_t offset, Int_t board) | |
544 | { | |
545 | // Set Roll-over of the HPTDC | |
546 | // The units are 25ns | |
547 | if((board>=0) && (board<kNCIUBoards)){ | |
548 | fRollOver[board] = offset; | |
549 | AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board])); | |
550 | } | |
551 | else | |
552 | AliError(Form("Board %d is not valid",board)); | |
553 | } | |
554 | ||
555 | //________________________________________________________________ | |
556 | void AliVZEROCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel) | |
557 | { | |
558 | // Set the TDC discriminator | |
559 | // threshold values expressed in units of ADC | |
560 | Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel); | |
561 | if(ch >= 0){ | |
562 | if (thr > 0) { | |
563 | fDiscriThr[ch]=thr; | |
564 | AliInfo(Form("Discriminator threshold for channel %d set to %f",ch,fDiscriThr[ch])); | |
565 | } | |
566 | else { | |
567 | AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,ch)); | |
568 | } | |
569 | } | |
570 | else | |
571 | AliError("Board/Channel numbers are not valid"); | |
572 | } | |
573 | ||
574 | //________________________________________________________________ | |
575 | void AliVZEROCalibData::SetDiscriThr(const Float_t* thresholds) | |
576 | { | |
577 | // Set the TDC discriminator | |
578 | // threshold values expressed in units of ADC | |
579 | if(thresholds) for(int t=0; t<64; t++) fDiscriThr[t] = thresholds[t]; | |
580 | else for(int t=0; t<64; t++) fDiscriThr[t] = 2.5; | |
581 | } | |
582 | ||
583 | Int_t AliVZEROCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel) | |
584 | { | |
585 | // Get the offline channel number from | |
586 | // the FEE board and channel indexes | |
587 | ||
588 | if (board < 0 || board >= 8) { | |
589 | AliErrorClass(Form("Wrong FEE board number: %d",board)); | |
590 | return -1; | |
591 | } | |
592 | if (channel < 0 || channel >= 8) { | |
593 | AliErrorClass(Form("Wrong FEE channel number: %d",channel)); | |
594 | return -1; | |
595 | } | |
596 | ||
597 | Int_t offCh = (board < 4) ? (8 * board + 32) : (8 * board -32); | |
598 | offCh += (7 - channel); | |
599 | ||
600 | return offCh; | |
601 | } | |
602 | ||
603 | Int_t AliVZEROCalibData::GetBoardNumber(Int_t channel) | |
604 | { | |
605 | // Get FEE board number | |
606 | // from offline channel index | |
607 | if (channel >= 0 && channel < 32) return (channel / 8 + 4); | |
608 | if (channel >=32 && channel < 64) return (channel / 8 - 4); | |
609 | ||
610 | AliErrorClass(Form("Wrong channel index: %d",channel)); | |
611 | return -1; | |
612 | } | |
613 | ||
614 | Int_t AliVZEROCalibData::GetFEEChannelNumber(Int_t channel) | |
615 | { | |
616 | // Get FEE channel number | |
617 | // from offline channel index | |
618 | if (channel >= 0 && channel < 64) return (7 - (channel % 8)); | |
619 | ||
620 | AliErrorClass(Form("Wrong channel index: %d",channel)); | |
621 | return -1; | |
622 | } | |
623 | ||
624 | Float_t AliVZEROCalibData::GetLightYields(Int_t channel) | |
625 | { | |
626 | // Get the light yield efficiency | |
627 | // for a given channel | |
628 | if (!fLightYields) InitLightYields(); | |
629 | ||
630 | if (channel >= 0 && channel < 64) { | |
631 | return fLightYields[channel]; | |
632 | } | |
633 | ||
634 | AliError(Form("Wrong channel index: %d",channel)); | |
635 | return 0; | |
636 | } | |
637 | ||
638 | void AliVZEROCalibData::InitLightYields() | |
639 | { | |
640 | // Initialize the light yield factors | |
641 | // Read from a separate OCDB entry | |
642 | if (fLightYields) return; | |
643 | ||
644 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/LightYields"); | |
645 | if (!entry) AliFatal("VZERO light yields are not found in OCDB !"); | |
646 | TH1F *yields = (TH1F*)entry->GetObject(); | |
647 | ||
648 | fLightYields = new Float_t[64]; | |
649 | for(Int_t i = 0 ; i < 64; ++i) { | |
650 | fLightYields[i] = yields->GetBinContent(i+1); | |
651 | } | |
652 | } | |
653 | ||
654 | void AliVZEROCalibData::InitPMGains() | |
655 | { | |
656 | // Initialize the PM gain factors | |
657 | // Read from a separate OCDB entry | |
658 | if (fPMGainsA) return; | |
659 | ||
660 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/PMGains"); | |
661 | if (!entry) AliFatal("VZERO PM gains are not found in OCDB !"); | |
662 | TH2F *gains = (TH2F*)entry->GetObject(); | |
663 | ||
664 | fPMGainsA = new Float_t[64]; | |
665 | fPMGainsB = new Float_t[64]; | |
666 | for(Int_t i = 0 ; i < 64; ++i) { | |
667 | fPMGainsA[i] = gains->GetBinContent(i+1,1); | |
668 | fPMGainsB[i] = gains->GetBinContent(i+1,2); | |
669 | } | |
670 | } | |
671 | ||
672 | Float_t AliVZEROCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled) | |
673 | { | |
674 | // The method returns actual TDC discri threshold | |
675 | // extracted from the data. | |
676 | // | |
677 | // In case scaled flag is set the threshold is scaled | |
678 | // so that to get 4.0 for a FEE threshold of 4.0. | |
679 | // In this way we avoid a change in the slewing correction | |
680 | // for the entire 2010 p-p data. | |
681 | // | |
682 | // The method is to be moved to OCDB object. | |
683 | ||
684 | Float_t thr = GetDiscriThr(channel); | |
685 | ||
686 | Float_t calThr = 0; | |
687 | if (thr <= 1.) | |
688 | calThr = 3.1; | |
689 | else if (thr >= 2.) | |
690 | calThr = (3.1+1.15*thr-1.7); | |
691 | else | |
692 | calThr = (3.1-0.3*thr+0.3*thr*thr); | |
693 | ||
694 | if (scaled) calThr *= 4./(3.1+1.15*4.-1.7); | |
695 | ||
696 | return calThr; | |
697 | } |