With this commit the VZERO trigger simulation is recovered. 1. The main change in...
[u/mrichter/AliRoot.git] / VZERO / AliVZERODigitizer.cxx
CommitLineData
9e04c3b6 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
090026bf 16/* $Id$ */
17
b0d2c2d3 18///_________________________________________________________________________
19///
20/// This class constructs Digits out of Hits
21///
22///
9e04c3b6 23
24// --- Standard library ---
9e04c3b6 25
26// --- ROOT system ---
090026bf 27#include <TMath.h>
9e04c3b6 28#include <TTree.h>
fe0adf2a 29#include <TMap.h>
8bd3e27a 30#include <TGeoManager.h>
31#include <TGeoPhysicalNode.h>
32#include <AliGeomManager.h>
e939a978 33#include <TRandom.h>
9672d66e 34#include <TF1.h>
4e2652e8 35#include <TH1F.h>
9e04c3b6 36
37// --- AliRoot header files ---
9e04c3b6 38#include "AliRun.h"
39#include "AliVZERO.h"
40#include "AliVZEROhit.h"
9e04c3b6 41#include "AliRunLoader.h"
42#include "AliLoader.h"
fe0adf2a 43#include "AliGRPObject.h"
9e04c3b6 44#include "AliRunDigitizer.h"
ce7090f5 45#include "AliCDBManager.h"
46#include "AliCDBStorage.h"
47#include "AliCDBEntry.h"
48#include "AliVZEROCalibData.h"
4e2652e8 49#include "AliCTPTimeParams.h"
9e04c3b6 50#include "AliVZEROdigit.h"
b0d2c2d3 51#include "AliVZERODigitizer.h"
9e04c3b6 52
53ClassImp(AliVZERODigitizer)
54
55 AliVZERODigitizer::AliVZERODigitizer()
fe0adf2a 56 :AliDigitizer(),
57 fCalibData(GetCalibData()),
58 fPhotoCathodeEfficiency(0.18),
fe0adf2a 59 fNdigits(0),
60 fDigits(0),
4e2652e8 61 fSignalShape(NULL),
62 fPMResponse(NULL),
63 fSinglePhESpectrum(NULL)
0b2bea8b 64
9e04c3b6 65{
b0d2c2d3 66 // default constructor
67
0b2bea8b 68// fNdigits = 0;
69// fDigits = 0;
70//
71// fPhotoCathodeEfficiency = 0.18;
72// fPMVoltage = 768.0;
73// fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
ce7090f5 74
0b2bea8b 75// fCalibData = GetCalibData();
9672d66e 76
77 fSignalShape = new TF1("VZEROSignalShape",this,&AliVZERODigitizer::SignalShape,0,200,6,"AliVZERODigitizer","SignalShape");
4e2652e8 78 // fSignalShape->SetParameters(0,1.57345e1,-4.25603e-1,2.9,6.40982,3.69339e-01);
81db2705 79 // fSignalShape->SetParameters(1.34330e+00,1.13007e+02,-4.95705e-01,
80 // 3.68911e+00,1.01040e+00, 3.94675e-01);
81 fSignalShape->SetParameters(-1.07335e+00,2.16002e+01,-1.26133e-01,
82 1.41619e+00,5.50334e-01,3.86111e-01);
83
4e2652e8 84 fPMResponse = new TF1("VZEROPMResponse",this,&AliVZERODigitizer::PMResponse,-kPMRespTime,2.*kPMRespTime,0,"AliVZERODigitizer","PMResponse");
85 fSinglePhESpectrum = new TF1("VZEROSinglePhESpectrum",this,&AliVZERODigitizer::SinglePhESpectrum,0,20,0,"AliVZERODigitizer","SinglePhESpectrum");
86
87 // Now get the CTP L0->L1 delay
88 AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
89 if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
90 AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject();
91 Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0;
92
93 AliCDBEntry *entry2 = AliCDBManager::Instance()->Get("VZERO/Calib/TimeDelays");
94 if (!entry2) AliFatal("VZERO time delays are not found in OCDB !");
95 TH1F *delays = (TH1F*)entry2->GetObject();
96
97 for(Int_t i = 0 ; i < 64; ++i) {
98
99 for(Int_t j = 0; j < kNClocks; ++j) fAdc[i][j] = 0;
100 fLeadingTime[i] = fTimeWidth[i] = 0;
101
102 fPmGain[i] = fCalibData->GetGain(i);
103
104 fAdcPedestal[i][0] = fCalibData->GetPedestal(i);
105 fAdcSigma[i][0] = fCalibData->GetSigma(i);
106 fAdcPedestal[i][1] = fCalibData->GetPedestal(i+64);
107 fAdcSigma[i][1] = fCalibData->GetSigma(i+64);
108
51980118 109 Int_t board = AliVZEROCalibData::GetBoardNumber(i);
4e2652e8 110 fNBins[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0+
111 (Float_t)kMaxTDCWidth*fCalibData->GetWidthResolution(board))/
112 fCalibData->GetTimeResolution(board));
113 fNBinsLT[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0)/
114 fCalibData->GetTimeResolution(board));
115 fBinSize[i] = fCalibData->GetTimeResolution(board);
116 fHptdcOffset[i] = (((Float_t)fCalibData->GetTriggerCountOffset(board)-
117 (Float_t)fCalibData->GetRollOver(board))*25.0+
118 fCalibData->GetTimeOffset(i)+
119 l1Delay+
120 delays->GetBinContent(i+1)+
121 kV0Offset);
122
123 fTime[i] = new Float_t[fNBins[i]];
124 memset(fTime[i],0,fNBins[i]*sizeof(Float_t));
125 }
126
9e04c3b6 127}
128
129//____________________________________________________________________________
130 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
0b2bea8b 131 :AliDigitizer(manager),
132 fCalibData(GetCalibData()),
133 fPhotoCathodeEfficiency(0.18),
0b2bea8b 134 fNdigits(0),
fe0adf2a 135 fDigits(0),
4e2652e8 136 fSignalShape(NULL),
137 fPMResponse(NULL),
138 fSinglePhESpectrum(NULL)
0b2bea8b 139
9e04c3b6 140{
141 // constructor
4e2652e8 142 // Initialize OCDB and containers used in the digitization
9e04c3b6 143
9672d66e 144 fSignalShape = new TF1("VZEROSignalShape",this,&AliVZERODigitizer::SignalShape,0,200,6,"AliVZERODigitizer","SignalShape");
4e2652e8 145 // fSignalShape->SetParameters(0,1.57345e1,-4.25603e-1,2.9,6.40982,3.69339e-01);
81db2705 146 // fSignalShape->SetParameters(1.34330e+00,1.13007e+02,-4.95705e-01,
147 // 3.68911e+00,1.01040e+00, 3.94675e-01);
148 fSignalShape->SetParameters(-1.07335e+00,2.16002e+01,-1.26133e-01,
149 1.41619e+00,5.50334e-01,3.86111e-01);
4e2652e8 150 fPMResponse = new TF1("VZEROPMResponse",this,&AliVZERODigitizer::PMResponse,-kPMRespTime,2.*kPMRespTime,0,"AliVZERODigitizer","PMResponse");
151 fSinglePhESpectrum = new TF1("VZEROSinglePhESpectrum",this,&AliVZERODigitizer::SinglePhESpectrum,0,20,0,"AliVZERODigitizer","SinglePhESpectrum");
ce7090f5 152
4e2652e8 153 // Now get the CTP L0->L1 delay
154 AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
155 if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
156 AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject();
157 Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0;
158
159 AliCDBEntry *entry2 = AliCDBManager::Instance()->Get("VZERO/Calib/TimeDelays");
160 if (!entry2) AliFatal("VZERO time delays are not found in OCDB !");
161 TH1F *delays = (TH1F*)entry2->GetObject();
162
163 for(Int_t i = 0 ; i < 64; ++i) {
164
165 for(Int_t j = 0; j < kNClocks; ++j) fAdc[i][j] = 0;
166 fLeadingTime[i] = fTimeWidth[i] = 0;
167
168 fPmGain[i] = fCalibData->GetGain(i);
169
170 fAdcPedestal[i][0] = fCalibData->GetPedestal(i);
171 fAdcSigma[i][0] = fCalibData->GetSigma(i);
172 fAdcPedestal[i][1] = fCalibData->GetPedestal(i+64);
173 fAdcSigma[i][1] = fCalibData->GetSigma(i+64);
174
51980118 175 Int_t board = AliVZEROCalibData::GetBoardNumber(i);
4e2652e8 176 fNBins[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0+
177 (Float_t)kMaxTDCWidth*fCalibData->GetWidthResolution(board))/
178 fCalibData->GetTimeResolution(board));
179 fNBinsLT[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0)/
180 fCalibData->GetTimeResolution(board));
181 fBinSize[i] = fCalibData->GetTimeResolution(board);
182 fHptdcOffset[i] = (((Float_t)fCalibData->GetTriggerCountOffset(board)-
183 (Float_t)fCalibData->GetRollOver(board))*25.0+
184 fCalibData->GetTimeOffset(i)+
185 l1Delay+
186 delays->GetBinContent(i+1)+
187 kV0Offset);
188
189 fTime[i] = new Float_t[fNBins[i]];
190 memset(fTime[i],0,fNBins[i]*sizeof(Float_t));
191 }
9e04c3b6 192}
193
194//____________________________________________________________________________
195 AliVZERODigitizer::~AliVZERODigitizer()
196{
197 // destructor
198
199 if (fDigits) {
200 fDigits->Delete();
201 delete fDigits;
b0d2c2d3 202 fDigits=0;
203 }
9672d66e 204
205 if (fSignalShape) {
206 delete fSignalShape;
207 fSignalShape = NULL;
208 }
4e2652e8 209 if (fPMResponse) {
210 delete fPMResponse;
211 fPMResponse = NULL;
212 }
213 if (fSinglePhESpectrum) {
214 delete fSinglePhESpectrum;
215 fSinglePhESpectrum = NULL;
216 }
217
218 for(Int_t i = 0 ; i < 64; ++i) {
219 if (fTime[i]) delete [] fTime[i];
220 }
9e04c3b6 221}
222
b0d2c2d3 223//_____________________________________________________________________________
224Bool_t AliVZERODigitizer::Init()
9e04c3b6 225{
b0d2c2d3 226 // Initialises the digitizer
9e04c3b6 227
b0d2c2d3 228 // Initialises the Digit array
9e04c3b6 229 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
8bd3e27a 230
b0d2c2d3 231 return kTRUE;
9e04c3b6 232}
233
234//____________________________________________________________________________
b0d2c2d3 235void AliVZERODigitizer::Exec(Option_t* /*option*/)
ce7090f5 236{
b0d2c2d3 237 // Creates digits from hits
ce7090f5 238 fNdigits = 0;
4e2652e8 239
30c4ff64 240 Int_t labels[64][3];
4e2652e8 241 for(Int_t i = 0 ; i < 64; ++i) {
242 memset(fTime[i],0,fNBins[i]*sizeof(Float_t));
243 for(Int_t j = 0; j < kNClocks; ++j) fAdc[i][j] = 0;
244 fLeadingTime[i] = fTimeWidth[i] = 0;
30c4ff64 245 labels[i][0] = labels[i][1] = labels[i][2] = -1;
fad64858 246 }
4e2652e8 247 Float_t integral = fPMResponse->Integral(-kPMRespTime,2.*kPMRespTime);
248 Float_t meansPhE = fSinglePhESpectrum->Mean(0,20);
249
fad64858 250 AliRunLoader* outRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
b0d2c2d3 251 if (!outRunLoader) {
252 Error("Exec", "Can not get output Run Loader");
fad64858 253 return;
254 }
ce7090f5 255
b0d2c2d3 256 AliLoader* outLoader = outRunLoader->GetLoader("VZEROLoader");
fad64858 257
b0d2c2d3 258 if (!outLoader) {
259 Error("Exec", "Can not get output VZERO Loader");
fad64858 260 return;
261 }
b0d2c2d3 262
e539620f 263 const char* mode = "update";
264 if(outRunLoader->GetEventNumber() == 0) mode = "recreate";
265 outLoader->LoadDigits(mode);
fad64858 266
b0d2c2d3 267 if (!outLoader->TreeD()) outLoader->MakeTree("D");
268 outLoader->MakeDigitsContainer();
ce7090f5 269 TTree* treeD = outLoader->TreeD();
b0d2c2d3 270 Int_t bufsize = 16000;
271 treeD->Branch("VZERODigit", &fDigits, bufsize);
c299dbe4 272
b0d2c2d3 273 for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) {
fad64858 274 AliRunLoader* runLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
8bd3e27a 275 AliLoader* loader = runLoader->GetLoader("VZEROLoader");
276 if (!loader) {
277 Error("Exec", "Can not get VZERO Loader for input %d", iInput);
fad64858 278 continue;
279 }
ce7090f5 280
8bd3e27a 281 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
b0d2c2d3 282
8bd3e27a 283 AliVZERO* vzero = (AliVZERO*) runLoader->GetAliRun()->GetDetector("VZERO");
284 if (!vzero) {
285 Error("Exec", "No VZERO detector for input %d", iInput);
fad64858 286 continue;
287 }
9e04c3b6 288
8bd3e27a 289 loader->LoadHits();
290 TTree* treeH = loader->TreeH();
291 if (!treeH) {
292 Error("Exec", "Cannot get TreeH for input %d", iInput);
fad64858 293 continue;
294 }
c299dbe4 295
8bd3e27a 296 TClonesArray* hits = vzero->Hits();
4e2652e8 297
298 // Float_t lightYieldCorr[64] = {0.00707,0.00517,0.00520,0.00537,0.00735,0.00537,0.00733,0.00605,0.00778,0.00749,0.00701,0.00755,0.00732,0.00617,0.00669,0.00525,0.00752,0.00820,0.00797,0.01107,0.01080,0.00889,0.00880,0.01712,0.00866,0.00701,0.00811,0.00602,0.00879,0.00821,0.00861,0.01433,0.00061,0.00032,0.00099,0.00061,0.00034,0.00046,0.00031,0.00122,0.00155,0.00091,0.00032,0.00096,0.00120,0.00067,0.00113,0.00060,0.00158,0.00136,0.00340,0.00066,0.00076,0.00119,0.00129,0.00147,0.00137,0.00117,0.00088,0.00164,0.00128,0.00081,0.00121,0.00250};
299 Float_t lightYieldCorr[64] = {0.01173,0.00874,0.00878,0.00886,0.01151,0.00925,0.01167,0.00983,0.01181,0.01243,0.01115,0.01220,0.01228,0.01053,0.01021,0.00930,0.01270,0.01411,0.01316,0.01894,0.01923,0.01860,0.01738,0.00305,0.01584,0.01251,0.01344,0.00310,0.01302,0.01266,0.01407,0.00338,0.00089,0.00100,0.00130,0.00081,0.00052,0.01230,0.00059,0.02452,0.02980,0.00137,0.01421,0.00116,0.00141,0.00092,0.02480,0.00096,0.00182,0.00174,0.00218,0.00106,0.00116,0.00160,0.00162,0.03097,0.00194,0.00171,0.00132,0.00239,0.00173,0.00118,0.00163,0.00262};
b0d2c2d3 300// Now makes Digits from hits
8bd3e27a 301 Int_t nTracks = (Int_t) treeH->GetEntries();
302 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
8bd3e27a 303 vzero->ResetHits();
304 treeH->GetEvent(iTrack);
305 Int_t nHits = hits->GetEntriesFast();
306 for (Int_t iHit = 0; iHit < nHits; iHit++) {
4e2652e8 307 AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit);
308 Int_t nPhot = hit->Nphot();
309 Int_t cell = hit->Cell();
310 Int_t pmt = Cell2Pmt(cell);
30c4ff64 311 Int_t trackLabel = hit->GetTrack();
312 for(Int_t l = 0; l < 3; ++l) {
313 if (labels[pmt][l] < 0) {
314 labels[pmt][l] = trackLabel;
315 break;
316 }
317 }
4e2652e8 318 Float_t dt_scintillator = gRandom->Gaus(0,kIntTimeRes);
319 Float_t t = dt_scintillator + 1e9*hit->Tof();
320 if (pmt < 32) t += kV0CDelayCables;
321 t += fHptdcOffset[pmt];
322 Int_t nPhE;
323 Float_t prob = lightYieldCorr[pmt]*fPhotoCathodeEfficiency; // Optical losses included!
324 if (nPhot > 100)
d0ff6548 325 nPhE = (Int_t)gRandom->Gaus(prob*Float_t(nPhot)+0.5,
326 sqrt(Float_t(nPhot)*prob*(1.-prob)));
4e2652e8 327 else
328 nPhE = gRandom->Binomial(nPhot,prob);
329 Float_t charge = TMath::Qe()*fPmGain[pmt]*fBinSize[pmt]/integral;
330 for (Int_t iPhE = 0; iPhE < nPhE; ++iPhE) {
331 Float_t tPhE = t + fSignalShape->GetRandom(0,fBinSize[pmt]*Float_t(fNBins[pmt]));
332 Float_t gainVar = fSinglePhESpectrum->GetRandom(0,20)/meansPhE;
333 Int_t firstBin = TMath::Max(0,(Int_t)((tPhE-kPMRespTime)/fBinSize[pmt]));
334 Int_t lastBin = TMath::Min(fNBins[pmt]-1,(Int_t)((tPhE+2.*kPMRespTime)/fBinSize[pmt]));
335 for(Int_t iBin = firstBin; iBin <= lastBin; ++iBin) {
336 Float_t tempT = fBinSize[pmt]*(0.5+iBin)-tPhE;
337 fTime[pmt][iBin] += gainVar*charge*fPMResponse->Eval(tempT);
338 }
339 } // ph.e. loop
340 } // hit loop
341 } // track loop
8bd3e27a 342 loader->UnloadHits();
4e2652e8 343 } // input loop
344
345 Float_t maximum = 0.9*fSignalShape->GetMaximum(0,200); // Not exact, one needs to do this on the convoluted
346 Float_t integral2 = fSignalShape->Integral(0,200); // function. Anyway the effect is small <10% on the 2.5 ADC thr
347 for (Int_t ipmt = 0; ipmt < 64; ++ipmt) {
348 Float_t thr = fCalibData->GetDiscriThr(ipmt)*kChargePerADC*maximum*fBinSize[ipmt]/integral2;
349 Bool_t ltFound = kFALSE, ttFound = kFALSE;
350 for (Int_t iBin = 0; iBin < fNBins[ipmt]; ++iBin) {
351 Float_t t = fBinSize[ipmt]*Float_t(iBin+0.5);
352 if (fTime[ipmt][iBin] > thr) {
353 if (!ltFound && (iBin < fNBinsLT[ipmt])) {
354 ltFound = kTRUE;
355 fLeadingTime[ipmt] = t;
356 }
357 }
358 else {
359 if (ltFound) {
360 if (!ttFound) {
361 ttFound = kTRUE;
362 fTimeWidth[ipmt] = t - fLeadingTime[ipmt];
363 }
364 }
365 }
d0ff6548 366 Float_t tadc = t - kClockOffset - fCalibData->GetTimeOffset(ipmt);
367 Int_t clock = kNClocks/2 - Int_t(tadc/25.0);
4e2652e8 368 if (clock >= 0 && clock < kNClocks)
369 fAdc[ipmt][clock] += fTime[ipmt][iBin]/kChargePerADC;
370 }
51980118 371 Int_t board = AliVZEROCalibData::GetBoardNumber(ipmt);
4e2652e8 372 if (ltFound && ttFound) {
373 fTimeWidth[ipmt] = fCalibData->GetWidthResolution(board)*
374 Float_t(Int_t(fTimeWidth[ipmt]/fCalibData->GetWidthResolution(board)));
375 if (fTimeWidth[ipmt] < Float_t(kMinTDCWidth)*fCalibData->GetWidthResolution(board))
376 fTimeWidth[ipmt] = Float_t(kMinTDCWidth)*fCalibData->GetWidthResolution(board);
377 if (fTimeWidth[ipmt] > Float_t(kMaxTDCWidth)*fCalibData->GetWidthResolution(board))
378 fTimeWidth[ipmt] = Float_t(kMaxTDCWidth)*fCalibData->GetWidthResolution(board);
379 }
380 }
b0d2c2d3 381
4e2652e8 382 Int_t evenOrOdd = gRandom->Integer(2);
383 for (Int_t j=0; j<64; ++j){
384 for (Int_t iClock = 0; iClock < kNClocks; ++iClock) {
385 Int_t integrator = (iClock + evenOrOdd) % 2;
386 fAdc[j][iClock] += gRandom->Gaus(fAdcPedestal[j][integrator], fAdcSigma[j][integrator]);
387 }
388 }
20277079 389
4e2652e8 390 // Now add digits to the digit Tree
391
30c4ff64 392 Short_t *chargeADC = new Short_t[kNClocks];
4e2652e8 393 for (Int_t i=0; i<64; i++) {
4e2652e8 394 Float_t totADC = 0;
30c4ff64 395 for (Int_t j = 0; j < kNClocks; ++j) {
4e2652e8 396 Int_t tempadc = Int_t(fAdc[i][j]);
397 if (tempadc > 1023) tempadc = 1023;
30c4ff64 398 chargeADC[j] = tempadc;
399 if (j >= 8 && j <= 11) {
400 Int_t integrator = (j + evenOrOdd) % 2;
401 if ((Float_t(tempadc) - fAdcPedestal[i][integrator]) > (2.*fAdcSigma[i][integrator]))
402 totADC += (Float_t(tempadc) - fAdcPedestal[i][integrator]);
403 }
4e2652e8 404 }
405 totADC += fAdcPedestal[i][(10+evenOrOdd)%2];
30c4ff64 406 AddDigit(i, totADC, fLeadingTime[i], fTimeWidth[i], Bool_t((10+evenOrOdd)%2), chargeADC, labels[i]);
4e2652e8 407 }
30c4ff64 408 delete [] chargeADC;
4e2652e8 409
b0d2c2d3 410 treeD->Fill();
411 outLoader->WriteDigits("OVERWRITE");
412 outLoader->UnloadDigits();
413 ResetDigit();
9e04c3b6 414}
415
416//____________________________________________________________________________
30c4ff64 417void AliVZERODigitizer::AddDigit(Int_t PMnumber, Float_t adc, Float_t time, Float_t width, Bool_t integrator, Short_t *chargeADC, Int_t *labels)
9e04c3b6 418 {
419
420// Adds Digit
421
422 TClonesArray &ldigits = *fDigits;
fad64858 423
30c4ff64 424 new(ldigits[fNdigits++]) AliVZEROdigit(PMnumber,adc,time,width,kFALSE,kFALSE,integrator,chargeADC,labels);
fad64858 425
9e04c3b6 426}
427//____________________________________________________________________________
428void AliVZERODigitizer::ResetDigit()
429{
fe0adf2a 430
9e04c3b6 431// Clears Digits
fe0adf2a 432
9e04c3b6 433 fNdigits = 0;
b0d2c2d3 434 if (fDigits) fDigits->Delete();
9e04c3b6 435}
ce7090f5 436
437//____________________________________________________________________________
438AliVZEROCalibData* AliVZERODigitizer::GetCalibData() const
439
440{
c0b82b5a 441 AliCDBManager *man = AliCDBManager::Instance();
ce7090f5 442
c0b82b5a 443 AliCDBEntry *entry=0;
ce7090f5 444
c0b82b5a 445 entry = man->Get("VZERO/Calib/Data");
446
df791951 447// if(!entry){
448// AliWarning("Load of calibration data from default storage failed!");
449// AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
450// Int_t runNumber = man->GetRun();
162637e4 451// entry = man->GetStorage("local://$ALICE_ROOT/OCDB")
df791951 452// ->Get("VZERO/Calib/Data",runNumber);
453//
454// }
c0b82b5a 455
456 // Retrieval of data in directory VZERO/Calib/Data:
ce7090f5 457
ce7090f5 458
c0b82b5a 459 AliVZEROCalibData *calibdata = 0;
ce7090f5 460
c0b82b5a 461 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
df791951 462 if (!calibdata) AliFatal("No calibration data from calibration database !");
ce7090f5 463
c0b82b5a 464 return calibdata;
ce7090f5 465
466}
467
9672d66e 468double AliVZERODigitizer::SignalShape(double *x, double *par)
469{
4e2652e8 470 // this function simulates the time
471 // of arrival of the photons at the
472 // photocathode
9672d66e 473 Double_t xx = x[0];
474 if (xx <= par[0]) return 0;
475 Double_t a = 1./TMath::Power((xx-par[0])/par[1],1./par[2]);
476 if (xx <= par[3]) return a;
477 Double_t b = 1./TMath::Power((xx-par[3])/par[4],1./par[5]);
9672d66e 478 Double_t f = a*b/(a+b);
479 AliDebug(100,Form("x=%f func=%f",xx,f));
480 return f;
481}
4e2652e8 482
483double AliVZERODigitizer::PMResponse(double *x, double * /* par */)
484{
485 // this function describes the
486 // PM time response to a single
487 // photoelectron
488 Double_t xx = x[0]+kPMRespTime;
489 return xx*xx*TMath::Exp(-xx*xx/(kPMRespTime*kPMRespTime));
490}
491
492double AliVZERODigitizer::SinglePhESpectrum(double *x, double * /* par */)
493{
494 // this function describes the
495 // PM amplitude response to a single
496 // photoelectron
497 Double_t xx = x[0];
498 if (xx < 0) return 0;
499 return (TMath::Poisson(xx,kPMNbOfSecElec)+kPMTransparency*TMath::Poisson(xx,1.0));
500}
501
502Int_t AliVZERODigitizer::Cell2Pmt(Int_t cell) const
503{
504 // The method maps the scintillator
505 // indexes to the PM ones
506 if (cell < 0 || cell >= 80) {
507 AliError(Form("Wrong VZERO cell index %d",cell));
508 return -1;
509 }
510 if (cell < 16) return cell;
511 if (cell < 48) return 8 + cell/2;
512 return cell - 16;
513}