1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliADCalibData.cxx, */
19 #include <TObjString.h>
24 #include "AliCDBManager.h"
25 #include "AliCDBEntry.h"
26 #include "AliADCalibData.h"
27 #include "AliADConst.h"
30 ClassImp(AliADCalibData)
33 //________________________________________________________________
34 AliADCalibData::AliADCalibData():
39 // default constructor
41 for(int t=0; t<16; t++) {
46 fDeadChannel[t]= kFALSE;
49 for(int t=0; t<32; t++) {
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
59 fSearchWindow[i] = 16;
60 fTriggerCountOffset[i] = 3247;
65 //________________________________________________________________
66 void AliADCalibData::Reset()
71 //________________________________________________________________
72 AliADCalibData::AliADCalibData(const char* name) :
78 TString namst = "Calib_";
80 SetName(namst.Data());
81 SetTitle(namst.Data());
82 for(int t=0; t<16; t++) {
87 fDeadChannel[t]= kFALSE;
90 for(int t=0; t<32; t++) {
96 for(int i=0; i<kNCIUBoards ;i++) {
97 fTimeResolution[i] = 25./256.; // Default time resolution in ns / channel
98 fWidthResolution[i] = 25./64.; // Default time width resolution in ns / channel
100 fSearchWindow[i] = 16;
101 fTriggerCountOffset[i] = 3247;
106 //________________________________________________________________
107 AliADCalibData::AliADCalibData(const AliADCalibData& calibda) :
115 SetName(calibda.GetName());
116 SetTitle(calibda.GetName());
118 for(int t=0; t<32; t++) {
119 fPedestal[t] = calibda.GetPedestal(t);
120 fSigma[t] = calibda.GetSigma(t);
121 fADCmean[t] = calibda.GetADCmean(t);
122 fADCsigma[t] = calibda.GetADCsigma(t); }
124 for(int t=0; t<16; t++) {
125 fMeanHV[t] = calibda.GetMeanHV(t);
126 fWidthHV[t] = calibda.GetWidthHV(t);
127 fTimeOffset[t] = calibda.GetTimeOffset(t);
128 fTimeGain[t] = calibda.GetTimeGain(t);
129 fDeadChannel[t] = calibda.IsChannelDead(t);
130 fDiscriThr[t] = calibda.GetDiscriThr(t);
133 for(int i=0; i<kNCIUBoards ;i++) {
134 fTimeResolution[i] = calibda.GetTimeResolution(i);
135 fWidthResolution[i] = calibda.GetWidthResolution(i);
136 fMatchWindow[i] = calibda.GetMatchWindow(i);
137 fSearchWindow[i] = calibda.GetSearchWindow(i);
138 fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
139 fRollOver[i] = calibda.GetRollOver(i);
144 //________________________________________________________________
145 AliADCalibData &AliADCalibData::operator =(const AliADCalibData& calibda)
147 // assignment operator
149 SetName(calibda.GetName());
150 SetTitle(calibda.GetName());
152 for(int t=0; t<32; t++) {
153 fPedestal[t] = calibda.GetPedestal(t);
154 fSigma[t] = calibda.GetSigma(t);
155 fADCmean[t] = calibda.GetADCmean(t);
156 fADCsigma[t] = calibda.GetADCsigma(t); }
158 for(int t=0; t<16; t++) {
159 fMeanHV[t] = calibda.GetMeanHV(t);
160 fWidthHV[t] = calibda.GetWidthHV(t);
161 fTimeOffset[t] = calibda.GetTimeOffset(t);
162 fTimeGain[t] = calibda.GetTimeGain(t);
163 fDeadChannel[t] = calibda.IsChannelDead(t);
164 fDiscriThr[t] = calibda.GetDiscriThr(t);
166 for(int i=0; i<kNCIUBoards ;i++) {
167 fTimeResolution[i] = calibda.GetTimeResolution(i);
168 fWidthResolution[i] = calibda.GetWidthResolution(i);
169 fMatchWindow[i] = calibda.GetMatchWindow(i);
170 fSearchWindow[i] = calibda.GetSearchWindow(i);
171 fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
172 fRollOver[i] = calibda.GetRollOver(i);
179 //________________________________________________________________
180 AliADCalibData::~AliADCalibData()
184 delete [] fLightYields;
191 //________________________________________________________________
192 Int_t AliADCalibData::GetBoardNumber(Int_t channel)
194 // Get FEE board number
195 // from offline channel index
196 if (channel >= 0 && channel < 8) return (0);
197 if (channel >=8 && channel < 16) return (1);
199 AliErrorClass(Form("Wrong channel index: %d",channel));
203 //________________________________________________________________
204 Float_t AliADCalibData::GetLightYields(Int_t channel)
206 // Get the light yield efficiency
207 // for a given channel
208 if (!fLightYields) InitLightYields();
210 if (channel >= 0 && channel < 16) {
211 return fLightYields[channel];
214 AliError(Form("Wrong channel index: %d",channel));
218 //________________________________________________________________
219 void AliADCalibData::InitLightYields()
221 // Initialize the light yield factors
222 // Read from a separate OCDB entry
223 if (fLightYields) return;
225 AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/LightYields");
226 if (!entry) AliFatal("AD light yields are not found in OCDB !");
227 TH1F *yields = (TH1F*)entry->GetObject();
229 fLightYields = new Float_t[16];
230 for(Int_t i = 0 ; i < 16; ++i) {
231 fLightYields[i] = yields->GetBinContent(i+1);
235 //________________________________________________________________
236 void AliADCalibData::InitPMGains()
238 // Initialize the PM gain factors
239 // Read from a separate OCDB entry
240 if (fPMGainsA) return;
242 AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/PMGains");
243 if (!entry) AliFatal("VZERO PM gains are not found in OCDB !");
244 TH2F *gains = (TH2F*)entry->GetObject();
246 fPMGainsA = new Float_t[16];
247 fPMGainsB = new Float_t[16];
248 for(Int_t i = 0 ; i < 16; ++i) {
249 fPMGainsA[i] = gains->GetBinContent(i+1,1);
250 fPMGainsB[i] = gains->GetBinContent(i+1,2);
254 //________________________________________________________________
255 Float_t AliADCalibData::GetGain(Int_t channel)
257 // Computes the PM gains
258 // Argument passed is the PM number (aliroot numbering)
259 if (!fPMGainsA) InitPMGains();
261 // High Voltage retrieval from Calibration Data Base:
262 Float_t hv = fMeanHV[channel];
265 gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv));
269 //________________________________________________________________
270 Float_t AliADCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled)
272 // The method returns actual TDC discri threshold
273 // extracted from the data.
275 // In case scaled flag is set the threshold is scaled
276 // so that to get 4.0 for a FEE threshold of 4.0.
277 // In this way we avoid a change in the slewing correction
278 // for the entire 2010 p-p data.
280 // The method is to be moved to OCDB object.
282 Float_t thr = GetDiscriThr(channel);
288 calThr = (3.1+1.15*thr-1.7);
290 calThr = (3.1-0.3*thr+0.3*thr*thr);
292 if (scaled) calThr *= 4./(3.1+1.15*4.-1.7);
297 //_____________________________________________________________________________
298 void AliADCalibData::SetParameter(TString name, Int_t val){
299 // Set given parameter
304 TSeqCollection* nameSplit = name.Tokenize("/");
305 TObjString * boardName = (TObjString *)nameSplit->At(2);
306 sscanf(boardName->String().Data(),"CIU%d",&iBoard);
308 TString paramName = ((TObjString *)nameSplit->At(3))->String();
309 Char_t channel[2] ; channel[1] = '\0';
310 channel[0] = paramName[paramName.Sizeof()-2];
311 sscanf(channel,"%d",&iChannel);
313 if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
314 else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
315 else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard);
316 else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard);
317 else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard);
318 else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard);
319 else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1));
320 else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,iBoard,(iChannel-1));
321 else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
326 //________________________________________________________________
327 void AliADCalibData::SetPedestal(const Float_t* Pedestal)
329 if(Pedestal) for(int t=0; t<32; t++) fPedestal[t] = Pedestal[t];
330 else for(int t=0; t<32; t++) fPedestal[t] = 0.0;
333 //________________________________________________________________
334 void AliADCalibData::SetSigma(const Float_t* Sigma)
336 if(Sigma) for(int t=0; t<32; t++) fSigma[t] = Sigma[t];
337 else for(int t=0; t<32; t++) fSigma[t] = 0.0;
340 //________________________________________________________________
341 void AliADCalibData::SetADCmean(const Float_t* ADCmean)
343 if(ADCmean) for(int t=0; t<32; t++) fADCmean[t] = ADCmean[t];
344 else for(int t=0; t<32; t++) fADCmean[t] = 0.0;
347 //________________________________________________________________
348 void AliADCalibData::SetADCsigma(const Float_t* ADCsigma)
350 if(ADCsigma) for(int t=0; t<32; t++) fADCsigma[t] = ADCsigma[t];
351 else for(int t=0; t<32; t++) fADCsigma[t] = 0.0;
354 //________________________________________________________________
355 void AliADCalibData::SetMeanHV(const Float_t* MeanHV)
357 if(MeanHV) for(int t=0; t<16; t++) fMeanHV[t] = MeanHV[t];
358 else for(int t=0; t<16; t++) fMeanHV[t] = 0.0;
361 //________________________________________________________________
362 void AliADCalibData::SetWidthHV(const Float_t* WidthHV)
364 if(WidthHV) for(int t=0; t<16; t++) fWidthHV[t] = WidthHV[t];
365 else for(int t=0; t<16; t++) fWidthHV[t] = 0.0;
368 //________________________________________________________________
369 void AliADCalibData::SetDeadMap(const Bool_t* deadMap)
371 if(deadMap) for(int t=0; t<16; t++) fDeadChannel[t] = deadMap[t];
372 else for(int t=0; t<16; t++) fDeadChannel[t] = kFALSE;
375 //________________________________________________________________
376 void AliADCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel)
378 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
381 AliInfo(Form("Time offset for channel %d set to %f",ch,fTimeOffset[ch]));
384 AliError("Board/Channel numbers are not valid");
387 //________________________________________________________________
388 void AliADCalibData::SetTimeOffset(const Float_t* TimeOffset)
390 if(TimeOffset) for(int t=0; t<16; t++) fTimeOffset[t] = TimeOffset[t];
391 else for(int t=0; t<16; t++) fTimeOffset[t] = 5.0;
393 //________________________________________________________________
394 void AliADCalibData::SetTimeGain(const Float_t* TimeGain)
396 if(TimeGain) for(int t=0; t<16; t++) fTimeGain[t] = TimeGain[t];
397 else for(int t=0; t<16; t++) fTimeGain[t] = 0.0;
399 //________________________________________________________________
400 void AliADCalibData::SetTimeResolution(UShort_t *resols){
401 // Set Time Resolution of the TDC
402 if(resols) for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
403 else AliError("Time Resolution not defined.");
406 //________________________________________________________________
407 void AliADCalibData::SetTimeResolution(UShort_t resol, Int_t board)
409 // Set Time Resolution of the TDC
410 if((board>=0) && (board<kNCIUBoards)) {
413 fTimeResolution[board] = 25./256.;
416 fTimeResolution[board] = 25./128.;
419 fTimeResolution[board] = 25./64.;
422 fTimeResolution[board] = 25./32.;
425 fTimeResolution[board] = 25./16.;
428 fTimeResolution[board] = 25./8.;
431 fTimeResolution[board] = 6.25;
434 fTimeResolution[board] = 12.5;
437 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
438 } else AliError(Form("Board %d is not valid",board));
440 //________________________________________________________________
441 void AliADCalibData::SetWidthResolution(UShort_t *resols){
442 // Set Time Width Resolution of the TDC
443 if(resols) for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
444 else AliError("Width Resolution not defined.");
447 //________________________________________________________________
448 void AliADCalibData::SetWidthResolution(UShort_t resol, Int_t board)
450 // Set Time Width Resolution of the TDC
451 if((board>=0) && (board<kNCIUBoards)){
454 fWidthResolution[board] = 25./256.;
457 fWidthResolution[board] = 25./128.;
460 fWidthResolution[board] = 25./64.;
463 fWidthResolution[board] = 25./32.;
466 fWidthResolution[board] = 25./16.;
469 fWidthResolution[board] = 25./8.;
472 fWidthResolution[board] = 6.25;
475 fWidthResolution[board] = 12.5;
478 fWidthResolution[board] = 25.;
481 fWidthResolution[board] = 50.;
484 fWidthResolution[board] = 100.;
487 fWidthResolution[board] = 200.;
490 fWidthResolution[board] = 400.;
493 fWidthResolution[board] = 800.;
497 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
498 }else AliError(Form("Board %d is not valid",board));
501 //________________________________________________________________
502 void AliADCalibData::SetMatchWindow(UInt_t *windows)
504 // Set Match window of the HPTDC
505 // The units are 25ns
506 if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
507 else AliError("Match windows not defined.");
510 //________________________________________________________________
511 void AliADCalibData::SetMatchWindow(UInt_t window, Int_t board)
513 // Set Match window of the HPTDC
514 // The units are 25ns
515 if((board>=0) && (board<kNCIUBoards)){
516 fMatchWindow[board] = window;
517 AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
520 AliError(Form("Board %d is not valid",board));
523 //________________________________________________________________
524 void AliADCalibData::SetSearchWindow(UInt_t *windows)
526 // Set Search window of the HPTDC
527 // The units are 25ns
528 if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
529 else AliError("Search windows not defined.");
532 //________________________________________________________________
533 void AliADCalibData::SetSearchWindow(UInt_t window, Int_t board)
535 // Set Search window of the HPTDC
536 // The units are 25ns
537 if((board>=0) && (board<kNCIUBoards)){
538 fSearchWindow[board] = window;
539 AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
542 AliError(Form("Board %d is not valid",board));
545 //________________________________________________________________
546 void AliADCalibData::SetTriggerCountOffset(UInt_t *offsets)
548 // Set trigger-count offset of the HPTDC
549 // The units are 25ns
550 if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
551 else AliError("Trigger count offsets not defined.");
554 //________________________________________________________________
555 void AliADCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
557 // Set trigger-count offsets of the HPTDC
558 // The units are 25ns
559 if((board>=0) && (board<kNCIUBoards)){
560 fTriggerCountOffset[board] = offset;
561 AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
564 AliError(Form("Board %d is not valid",board));
567 //________________________________________________________________
568 void AliADCalibData::SetRollOver(UInt_t *offsets)
570 // Set Roll-over of the HPTDC
571 // The units are 25ns
572 if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
573 else AliError("Roll-over offsets not defined.");
576 //________________________________________________________________
577 void AliADCalibData::SetRollOver(UInt_t offset, Int_t board)
579 // Set Roll-over of the HPTDC
580 // The units are 25ns
581 if((board>=0) && (board<kNCIUBoards)){
582 fRollOver[board] = offset;
583 AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
586 AliError(Form("Board %d is not valid",board));
589 //________________________________________________________________
590 void AliADCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel)
592 // Set the TDC discriminator
593 // threshold values expressed in units of ADC
594 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
598 AliInfo(Form("Discriminator threshold for channel %d set to %f",ch,fDiscriThr[ch]));
601 AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,ch));
605 AliError("Board/Channel numbers are not valid");
608 //________________________________________________________________
609 void AliADCalibData::SetDiscriThr(const Float_t* thresholds)
611 // Set the TDC discriminator
612 // threshold values expressed in units of ADC
613 if(thresholds) for(int t=0; t<16; t++) fDiscriThr[t] = thresholds[t];
614 else for(int t=0; t<16; t++) fDiscriThr[t] = 2.5;
617 //________________________________________________________________
618 Int_t AliADCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel)
620 // Get the offline channel number from
621 // the FEE board and channel indexes
623 if (board < 0 || board >= 2) {
624 AliErrorClass(Form("Wrong FEE board number: %d",board));
627 if (channel < 0 || channel >= 8) {
628 AliErrorClass(Form("Wrong FEE channel number: %d",channel));
632 Int_t offCh = (board+1)*channel;
636 //________________________________________________________________
637 Int_t AliADCalibData::GetFEEChannelNumber(Int_t channel)
639 // Get FEE channel number
640 // from offline channel index
641 if (channel >= 0 && channel < 16) return ((channel % 8));
643 AliErrorClass(Form("Wrong channel index: %d",channel));