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 "AliDCSValue.h"
25 #include "AliCDBManager.h"
26 #include "AliCDBEntry.h"
27 #include "AliADDataDCS.h"
28 #include "AliADCalibData.h"
29 #include "AliADConst.h"
32 ClassImp(AliADCalibData)
35 //________________________________________________________________
36 AliADCalibData::AliADCalibData():
44 fBBAForBGThreshold(0) ,
45 fBBCForBGThreshold(0) ,
51 // default constructor
53 for(int t=0; t<16; t++) {
58 fDeadChannel[t]= kFALSE;
61 for(int t=0; t<32; t++) {
67 for(int i=0; i<kNCIUBoards ;i++) {
68 fTimeResolution[i] = 25./256.; // Default time resolution
69 fWidthResolution[i] = 25./64.; // Default time width resolution
71 fSearchWindow[i] = 16;
72 fTriggerCountOffset[i] = 3247;
75 for(int i=0; i<kNCIUBoards ;i++) {
76 fClk1Win1[i] = fClk1Win2[i] = 0;
77 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;
78 fClk2Win1[i] = fClk2Win2[i] = 0;
79 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;
80 fLatchWin1[i] = fLatchWin2[i] = 0;
81 fResetWin1[i] = fResetWin2[i] = 0;
82 fPedestalSubtraction[i] = kFALSE;
84 for(Int_t j = 0; j < 16; ++j) {
85 fEnableCharge[j] = fEnableTiming[j] = kFALSE;
86 fPedestalOdd[j] = fPedestalEven[j] = 0;
87 fPedestalCutOdd[j] = fPedestalCutEven[j] = 0;
89 for(Int_t i = 0; i < 5; ++i) fTriggerSelected[i] = 0;
92 //________________________________________________________________
93 void AliADCalibData::Reset()
98 //________________________________________________________________
99 AliADCalibData::AliADCalibData(const char* name) :
107 fBBAForBGThreshold(0) ,
108 fBBCForBGThreshold(0) ,
115 TString namst = "Calib_";
117 SetName(namst.Data());
118 SetTitle(namst.Data());
119 for(int t=0; t<16; t++) {
122 fTimeOffset[t] = 5.0;
124 fDeadChannel[t]= kFALSE;
127 for(int t=0; t<32; t++) {
133 for(int i=0; i<kNCIUBoards ;i++) {
134 fTimeResolution[i] = 25./256.; // Default time resolution in ns / channel
135 fWidthResolution[i] = 25./64.; // Default time width resolution in ns / channel
137 fSearchWindow[i] = 16;
138 fTriggerCountOffset[i] = 3247;
141 for(int i=0; i<kNCIUBoards ;i++) {
142 fClk1Win1[i] = fClk1Win2[i] = 0;
143 fDelayClk1Win1[i] = fDelayClk1Win2[i] = 0;
144 fClk2Win1[i] = fClk2Win2[i] = 0;
145 fDelayClk2Win1[i] = fDelayClk2Win2[i] = 0;
146 fLatchWin1[i] = fLatchWin2[i] = 0;
147 fResetWin1[i] = fResetWin2[i] = 0;
148 fPedestalSubtraction[i] = kFALSE;
150 for(Int_t j = 0; j < 16; ++j) {
151 fEnableCharge[j] = fEnableTiming[j] = kFALSE;
152 fPedestalOdd[j] = fPedestalEven[j] = 0;
153 fPedestalCutOdd[j] = fPedestalCutEven[j] = 0;
155 for(Int_t i = 0; i < 5; ++i) fTriggerSelected[i] = 0;
158 //________________________________________________________________
159 AliADCalibData::AliADCalibData(const AliADCalibData& calibda) :
167 SetName(calibda.GetName());
168 SetTitle(calibda.GetName());
170 for(int t=0; t<32; t++) {
171 fPedestal[t] = calibda.GetPedestal(t);
172 fSigma[t] = calibda.GetSigma(t);
173 fADCmean[t] = calibda.GetADCmean(t);
174 fADCsigma[t] = calibda.GetADCsigma(t); }
176 for(int t=0; t<16; t++) {
177 fMeanHV[t] = calibda.GetMeanHV(t);
178 fWidthHV[t] = calibda.GetWidthHV(t);
179 fTimeOffset[t] = calibda.GetTimeOffset(t);
180 fTimeGain[t] = calibda.GetTimeGain(t);
181 fDeadChannel[t] = calibda.IsChannelDead(t);
182 fDiscriThr[t] = calibda.GetDiscriThr(t);
185 for(int i=0; i<kNCIUBoards ;i++) {
186 fTimeResolution[i] = calibda.GetTimeResolution(i);
187 fWidthResolution[i] = calibda.GetWidthResolution(i);
188 fMatchWindow[i] = calibda.GetMatchWindow(i);
189 fSearchWindow[i] = calibda.GetSearchWindow(i);
190 fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
191 fRollOver[i] = calibda.GetRollOver(i);
196 //________________________________________________________________
197 AliADCalibData &AliADCalibData::operator =(const AliADCalibData& calibda)
199 // assignment operator
201 SetName(calibda.GetName());
202 SetTitle(calibda.GetName());
204 for(int t=0; t<32; t++) {
205 fPedestal[t] = calibda.GetPedestal(t);
206 fSigma[t] = calibda.GetSigma(t);
207 fADCmean[t] = calibda.GetADCmean(t);
208 fADCsigma[t] = calibda.GetADCsigma(t); }
210 for(int t=0; t<16; t++) {
211 fMeanHV[t] = calibda.GetMeanHV(t);
212 fWidthHV[t] = calibda.GetWidthHV(t);
213 fTimeOffset[t] = calibda.GetTimeOffset(t);
214 fTimeGain[t] = calibda.GetTimeGain(t);
215 fDeadChannel[t] = calibda.IsChannelDead(t);
216 fDiscriThr[t] = calibda.GetDiscriThr(t);
218 for(int i=0; i<kNCIUBoards ;i++) {
219 fTimeResolution[i] = calibda.GetTimeResolution(i);
220 fWidthResolution[i] = calibda.GetWidthResolution(i);
221 fMatchWindow[i] = calibda.GetMatchWindow(i);
222 fSearchWindow[i] = calibda.GetSearchWindow(i);
223 fTriggerCountOffset[i] = calibda.GetTriggerCountOffset(i);
224 fRollOver[i] = calibda.GetRollOver(i);
231 //________________________________________________________________
232 AliADCalibData::~AliADCalibData()
236 delete [] fLightYields;
243 //________________________________________________________________
244 Int_t AliADCalibData::GetBoardNumber(Int_t channel)
246 // Get FEE board number
247 // from offline channel index
248 if (channel >= 0 && channel < 8) return (0);
249 if (channel >=8 && channel < 16) return (1);
251 AliErrorClass(Form("Wrong channel index: %d",channel));
255 //________________________________________________________________
256 Float_t AliADCalibData::GetLightYields(Int_t channel)
258 // Get the light yield efficiency
259 // for a given channel
260 if (!fLightYields) InitLightYields();
262 if (channel >= 0 && channel < 16) {
263 return fLightYields[channel];
266 AliError(Form("Wrong channel index: %d",channel));
270 //________________________________________________________________
271 void AliADCalibData::InitLightYields()
273 // Initialize the light yield factors
274 // Read from a separate OCDB entry
275 if (fLightYields) return;
277 AliCDBEntry *entry = AliCDBManager::Instance()->Get("AD/Calib/LightYields");
278 if (!entry) AliFatal("AD light yields are not found in OCDB !");
279 TH1F *yields = (TH1F*)entry->GetObject();
281 fLightYields = new Float_t[16];
282 for(Int_t i = 0 ; i < 16; ++i) {
283 fLightYields[i] = yields->GetBinContent(i+1);
287 //________________________________________________________________
288 void AliADCalibData::InitPMGains()
290 // Initialize the PM gain factors
291 // Read from a separate OCDB entry
292 if (fPMGainsA) return;
294 AliCDBEntry *entry = AliCDBManager::Instance()->Get("AD/Calib/PMGains");
295 if (!entry) AliFatal("AD PM gains are not found in OCDB !");
296 TH2F *gains = (TH2F*)entry->GetObject();
298 fPMGainsA = new Float_t[16];
299 fPMGainsB = new Float_t[16];
300 for(Int_t i = 0 ; i < 16; ++i) {
301 fPMGainsA[i] = gains->GetBinContent(i+1,1);
302 fPMGainsB[i] = gains->GetBinContent(i+1,2);
306 //________________________________________________________________
307 Float_t AliADCalibData::GetGain(Int_t channel)
309 // Computes the PM gains
310 // Argument passed is the PM number (aliroot numbering)
311 if (!fPMGainsA) InitPMGains();
313 // High Voltage retrieval from Calibration Data Base:
314 Float_t hv = fMeanHV[channel];
317 //gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv));
318 gain = TMath::Power(hv/fPMGainsA[channel],fPMGainsB[channel])*kChargePerADC/kNPhotonsPerMIP;
322 //________________________________________________________________
323 Float_t AliADCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled)
325 // The method returns actual TDC discri threshold
326 // extracted from the data.
328 // In case scaled flag is set the threshold is scaled
329 // so that to get 4.0 for a FEE threshold of 4.0.
330 // In this way we avoid a change in the slewing correction
331 // for the entire 2010 p-p data.
333 // The method is to be moved to OCDB object.
335 Float_t thr = GetDiscriThr(channel);
341 calThr = (3.1+1.15*thr-1.7);
343 calThr = (3.1-0.3*thr+0.3*thr*thr);
345 if (scaled) calThr *= 4./(3.1+1.15*4.-1.7);
349 //_____________________________________________________________________________
350 void AliADCalibData::FillDCSData(AliADDataDCS * data){
351 // Set all parameters from the data get by the shuttle
352 TMap * params = data->GetFEEParameters();
354 TObjString* aliasName;
356 while (( aliasName = (TObjString*) iter.Next() )) {
357 AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName);
360 val = aValue->GetInt();
361 AliInfo(Form("%s : %d",aliasName->String().Data(), val));
362 SetParameter(aliasName->String(),val);
366 SetMeanHV(data->GetMeanHV());
367 SetWidthHV(data->GetWidthHV());
368 SetDeadMap(data->GetDeadMap());
371 //_____________________________________________________________________________
372 void AliADCalibData::SetParameter(TString name, Int_t val){
373 // Set given parameter
378 TSeqCollection* nameSplit = name.Tokenize("/");
379 TObjString * boardName = (TObjString *)nameSplit->At(2);
380 sscanf(boardName->String().Data(),"CIU%d",&iBoard);
382 TString paramName = ((TObjString *)nameSplit->At(3))->String();
383 Char_t channel[2] ; channel[1] = '\0';
384 channel[0] = paramName[paramName.Sizeof()-2];
385 sscanf(channel,"%d",&iChannel);
387 if(name.Contains("TimeResolution")) SetTimeResolution((UShort_t) val,iBoard);
388 else if(name.Contains("WidthResolution")) SetWidthResolution((UShort_t) val,iBoard);
389 else if(name.Contains("MatchWindow")) SetMatchWindow((UInt_t) val,iBoard);
390 else if(name.Contains("SearchWindow")) SetSearchWindow((UInt_t) val,iBoard);
391 else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard);
392 else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard);
393 else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1));
394 else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-1040.)/112.,iBoard,(iChannel-1));
396 else if(name.Contains("DelayClk1Win1")) SetDelayClk1Win1((UShort_t) val,iBoard);
397 else if(name.Contains("Clk1Win1")) SetClk1Win1((UShort_t) val,iBoard);
398 else if(name.Contains("DelayClk1Win2")) SetDelayClk1Win2((UShort_t) val,iBoard);
399 else if(name.Contains("Clk1Win2")) SetClk1Win2((UShort_t) val,iBoard);
400 else if(name.Contains("DelayClk2Win1")) SetDelayClk2Win1((UShort_t) val,iBoard);
401 else if(name.Contains("Clk2Win1")) SetClk2Win1((UShort_t) val,iBoard);
402 else if(name.Contains("DelayClk2Win2")) SetDelayClk2Win2((UShort_t) val,iBoard);
403 else if(name.Contains("Clk2Win2")) SetClk2Win2((UShort_t) val,iBoard);
404 else if(name.Contains("LatchWin1")) SetLatchWin1((UShort_t) val,iBoard);
405 else if(name.Contains("LatchWin2")) SetLatchWin2((UShort_t) val,iBoard);
406 else if(name.Contains("ResetWin1")) SetResetWin1((UShort_t) val,iBoard);
407 else if(name.Contains("ResetWin2")) SetResetWin2((UShort_t) val,iBoard);
408 else if(name.Contains("PedestalSubtraction")) SetPedestalSubtraction((Bool_t) val,iBoard);
409 else if(name.Contains("BBAThreshold")) SetBBAThreshold((UShort_t) val);
410 else if(name.Contains("BBCThreshold")) SetBBCThreshold((UShort_t) val);
411 else if(name.Contains("BGAThreshold")) SetBGAThreshold((UShort_t) val);
412 else if(name.Contains("BGCThreshold")) SetBGCThreshold((UShort_t) val);
413 else if(name.Contains("BBAForBGThreshold")) SetBBAForBGThreshold((UShort_t) val);
414 else if(name.Contains("BBCForBGThreshold")) SetBBCForBGThreshold((UShort_t) val);
415 else if(name.Contains("MultADAThrLow")) SetMultADAThrLow((UShort_t) val);
416 else if(name.Contains("MultADAThrHigh")) SetMultADAThrHigh((UShort_t) val);
417 else if(name.Contains("MultADCThrLow")) SetMultADCThrLow((UShort_t) val);
418 else if(name.Contains("MultADCThrHigh")) SetMultADCThrHigh((UShort_t) val);
419 else if(name.Contains("TriggerSelect")) SetTriggerSelected((UShort_t) val, iChannel-1 );
420 else if(name.Contains("EnableCharge")) SetEnableCharge((Bool_t) val, iBoard , iChannel-1);
421 else if(name.Contains("EnableTiming")) SetEnableTiming((Bool_t) val, iBoard , iChannel-1);
422 else if(name.Contains("PedOdd")) SetOnlinePedestal((UShort_t) val, 1, iBoard, iChannel-1);
423 else if(name.Contains("PedEven")) SetOnlinePedestal((UShort_t) val, 0, iBoard, iChannel-1);
424 else if(name.Contains("PedCutOdd")) SetOnlinePedestalCut((UShort_t) val, 1, iBoard, iChannel-1);
425 else if(name.Contains("PedCutEven")) SetOnlinePedestalCut((UShort_t) val, 0, iBoard, iChannel-1);
427 else AliError(Form("No Setter found for FEE parameter : %s",name.Data()));
432 //________________________________________________________________
433 void AliADCalibData::SetPedestal(const Float_t* Pedestal)
435 if(Pedestal) for(int t=0; t<32; t++) fPedestal[t] = Pedestal[t];
436 else for(int t=0; t<32; t++) fPedestal[t] = 0.0;
439 //________________________________________________________________
440 void AliADCalibData::SetSigma(const Float_t* Sigma)
442 if(Sigma) for(int t=0; t<32; t++) fSigma[t] = Sigma[t];
443 else for(int t=0; t<32; t++) fSigma[t] = 0.0;
446 //________________________________________________________________
447 void AliADCalibData::SetADCmean(const Float_t* ADCmean)
449 if(ADCmean) for(int t=0; t<32; t++) fADCmean[t] = ADCmean[t];
450 else for(int t=0; t<32; t++) fADCmean[t] = 0.0;
453 //________________________________________________________________
454 void AliADCalibData::SetADCsigma(const Float_t* ADCsigma)
456 if(ADCsigma) for(int t=0; t<32; t++) fADCsigma[t] = ADCsigma[t];
457 else for(int t=0; t<32; t++) fADCsigma[t] = 0.0;
460 //________________________________________________________________
461 void AliADCalibData::SetMeanHV(const Float_t* MeanHV)
463 if(MeanHV) for(int t=0; t<16; t++) fMeanHV[t] = MeanHV[t];
464 else for(int t=0; t<16; t++) fMeanHV[t] = 0.0;
467 //________________________________________________________________
468 void AliADCalibData::SetWidthHV(const Float_t* WidthHV)
470 if(WidthHV) for(int t=0; t<16; t++) fWidthHV[t] = WidthHV[t];
471 else for(int t=0; t<16; t++) fWidthHV[t] = 0.0;
474 //________________________________________________________________
475 void AliADCalibData::SetDeadMap(const Bool_t* deadMap)
477 if(deadMap) for(int t=0; t<16; t++) fDeadChannel[t] = deadMap[t];
478 else for(int t=0; t<16; t++) fDeadChannel[t] = kFALSE;
481 //________________________________________________________________
482 void AliADCalibData::SetTimeOffset(Float_t val, Int_t board, Int_t channel)
484 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
487 AliInfo(Form("Time offset for channel %d set to %f",ch,fTimeOffset[ch]));
490 AliError("Board/Channel numbers are not valid");
493 //________________________________________________________________
494 void AliADCalibData::SetTimeOffset(const Float_t* TimeOffset)
496 if(TimeOffset) for(int t=0; t<16; t++) fTimeOffset[t] = TimeOffset[t];
497 else for(int t=0; t<16; t++) fTimeOffset[t] = 5.0;
499 //________________________________________________________________
500 void AliADCalibData::SetTimeGain(const Float_t* TimeGain)
502 if(TimeGain) for(int t=0; t<16; t++) fTimeGain[t] = TimeGain[t];
503 else for(int t=0; t<16; t++) fTimeGain[t] = 0.0;
505 //________________________________________________________________
506 void AliADCalibData::SetTimeResolution(UShort_t *resols){
507 // Set Time Resolution of the TDC
508 if(resols) for(int t=0; t<kNCIUBoards; t++) SetTimeResolution(resols[t],t);
509 else AliError("Time Resolution not defined.");
512 //________________________________________________________________
513 void AliADCalibData::SetTimeResolution(UShort_t resol, Int_t board)
515 // Set Time Resolution of the TDC
516 if((board>=0) && (board<kNCIUBoards)) {
519 fTimeResolution[board] = 25./256.;
522 fTimeResolution[board] = 25./128.;
525 fTimeResolution[board] = 25./64.;
528 fTimeResolution[board] = 25./32.;
531 fTimeResolution[board] = 25./16.;
534 fTimeResolution[board] = 25./8.;
537 fTimeResolution[board] = 6.25;
540 fTimeResolution[board] = 12.5;
543 AliInfo(Form("Time Resolution of board %d set to %f",board,fTimeResolution[board]));
544 } else AliError(Form("Board %d is not valid",board));
546 //________________________________________________________________
547 void AliADCalibData::SetWidthResolution(UShort_t *resols){
548 // Set Time Width Resolution of the TDC
549 if(resols) for(int t=0; t<kNCIUBoards; t++) SetWidthResolution(resols[t],t);
550 else AliError("Width Resolution not defined.");
553 //________________________________________________________________
554 void AliADCalibData::SetWidthResolution(UShort_t resol, Int_t board)
556 // Set Time Width Resolution of the TDC
557 if((board>=0) && (board<kNCIUBoards)){
560 fWidthResolution[board] = 25./256.;
563 fWidthResolution[board] = 25./128.;
566 fWidthResolution[board] = 25./64.;
569 fWidthResolution[board] = 25./32.;
572 fWidthResolution[board] = 25./16.;
575 fWidthResolution[board] = 25./8.;
578 fWidthResolution[board] = 6.25;
581 fWidthResolution[board] = 12.5;
584 fWidthResolution[board] = 25.;
587 fWidthResolution[board] = 50.;
590 fWidthResolution[board] = 100.;
593 fWidthResolution[board] = 200.;
596 fWidthResolution[board] = 400.;
599 fWidthResolution[board] = 800.;
603 AliInfo(Form("Width Resolution of board %d set to %f",board,fWidthResolution[board]));
604 }else AliError(Form("Board %d is not valid",board));
607 //________________________________________________________________
608 void AliADCalibData::SetMatchWindow(UInt_t *windows)
610 // Set Match window of the HPTDC
611 // The units are 25ns
612 if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetMatchWindow(windows[b],b);
613 else AliError("Match windows not defined.");
616 //________________________________________________________________
617 void AliADCalibData::SetMatchWindow(UInt_t window, Int_t board)
619 // Set Match window of the HPTDC
620 // The units are 25ns
621 if((board>=0) && (board<kNCIUBoards)){
622 fMatchWindow[board] = window;
623 AliInfo(Form("Match window of board %d set to %d",board,fMatchWindow[board]));
626 AliError(Form("Board %d is not valid",board));
629 //________________________________________________________________
630 void AliADCalibData::SetSearchWindow(UInt_t *windows)
632 // Set Search window of the HPTDC
633 // The units are 25ns
634 if(windows) for(Int_t b=0; b<kNCIUBoards; b++) SetSearchWindow(windows[b],b);
635 else AliError("Search windows not defined.");
638 //________________________________________________________________
639 void AliADCalibData::SetSearchWindow(UInt_t window, Int_t board)
641 // Set Search window of the HPTDC
642 // The units are 25ns
643 if((board>=0) && (board<kNCIUBoards)){
644 fSearchWindow[board] = window;
645 AliInfo(Form("Search window of board %d set to %d",board,fSearchWindow[board]));
648 AliError(Form("Board %d is not valid",board));
651 //________________________________________________________________
652 void AliADCalibData::SetTriggerCountOffset(UInt_t *offsets)
654 // Set trigger-count offset of the HPTDC
655 // The units are 25ns
656 if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetTriggerCountOffset(offsets[b],b);
657 else AliError("Trigger count offsets not defined.");
660 //________________________________________________________________
661 void AliADCalibData::SetTriggerCountOffset(UInt_t offset, Int_t board)
663 // Set trigger-count offsets of the HPTDC
664 // The units are 25ns
665 if((board>=0) && (board<kNCIUBoards)){
666 fTriggerCountOffset[board] = offset;
667 AliInfo(Form("Trigger-count offset of board %d set to %d",board,fTriggerCountOffset[board]));
670 AliError(Form("Board %d is not valid",board));
673 //________________________________________________________________
674 void AliADCalibData::SetRollOver(UInt_t *offsets)
676 // Set Roll-over of the HPTDC
677 // The units are 25ns
678 if(offsets) for(Int_t b=0; b<kNCIUBoards; b++) SetRollOver(offsets[b],b);
679 else AliError("Roll-over offsets not defined.");
682 //________________________________________________________________
683 void AliADCalibData::SetRollOver(UInt_t offset, Int_t board)
685 // Set Roll-over of the HPTDC
686 // The units are 25ns
687 if((board>=0) && (board<kNCIUBoards)){
688 fRollOver[board] = offset;
689 AliInfo(Form("Roll-over offset of board %d set to %d",board,fRollOver[board]));
692 AliError(Form("Board %d is not valid",board));
695 //________________________________________________________________
696 void AliADCalibData::SetDiscriThr(Float_t thr, Int_t board, Int_t channel)
698 // Set the TDC discriminator
699 // threshold values expressed in units of ADC
700 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
704 AliInfo(Form("Discriminator threshold for channel %d set to %f",ch,fDiscriThr[ch]));
707 AliWarning(Form("Ignore wrong threshold value (%f) for channel %d !",thr,ch));
711 AliError("Board/Channel numbers are not valid");
714 //________________________________________________________________
715 void AliADCalibData::SetDiscriThr(const Float_t* thresholds)
717 // Set the TDC discriminator
718 // threshold values expressed in units of ADC
719 if(thresholds) for(int t=0; t<16; t++) fDiscriThr[t] = thresholds[t];
720 else for(int t=0; t<16; t++) fDiscriThr[t] = 2.5;
724 //________________________________________________________________
725 void AliADCalibData::SetOnlinePedestalCut(UShort_t val,Int_t integrator, Int_t channel)
727 // Set Pedestal Cut of individual channel
728 if(channel>=0 && channel<16) {
729 if(integrator) fPedestalCutOdd[channel] = val;
730 else fPedestalCutEven[channel] = val;
731 } else AliError(Form("Impossible to write at : Channel %d",channel));
733 //________________________________________________________________
734 void AliADCalibData::SetOnlinePedestalCut(UShort_t val,Int_t integrator, Int_t board, Int_t channel)
736 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
738 if(integrator) fPedestalCutOdd[ch] = val;
739 else fPedestalCutEven[ch] = val;
742 AliError("Board/Channel numbers are not valid");
744 //________________________________________________________________
745 UShort_t AliADCalibData::GetOnlinePedestalCut(Int_t integrator, Int_t channel)
747 // Get Pedestal Cut of individual channel
748 if(channel>=0 && channel<16) {
749 if(integrator) return(fPedestalCutOdd[channel]);
750 else return(fPedestalCutEven[channel]);
751 }else AliError(Form("Impossible to read at : Channel %d",channel));
754 //________________________________________________________________
755 void AliADCalibData::SetOnlinePedestal(UShort_t val, Int_t integrator, Int_t channel)
757 // Set Pedestal of individual channel
758 if(channel>=0 && channel<16) {
759 if(integrator) fPedestalOdd[channel] = val;
760 else fPedestalEven[channel] = val;
761 } else AliError(Form("Impossible to write at : Channel %d ; Integrator %d ",channel,integrator));
763 //________________________________________________________________
764 void AliADCalibData::SetOnlinePedestal(UShort_t val,Int_t integrator, Int_t board, Int_t channel)
766 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
768 if(integrator) fPedestalOdd[ch] = val;
769 else fPedestalEven[ch] = val;
772 AliError("Board/Channel numbers are not valid");
774 //________________________________________________________________
775 UShort_t AliADCalibData::GetOnlinePedestal(Int_t integrator, Int_t channel)
777 // Get Pedestal of individual channel
778 if(channel>=0 && channel<16) {
779 if(integrator) return(fPedestalOdd[channel]);
780 else return(fPedestalEven[channel]);
781 } else AliError(Form("Impossible to read at : Channel %d",channel));
784 //________________________________________________________________
785 void AliADCalibData::SetEnableCharge(Bool_t val, Int_t channel)
787 // Set the channels enabled for Charge triggers
788 if(channel>=0 && channel<16) fEnableCharge[channel] = val;
789 else AliError(Form("Impossible to write at : Channel %d",channel));
791 //________________________________________________________________
792 Bool_t AliADCalibData::GetEnableCharge(Int_t channel)
794 // Get the channels enabled for Charge triggers
795 if(channel>=0 && channel<16) return(fEnableCharge[channel]);
796 else AliError(Form("Impossible to read at : Channel %d",channel));
799 //________________________________________________________________
800 void AliADCalibData::SetEnableTiming(Bool_t val, Int_t channel)
802 // Set the channels enabled for Timing triggers
803 if(channel>=0 && channel<16) fEnableTiming[channel] = val;
804 else AliError(Form("Impossible to write at : Channel %d",channel));
806 //________________________________________________________________
807 Bool_t AliADCalibData::GetEnableTiming(Int_t channel)
809 // Get the channels enabled for Timing triggers
810 if(channel>=0 && channel<16) return(fEnableTiming[channel]);
811 else AliError(Form("Impossible to read at : Channel %d",channel));
814 //________________________________________________________________
815 void AliADCalibData::SetEnableCharge(Bool_t val,Int_t board, Int_t channel)
817 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
818 // Set the channels enabled for Charge triggers
819 if(ch>=0) fEnableCharge[ch] = val;
820 else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
822 //________________________________________________________________
823 void AliADCalibData::SetEnableTiming(Bool_t val,Int_t board, Int_t channel)
825 Int_t ch = AliADCalibData::GetOfflineChannelNumber(board,channel);
826 // Set the channels enabled for Timing triggers
827 if(ch>=0) fEnableTiming[ch] = val;
828 else AliError(Form("Impossible to write at : Board %d ; Channel %d",board,channel));
830 //________________________________________________________________
831 void AliADCalibData::SetTriggerSelected(UShort_t trigger, Int_t output)
833 // Set the trigger selected on the outputs to CTP
834 if(output>=0 && output<5) fTriggerSelected[output] = trigger;
835 else AliError(Form("Trigger output number %d not valid",output));
838 //________________________________________________________________
839 void AliADCalibData::SetClk1Win1(UShort_t* clks)
841 // Set Win clock of BB
842 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win1(clks[t],t);
843 else AliError("Profil Clock1 Win1 Not defined.");
845 //________________________________________________________________
846 void AliADCalibData::SetClk2Win1(UShort_t* clks)
848 // Set Win clock of BB
849 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win1(clks[t],t);
850 else AliError("Profil Clock2 Win1 Not defined.");
852 //________________________________________________________________
853 void AliADCalibData::SetClk1Win1(UShort_t clk, Int_t board)
855 // Set Win clock of BB
856 if((board>=0) && (board<kNCIUBoards)) {
857 fClk1Win1[board] = clk;
858 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win1 of board %d is not valid : %d",board,clk));
860 AliError(Form("Impossible to Write at Board %d",board));
863 //________________________________________________________________
864 void AliADCalibData::SetClk2Win1(UShort_t clk, Int_t board)
866 // Set Win clock of BB
867 if((board>=0) && (board<kNCIUBoards)) {
868 fClk2Win1[board] = clk;
869 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win1 of board %d is not valid : %d",board,clk));
871 AliError(Form("Impossible to Write at Board %d",board));
874 //________________________________________________________________
875 void AliADCalibData::SetClk1Win2(UShort_t* clks)
877 // Set Win clock of BG
878 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk1Win2(clks[t],t);
879 else AliError("Profil Clock1 Win2 Not defined.");
881 //________________________________________________________________
882 void AliADCalibData::SetClk2Win2(UShort_t* clks)
884 // Set Win clock of BG
885 if(clks) for(int t=0; t<kNCIUBoards; t++) SetClk2Win2(clks[t],t);
886 else AliError("Profil Clock2 Win2 Not defined.");
888 //________________________________________________________________
889 void AliADCalibData::SetClk1Win2(UShort_t clk, Int_t board)
891 // Set Win clock of BG
892 if((board>=0) && (board<kNCIUBoards)) {
893 fClk1Win2[board] = clk;
894 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock1 Win2 of board %d is not valid : %d",board,clk));
896 AliError(Form("Impossible to Write at Board %d",board));
899 //________________________________________________________________
900 void AliADCalibData::SetClk2Win2(UShort_t clk, Int_t board)
902 // Set Win clock of BG
903 if((board>=0) && (board<kNCIUBoards)) {
904 fClk2Win2[board] = clk;
905 if(!IsClkValid(clk)) AliWarning(Form("Profil Clock2 Win2 of board %d is not valid : %d",board,clk));
907 AliError(Form("Impossible to Write at Board %d",board));
910 //________________________________________________________________
911 void AliADCalibData::SetDelayClk1Win1(UShort_t* delays)
913 // Set Delay for Win clock of BB
914 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win1(delays[t],t);
915 else AliError("Profil Clock1 Win1 Delays Not defined.");
917 //________________________________________________________________
918 void AliADCalibData::SetDelayClk1Win1(UShort_t delay, Int_t board)
920 // Set Delay for Win clock of BB
922 AliWarning(Form("Profil Clock1 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
923 delay = delay & 0x3FF;
925 if((board>=0) && (board<kNCIUBoards)) fDelayClk1Win1[board] = delay;
926 else AliError(Form("Trying to write out of the array Board = %d",board));
928 //________________________________________________________________
929 void AliADCalibData::SetDelayClk2Win1(UShort_t* delays)
931 // Set Delay for Win clock of BB
932 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win1(delays[t],t);
933 else AliError("Profil Clock2 Win1 Delays Not defined.");
935 //________________________________________________________________
936 void AliADCalibData::SetDelayClk2Win1(UShort_t delay, Int_t board)
938 // Set Delay for Win clock of BB
940 AliWarning(Form("Profil Clock2 Win1 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
941 delay = delay & 0x3FF;
943 if((board>=0) && (board<kNCIUBoards)) fDelayClk2Win1[board] = delay;
944 else AliError(Form("Trying to write out of the array Board = %d",board));
946 //________________________________________________________________
947 void AliADCalibData::SetDelayClk1Win2(UShort_t* delays)
949 // Set Delay for Win clock of BG
950 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk1Win2(delays[t],t);
951 else AliError("Profil Clock1 Win2 Delays Not defined.");
953 //________________________________________________________________
954 void AliADCalibData::SetDelayClk1Win2(UShort_t delay, Int_t board)
956 // Set Delay for Win clock of BG
958 AliWarning(Form("Profil Clock1 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
959 delay = delay & 0x3FF;
961 if((board>=0) && (board<kNCIUBoards)) fDelayClk1Win2[board] = delay;
962 else AliError(Form("Trying to write out of the array Board = %d",board));
964 //________________________________________________________________
965 void AliADCalibData::SetDelayClk2Win2(UShort_t* delays)
967 // Set Delay for Win clock of BG
968 if(delays) for(int t=0; t<kNCIUBoards; t++) SetDelayClk2Win2(delays[t],t);
969 else AliError("Profil Clock2 Win2 Delays Not defined.");
971 //________________________________________________________________
972 void AliADCalibData::SetDelayClk2Win2(UShort_t delay, Int_t board)
974 // Set Delay for Win clock of BG
976 AliWarning(Form("Profil Clock2 Win2 Delay of board %d should be less 1023 is currently %d. Truncated to the first 10 bits",board, delay));
977 delay = delay & 0x3FF;
979 if((board>=0) && (board<kNCIUBoards)) fDelayClk2Win2[board] = delay;
980 else AliError(Form("Trying to write out of the array Board = %d",board));
982 //________________________________________________________________
983 void AliADCalibData::SetLatchWin1(UShort_t *latchs){
984 // Set Latch Win clock for BB
985 if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin1(latchs[t],t);
986 else AliError("Latch Win1 profil Not defined.");
988 //________________________________________________________________
989 void AliADCalibData::SetLatchWin1(UShort_t latch, Int_t board)
991 // Set Latch Win clock for BB
992 if((board>=0) && (board<kNCIUBoards)) {
993 fLatchWin1[board] = latch;
994 if(!IsClkValid(latch)) AliWarning(Form("Latch Win1 of board %d is not valid : %d",board,latch));
996 AliError(Form("Impossible to Write at Board %d",board));
999 //________________________________________________________________
1000 void AliADCalibData::SetLatchWin2(UShort_t *latchs){
1001 // Set Latch Win clock for BG
1002 if(latchs) for(int t=0; t<kNCIUBoards; t++) SetLatchWin2(latchs[t],t);
1003 else AliError("Latch Win2 profil Not defined.");
1005 //________________________________________________________________
1006 void AliADCalibData::SetLatchWin2(UShort_t latch, Int_t board)
1008 // Set Latch Win clock for BG
1009 if((board>=0) && (board<kNCIUBoards)) {
1010 fLatchWin2[board] = latch;
1011 if(!IsClkValid(latch)) AliWarning(Form("Latch Win2 of board %d is not valid : %d",board,latch));
1013 AliError(Form("Impossible to Write at Board %d",board));
1016 //________________________________________________________________
1017 void AliADCalibData::SetResetWin1(UShort_t *resets){
1018 // Set Reset Win clock for BB
1019 if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin1(resets[t],t);
1020 else AliError("Reset Win1 profil Not defined.");
1022 //________________________________________________________________
1023 void AliADCalibData::SetResetWin1(UShort_t reset, Int_t board)
1025 // Set Reset Win clock for BB
1026 if((board>=0) && (board<kNCIUBoards)) {
1027 fResetWin1[board] = reset;
1028 if(!IsClkValid(reset)) AliWarning(Form("Reset Win1 of board %d is not valid : %d",board,reset));
1030 AliError(Form("Impossible to Write at Board %d",board));
1033 //________________________________________________________________
1034 void AliADCalibData::SetResetWin2(UShort_t *resets){
1035 // Set Reset Win clock for BG
1036 if(resets) for(int t=0; t<kNCIUBoards; t++) SetResetWin2(resets[t],t);
1037 else AliError("Reset Win2 profil Not defined.");
1039 //________________________________________________________________
1040 void AliADCalibData::SetResetWin2(UShort_t reset, Int_t board)
1042 // Set Reset Win clock for BG
1043 if((board>=0) && (board<kNCIUBoards)) {
1044 fResetWin2[board] = reset;
1045 if(!IsClkValid(reset)) AliWarning(Form("Reset Win2 of board %d is not valid : %d",board,reset));
1047 AliError(Form("Impossible to Write at Board %d",board));
1050 //________________________________________________________________
1051 void AliADCalibData::SetPedestalSubtraction(Bool_t *peds){
1052 // Set Pedestal Subtraction Parameter
1053 if(peds) for(int t=0; t<kNCIUBoards; t++) SetPedestalSubtraction(peds[t],t);
1054 else AliError("Pedestal Subtraction Not defined.");
1057 //________________________________________________________________
1058 void AliADCalibData::SetPedestalSubtraction(Bool_t ped, Int_t board)
1060 // Set Pedestal Subtraction Parameter
1061 if((board>=0) && (board<kNCIUBoards)) fPedestalSubtraction[board] = ped;
1062 else AliError(Form("Board %d is not valid",board));
1065 //________________________________________________________________
1066 Bool_t AliADCalibData::IsClkValid(UShort_t clock) const {
1067 // Check if the given clock has a valid profil.
1069 Bool_t isValid = kTRUE;
1070 Short_t risingEdge = 0;
1071 Short_t fallingEdge = 0;
1072 for(int i=0 ; i<5 ; i++) word[i] = (clock >> i) & 0x1;
1074 if(word[0] != word[4]){
1075 if(word[4]) fallingEdge++;
1078 for(int i=1 ; i<5 ; i++){
1079 if(word[i] != word[i-1]) {
1080 if(word[i-1]) fallingEdge++;
1084 if((fallingEdge>1)||(risingEdge>1)) isValid = kFALSE;
1085 if(((risingEdge==0)&&(fallingEdge==0)) &&(!word[0])) isValid = kFALSE;
1089 //________________________________________________________________
1090 Int_t AliADCalibData::GetOfflineChannelNumber(Int_t board, Int_t channel)
1092 // Get the offline channel number from
1093 // the FEE board and channel indexes
1095 if (board < 0 || board >= 2) {
1096 AliErrorClass(Form("Wrong FEE board number: %d",board));
1099 if (channel < 0 || channel >= 8) {
1100 AliErrorClass(Form("Wrong FEE channel number: %d",channel));
1104 Int_t offCh = (board+1)*channel;
1108 //________________________________________________________________
1109 Int_t AliADCalibData::GetFEEChannelNumber(Int_t channel)
1111 // Get FEE channel number
1112 // from offline channel index
1113 if (channel >= 0 && channel < 16) return ((channel % 8));
1115 AliErrorClass(Form("Wrong channel index: %d",channel));