]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AD/AliADCalibData.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / AD / AliADCalibData.cxx
CommitLineData
5e319bd5 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
aa8120bb 18#include <TMath.h>
19#include <TObjString.h>
20#include <TMap.h>
21#include <TH1F.h>
22#include <TH2F.h>
5e319bd5 23
aa8120bb 24#include "AliCDBManager.h"
25#include "AliCDBEntry.h"
5e319bd5 26#include "AliADCalibData.h"
aa8120bb 27#include "AliADConst.h"
28#include "AliLog.h"
5e319bd5 29
30ClassImp(AliADCalibData)
31
32
33//________________________________________________________________
aa8120bb 34AliADCalibData::AliADCalibData():
35 fLightYields(NULL),
36 fPMGainsA(NULL),
37 fPMGainsB(NULL)
5e319bd5 38{
aa8120bb 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 }
5e319bd5 63
aa8120bb 64}
5e319bd5 65//________________________________________________________________
66void AliADCalibData::Reset()
67{
68
69}
70
71//________________________________________________________________
72AliADCalibData::AliADCalibData(const char* name) :
aa8120bb 73 fLightYields(NULL),
74 fPMGainsA(NULL),
75 fPMGainsB(NULL)
5e319bd5 76{
aa8120bb 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 }
5e319bd5 104}
105
106//________________________________________________________________
107AliADCalibData::AliADCalibData(const AliADCalibData& calibda) :
aa8120bb 108 TNamed(calibda),
109 fLightYields(NULL),
110 fPMGainsA(NULL),
111 fPMGainsB(NULL)
5e319bd5 112{
113// copy constructor
114
115 SetName(calibda.GetName());
116 SetTitle(calibda.GetName());
117
aa8120bb 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);
5e319bd5 140 }
aa8120bb 141
5e319bd5 142}
5e319bd5 143
5e319bd5 144//________________________________________________________________
145AliADCalibData &AliADCalibData::operator =(const AliADCalibData& calibda)
146{
147// assignment operator
148
149 SetName(calibda.GetName());
150 SetTitle(calibda.GetName());
aa8120bb 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);
5e319bd5 173 }
aa8120bb 174
5e319bd5 175 return *this;
aa8120bb 176
5e319bd5 177}
5e319bd5 178
aa8120bb 179//________________________________________________________________
180AliADCalibData::~AliADCalibData()
181{
182 // destructor
183 if (fLightYields)
184 delete [] fLightYields;
185 if (fPMGainsA)
186 delete [] fPMGainsA;
187 if (fPMGainsB)
188 delete [] fPMGainsB;
189}
5e319bd5 190
aa8120bb 191//________________________________________________________________
192Int_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);
5e319bd5 198
aa8120bb 199 AliErrorClass(Form("Wrong channel index: %d",channel));
200 return -1;
5e319bd5 201}
5e319bd5 202
203//________________________________________________________________
aa8120bb 204Float_t AliADCalibData::GetLightYields(Int_t channel)
5e319bd5 205{
aa8120bb 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 }
5e319bd5 213
aa8120bb 214 AliError(Form("Wrong channel index: %d",channel));
215 return 0;
216}
5e319bd5 217
218//________________________________________________________________
aa8120bb 219void AliADCalibData::InitLightYields()
5e319bd5 220{
aa8120bb 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 }
5e319bd5 233}
234
aa8120bb 235//________________________________________________________________
236void AliADCalibData::InitPMGains()
5e319bd5 237{
aa8120bb 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 }
5e319bd5 252}
253
aa8120bb 254//________________________________________________________________
255Float_t AliADCalibData::GetGain(Int_t channel)
5e319bd5 256{
aa8120bb 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;
5e319bd5 267}
268
aa8120bb 269//________________________________________________________________
270Float_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}