]>
Commit | Line | Data |
---|---|---|
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" |
72da5ce8 | 52 | #include "AliVZEROSDigit.h" |
9e04c3b6 | 53 | |
54 | ClassImp(AliVZERODigitizer) | |
55 | ||
56 | AliVZERODigitizer::AliVZERODigitizer() | |
fe0adf2a | 57 | :AliDigitizer(), |
58 | fCalibData(GetCalibData()), | |
59 | fPhotoCathodeEfficiency(0.18), | |
fe0adf2a | 60 | fNdigits(0), |
61 | fDigits(0), | |
4e2652e8 | 62 | fSignalShape(NULL), |
63 | fPMResponse(NULL), | |
72da5ce8 | 64 | fSinglePhESpectrum(NULL), |
65 | fEvenOrOdd(kFALSE), | |
66 | fTask(kHits2Digits), | |
67 | fVZERO(NULL) | |
9e04c3b6 | 68 | { |
b0d2c2d3 | 69 | // default constructor |
72da5ce8 | 70 | // Initialize OCDB and containers used in the digitization |
b0d2c2d3 | 71 | |
72da5ce8 | 72 | Init(); |
73 | } | |
4e2652e8 | 74 | |
72da5ce8 | 75 | //____________________________________________________________________________ |
76 | AliVZERODigitizer::AliVZERODigitizer(AliVZERO *vzero, DigiTask_t task) | |
77 | :AliDigitizer(), | |
78 | fCalibData(GetCalibData()), | |
79 | fPhotoCathodeEfficiency(0.18), | |
80 | fNdigits(0), | |
81 | fDigits(0), | |
82 | fSignalShape(NULL), | |
83 | fPMResponse(NULL), | |
84 | fSinglePhESpectrum(NULL), | |
85 | fEvenOrOdd(kFALSE), | |
86 | fTask(task), | |
87 | fVZERO(vzero) | |
88 | { | |
89 | // constructor | |
90 | // Initialize OCDB and containers used in the digitization | |
4e2652e8 | 91 | |
72da5ce8 | 92 | Init(); |
9e04c3b6 | 93 | } |
72da5ce8 | 94 | |
9e04c3b6 | 95 | //____________________________________________________________________________ |
96 | AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager) | |
0b2bea8b | 97 | :AliDigitizer(manager), |
98 | fCalibData(GetCalibData()), | |
99 | fPhotoCathodeEfficiency(0.18), | |
0b2bea8b | 100 | fNdigits(0), |
fe0adf2a | 101 | fDigits(0), |
4e2652e8 | 102 | fSignalShape(NULL), |
103 | fPMResponse(NULL), | |
72da5ce8 | 104 | fSinglePhESpectrum(NULL), |
105 | fEvenOrOdd(kFALSE), | |
106 | fTask(kHits2Digits), | |
107 | fVZERO(NULL) | |
9e04c3b6 | 108 | { |
109 | // constructor | |
4e2652e8 | 110 | // Initialize OCDB and containers used in the digitization |
72da5ce8 | 111 | |
112 | Init(); | |
113 | } | |
114 | ||
115 | //____________________________________________________________________________ | |
116 | AliVZERODigitizer::~AliVZERODigitizer() | |
117 | { | |
118 | // destructor | |
9e04c3b6 | 119 | |
72da5ce8 | 120 | if (fDigits) { |
121 | fDigits->Delete(); | |
122 | delete fDigits; | |
123 | fDigits=0; | |
124 | } | |
125 | ||
126 | if (fSignalShape) { | |
127 | delete fSignalShape; | |
128 | fSignalShape = NULL; | |
129 | } | |
130 | if (fPMResponse) { | |
131 | delete fPMResponse; | |
132 | fPMResponse = NULL; | |
133 | } | |
134 | if (fSinglePhESpectrum) { | |
135 | delete fSinglePhESpectrum; | |
136 | fSinglePhESpectrum = NULL; | |
137 | } | |
138 | ||
139 | for(Int_t i = 0 ; i < 64; ++i) { | |
140 | if (fTime[i]) delete [] fTime[i]; | |
141 | } | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | Bool_t AliVZERODigitizer::Init() | |
146 | { | |
147 | // Initialises the digitizer | |
148 | // Initialize OCDB and containers used in the digitization | |
149 | ||
150 | // check if the digitizer was already initialized | |
151 | if (fSignalShape) return kTRUE; | |
152 | ||
9672d66e | 153 | fSignalShape = new TF1("VZEROSignalShape",this,&AliVZERODigitizer::SignalShape,0,200,6,"AliVZERODigitizer","SignalShape"); |
4e2652e8 | 154 | // fSignalShape->SetParameters(0,1.57345e1,-4.25603e-1,2.9,6.40982,3.69339e-01); |
81db2705 | 155 | // fSignalShape->SetParameters(1.34330e+00,1.13007e+02,-4.95705e-01, |
156 | // 3.68911e+00,1.01040e+00, 3.94675e-01); | |
157 | fSignalShape->SetParameters(-1.07335e+00,2.16002e+01,-1.26133e-01, | |
158 | 1.41619e+00,5.50334e-01,3.86111e-01); | |
4e2652e8 | 159 | fPMResponse = new TF1("VZEROPMResponse",this,&AliVZERODigitizer::PMResponse,-kPMRespTime,2.*kPMRespTime,0,"AliVZERODigitizer","PMResponse"); |
160 | fSinglePhESpectrum = new TF1("VZEROSinglePhESpectrum",this,&AliVZERODigitizer::SinglePhESpectrum,0,20,0,"AliVZERODigitizer","SinglePhESpectrum"); | |
ce7090f5 | 161 | |
4e2652e8 | 162 | // Now get the CTP L0->L1 delay |
163 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming"); | |
164 | if (!entry) AliFatal("CTP timing parameters are not found in OCDB !"); | |
165 | AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject(); | |
166 | Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0; | |
167 | ||
7905581c | 168 | AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign"); |
169 | if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !"); | |
170 | AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject(); | |
171 | l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0); | |
172 | ||
4e2652e8 | 173 | AliCDBEntry *entry2 = AliCDBManager::Instance()->Get("VZERO/Calib/TimeDelays"); |
174 | if (!entry2) AliFatal("VZERO time delays are not found in OCDB !"); | |
175 | TH1F *delays = (TH1F*)entry2->GetObject(); | |
176 | ||
177 | for(Int_t i = 0 ; i < 64; ++i) { | |
178 | ||
179 | for(Int_t j = 0; j < kNClocks; ++j) fAdc[i][j] = 0; | |
180 | fLeadingTime[i] = fTimeWidth[i] = 0; | |
181 | ||
182 | fPmGain[i] = fCalibData->GetGain(i); | |
183 | ||
184 | fAdcPedestal[i][0] = fCalibData->GetPedestal(i); | |
185 | fAdcSigma[i][0] = fCalibData->GetSigma(i); | |
186 | fAdcPedestal[i][1] = fCalibData->GetPedestal(i+64); | |
187 | fAdcSigma[i][1] = fCalibData->GetSigma(i+64); | |
188 | ||
51980118 | 189 | Int_t board = AliVZEROCalibData::GetBoardNumber(i); |
4e2652e8 | 190 | fNBins[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0+ |
191 | (Float_t)kMaxTDCWidth*fCalibData->GetWidthResolution(board))/ | |
192 | fCalibData->GetTimeResolution(board)); | |
193 | fNBinsLT[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0)/ | |
194 | fCalibData->GetTimeResolution(board)); | |
195 | fBinSize[i] = fCalibData->GetTimeResolution(board); | |
196 | fHptdcOffset[i] = (((Float_t)fCalibData->GetTriggerCountOffset(board)- | |
197 | (Float_t)fCalibData->GetRollOver(board))*25.0+ | |
7905581c | 198 | fCalibData->GetTimeOffset(i)- |
4e2652e8 | 199 | l1Delay+ |
200 | delays->GetBinContent(i+1)+ | |
201 | kV0Offset); | |
202 | ||
203 | fTime[i] = new Float_t[fNBins[i]]; | |
204 | memset(fTime[i],0,fNBins[i]*sizeof(Float_t)); | |
205 | } | |
72da5ce8 | 206 | |
207 | return kTRUE; | |
9e04c3b6 | 208 | } |
9672d66e | 209 | |
72da5ce8 | 210 | //____________________________________________________________________________ |
211 | void AliVZERODigitizer::Exec(Option_t* /*option*/) | |
212 | { | |
213 | // Creates digits from hits | |
214 | fNdigits = 0; | |
215 | ||
216 | if (fVZERO && !fManager) { | |
217 | AliLoader *loader = fVZERO->GetLoader(); | |
218 | if (!loader) { | |
219 | AliError("Can not get VZERO Loader via AliVZERO object!"); | |
220 | return; | |
221 | } | |
222 | AliRunLoader* runLoader = AliRunLoader::Instance(); | |
223 | for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); ++iEvent) { | |
224 | runLoader->GetEvent(iEvent); | |
225 | if (fTask == kHits2Digits) { | |
226 | DigitizeHits(); | |
227 | DigitizeSDigits(); | |
228 | WriteDigits(loader); | |
229 | } | |
230 | else { | |
231 | DigitizeHits(); | |
232 | WriteSDigits(loader); | |
233 | } | |
234 | } | |
4e2652e8 | 235 | } |
72da5ce8 | 236 | else if (fManager) { |
237 | ReadSDigits(); | |
238 | DigitizeSDigits(); | |
239 | AliRunLoader *currentLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); | |
240 | AliLoader *loader = currentLoader->GetLoader("VZEROLoader"); | |
241 | if (!loader) { | |
242 | AliError("Cannot get VZERO Loader via RunDigitizer!"); | |
243 | return; | |
244 | } | |
245 | WriteDigits(loader); | |
4e2652e8 | 246 | } |
72da5ce8 | 247 | else { |
248 | AliFatal("Invalid digitization task! Exiting!"); | |
4e2652e8 | 249 | } |
9e04c3b6 | 250 | } |
251 | ||
72da5ce8 | 252 | //____________________________________________________________________________ |
253 | void AliVZERODigitizer::AddDigit(Int_t pmnumber, Float_t time, Float_t width, Bool_t integrator, Short_t *chargeADC, Int_t *labels) | |
254 | { | |
255 | ||
256 | // Adds Digit | |
257 | ||
258 | TClonesArray &ldigits = *fDigits; | |
259 | ||
260 | new(ldigits[fNdigits++]) AliVZEROdigit(pmnumber,time,width,integrator,chargeADC,labels); | |
261 | ||
262 | } | |
263 | //____________________________________________________________________________ | |
264 | void AliVZERODigitizer::AddSDigit(Int_t pmnumber, Int_t nbins, Float_t *charges, Int_t *labels) | |
265 | { | |
266 | ||
267 | // Adds SDigit | |
268 | ||
269 | TClonesArray &ldigits = *fDigits; | |
270 | ||
271 | new(ldigits[fNdigits++]) AliVZEROSDigit(pmnumber,nbins,charges,labels); | |
272 | ||
273 | } | |
274 | //____________________________________________________________________________ | |
275 | void AliVZERODigitizer::ResetDigits() | |
9e04c3b6 | 276 | { |
9e04c3b6 | 277 | |
72da5ce8 | 278 | // Clears Digits |
279 | ||
280 | fNdigits = 0; | |
281 | if (fDigits) fDigits->Clear(); | |
9e04c3b6 | 282 | } |
283 | ||
284 | //____________________________________________________________________________ | |
72da5ce8 | 285 | AliVZEROCalibData* AliVZERODigitizer::GetCalibData() const |
286 | ||
287 | { | |
288 | AliCDBManager *man = AliCDBManager::Instance(); | |
289 | ||
290 | AliCDBEntry *entry=0; | |
291 | ||
292 | entry = man->Get("VZERO/Calib/Data"); | |
293 | ||
294 | // if(!entry){ | |
295 | // AliWarning("Load of calibration data from default storage failed!"); | |
296 | // AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)"); | |
297 | // Int_t runNumber = man->GetRun(); | |
298 | // entry = man->GetStorage("local://$ALICE_ROOT/OCDB") | |
299 | // ->Get("VZERO/Calib/Data",runNumber); | |
300 | // | |
301 | // } | |
302 | ||
303 | // Retrieval of data in directory VZERO/Calib/Data: | |
304 | ||
305 | ||
306 | AliVZEROCalibData *calibdata = 0; | |
307 | ||
308 | if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject(); | |
309 | if (!calibdata) AliFatal("No calibration data from calibration database !"); | |
310 | ||
311 | return calibdata; | |
312 | ||
313 | } | |
314 | ||
315 | double AliVZERODigitizer::SignalShape(double *x, double *par) | |
316 | { | |
317 | // this function simulates the time | |
318 | // of arrival of the photons at the | |
319 | // photocathode | |
320 | Double_t xx = x[0]; | |
321 | if (xx <= par[0]) return 0; | |
322 | Double_t a = 1./TMath::Power((xx-par[0])/par[1],1./par[2]); | |
323 | if (xx <= par[3]) return a; | |
324 | Double_t b = 1./TMath::Power((xx-par[3])/par[4],1./par[5]); | |
325 | Double_t f = a*b/(a+b); | |
326 | AliDebug(100,Form("x=%f func=%f",xx,f)); | |
327 | return f; | |
328 | } | |
329 | ||
330 | double AliVZERODigitizer::PMResponse(double *x, double * /* par */) | |
331 | { | |
332 | // this function describes the | |
333 | // PM time response to a single | |
334 | // photoelectron | |
335 | Double_t xx = x[0]+kPMRespTime; | |
336 | return xx*xx*TMath::Exp(-xx*xx/(kPMRespTime*kPMRespTime)); | |
337 | } | |
338 | ||
339 | double AliVZERODigitizer::SinglePhESpectrum(double *x, double * /* par */) | |
340 | { | |
341 | // this function describes the | |
342 | // PM amplitude response to a single | |
343 | // photoelectron | |
344 | Double_t xx = x[0]; | |
345 | if (xx < 0) return 0; | |
346 | return (TMath::Poisson(xx,kPMNbOfSecElec)+kPMTransparency*TMath::Poisson(xx,1.0)); | |
347 | } | |
348 | ||
349 | Int_t AliVZERODigitizer::Cell2Pmt(Int_t cell) const | |
350 | { | |
351 | // The method maps the scintillator | |
352 | // indexes to the PM ones | |
353 | if (cell < 0 || cell >= 80) { | |
354 | AliError(Form("Wrong VZERO cell index %d",cell)); | |
355 | return -1; | |
356 | } | |
357 | if (cell < 16) return cell; | |
358 | if (cell < 48) return 8 + cell/2; | |
359 | return cell - 16; | |
360 | } | |
361 | ||
362 | void AliVZERODigitizer::DigitizeHits() | |
363 | { | |
364 | // Digitize the hits to the level of | |
365 | // SDigits (fTime arrays) | |
4e2652e8 | 366 | |
367 | for(Int_t i = 0 ; i < 64; ++i) { | |
368 | memset(fTime[i],0,fNBins[i]*sizeof(Float_t)); | |
72da5ce8 | 369 | fLabels[i][0] = fLabels[i][1] = fLabels[i][2] = -1; |
fad64858 | 370 | } |
4e2652e8 | 371 | Float_t integral = fPMResponse->Integral(-kPMRespTime,2.*kPMRespTime); |
372 | Float_t meansPhE = fSinglePhESpectrum->Mean(0,20); | |
373 | ||
72da5ce8 | 374 | AliLoader* loader = fVZERO->GetLoader(); |
8bd3e27a | 375 | if (!loader) { |
72da5ce8 | 376 | AliError("Can not get VZERO Loader!"); |
377 | return; | |
378 | } | |
8bd3e27a | 379 | loader->LoadHits(); |
380 | TTree* treeH = loader->TreeH(); | |
381 | if (!treeH) { | |
72da5ce8 | 382 | AliError("Cannot get TreeH!"); |
383 | return; | |
384 | } | |
385 | TClonesArray* hits = fVZERO->Hits(); | |
4e2652e8 | 386 | |
387 | // 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}; | |
388 | 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 | 389 | // Now makes Digits from hits |
8bd3e27a | 390 | Int_t nTracks = (Int_t) treeH->GetEntries(); |
391 | for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) { | |
72da5ce8 | 392 | fVZERO->ResetHits(); |
8bd3e27a | 393 | treeH->GetEvent(iTrack); |
394 | Int_t nHits = hits->GetEntriesFast(); | |
395 | for (Int_t iHit = 0; iHit < nHits; iHit++) { | |
4e2652e8 | 396 | AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit); |
397 | Int_t nPhot = hit->Nphot(); | |
398 | Int_t cell = hit->Cell(); | |
399 | Int_t pmt = Cell2Pmt(cell); | |
30c4ff64 | 400 | Int_t trackLabel = hit->GetTrack(); |
401 | for(Int_t l = 0; l < 3; ++l) { | |
72da5ce8 | 402 | if (fLabels[pmt][l] < 0) { |
403 | fLabels[pmt][l] = trackLabel; | |
30c4ff64 | 404 | break; |
405 | } | |
406 | } | |
4e2652e8 | 407 | Float_t dt_scintillator = gRandom->Gaus(0,kIntTimeRes); |
408 | Float_t t = dt_scintillator + 1e9*hit->Tof(); | |
409 | if (pmt < 32) t += kV0CDelayCables; | |
410 | t += fHptdcOffset[pmt]; | |
411 | Int_t nPhE; | |
412 | Float_t prob = lightYieldCorr[pmt]*fPhotoCathodeEfficiency; // Optical losses included! | |
413 | if (nPhot > 100) | |
d0ff6548 | 414 | nPhE = (Int_t)gRandom->Gaus(prob*Float_t(nPhot)+0.5, |
415 | sqrt(Float_t(nPhot)*prob*(1.-prob))); | |
4e2652e8 | 416 | else |
417 | nPhE = gRandom->Binomial(nPhot,prob); | |
418 | Float_t charge = TMath::Qe()*fPmGain[pmt]*fBinSize[pmt]/integral; | |
419 | for (Int_t iPhE = 0; iPhE < nPhE; ++iPhE) { | |
420 | Float_t tPhE = t + fSignalShape->GetRandom(0,fBinSize[pmt]*Float_t(fNBins[pmt])); | |
421 | Float_t gainVar = fSinglePhESpectrum->GetRandom(0,20)/meansPhE; | |
422 | Int_t firstBin = TMath::Max(0,(Int_t)((tPhE-kPMRespTime)/fBinSize[pmt])); | |
423 | Int_t lastBin = TMath::Min(fNBins[pmt]-1,(Int_t)((tPhE+2.*kPMRespTime)/fBinSize[pmt])); | |
424 | for(Int_t iBin = firstBin; iBin <= lastBin; ++iBin) { | |
425 | Float_t tempT = fBinSize[pmt]*(0.5+iBin)-tPhE; | |
426 | fTime[pmt][iBin] += gainVar*charge*fPMResponse->Eval(tempT); | |
427 | } | |
428 | } // ph.e. loop | |
429 | } // hit loop | |
430 | } // track loop | |
8bd3e27a | 431 | loader->UnloadHits(); |
72da5ce8 | 432 | } |
433 | ||
434 | ||
435 | void AliVZERODigitizer::DigitizeSDigits() | |
436 | { | |
437 | // Digitize the fTime arrays (SDigits) to the level of | |
438 | // Digits (fAdc arrays) | |
439 | for(Int_t i = 0 ; i < 64; ++i) { | |
440 | for(Int_t j = 0; j < kNClocks; ++j) fAdc[i][j] = 0; | |
441 | fLeadingTime[i] = fTimeWidth[i] = 0; | |
442 | } | |
4e2652e8 | 443 | |
444 | Float_t maximum = 0.9*fSignalShape->GetMaximum(0,200); // Not exact, one needs to do this on the convoluted | |
445 | Float_t integral2 = fSignalShape->Integral(0,200); // function. Anyway the effect is small <10% on the 2.5 ADC thr | |
446 | for (Int_t ipmt = 0; ipmt < 64; ++ipmt) { | |
447 | Float_t thr = fCalibData->GetDiscriThr(ipmt)*kChargePerADC*maximum*fBinSize[ipmt]/integral2; | |
448 | Bool_t ltFound = kFALSE, ttFound = kFALSE; | |
449 | for (Int_t iBin = 0; iBin < fNBins[ipmt]; ++iBin) { | |
b6fd9c4a | 450 | Float_t t = fBinSize[ipmt]*Float_t(iBin); |
4e2652e8 | 451 | if (fTime[ipmt][iBin] > thr) { |
452 | if (!ltFound && (iBin < fNBinsLT[ipmt])) { | |
453 | ltFound = kTRUE; | |
454 | fLeadingTime[ipmt] = t; | |
455 | } | |
456 | } | |
457 | else { | |
458 | if (ltFound) { | |
459 | if (!ttFound) { | |
460 | ttFound = kTRUE; | |
461 | fTimeWidth[ipmt] = t - fLeadingTime[ipmt]; | |
462 | } | |
463 | } | |
464 | } | |
d0ff6548 | 465 | Float_t tadc = t - kClockOffset - fCalibData->GetTimeOffset(ipmt); |
466 | Int_t clock = kNClocks/2 - Int_t(tadc/25.0); | |
4e2652e8 | 467 | if (clock >= 0 && clock < kNClocks) |
468 | fAdc[ipmt][clock] += fTime[ipmt][iBin]/kChargePerADC; | |
469 | } | |
51980118 | 470 | Int_t board = AliVZEROCalibData::GetBoardNumber(ipmt); |
4e2652e8 | 471 | if (ltFound && ttFound) { |
472 | fTimeWidth[ipmt] = fCalibData->GetWidthResolution(board)* | |
473 | Float_t(Int_t(fTimeWidth[ipmt]/fCalibData->GetWidthResolution(board))); | |
474 | if (fTimeWidth[ipmt] < Float_t(kMinTDCWidth)*fCalibData->GetWidthResolution(board)) | |
475 | fTimeWidth[ipmt] = Float_t(kMinTDCWidth)*fCalibData->GetWidthResolution(board); | |
476 | if (fTimeWidth[ipmt] > Float_t(kMaxTDCWidth)*fCalibData->GetWidthResolution(board)) | |
477 | fTimeWidth[ipmt] = Float_t(kMaxTDCWidth)*fCalibData->GetWidthResolution(board); | |
478 | } | |
479 | } | |
b0d2c2d3 | 480 | |
72da5ce8 | 481 | fEvenOrOdd = gRandom->Integer(2); |
4e2652e8 | 482 | for (Int_t j=0; j<64; ++j){ |
483 | for (Int_t iClock = 0; iClock < kNClocks; ++iClock) { | |
72da5ce8 | 484 | Int_t integrator = (iClock + fEvenOrOdd) % 2; |
4e2652e8 | 485 | fAdc[j][iClock] += gRandom->Gaus(fAdcPedestal[j][integrator], fAdcSigma[j][integrator]); |
486 | } | |
487 | } | |
20277079 | 488 | |
72da5ce8 | 489 | } |
490 | ||
491 | void AliVZERODigitizer::WriteDigits(AliLoader *loader) | |
492 | { | |
493 | // Take fAdc arrays filled by the previous | |
494 | // method and produce and add digits to the digit Tree | |
495 | ||
496 | loader->LoadDigits("UPDATE"); | |
4e2652e8 | 497 | |
72da5ce8 | 498 | if (!loader->TreeD()) loader->MakeTree("D"); |
499 | loader->MakeDigitsContainer(); | |
500 | TTree* treeD = loader->TreeD(); | |
501 | DigitsArray(); | |
502 | treeD->Branch("VZERODigit", &fDigits); | |
503 | ||
30c4ff64 | 504 | Short_t *chargeADC = new Short_t[kNClocks]; |
4e2652e8 | 505 | for (Int_t i=0; i<64; i++) { |
30c4ff64 | 506 | for (Int_t j = 0; j < kNClocks; ++j) { |
4e2652e8 | 507 | Int_t tempadc = Int_t(fAdc[i][j]); |
508 | if (tempadc > 1023) tempadc = 1023; | |
30c4ff64 | 509 | chargeADC[j] = tempadc; |
4e2652e8 | 510 | } |
72da5ce8 | 511 | AddDigit(i, fLeadingTime[i], fTimeWidth[i], Bool_t((10+fEvenOrOdd)%2), chargeADC, fLabels[i]); |
4e2652e8 | 512 | } |
30c4ff64 | 513 | delete [] chargeADC; |
4e2652e8 | 514 | |
b0d2c2d3 | 515 | treeD->Fill(); |
72da5ce8 | 516 | loader->WriteDigits("OVERWRITE"); |
517 | loader->UnloadDigits(); | |
518 | ResetDigits(); | |
9e04c3b6 | 519 | } |
520 | ||
72da5ce8 | 521 | void AliVZERODigitizer::WriteSDigits(AliLoader *loader) |
9e04c3b6 | 522 | { |
72da5ce8 | 523 | // Take fTime arrays filled by the previous |
524 | // method and produce and add sdigits to the sdigit Tree | |
fe0adf2a | 525 | |
72da5ce8 | 526 | loader->LoadSDigits("UPDATE"); |
fe0adf2a | 527 | |
72da5ce8 | 528 | if (!loader->TreeS()) loader->MakeTree("S"); |
529 | loader->MakeSDigitsContainer(); | |
530 | TTree* treeS = loader->TreeS(); | |
531 | SDigitsArray(); | |
532 | treeS->Branch("VZEROSDigit", &fDigits); | |
533 | ||
534 | for (Int_t ipmt = 0; ipmt < 64; ++ipmt) { | |
535 | AddSDigit(ipmt,fNBins[ipmt],fTime[ipmt],fLabels[ipmt]); | |
536 | } | |
ce7090f5 | 537 | |
72da5ce8 | 538 | treeS->Fill(); |
539 | loader->WriteSDigits("OVERWRITE"); | |
540 | loader->UnloadSDigits(); | |
541 | ResetDigits(); | |
542 | } | |
ce7090f5 | 543 | |
72da5ce8 | 544 | void AliVZERODigitizer::ReadSDigits() |
ce7090f5 | 545 | { |
72da5ce8 | 546 | // Read SDigits which are then to precessed |
547 | // in the following method | |
548 | for(Int_t i = 0 ; i < 64; ++i) { | |
549 | memset(fTime[i],0,fNBins[i]*sizeof(Float_t)); | |
550 | fLabels[i][0] = fLabels[i][1] = fLabels[i][2] = -1; | |
551 | } | |
ce7090f5 | 552 | |
72da5ce8 | 553 | // Loop over input files |
554 | Int_t nFiles= fManager->GetNinputs(); | |
555 | for (Int_t inputFile = 0; inputFile < nFiles; inputFile++) { | |
556 | // Get the current loader | |
557 | AliRunLoader* currentLoader = | |
558 | AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); | |
ce7090f5 | 559 | |
72da5ce8 | 560 | AliLoader *loader = currentLoader->GetLoader("VZEROLoader"); |
561 | loader->LoadSDigits("READ"); | |
562 | ||
563 | // Get the tree of summable digits | |
564 | TTree* sdigitsTree = loader->TreeS(); | |
565 | if (!sdigitsTree) { | |
566 | AliError("No sdigit tree from manager"); | |
567 | continue; | |
568 | } | |
ce7090f5 | 569 | |
72da5ce8 | 570 | // Get the branch |
571 | TBranch* sdigitsBranch = sdigitsTree->GetBranch("VZEROSDigit"); | |
572 | if (!sdigitsBranch) { | |
573 | AliError("Failed to get sdigit branch"); | |
574 | return; | |
575 | } | |
4e2652e8 | 576 | |
72da5ce8 | 577 | // Set the branch address |
578 | TClonesArray *sdigitsArray = NULL; | |
579 | sdigitsBranch->SetAddress(&sdigitsArray); | |
580 | ||
581 | // Sum contributions from the sdigits | |
582 | // Get number of entries in the tree | |
583 | Int_t nentries = Int_t(sdigitsBranch->GetEntries()); | |
584 | for (Int_t entry = 0; entry < nentries; ++entry) { | |
585 | sdigitsBranch->GetEntry(entry); | |
586 | // Get the number of sdigits | |
587 | Int_t nsdigits = sdigitsArray->GetEntries(); | |
588 | for (Int_t sdigit = 0; sdigit < nsdigits; sdigit++) { | |
589 | AliVZEROSDigit* sDigit = static_cast<AliVZEROSDigit*>(sdigitsArray->UncheckedAt(sdigit)); | |
590 | Int_t pmNumber = sDigit->PMNumber(); | |
591 | Int_t nbins = sDigit->GetNBins(); | |
592 | if (nbins != fNBins[pmNumber]) { | |
593 | AliError(Form("Incompatible number of bins between digitizer (%d) and sdigit (%d) for PM %d! Skipping sdigit!", | |
594 | fNBins[pmNumber],nbins,pmNumber)); | |
595 | continue; | |
596 | } | |
597 | // Sum the charges | |
598 | Float_t *charges = sDigit->GetCharges(); | |
599 | for(Int_t iBin = 0; iBin < nbins; ++iBin) fTime[pmNumber][iBin] += charges[iBin]; | |
600 | // and the labels | |
601 | Int_t *labels = sDigit->GetTracks(); | |
602 | Int_t j = 0; | |
603 | for(Int_t i = 0; i < 3; ++i) { | |
604 | if (fLabels[pmNumber][i] < 0) { | |
605 | if (labels[j] < 0) break; | |
606 | fLabels[pmNumber][i] = labels[j]; | |
607 | j++; | |
608 | } | |
609 | } | |
610 | } | |
611 | } | |
612 | loader->UnloadSDigits(); | |
613 | } | |
4e2652e8 | 614 | } |
615 | ||
72da5ce8 | 616 | //____________________________________________________________________ |
617 | TClonesArray* | |
618 | AliVZERODigitizer::DigitsArray() | |
4e2652e8 | 619 | { |
72da5ce8 | 620 | // Initialize digit array if not already and |
621 | // return pointer to it. | |
622 | if (!fDigits) { | |
623 | fDigits = new TClonesArray("AliVZEROdigit", 64); | |
624 | fNdigits = 0; | |
625 | } | |
626 | return fDigits; | |
4e2652e8 | 627 | } |
628 | ||
72da5ce8 | 629 | //____________________________________________________________________ |
630 | TClonesArray* | |
631 | AliVZERODigitizer::SDigitsArray() | |
4e2652e8 | 632 | { |
72da5ce8 | 633 | // Initialize sdigit array if not already and |
634 | // return pointer to it. | |
635 | if (!fDigits) { | |
636 | fDigits = new TClonesArray("AliVZEROSDigit", 64); | |
637 | fNdigits = 0; | |
4e2652e8 | 638 | } |
72da5ce8 | 639 | return fDigits; |
4e2652e8 | 640 | } |