]>
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: AliADCalibData.cxx, */ | |
17 | ||
18 | #include <TMath.h> | |
19 | #include <TObjString.h> | |
20 | #include <TMap.h> | |
21 | #include <TH1F.h> | |
22 | #include <TH2F.h> | |
23 | ||
24 | #include "AliCDBManager.h" | |
25 | #include "AliCDBEntry.h" | |
26 | #include "AliADCalibData.h" | |
27 | #include "AliADConst.h" | |
28 | #include "AliLog.h" | |
29 | ||
30 | ClassImp(AliADCalibData) | |
31 | ||
32 | ||
33 | //________________________________________________________________ | |
34 | AliADCalibData::AliADCalibData(): | |
35 | fLightYields(NULL), | |
36 | fPMGainsA(NULL), | |
37 | fPMGainsB(NULL) | |
38 | { | |
39 | // default constructor | |
40 | ||
41 | for(int t=0; t<16; t++) { | |
42 | fMeanHV[t] = 100.0; | |
43 | fWidthHV[t] = 0.0; | |
44 | fTimeOffset[t] = 5.0; | |
45 | fTimeGain[t] = 1.0; | |
46 | fDeadChannel[t]= kFALSE; | |
47 | fDiscriThr[t] = 2.5; | |
48 | } | |
49 | for(int t=0; t<32; t++) { | |
50 | fPedestal[t] = 0.0; | |
51 | fSigma[t] = 0.0; | |
52 | fADCmean[t] = 0.0; | |
53 | fADCsigma[t] = 0.0; | |
54 | } | |
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 | |
58 | fMatchWindow[i] = 4; | |
59 | fSearchWindow[i] = 16; | |
60 | fTriggerCountOffset[i] = 3247; | |
61 | fRollOver[i] = 3563; | |
62 | } | |
63 | ||
64 | } | |
65 | //________________________________________________________________ | |
66 | void AliADCalibData::Reset() | |
67 | { | |
68 | ||
69 | } | |
70 | ||
71 | //________________________________________________________________ | |
72 | AliADCalibData::AliADCalibData(const char* name) : | |
73 | fLightYields(NULL), | |
74 | fPMGainsA(NULL), | |
75 | fPMGainsB(NULL) | |
76 | { | |
77 | // Constructor | |
78 | TString namst = "Calib_"; | |
79 | namst += name; | |
80 | SetName(namst.Data()); | |
81 | SetTitle(namst.Data()); | |
82 | for(int t=0; t<16; t++) { | |
83 | fMeanHV[t] = 100.0; | |
84 | fWidthHV[t] = 0.0; | |
85 | fTimeOffset[t] = 5.0; | |
86 | fTimeGain[t] = 1.0; | |
87 | fDeadChannel[t]= kFALSE; | |
88 | fDiscriThr[t] = 2.5; | |
89 | } | |
90 | for(int t=0; t<32; t++) { | |
91 | fPedestal[t] = 0.0; | |
92 | fSigma[t] = 0.0; | |
93 | fADCmean[t] = 0.0; | |
94 | fADCsigma[t] = 0.0; | |
95 | } | |
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 | |
99 | fMatchWindow[i] = 4; | |
100 | fSearchWindow[i] = 16; | |
101 | fTriggerCountOffset[i] = 3247; | |
102 | fRollOver[i] = 3563; | |
103 | } | |
104 | } | |
105 | ||
106 | //________________________________________________________________ | |
107 | AliADCalibData::AliADCalibData(const AliADCalibData& calibda) : | |
108 | TNamed(calibda), | |
109 | fLightYields(NULL), | |
110 | fPMGainsA(NULL), | |
111 | fPMGainsB(NULL) | |
112 | { | |
113 | // copy constructor | |
114 | ||
115 | SetName(calibda.GetName()); | |
116 | SetTitle(calibda.GetName()); | |
117 | ||
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); } | |
123 | ||
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); | |
131 | } | |
132 | ||
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); | |
140 | } | |
141 | ||
142 | } | |
143 | ||
144 | //________________________________________________________________ | |
145 | AliADCalibData &AliADCalibData::operator =(const AliADCalibData& calibda) | |
146 | { | |
147 | // assignment operator | |
148 | ||
149 | SetName(calibda.GetName()); | |
150 | SetTitle(calibda.GetName()); | |
151 | ||
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); } | |
157 | ||
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); | |
165 | } | |
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); | |
173 | } | |
174 | ||
175 | return *this; | |
176 | ||
177 | } | |
178 | ||
179 | //________________________________________________________________ | |
180 | AliADCalibData::~AliADCalibData() | |
181 | { | |
182 | // destructor | |
183 | if (fLightYields) | |
184 | delete [] fLightYields; | |
185 | if (fPMGainsA) | |
186 | delete [] fPMGainsA; | |
187 | if (fPMGainsB) | |
188 | delete [] fPMGainsB; | |
189 | } | |
190 | ||
191 | //________________________________________________________________ | |
192 | Int_t AliADCalibData::GetBoardNumber(Int_t channel) | |
193 | { | |
194 | // Get FEE board number | |
195 | // from offline channel index | |
196 | if (channel >= 0 && channel < 16) return (channel); | |
197 | //if (channel >=8 && channel < 16) return (channel / 2); | |
198 | ||
199 | AliErrorClass(Form("Wrong channel index: %d",channel)); | |
200 | return -1; | |
201 | } | |
202 | ||
203 | //________________________________________________________________ | |
204 | Float_t AliADCalibData::GetLightYields(Int_t channel) | |
205 | { | |
206 | // Get the light yield efficiency | |
207 | // for a given channel | |
208 | if (!fLightYields) InitLightYields(); | |
209 | ||
210 | if (channel >= 0 && channel < 64) { | |
211 | return fLightYields[channel]; | |
212 | } | |
213 | ||
214 | AliError(Form("Wrong channel index: %d",channel)); | |
215 | return 0; | |
216 | } | |
217 | ||
218 | //________________________________________________________________ | |
219 | void AliADCalibData::InitLightYields() | |
220 | { | |
221 | // Initialize the light yield factors | |
222 | // Read from a separate OCDB entry | |
223 | if (fLightYields) return; | |
224 | ||
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(); | |
228 | ||
229 | fLightYields = new Float_t[16]; | |
230 | for(Int_t i = 0 ; i < 16; ++i) { | |
231 | fLightYields[i] = yields->GetBinContent(i+1); | |
232 | } | |
233 | } | |
234 | ||
235 | //________________________________________________________________ | |
236 | void AliADCalibData::InitPMGains() | |
237 | { | |
238 | // Initialize the PM gain factors | |
239 | // Read from a separate OCDB entry | |
240 | if (fPMGainsA) return; | |
241 | ||
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(); | |
245 | ||
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); | |
251 | } | |
252 | } | |
253 | ||
254 | //________________________________________________________________ | |
255 | Float_t AliADCalibData::GetGain(Int_t channel) | |
256 | { | |
257 | // Computes the PM gains | |
258 | // Argument passed is the PM number (aliroot numbering) | |
259 | if (!fPMGainsA) InitPMGains(); | |
260 | ||
261 | // High Voltage retrieval from Calibration Data Base: | |
262 | Float_t hv = fMeanHV[channel]; | |
263 | Float_t gain = 0; | |
264 | if (hv>0) | |
265 | gain = TMath::Exp(fPMGainsA[channel]+fPMGainsB[channel]*TMath::Log(hv)); | |
266 | return gain; | |
267 | } | |
268 | ||
269 | //________________________________________________________________ | |
270 | Float_t AliADCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled) | |
271 | { | |
272 | // The method returns actual TDC discri threshold | |
273 | // extracted from the data. | |
274 | // | |
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. | |
279 | // | |
280 | // The method is to be moved to OCDB object. | |
281 | ||
282 | Float_t thr = GetDiscriThr(channel); | |
283 | ||
284 | Float_t calThr = 0; | |
285 | if (thr <= 1.) | |
286 | calThr = 3.1; | |
287 | else if (thr >= 2.) | |
288 | calThr = (3.1+1.15*thr-1.7); | |
289 | else | |
290 | calThr = (3.1-0.3*thr+0.3*thr*thr); | |
291 | ||
292 | if (scaled) calThr *= 4./(3.1+1.15*4.-1.7); | |
293 | ||
294 | return calThr; | |
295 | } |