]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigitizer.cxx
remove bad modules BEFORE cleaning digits
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigitizer.cxx
CommitLineData
990119d6 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$ */
17
702ab87e 18/* History of cvs commits:
19 *
a28333c5 20 * $Log: AliPHOSDigitizer.cxx,v $
21 * Revision 1.104 2007/12/18 09:08:18 hristov
22 * Splitting of the QA maker into simulation and reconstruction dependent parts (Yves)
23 *
04236e67 24 * Revision 1.103 2007/11/07 11:25:06 schutz
25 * Comment out the QA checking before starting digitization
26 *
18c3b8c2 27 * Revision 1.102 2007/10/19 18:04:29 schutz
28 * The standalone QA data maker is called from AliSimulation and AliReconstruction outside the event loop; i.e. re-reading the data. The QA data making in the event loop has been commented out.
29 *
c65c502a 30 * Revision 1.101 2007/10/14 21:08:10 schutz
31 * Introduced the checking of QA results from previous step before entering the event loop
32 *
8661738e 33 * Revision 1.100 2007/10/10 09:05:10 schutz
34 * Changing name QualAss to QA
35 *
b8274834 36 * Revision 1.99 2007/09/30 17:08:20 schutz
37 * Introducing the notion of QA data acquisition cycle (needed by online)
38 *
5b188f2f 39 * Revision 1.98 2007/09/26 14:22:17 cvetan
40 * Important changes to the reconstructor classes. Complete elimination of the run-loaders, which are now steered only from AliReconstruction. Removal of the corresponding Reconstruct() and FillESD() methods.
41 *
d76c31f4 42 * Revision 1.97 2007/08/07 14:12:03 kharlov
43 * Quality assurance added (Yves Schutz)
44 *
ddd1a39c 45 * Revision 1.96 2007/04/28 10:43:36 policheh
46 * Dead channels simulation: digit energy sets to 0.
47 *
1c6a163f 48 * Revision 1.95 2007/04/10 07:20:52 kharlov
49 * Decalibration should use the same CDB as calibration in AliPHOSClusterizerv1
50 *
1a197b77 51 * Revision 1.94 2007/02/01 10:34:47 hristov
52 * Removing warnings on Solaris x86
53 *
ad4aeaf4 54 * Revision 1.93 2006/10/17 13:17:01 kharlov
55 * Replace AliInfo by AliDebug
56 *
d6e8d7d3 57 * Revision 1.92 2006/08/28 10:01:56 kharlov
58 * Effective C++ warnings fixed (Timur Pocheptsov)
59 *
3663622c 60 * Revision 1.91 2006/04/29 20:25:30 hristov
61 * Decalibration is implemented (Yu.Kharlov)
62 *
877695e7 63 * Revision 1.90 2006/04/22 10:30:17 hristov
64 * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
65 *
27a73a5d 66 * Revision 1.89 2006/04/11 15:22:59 hristov
67 * run number in query set to -1: forces AliCDBManager to use its run number (A.Colla)
68 *
28871337 69 * Revision 1.88 2006/03/13 14:05:43 kharlov
70 * Calibration objects for EMC and CPV
71 *
fc6706cb 72 * Revision 1.87 2005/08/24 15:33:49 kharlov
73 * Calibration data for raw digits
74 *
a8ec0771 75 * Revision 1.86 2005/07/12 20:07:35 hristov
76 * Changes needed to run simulation and reconstrruction in the same AliRoot session
77 *
7c193632 78 * Revision 1.85 2005/05/28 14:19:04 schutz
79 * Compilation warnings fixed by T.P.
80 *
702ab87e 81 */
88cb7938 82
990119d6 83//_________________________________________________________________________
990119d6 84//*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
85//////////////////////////////////////////////////////////////////////////////
a4e98857 86// This TTask performs digitization of Summable digits (in the PHOS case it is just
87// the sum of contributions from all primary particles into a given cell).
990119d6 88// In addition it performs mixing of summable digits from different events.
7b7c1533 89// The name of the TTask is also the title of the branch that will contain
90// the created SDigits
91// The title of the TTAsk is the name of the file that contains the hits from
92// which the SDigits are created
bca3b32a 93//
94// For each event two branches are created in TreeD:
95// "PHOS" - list of digits
96// "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
97//
a4e98857 98// Note, that one can set a title for new digits branch, and repeat digitization with
bca3b32a 99// another set of parameters.
100//
a4e98857 101// Use case:
990119d6 102// root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
103// root[1] d->ExecuteTask()
104// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
105// //Digitizes SDigitis in all events found in file galice.root
bca3b32a 106//
8cb3533f 107// root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
108// // Will read sdigits from galice1.root
109// root[3] d1->MixWith("galice2.root")
990119d6 110// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
a4e98857 111// // Reads another set of sdigits from galice2.root
8cb3533f 112// root[3] d1->MixWith("galice3.root")
a4e98857 113// // Reads another set of sdigits from galice3.root
8cb3533f 114// root[4] d->ExecuteTask("deb timing")
115// // Reads SDigits from files galice1.root, galice2.root ....
116// // mixes them and stores produced Digits in file galice1.root
117// // deb - prints number of produced digits
118// // deb all - prints list of produced digits
119// // timing - prints time used for digitization
990119d6 120//
990119d6 121
122// --- ROOT system ---
990119d6 123#include "TTree.h"
124#include "TSystem.h"
8cb3533f 125#include "TBenchmark.h"
e957fea8 126#include "TRandom.h"
ba54256b 127
990119d6 128// --- Standard library ---
129
130// --- AliRoot header files ---
351dd634 131#include "AliLog.h"
3f81a70b 132#include "AliRunDigitizer.h"
990119d6 133#include "AliPHOSDigit.h"
7b7c1533 134#include "AliPHOSGetter.h"
990119d6 135#include "AliPHOSDigitizer.h"
136#include "AliPHOSSDigitizer.h"
8cb3533f 137#include "AliPHOSGeometry.h"
7437a0f7 138#include "AliPHOSTick.h"
990119d6 139
140ClassImp(AliPHOSDigitizer)
141
142
143//____________________________________________________________________________
3663622c 144AliPHOSDigitizer::AliPHOSDigitizer() :
145 AliDigitizer("",""),
146 fDefaultInit(kTRUE),
147 fDigitsInRun(0),
148 fInit(kFALSE),
149 fInput(0),
150 fInputFileNames(0x0),
151 fEventNames(0x0),
152 fEmcCrystals(0),
153 fPinNoise(0.f),
154 fEMCDigitThreshold(0.f),
155 fCPVNoise(0.f),
156 fCPVDigitThreshold(0.f),
157 fTimeResolution(0.f),
158 fTimeThreshold(0.f),
159 fTimeSignalLength(0.f),
160 fADCchanelEmc(0.f),
161 fADCpedestalEmc(0.f),
162 fNADCemc(0),
163 fADCchanelCpv(0.f),
164 fADCpedestalCpv(0.f),
165 fNADCcpv(0),
166 fEventFolderName(""),
167 fFirstEvent(0),
ddd1a39c 168 fLastEvent(0),
c65c502a 169// fQADM (0x0),
ddd1a39c 170 fEventCounter(0)
990119d6 171{
172 // ctor
8d0f3f77 173 InitParameters() ;
fbf811ec 174 fManager = 0 ; // We work in the standalong mode
88cb7938 175}
3f81a70b 176
177//____________________________________________________________________________
e191bb57 178AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
179 TString eventFolderName):
3663622c 180 AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(), alirunFileName),
181 fDefaultInit(kFALSE),
182 fDigitsInRun(0),
183 fInit(kFALSE),
184 fInput(0),
185 fInputFileNames(0x0),
186 fEventNames(0x0),
187 fEmcCrystals(0),
188 fPinNoise(0.f),
189 fEMCDigitThreshold(0.f),
190 fCPVNoise(0.f),
191 fCPVDigitThreshold(0.f),
192 fTimeResolution(0.f),
193 fTimeThreshold(0.f),
194 fTimeSignalLength(0.f),
195 fADCchanelEmc(0.f),
196 fADCpedestalEmc(0.f),
197 fNADCemc(0),
198 fADCchanelCpv(0.f),
199 fADCpedestalCpv(0.f),
200 fNADCcpv(0),
201 fEventFolderName(eventFolderName),
202 fFirstEvent(0),
ddd1a39c 203 fLastEvent(0),
c65c502a 204// fQADM (0x0),
ddd1a39c 205 fEventCounter(0)
3f81a70b 206{
207 // ctor
8d0f3f77 208 InitParameters() ;
3f81a70b 209 Init() ;
92f521a9 210 fDefaultInit = kFALSE ;
88cb7938 211 fManager = 0 ; // We work in the standalong mode
c65c502a 212 // //Initialize the quality assurance data maker only once
213// fQADM = new AliPHOSQADataMaker() ;
214// //FIXME: get the run number
215// Int_t run = 0 ;
216// //EMXIF
217// GetQADataMaker()->Init(AliQA::kDIGITS, run, fgkCycles) ;
218// GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;
88cb7938 219}
220
221//____________________________________________________________________________
3663622c 222AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d) :
223 AliDigitizer(d),
224 fDefaultInit(d.fDefaultInit),
225 fDigitsInRun(d.fDigitsInRun),
226 fInit(d.fInit),
227 fInput(d.fInput),
228 fInputFileNames(0x0),//?
229 fEventNames(0x0),//?
230 fEmcCrystals(d.fEmcCrystals),
231 fPinNoise(d.fPinNoise),
232 fEMCDigitThreshold(d.fEMCDigitThreshold),
233 fCPVNoise(d.fCPVNoise),
234 fCPVDigitThreshold(d.fCPVDigitThreshold),
235 fTimeResolution(d.fTimeResolution),
236 fTimeThreshold(d.fTimeThreshold),
237 fTimeSignalLength(d.fTimeSignalLength),
238 fADCchanelEmc(d.fADCchanelEmc),
239 fADCpedestalEmc(d.fADCpedestalEmc),
240 fNADCemc(d.fNADCemc),
241 fADCchanelCpv(d.fADCchanelCpv),
242 fADCpedestalCpv(d.fADCpedestalCpv),
243 fNADCcpv(d.fNADCcpv),
244 fEventFolderName(d.fEventFolderName),
245 fFirstEvent(d.fFirstEvent),
ddd1a39c 246 fLastEvent(d.fLastEvent),
c65c502a 247// fQADM (d.fQADM),
ddd1a39c 248 fEventCounter(0)
249
88cb7938 250{
251 // copyy ctor
88cb7938 252 SetName(d.GetName()) ;
253 SetTitle(d.GetTitle()) ;
ddd1a39c 254//Initialize the quality assurance data maker only once
5b188f2f 255 //FIXME: get the run number
c65c502a 256// Int_t run = 0 ;
257// //EMXIF
258// GetQADataMaker()->Init(AliQA::kDIGITS, run, fgkCycles) ;
259// GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;
990119d6 260}
261
990119d6 262//____________________________________________________________________________
3663622c 263AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd) :
264 AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()),
265 fDefaultInit(kFALSE),
266 fDigitsInRun(0),
267 fInit(kFALSE),
268 fInput(0),
269 fInputFileNames(0x0),
270 fEventNames(0x0),
271 fEmcCrystals(0),
272 fPinNoise(0.f),
273 fEMCDigitThreshold(0.f),
274 fCPVNoise(0.f),
275 fCPVDigitThreshold(0.f),
276 fTimeResolution(0.f),
277 fTimeThreshold(0.f),
278 fTimeSignalLength(0.f),
279 fADCchanelEmc(0.f),
280 fADCpedestalEmc(0.f),
281 fNADCemc(0),
282 fADCchanelCpv(0.f),
283 fADCpedestalCpv(0.f),
284 fNADCcpv(0),
285 fEventFolderName(fManager->GetInputFolderName(0)),
286 fFirstEvent(0),
ddd1a39c 287 fLastEvent(0),
c65c502a 288// fQADM (0x0),
ddd1a39c 289 fEventCounter(0)
290
990119d6 291{
45fa49ca 292 // ctor Init() is called by RunDigitizer
88cb7938 293 fManager = rd ;
88cb7938 294 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
b22e4735 295 InitParameters() ;
fbf811ec 296 fDefaultInit = kFALSE ;
ddd1a39c 297//Initialize the quality assurance data maker only once
c65c502a 298// fQADM = new AliPHOSQADataMaker() ;
299// //FIXME: get the run number
300// Int_t run = 0 ;
301// //EMXIF
302// GetQADataMaker()->Init(AliQA::kDIGITS, run) ;
303// GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;
990119d6 304}
305
306//____________________________________________________________________________
307 AliPHOSDigitizer::~AliPHOSDigitizer()
308{
7c193632 309 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
310
311 // Clean Digitizer from the white board
312 gime->PhosLoader()->CleanDigitizer() ;
990119d6 313 // dtor
88cb7938 314 delete [] fInputFileNames ;
315 delete [] fEventNames ;
ddd1a39c 316
c65c502a 317// delete fQADM ;
ddd1a39c 318
990119d6 319}
320
321//____________________________________________________________________________
fc7e2f43 322void AliPHOSDigitizer::Digitize(Int_t event)
a4e98857 323{
324
325 // Makes the digitization of the collected summable digits.
326 // It first creates the array of all PHOS modules
dc986a1d 327 // filled with noise (different for EMC, and CPV) and
a4e98857 328 // then adds contributions from SDigits.
329 // This design avoids scanning over the list of digits to add
330 // contribution to new SDigits only.
990119d6 331
f98c06a1 332 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
45fa49ca 333 Int_t ReadEvent = event ;
334 if (fManager)
335 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
d6e8d7d3 336 AliDebug(1,Form("Adding event %d from input stream 0 %s %s",
337 ReadEvent, GetTitle(), fEventFolderName.Data())) ;
45fa49ca 338 gime->Event(ReadEvent, "S") ;
88cb7938 339 TClonesArray * digits = gime->Digits() ;
7b7c1533 340 digits->Clear() ;
990119d6 341
7b7c1533 342 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
990119d6 343 //Making digits with noise, first EMC
344 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
345
346 Int_t nCPV ;
990119d6 347 Int_t absID ;
990119d6 348
88cb7938 349 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
350
9688c1dd 351 digits->Expand(nCPV) ;
8cb3533f 352
88cb7938 353 // get first the sdigitizer from the tasks list
354 if ( !gime->SDigitizer() )
355 gime->LoadSDigitizer();
356 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
357
358 if ( !sDigitizer )
351dd634 359 AliFatal(Form("SDigitizer with name %s %s not found",
360 GetTitle(), fEventFolderName.Data() )) ;
88cb7938 361
362 //take all the inputs to add together and load the SDigits
363 TObjArray * sdigArray = new TObjArray(fInput) ;
364 sdigArray->AddAt(gime->SDigits(), 0) ;
365 Int_t i ;
366 for(i = 1 ; i < fInput ; i++){
367 TString tempo(fEventNames[i]) ;
368 tempo += i ;
ad4aeaf4 369 AliPHOSGetter * gime1 = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
45fa49ca 370 if (fManager)
371 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
351dd634 372 AliInfo(Form("Adding event %d from input stream %d %s %s",
373 ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
ad4aeaf4 374 gime1->Event(ReadEvent,"S");
375 sdigArray->AddAt(gime1->SDigits(), i) ;
38bb0fd5 376 }
9688c1dd 377
27a73a5d 378 //Find the first crystal with signal
9688c1dd 379 Int_t nextSig = 200000 ;
88cb7938 380 TClonesArray * sdigits ;
381 for(i = 0 ; i < fInput ; i++){
382 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
a6eedfad 383 if ( !sdigits->GetEntriesFast() )
7a9d98f9 384 continue ;
88cb7938 385 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
386 if(curNext < nextSig)
387 nextSig = curNext ;
9688c1dd 388 }
88cb7938 389
390 TArrayI index(fInput) ;
9688c1dd 391 index.Reset() ; //Set all indexes to zero
88cb7938 392
9688c1dd 393 AliPHOSDigit * digit ;
394 AliPHOSDigit * curSDigit ;
88cb7938 395
7437a0f7 396 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
88cb7938 397
9688c1dd 398 //Put Noise contribution
88cb7938 399 for(absID = 1 ; absID <= nEMC ; absID++){
9688c1dd 400 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
27a73a5d 401 // YVK: do not digitize amplitudes for EMC
402// new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
403 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, noise, TimeOfNoise() ) ;
9688c1dd 404 //look if we have to add signal?
88cb7938 405 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
406
9688c1dd 407 if(absID==nextSig){
408 //Add SDigits from all inputs
7437a0f7 409 ticks->Clear() ;
9688c1dd 410 Int_t contrib = 0 ;
27a73a5d 411 Float_t a = digit->GetEnergy() ;
88cb7938 412 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
413 //Mark the beginning of the signal
7437a0f7 414 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
27a73a5d 415 //Mark the end of the signal
7437a0f7 416 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
88cb7938 417
9688c1dd 418 //loop over inputs
88cb7938 419 for(i = 0 ; i < fInput ; i++){
420 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
421 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
5c9dfca0 422 else
423 curSDigit = 0 ;
9688c1dd 424 //May be several digits will contribute from the same input
425 while(curSDigit && curSDigit->GetId() == absID){
426 //Shift primary to separate primaries belonging different inputs
427 Int_t primaryoffset ;
9891b76e 428 if(fManager)
429 primaryoffset = fManager->GetMask(i) ;
9688c1dd 430 else
21c293b7 431 primaryoffset = 10000000*i ;
432 curSDigit->ShiftPrimary(primaryoffset) ;
7437a0f7 433
27a73a5d 434 a = curSDigit->GetEnergy() ;
7437a0f7 435 b = a /fTimeSignalLength ;
436 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
437 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
88cb7938 438
3663622c 439 *digit += *curSDigit ; //add energies
27a73a5d 440
9688c1dd 441 index[i]++ ;
88cb7938 442 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
443 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
5c9dfca0 444 else
445 curSDigit = 0 ;
9688c1dd 446 }
447 }
88cb7938 448
9688c1dd 449 //calculate and set time
7437a0f7 450 Float_t time = FrontEdgeTime(ticks) ;
9688c1dd 451 digit->SetTime(time) ;
88cb7938 452
9688c1dd 453 //Find next signal module
7437a0f7 454 nextSig = 200000 ;
88cb7938 455 for(i = 0 ; i < fInput ; i++){
456 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
5c9dfca0 457 Int_t curNext = nextSig ;
458 if(sdigits->GetEntriesFast() > index[i] ){
88cb7938 459 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
5c9dfca0 460 }
9688c1dd 461 if(curNext < nextSig) nextSig = curNext ;
7b7c1533 462 }
463 }
990119d6 464 }
3f81a70b 465
7437a0f7 466 ticks->Delete() ;
467 delete ticks ;
88cb7938 468
9688c1dd 469 //Now CPV digits (different noise and no timing)
470 for(absID = nEMC+1; absID <= nCPV; absID++){
471 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
472 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
473 //look if we have to add signal?
474 if(absID==nextSig){
88cb7938 475 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
9688c1dd 476 //Add SDigits from all inputs
88cb7938 477 for(i = 0 ; i < fInput ; i++){
478 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
479 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
5c9dfca0 480 else
481 curSDigit = 0 ;
a6eedfad 482
9688c1dd 483 //May be several digits will contribute from the same input
484 while(curSDigit && curSDigit->GetId() == absID){
485 //Shift primary to separate primaries belonging different inputs
486 Int_t primaryoffset ;
9891b76e 487 if(fManager)
488 primaryoffset = fManager->GetMask(i) ;
9688c1dd 489 else
490 primaryoffset = 10000000*i ;
491 curSDigit->ShiftPrimary(primaryoffset) ;
492
493 //add energies
3663622c 494 *digit += *curSDigit ;
9688c1dd 495 index[i]++ ;
88cb7938 496 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
497 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
5c9dfca0 498 else
499 curSDigit = 0 ;
9688c1dd 500 }
501 }
a6eedfad 502
9688c1dd 503 //Find next signal module
a6eedfad 504 nextSig = 200000 ;
88cb7938 505 for(i = 0 ; i < fInput ; i++){
506 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
5c9dfca0 507 Int_t curNext = nextSig ;
508 if(sdigits->GetEntriesFast() > index[i] )
88cb7938 509 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
9688c1dd 510 if(curNext < nextSig) nextSig = curNext ;
511 }
512
513 }
514 }
88cb7938 515
516 delete sdigArray ; //We should not delete its contents
9688c1dd 517
1dfe0f3c 518 Int_t relId[4];
519
520 //set amplitudes in bad channels to zero
521 if(!gime->CalibData()) {
522 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1);
523 gime->SetCalibData(cdb);
524 }
525 for(i = 0 ; i <digits->GetEntries(); i++){
526 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
527 gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
528 if(relId[1] == 0) // Emc
529 if(gime->CalibData()->IsBadChannelEmc(relId[0],relId[3],relId[2])) digit->SetEnergy(0.);
530 }
531
990119d6 532 //remove digits below thresholds
88cb7938 533 for(i = 0 ; i < nEMC ; i++){
548f0134 534 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
a28333c5 535//By default no decalibration should be applyed
536// DecalibrateEMC(digit);
537
27a73a5d 538 if(digit->GetEnergy() < fEMCDigitThreshold)
a6eedfad 539 digits->RemoveAt(i) ;
aaf8a71c 540 else
541 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
542 }
543
a6eedfad 544 for(i = nEMC; i < nCPV ; i++)
27a73a5d 545// if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
546 if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < fCPVDigitThreshold )
a6eedfad 547 digits->RemoveAt(i) ;
9688c1dd 548
7b7c1533 549 digits->Compress() ;
990119d6 550
7b7c1533 551 Int_t ndigits = digits->GetEntriesFast() ;
7b7c1533 552 digits->Expand(ndigits) ;
990119d6 553
3758d9fc 554 //Set indexes in list of digits and make true digitization of the energy
990119d6 555 for (i = 0 ; i < ndigits ; i++) {
548f0134 556 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
990119d6 557 digit->SetIndexInList(i) ;
27a73a5d 558 if(digit->GetId() > fEmcCrystals){ //digitize CPV only
877695e7 559 digit->SetAmp(DigitizeCPV(digit->GetEnergy(),digit->GetId()) ) ;
27a73a5d 560 }
990119d6 561 }
7b7c1533 562}
548f0134 563
3758d9fc 564//____________________________________________________________________________
877695e7 565void AliPHOSDigitizer::DecalibrateEMC(AliPHOSDigit *digit)
3758d9fc 566{
877695e7 567 // Decalibrate EMC digit, i.e. change its energy by a factor read from CDB
568
569 AliPHOSGetter* gime = AliPHOSGetter::Instance();
570
571 if(!gime->CalibData()) {
572 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1);
573 gime->SetCalibData(cdb);
574 }
575
576 //Determine rel.position of the cell absolute ID
577 Int_t relId[4];
578 gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
579 Int_t module=relId[0];
580 Int_t row =relId[2];
581 Int_t column=relId[3];
582 Float_t decalibration = gime->CalibData()->GetADCchannelEmc(module,column,row);
1a197b77 583 Float_t energy = digit->GetEnergy() / decalibration;
877695e7 584 digit->SetEnergy(energy);
585}
586//____________________________________________________________________________
587Int_t AliPHOSDigitizer::DigitizeCPV(Float_t charge, Int_t absId)
588{
589 // Returns digitized value of the CPV charge in a pad absId
0bc3b8ed 590
a8ec0771 591 AliPHOSGetter* gime = AliPHOSGetter::Instance();
592
fc6706cb 593 if(!gime->CalibData()) {
28871337 594 AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); // use AliCDBManager's run number
fc6706cb 595 gime->SetCalibData(cdb);
596 }
597
a8ec0771 598 //Determine rel.position of the cell absId
599 Int_t relId[4];
600 gime->PHOSGeometry()->AbsToRelNumbering(absId,relId);
601 Int_t module=relId[0];
27a73a5d 602 Int_t row =relId[2];
a8ec0771 603 Int_t column=relId[3];
604
877695e7 605 Int_t channel = 0;
a8ec0771 606
877695e7 607 if(absId > fEmcCrystals){ //digitize CPV only
a8ec0771 608
609 //reading calibration data for cell absId.
610 //If no calibration DB found, accept default values.
611
fc6706cb 612 if(gime->CalibData()) {
27a73a5d 613 fADCpedestalCpv = gime->CalibData()->GetADCpedestalCpv(module,column,row);
877695e7 614 fADCchanelCpv = gime->CalibData()->GetADCchannelCpv( module,column,row);
fc6706cb 615 }
616
877695e7 617 channel = (Int_t) TMath::Ceil((charge - fADCpedestalCpv)/fADCchanelCpv) ;
618 if(channel > fNADCcpv ) channel = fNADCcpv ;
3758d9fc 619 }
877695e7 620 return channel ;
3758d9fc 621}
548f0134 622
7b7c1533 623//____________________________________________________________________________
624void AliPHOSDigitizer::Exec(Option_t *option)
625{
212d1c0f 626 // Steering method to process digitization for events
627 // in the range from fFirstEvent to fLastEvent.
628 // This range is optionally set by SetEventRange().
45fa49ca 629 // if fLastEvent=-1, then process events until the end.
630 // by default fLastEvent = fFirstEvent (process only one event)
88cb7938 631
632 if (!fInit) { // to prevent overwrite existing file
351dd634 633 AliError(Form("Give a version name different from %s",
634 fEventFolderName.Data() )) ;
88cb7938 635 return ;
636 }
990119d6 637
7b7c1533 638 if (strstr(option,"print")) {
88cb7938 639 Print();
7b7c1533 640 return ;
8cb3533f 641 }
990119d6 642
18c3b8c2 643 // // check the QA result for Hits and SDigits
644// AliQA * qa = AliQA::Instance(AliQA::kPHOS) ;
645// if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kFATAL)) {
646// AliFatal("QA status in Hits and/or SDIGITS was Fatal") ;
647// } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kERROR)) {
648// AliError("QA status in Hits and/or SDIGITS was Error") ;
649// } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kWARNING) ) {
650// AliWarning("QA status in Hits and/or SDIGITS was Warning") ;
651// } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kINFO) ) {
652// AliInfo("QA status in Hits and/or SDIGITS was Info") ;
653// }
8661738e 654
655 if(strstr(option,"tim"))
656 gBenchmark->Start("PHOSDigitizer");
3f81a70b 657
fb43ada4 658 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
88cb7938 659
5b4d2c50 660 // Post Digitizer to the white board
661 gime->PostDigitizer(this) ;
662
212d1c0f 663 if (fLastEvent == -1)
664 fLastEvent = gime->MaxEvent() - 1 ;
396a348e 665 else if (fManager)
666 fLastEvent = fFirstEvent ;
45fa49ca 667
212d1c0f 668 Int_t nEvents = fLastEvent - fFirstEvent + 1;
669
7b7c1533 670 Int_t ievent ;
88cb7938 671
212d1c0f 672 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
ddd1a39c 673 fEventCounter++ ;
88cb7938 674 gime->Event(ievent,"S") ;
b22e4735 675
7b7c1533 676 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
88cb7938 677
c65c502a 678// //makes the quality assurance data
679// if (GetQADataMaker()->IsCycleDone() ) {
680// GetQADataMaker()->EndOfCycle(AliQA::kDIGITS) ;
681// GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;
682// }
683// GetQADataMaker()->Exec(AliQA::kDIGITS, gime->Digits()) ;
684// GetQADataMaker()->Increment() ;
ddd1a39c 685
90cceaf6 686 WriteDigits() ;
88cb7938 687
01a599c9 688 if(strstr(option,"deb"))
689 PrintDigits(option);
94de8339 690
691 //increment the total number of Digits per run
692 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
88cb7938 693 }
ddd1a39c 694
c65c502a 695// //Write the quality assurance data only after the last event
696// if ( fEventCounter == gime->MaxEvent() ) {
697// GetQADataMaker()->EndOfCycle(AliQA::kDIGITS) ;
698// GetQADataMaker()->Finish() ;
699// }
88cb7938 700
5b4d2c50 701 gime->PhosLoader()->CleanDigitizer();
702
8cb3533f 703 if(strstr(option,"tim")){
704 gBenchmark->Stop("PHOSDigitizer");
21cd0c07 705 TString message ;
706 message = " took %f seconds for Digitizing %f seconds per event\n" ;
351dd634 707 AliInfo(Form( message.Data(),
21cd0c07 708 gBenchmark->GetCpuTime("PHOSDigitizer"),
351dd634 709 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents ));
21cd0c07 710 }
990119d6 711}
712
9688c1dd 713//____________________________________________________________________________
0bc3b8ed 714Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
715{
716 // Returns the shortest time among all time ticks
717
7437a0f7 718 ticks->Sort() ; //Sort in accordance with times of ticks
719 TIter it(ticks) ;
720 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
721 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
722
723 AliPHOSTick * t ;
724 while((t=(AliPHOSTick*) it.Next())){
725 if(t->GetTime() < time) //This tick starts before crossing
726 *ctick+=*t ;
727 else
728 return time ;
729
730 time = ctick->CrossingTime(fTimeThreshold) ;
9688c1dd 731 }
732 return time ;
9688c1dd 733}
8d0f3f77 734
7b7c1533 735//____________________________________________________________________________
3f81a70b 736Bool_t AliPHOSDigitizer::Init()
8d0f3f77 737{
fbf811ec 738 // Makes all memory allocations
88cb7938 739 fInit = kTRUE ;
740 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
8d0f3f77 741 if ( gime == 0 ) {
351dd634 742 AliFatal(Form("Could not obtain the Getter object for file %s and event %s !",
743 GetTitle(), fEventFolderName.Data()));
8d0f3f77 744 return kFALSE;
745 }
746
747 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
b22e4735 748
88cb7938 749 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
8d0f3f77 750
88cb7938 751 TString opt("Digits") ;
752 if(gime->VersionExists(opt) ) {
351dd634 753 AliError(Form("Give a version name different from %s",
754 fEventFolderName.Data() )) ;
88cb7938 755 fInit = kFALSE ;
756 }
757
45fa49ca 758 fFirstEvent = 0 ;
759 fLastEvent = fFirstEvent ;
88cb7938 760 if (fManager)
761 fInput = fManager->GetNinputs() ;
762 else
763 fInput = 1 ;
764
765 fInputFileNames = new TString[fInput] ;
766 fEventNames = new TString[fInput] ;
767 fInputFileNames[0] = GetTitle() ;
768 fEventNames[0] = fEventFolderName.Data() ;
769 Int_t index ;
770 for (index = 1 ; index < fInput ; index++) {
771 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
772 TString tempo = fManager->GetInputFolderName(index) ;
45fa49ca 773 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
8d0f3f77 774 }
88cb7938 775
776 //to prevent cleaning of this object while GetEvent is called
777 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
778
779 return fInit ;
8d0f3f77 780}
781
782//____________________________________________________________________________
783void AliPHOSDigitizer::InitParameters()
a4e98857 784{
45fa49ca 785 // Set initial parameters Digitizer
0bc3b8ed 786
27a73a5d 787 fPinNoise = 0.004 ; // [GeV]
788 fEMCDigitThreshold = 0.012 ; // [GeV]
789 fCPVNoise = 0.01; // [aux units]
790 fCPVDigitThreshold = 0.09 ; // [aux units]
791 fTimeResolution = 0.5e-9 ; // [sec]
792 fTimeSignalLength = 1.0e-9 ; // [sec]
3758d9fc 793 fDigitsInRun = 0 ;
877695e7 794 fADCchanelEmc = 1.0; // Coefficient between real and measured energies in EMC
795 fADCpedestalEmc = 0. ; //
3758d9fc 796 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
797
798 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
799 fADCpedestalCpv = 0.012 ; //
800 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
801
27a73a5d 802// fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
803 fTimeThreshold = 0.001 ; // [GeV]
212d1c0f 804 SetEventRange(0,-1) ;
8cb3533f 805
990119d6 806}
7b7c1533 807
990119d6 808//__________________________________________________________________
fc7e2f43 809void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
a4e98857 810{
ba54256b 811 // Allows to produce digits by superimposing background and signal event.
bca3b32a 812 // It is assumed, that headers file with SIGNAL events is opened in
a4e98857 813 // the constructor.
814 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
815 // Thus we avoid writing (changing) huge and expensive
bca3b32a 816 // backgound files: all output will be writen into SIGNAL, i.e.
817 // opened in constructor file.
818 //
a4e98857 819 // One can open as many files to mix with as one needs.
7b7c1533 820 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
821 // can be mixed.
bca3b32a 822
88cb7938 823 if( strcmp(fEventFolderName, "") == 0 )
8cb3533f 824 Init() ;
825
9891b76e 826 if(fManager){
88cb7938 827 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
3f81a70b 828 return ;
829 }
88cb7938 830 // looking for file which contains AliRun
831 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
351dd634 832 AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
88cb7938 833 return ;
990119d6 834 }
88cb7938 835 // looking for the file which contains SDigits
836 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
837 TString fileName( gime->GetSDigitsFileName() ) ;
e191bb57 838 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
88cb7938 839 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
840 if ( (gSystem->AccessPathName(fileName)) ) {
351dd634 841 AliError(Form("The file %s does not exist!", fileName.Data())) ;
88cb7938 842 return ;
7b7c1533 843 }
88cb7938 844 // need to increase the arrays
845 TString tempo = fInputFileNames[fInput-1] ;
846 delete [] fInputFileNames ;
847 fInputFileNames = new TString[fInput+1] ;
848 fInputFileNames[fInput-1] = tempo ;
849
850 tempo = fEventNames[fInput-1] ;
851 delete [] fEventNames ;
852 fEventNames = new TString[fInput+1] ;
853 fEventNames[fInput-1] = tempo ;
854
855 fInputFileNames[fInput] = alirunFileName ;
856 fEventNames[fInput] = eventFolderName ;
857 fInput++ ;
990119d6 858}
7b7c1533 859
990119d6 860//__________________________________________________________________
702ab87e 861void AliPHOSDigitizer::Print(const Option_t *)const
21cd0c07 862{
dd5c4038 863 // Print Digitizer's parameters
351dd634 864 AliInfo(Form("\n------------------- %s -------------", GetName() )) ;
88cb7938 865 if( strcmp(fEventFolderName.Data(), "") != 0 ){
866 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
867
868 Int_t nStreams ;
869 if (fManager)
870 nStreams = GetNInputStreams() ;
871 else
872 nStreams = fInput ;
873
874 Int_t index = 0 ;
875 for (index = 0 ; index < nStreams ; index++) {
876 TString tempo(fEventNames[index]) ;
877 tempo += index ;
878 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
879 TString fileName( gime->GetSDigitsFileName() ) ;
e191bb57 880 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
88cb7938 881 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
882 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
883 }
884 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
885 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
886
887 printf("\nWith following parameters:\n") ;
27a73a5d 888 printf(" Electronics noise in EMC (fPinNoise) = %f GeV\n", fPinNoise ) ;
889 printf(" Threshold in EMC (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ;
890 printf(" Noise in CPV (fCPVNoise) = %f aux units\n", fCPVNoise ) ;
891 printf(" Threshold in CPV (fCPVDigitThreshold) = %f aux units\n",fCPVDigitThreshold ) ;
88cb7938 892 printf(" ---------------------------------------------------\n") ;
990119d6 893 }
8cb3533f 894 else
351dd634 895 AliInfo(Form("AliPHOSDigitizer not initialized" )) ;
8cb3533f 896
897}
88cb7938 898
8cb3533f 899//__________________________________________________________________
21cd0c07 900 void AliPHOSDigitizer::PrintDigits(Option_t * option)
901{
3bf72d32 902 // Print a table of digits
21cd0c07 903
88cb7938 904 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
3bf72d32 905 TClonesArray * digits = gime->Digits() ;
906
351dd634 907 AliInfo(Form("%d", digits->GetEntriesFast())) ;
88cb7938 908 printf("\nevent %d", gAlice->GetEvNumber()) ;
909 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
910
11f9c5ff 911
3bf72d32 912 if(strstr(option,"all")||strstr(option,"EMC")){
8cb3533f 913 //loop over digits
914 AliPHOSDigit * digit;
88cb7938 915 printf("\nEMC digits (with primaries):\n") ;
916 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
9688c1dd 917 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
8cb3533f 918 Int_t index ;
a6eedfad 919 for (index = 0 ; (index < digits->GetEntriesFast()) &&
88cb7938 920 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
7b7c1533 921 digit = (AliPHOSDigit * ) digits->At(index) ;
21cd0c07 922 if(digit->GetNprimary() == 0)
923 continue;
27a73a5d 924// printf("%6d %8d %6.5e %4d %2d :",
925// digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; // YVK
926 printf("%6d %.4f %6.5e %4d %2d :",
927 digit->GetId(), digit->GetEnergy(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
8cb3533f 928 Int_t iprimary;
21cd0c07 929 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
88cb7938 930 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
21cd0c07 931 }
81d5f731 932 printf("\n") ;
21cd0c07 933 }
9688c1dd 934 }
3bf72d32 935
9688c1dd 936 if(strstr(option,"all")||strstr(option,"CPV")){
8cb3533f 937
9688c1dd 938 //loop over CPV digits
939 AliPHOSDigit * digit;
88cb7938 940 printf("\nCPV digits (with primaries):\n") ;
941 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
9688c1dd 942 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
943 Int_t index ;
a6eedfad 944 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
9688c1dd 945 digit = (AliPHOSDigit * ) digits->At(index) ;
946 if(digit->GetId() > maxEmc){
81d5f731 947 printf("%6d %8d %4d %2d :",
11f9c5ff 948 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
9688c1dd 949 Int_t iprimary;
21cd0c07 950 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
88cb7938 951 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
21cd0c07 952 }
81d5f731 953 printf("\n") ;
21cd0c07 954 }
9688c1dd 955 }
8cb3533f 956 }
88cb7938 957
8cb3533f 958}
7b7c1533 959
9688c1dd 960//__________________________________________________________________
0bc3b8ed 961Float_t AliPHOSDigitizer::TimeOfNoise(void) const
9688c1dd 962{ // Calculates the time signal generated by noise
26a2ef9d 963 //PH Info("TimeOfNoise", "Change me") ;
04f0bda3 964 return gRandom->Rndm() * 1.28E-5;
8cb3533f 965}
7b7c1533 966
88cb7938 967//__________________________________________________________________
968void AliPHOSDigitizer::Unload()
969{
970
971 Int_t i ;
972 for(i = 1 ; i < fInput ; i++){
973 TString tempo(fEventNames[i]) ;
974 tempo += i ;
975 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
976 gime->PhosLoader()->UnloadSDigits() ;
977 }
978
979 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
980 gime->PhosLoader()->UnloadDigits() ;
981}
982
7b7c1533 983//____________________________________________________________________________
90cceaf6 984void AliPHOSDigitizer::WriteDigits()
7b7c1533 985{
986
987 // Makes TreeD in the output file.
988 // Check if branch already exists:
989 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
990 // already existing branches.
991 // else creates branch with Digits, named "PHOS", title "...",
992 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
993 // and names of files, from which digits are made.
994
f98c06a1 995 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
88cb7938 996 const TClonesArray * digits = gime->Digits() ;
997 TTree * treeD = gime->TreeD();
998
7b7c1533 999 // -- create Digits branch
1000 Int_t bufferSize = 32000 ;
2524c56f 1001 TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
88cb7938 1002 digitsBranch->SetTitle(fEventFolderName);
1003 digitsBranch->Fill() ;
fbf811ec 1004
88cb7938 1005 gime->WriteDigits("OVERWRITE");
1006 gime->WriteDigitizer("OVERWRITE");
1007
1008 Unload() ;
b3690abb 1009
7b7c1533 1010}