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: AliVZEROCalibData.cxx, */
18 /////////////////////////////////////////////////////////////////////////////
20 // class for VZERO calibration //
22 /////////////////////////////////////////////////////////////////////////////
25 #include <TObjString.h>
30 #include "AliDCSValue.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBEntry.h"
33 #include "AliVZEROCalibData.h"
34 #include "AliVZERODataDCS.h"
35 #include "AliVZEROConst.h"
38 ClassImp(AliVZEROCalibData)
40 //________________________________________________________________
41 AliVZEROCalibData::AliVZEROCalibData():
46 // default constructor
48 for(int t=0; t<64; t++) {
53 fDeadChannel[t]= kFALSE;
56 for(int t=0; t<128; t++) {
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
66 fSearchWindow[i] = 16;
67 fTriggerCountOffset[i] = 3247;
73 //________________________________________________________________
74 void AliVZEROCalibData::Reset()
79 //________________________________________________________________
80 AliVZEROCalibData::AliVZEROCalibData(const char* name):
86 TString namst = "Calib_";
88 SetName(namst.Data());
89 SetTitle(namst.Data());
90 for(int t=0; t<64; t++) {
95 fDeadChannel[t]= kFALSE;
98 for(int t=0; t<128; t++) {
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
108 fSearchWindow[i] = 16;
109 fTriggerCountOffset[i] = 3247;
115 //________________________________________________________________
116 AliVZEROCalibData::AliVZEROCalibData(const AliVZEROCalibData& calibda) :
124 SetName(calibda.GetName());
125 SetTitle(calibda.GetName());
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); }
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);
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);
153 //________________________________________________________________
154 AliVZEROCalibData &AliVZEROCalibData::operator =(const AliVZEROCalibData& calibda)
156 // assignment operator
158 SetName(calibda.GetName());
159 SetTitle(calibda.GetName());
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); }
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);
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);
188 //________________________________________________________________
189 AliVZEROCalibData::~AliVZEROCalibData()
193 delete [] fLightYields;
199 //_____________________________________________________________________________
200 void AliVZEROCalibData::FillDCSData(AliVZERODataDCS * data){
201 // Set all parameters from the data get by the shuttle
202 TMap * params = data->GetFEEParameters();
204 TObjString* aliasName;
206 while (( aliasName = (TObjString*) iter.Next() )) {
207 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
210 val = aValue->GetUInt();
211 AliInfo(Form("%s : %d",aliasName->String().Data(), val));
212 SetParameter(aliasName->String(),val);
216 SetMeanHV(data->GetMeanHV());
217 SetWidthHV(data->GetWidthHV());
218 SetDeadMap(data->GetDeadMap());
221 //_____________________________________________________________________________
222 void AliVZEROCalibData::SetParameter(TString name, Int_t val){
223 // Set given parameter
228 TSeqCollection* nameSplit = name.Tokenize("/");
229 TObjString * boardName = (TObjString *)nameSplit->At(2);
230 sscanf(boardName->String().Data(),"CIU%d",&iBoard);
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);
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()));
248 //________________________________________________________________
249 void AliVZEROCalibData::SetPedestal(const Float_t* Pedestal)
251 if(Pedestal) for(int t=0; t<128; t++) fPedestal[t] = Pedestal[t];
252 else for(int t=0; t<128; t++) fPedestal[t] = 0.0;
255 //________________________________________________________________
256 void AliVZEROCalibData::SetSigma(const Float_t* Sigma)
258 if(Sigma) for(int t=0; t<128; t++) fSigma[t] = Sigma[t];
259 else for(int t=0; t<128; t++) fSigma[t] = 0.0;
262 //________________________________________________________________
263 void AliVZEROCalibData::SetADCmean(const Float_t* ADCmean)
265 if(ADCmean) for(int t=0; t<128; t++) fADCmean[t] = ADCmean[t];
266 else for(int t=0; t<128; t++) fADCmean[t] = 0.0;
269 //________________________________________________________________
270 void AliVZEROCalibData::SetADCsigma(const Float_t* ADCsigma)
272 if(ADCsigma) for(int t=0; t<128; t++) fADCsigma[t] = ADCsigma[t];
273 else for(int t=0; t<128; t++) fADCsigma[t] = 0.0;
276 //________________________________________________________________
277 void AliVZEROCalibData::SetMeanHV(const Float_t* MeanHV)
279 if(MeanHV) for(int t=0; t<64; t++) fMeanHV[t] = MeanHV[t];
280 else for(int t=0; t<64; t++) fMeanHV[t] = 0.0;
283 //________________________________________________________________
284 void AliVZEROCalibData::SetWidthHV(const Float_t* WidthHV)
286 if(WidthHV) for(int t=0; t<64; t++) fWidthHV[t] = WidthHV[t];
287 else for(int t=0; t<64; t++) fWidthHV[t] = 0.0;
290 //________________________________________________________________
291 void AliVZEROCalibData::SetDeadMap(const Bool_t* deadMap)
293 if(deadMap) for(int t=0; t<64; t++) fDeadChannel[t] = deadMap[t];
294 else for(int t=0; t<64; t++) fDeadChannel[t] = kFALSE;
297 //________________________________________________________________
298 void AliVZEROCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel)
300 Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel);
303 AliInfo(Form("Time offset for channel %d set to %f",ch,fTimeOffset[ch]));
306 AliError("Board/Channel numbers are not valid");
309 //________________________________________________________________
310 void AliVZEROCalibData::SetTimeOffset(const Float_t* TimeOffset)
312 if(TimeOffset) for(int t=0; t<64; t++) fTimeOffset[t] = TimeOffset[t];
313 else for(int t=0; t<64; t++) fTimeOffset[t] = 5.0;
316 //________________________________________________________________
317 void AliVZEROCalibData::SetTimeGain(const Float_t* TimeGain)
319 if(TimeGain) for(int t=0; t<64; t++) fTimeGain[t] = TimeGain[t];
320 else for(int t=0; t<64; t++) fTimeGain[t] = 0.0;
323 //_____________________________________________________________________________
324 Float_t AliVZEROCalibData::GetMIPperADC(Int_t channel) {
326 // Computes the MIP conversion factor - MIP per ADC channel -
327 // Argument passed is the PM number (aliroot numbering)
329 Float_t nPhPerMIP = (channel < 32) ? 6950 : 33690;
330 return 1./(nPhPerMIP*GetLightYields(channel)*0.18*TMath::Qe()*GetGain(channel)/kChargePerADC);
334 //________________________________________________________________
335 Float_t AliVZEROCalibData::GetGain(Int_t channel)
337 // Computes the PM gains
338 // Argument passed is the PM number (aliroot numbering)
339 if (!fPMGainsA) InitPMGains();
341 // High Voltage retrieval from Calibration Data Base:
342 Float_t hv = fMeanHV[channel];
345 gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv));
349 //________________________________________________________________
350 void AliVZEROCalibData::SetTimeResolution(UShort_t *resols){
351 // Set Time Resolution of the TDC
352 if(resols) for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
353 else AliError("Time Resolution not defined.");
356 //________________________________________________________________
357 void AliVZEROCalibData::SetTimeResolution(UShort_t resol, Int_t board)
359 // Set Time Resolution of the TDC
360 if((board>=0) && (board<kNCIUBoards)) {
363 fTimeResolution[board] = 25./256.;
366 fTimeResolution[board] = 25./128.;
369 fTimeResolution[board] = 25./64.;
372 fTimeResolution[board] = 25./32.;
375 fTimeResolution[board] = 25./16.;
378 fTimeResolution[board] = 25./8.;
381 fTimeResolution[board] = 6.25;
384 fTimeResolution[board] = 12.5;
387 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
388 } else AliError(Form("Board %d is not valid",board));
390 //________________________________________________________________
391 void AliVZEROCalibData::SetWidthResolution(UShort_t *resols){
392 // Set Time Width Resolution of the TDC
393 if(resols) for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
394 else AliError("Width Resolution not defined.");
397 //________________________________________________________________
398 void AliVZEROCalibData::SetWidthResolution(UShort_t resol, Int_t board)
400 // Set Time Width Resolution of the TDC
401 if((board>=0) && (board<kNCIUBoards)){
404 fWidthResolution[board] = 25./256.;
407 fWidthResolution[board] = 25./128.;
410 fWidthResolution[board] = 25./64.;
413 fWidthResolution[board] = 25./32.;
416 fWidthResolution[board] = 25./16.;
419 fWidthResolution[board] = 25./8.;
422 fWidthResolution[board] = 6.25;
425 fWidthResolution[board] = 12.5;
428 fWidthResolution[board] = 25.;
431 fWidthResolution[board] = 50.;
434 fWidthResolution[board] = 100.;
437 fWidthResolution[board] = 200.;
440 fWidthResolution[board] = 400.;
443 fWidthResolution[board] = 800.;
447 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
448 }else AliError(Form("Board %d is not valid",board));
451 //________________________________________________________________
452 void AliVZEROCalibData::SetMatchWindow(UInt_t *windows)
454 // Set Match window of the HPTDC
455 // The units are 25ns
456 if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
457 else AliError("Match windows not defined.");
460 //________________________________________________________________
461 void AliVZEROCalibData::SetMatchWindow(UInt_t window, Int_t board)
463 // Set Match window of the HPTDC
464 // The units are 25ns
465 if((board>=0) && (board<kNCIUBoards)){
466 fMatchWindow[board] = window;
467 AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
470 AliError(Form("Board %d is not valid",board));
473 //________________________________________________________________
474 void AliVZEROCalibData::SetSearchWindow(UInt_t *windows)
476 // Set Search window of the HPTDC
477 // The units are 25ns
478 if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
479 else AliError("Search windows not defined.");
482 //________________________________________________________________
483 void AliVZEROCalibData::SetSearchWindow(UInt_t window, Int_t board)
485 // Set Search window of the HPTDC
486 // The units are 25ns
487 if((board>=0) && (board<kNCIUBoards)){
488 fSearchWindow[board] = window;
489 AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
492 AliError(Form("Board %d is not valid",board));
495 //________________________________________________________________
496 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t *offsets)
498 // Set trigger-count offset of the HPTDC
499 // The units are 25ns
500 if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
501 else AliError("Trigger count offsets not defined.");
504 //________________________________________________________________
505 void AliVZEROCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
507 // Set trigger-count offsets of the HPTDC
508 // The units are 25ns
509 if((board>=0) && (board<kNCIUBoards)){
510 fTriggerCountOffset[board] = offset;
511 AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
514 AliError(Form("Board %d is not valid",board));
517 //________________________________________________________________
518 void AliVZEROCalibData::SetRollOver(UInt_t *offsets)
520 // Set Roll-over of the HPTDC
521 // The units are 25ns
522 if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
523 else AliError("Roll-over offsets not defined.");
526 //________________________________________________________________
527 void AliVZEROCalibData::SetRollOver(UInt_t offset, Int_t board)
529 // Set Roll-over of the HPTDC
530 // The units are 25ns
531 if((board>=0) && (board<kNCIUBoards)){
532 fRollOver[board] = offset;
533 AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
536 AliError(Form("Board %d is not valid",board));
539 //________________________________________________________________
540 void AliVZEROCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel)
542 // Set the TDC discriminator
543 // threshold values expressed in units of ADC
544 Int_t ch = AliVZEROCalibData::GetOfflineChannelNumber(board,channel);
548 AliInfo(Form("Discriminator threshold for channel %d set to %f",ch,fDiscriThr[ch]));
551 AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,ch));
555 AliError("Board/Channel numbers are not valid");
558 //________________________________________________________________
559 void AliVZEROCalibData::SetDiscriThr(const Float_t* thresholds)
561 // Set the TDC discriminator
562 // threshold values expressed in units of ADC
563 if(thresholds) for(int t=0; t<64; t++) fDiscriThr[t] = thresholds[t];
564 else for(int t=0; t<64; t++) fDiscriThr[t] = 2.5;
567 Int_t AliVZEROCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel)
569 // Get the offline channel number from
570 // the FEE board and channel indexes
572 if (board < 0 || board >= 8) {
573 AliErrorClass(Form("Wrong FEE board number: %d",board));
576 if (channel < 0 || channel >= 8) {
577 AliErrorClass(Form("Wrong FEE channel number: %d",channel));
581 Int_t offCh = (board < 4) ? (8 * board + 32) : (8 * board -32);
582 offCh += (7 - channel);
587 Int_t AliVZEROCalibData::GetBoardNumber(Int_t channel)
589 // Get FEE board number
590 // from offline channel index
591 if (channel >= 0 && channel < 32) return (channel / 8 + 4);
592 if (channel >=32 && channel < 64) return (channel / 8 - 4);
594 AliErrorClass(Form("Wrong channel index: %d",channel));
598 Int_t AliVZEROCalibData::GetFEEChannelNumber(Int_t channel)
600 // Get FEE channel number
601 // from offline channel index
602 if (channel >= 0 && channel < 64) return (7 - (channel % 8));
604 AliErrorClass(Form("Wrong channel index: %d",channel));
608 Float_t AliVZEROCalibData::GetLightYields(Int_t channel)
610 // Get the light yield efficiency
611 // for a given channel
612 if (!fLightYields) InitLightYields();
614 if (channel >= 0 && channel < 64) {
615 return fLightYields[channel];
618 AliError(Form("Wrong channel index: %d",channel));
622 void AliVZEROCalibData::InitLightYields()
624 // Initialize the light yield factors
625 // Read from a separate OCDB entry
626 if (fLightYields) return;
628 AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/LightYields");
629 if (!entry) AliFatal("VZERO light yields are not found in OCDB !");
630 TH1F *yields = (TH1F*)entry->GetObject();
632 fLightYields = new Float_t[64];
633 for(Int_t i = 0 ; i < 64; ++i) {
634 fLightYields[i] = yields->GetBinContent(i+1);
638 void AliVZEROCalibData::InitPMGains()
640 // Initialize the PM gain factors
641 // Read from a separate OCDB entry
642 if (fPMGainsA) return;
644 AliCDBEntry *entry = AliCDBManager::Instance()->Get("VZERO/Calib/PMGains");
645 if (!entry) AliFatal("VZERO PM gains are not found in OCDB !");
646 TH2F *gains = (TH2F*)entry->GetObject();
648 fPMGainsA = new Float_t[64];
649 fPMGainsB = new Float_t[64];
650 for(Int_t i = 0 ; i < 64; ++i) {
651 fPMGainsA[i] = gains->GetBinContent(i+1,1);
652 fPMGainsB[i] = gains->GetBinContent(i+1,2);
656 Float_t AliVZEROCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled)
658 // The method returns actual TDC discri threshold
659 // extracted from the data.
661 // In case scaled flag is set the threshold is scaled
662 // so that to get 4.0 for a FEE threshold of 4.0.
663 // In this way we avoid a change in the slewing correction
664 // for the entire 2010 p-p data.
666 // The method is to be moved to OCDB object.
668 Float_t thr = GetDiscriThr(channel);
674 calThr = (3.1+1.15*thr-1.7);
676 calThr = (3.1-0.3*thr+0.3*thr*thr);
678 if (scaled) calThr *= 4./(3.1+1.15*4.-1.7);