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);