1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 //_________________________________________________________________________
20 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
21 //////////////////////////////////////////////////////////////////////////////
22 // This TTask performs digitization of Summable digits (in the PHOS case it is just
23 // the sum of contributions from all primary particles into a given cell).
24 // In addition it performs mixing of summable digits from different events.
25 // The name of the TTask is also the title of the branch that will contain
26 // the created SDigits
27 // The title of the TTAsk is the name of the file that contains the hits from
28 // which the SDigits are created
30 // For each event two branches are created in TreeD:
31 // "PHOS" - list of digits
32 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
34 // Note, that one can set a title for new digits branch, and repeat digitization with
35 // another set of parameters.
38 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
39 // root[1] d->ExecuteTask()
40 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
41 // //Digitizes SDigitis in all events found in file galice.root
43 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
44 // // Will read sdigits from galice1.root
45 // root[3] d1->MixWith("galice2.root")
46 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
47 // // Reads another set of sdigits from galice2.root
48 // root[3] d1->MixWith("galice3.root")
49 // // Reads another set of sdigits from galice3.root
50 // root[4] d->ExecuteTask("deb timing")
51 // // Reads SDigits from files galice1.root, galice2.root ....
52 // // mixes them and stores produced Digits in file galice1.root
53 // // deb - prints number of produced digits
54 // // deb all - prints list of produced digits
55 // // timing - prints time used for digitization
58 // --- ROOT system ---
61 #include "TBenchmark.h"
64 // --- Standard library ---
66 // --- AliRoot header files ---
68 #include "AliRunDigitizer.h"
69 #include "AliPHOSDigit.h"
70 #include "AliPHOSGetter.h"
71 #include "AliPHOSDigitizer.h"
72 #include "AliPHOSSDigitizer.h"
73 #include "AliPHOSGeometry.h"
74 #include "AliPHOSTick.h"
76 ClassImp(AliPHOSDigitizer)
79 //____________________________________________________________________________
80 AliPHOSDigitizer::AliPHOSDigitizer():AliDigitizer("",""),
87 fDefaultInit = kTRUE ;
88 fManager = 0 ; // We work in the standalong mode
89 fEventFolderName = "" ;
92 //____________________________________________________________________________
93 AliPHOSDigitizer::AliPHOSDigitizer(const TString alirunFileName, const TString eventFolderName):
94 AliDigitizer("PHOS"+AliConfig::fgkDigitizerTaskName, alirunFileName),
95 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
101 fDefaultInit = kFALSE ;
102 fManager = 0 ; // We work in the standalong mode
105 //____________________________________________________________________________
106 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
111 SetName(d.GetName()) ;
112 SetTitle(d.GetTitle()) ;
113 fPinNoise = d.fPinNoise ;
114 fEMCDigitThreshold = d.fEMCDigitThreshold ;
115 fCPVNoise = d.fCPVNoise ;
116 fCPVDigitThreshold = d.fCPVDigitThreshold ;
117 fTimeResolution = d.fTimeResolution ;
118 fTimeThreshold = d.fTimeThreshold ;
119 fTimeSignalLength = d.fTimeSignalLength ;
120 fADCchanelEmc = d.fADCchanelEmc ;
121 fADCpedestalEmc = d.fADCpedestalEmc ;
122 fNADCemc = d.fNADCemc ;
123 fADCchanelCpv = d.fADCchanelCpv ;
124 fADCpedestalCpv = d.fADCpedestalCpv ;
125 fNADCcpv = d.fNADCcpv ;
126 fEventFolderName = d.fEventFolderName;
129 //____________________________________________________________________________
130 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
131 AliDigitizer(rd,"PHOS"+AliConfig::fgkDigitizerTaskName),
136 // SetName(fManager->GetInputFolderName(0)) ;
137 // take title as name of stream 0
138 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
141 fDefaultInit = kFALSE ;
144 //____________________________________________________________________________
145 AliPHOSDigitizer::~AliPHOSDigitizer()
148 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(),fEventFolderName);
149 gime->PhosLoader()->CleanDigitizer();
150 delete [] fInputFileNames ;
151 delete [] fEventNames ;
155 //____________________________________________________________________________
156 void AliPHOSDigitizer::Digitize(const Int_t event)
159 // Makes the digitization of the collected summable digits.
160 // It first creates the array of all PHOS modules
161 // filled with noise (different for EMC, CPV and PPSD) and
162 // then adds contributions from SDigits.
163 // This design avoids scanning over the list of digits to add
164 // contribution to new SDigits only.
166 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
167 TClonesArray * digits = gime->Digits() ;
170 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
171 //Making digits with noise, first EMC
172 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
177 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
179 digits->Expand(nCPV) ;
181 // get first the sdigitizer from the tasks list
182 if ( !gime->SDigitizer() )
183 gime->LoadSDigitizer();
184 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
187 Fatal("Digitize", "SDigitizer with name %s %s not found", fEventFolderName.Data(), GetTitle() ) ;
189 //take all the inputs to add together and load the SDigits
190 TObjArray * sdigArray = new TObjArray(fInput) ;
191 sdigArray->AddAt(gime->SDigits(), 0) ;
193 for(i = 1 ; i < fInput ; i++){
194 TString tempo(fEventNames[i]) ;
196 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
197 gime->Event(event,"S");
198 sdigArray->AddAt(gime->SDigits(), i) ;
201 //Find the first crystall with signal
202 Int_t nextSig = 200000 ;
203 TClonesArray * sdigits ;
204 for(i = 0 ; i < fInput ; i++){
205 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
206 if ( !sdigits->GetEntriesFast() )
208 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
209 if(curNext < nextSig)
213 TArrayI index(fInput) ;
214 index.Reset() ; //Set all indexes to zero
216 AliPHOSDigit * digit ;
217 AliPHOSDigit * curSDigit ;
219 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
221 //Put Noise contribution
222 for(absID = 1 ; absID <= nEMC ; absID++){
223 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
224 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
225 //look if we have to add signal?
226 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
229 //Add SDigits from all inputs
232 Float_t a = digit->GetAmp() ;
233 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
234 //Mark the beginning of the signal
235 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
236 //Mark the end of the ignal
237 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
240 for(i = 0 ; i < fInput ; i++){
241 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
242 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
245 //May be several digits will contribute from the same input
246 while(curSDigit && curSDigit->GetId() == absID){
247 //Shift primary to separate primaries belonging different inputs
248 Int_t primaryoffset ;
250 primaryoffset = fManager->GetMask(i) ;
252 primaryoffset = 10000000*i ;
253 curSDigit->ShiftPrimary(primaryoffset) ;
255 a = curSDigit->GetAmp() ;
256 b = a /fTimeSignalLength ;
257 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
258 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
260 *digit = *digit + *curSDigit ; //add energies
263 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
264 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
270 //calculate and set time
271 Float_t time = FrontEdgeTime(ticks) ;
272 digit->SetTime(time) ;
274 //Find next signal module
276 for(i = 0 ; i < fInput ; i++){
277 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
278 Int_t curNext = nextSig ;
279 if(sdigits->GetEntriesFast() > index[i] ){
280 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
282 if(curNext < nextSig) nextSig = curNext ;
290 //Now CPV digits (different noise and no timing)
291 for(absID = nEMC+1; absID <= nCPV; absID++){
292 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
293 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
294 //look if we have to add signal?
296 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
297 //Add SDigits from all inputs
298 for(i = 0 ; i < fInput ; i++){
299 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
300 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
304 //May be several digits will contribute from the same input
305 while(curSDigit && curSDigit->GetId() == absID){
306 //Shift primary to separate primaries belonging different inputs
307 Int_t primaryoffset ;
309 primaryoffset = fManager->GetMask(i) ;
311 primaryoffset = 10000000*i ;
312 curSDigit->ShiftPrimary(primaryoffset) ;
315 *digit = *digit + *curSDigit ;
317 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
318 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
324 //Find next signal module
326 for(i = 0 ; i < fInput ; i++){
327 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
328 Int_t curNext = nextSig ;
329 if(sdigits->GetEntriesFast() > index[i] )
330 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
331 if(curNext < nextSig) nextSig = curNext ;
337 delete sdigArray ; //We should not delete its contents
339 //remove digits below thresholds
340 for(i = 0 ; i < nEMC ; i++){
341 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
342 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
343 digits->RemoveAt(i) ;
345 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
349 for(i = nEMC; i < nCPV ; i++)
350 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
351 digits->RemoveAt(i) ;
355 Int_t ndigits = digits->GetEntriesFast() ;
356 digits->Expand(ndigits) ;
358 //Set indexes in list of digits and make true digitization of the energy
359 for (i = 0 ; i < ndigits ; i++) {
360 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
361 digit->SetIndexInList(i) ;
362 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
363 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
367 //____________________________________________________________________________
368 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
370 // Returns digitized value of the energy in a cell absId
373 if(absId <= fEmcCrystals){ //digitize as EMC
374 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
375 if(chanel > fNADCemc ) chanel = fNADCemc ;
377 else{ //Digitize as CPV
378 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
379 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
384 //____________________________________________________________________________
385 void AliPHOSDigitizer::Exec(Option_t *option)
389 if (!fInit) { // to prevent overwrite existing file
390 Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
394 if (strstr(option,"print")) {
399 if(strstr(option,"tim"))
400 gBenchmark->Start("PHOSDigitizer");
403 fInput = fManager->GetNinputs() ;
405 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
407 Int_t nevents = gime->MaxEvent() ;
411 for(ievent = 0; ievent < nevents; ievent++){
413 gime->Event(ievent,"S") ;
415 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
419 if(strstr(option,"deb"))
422 //increment the total number of Digits per run
423 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
426 if(strstr(option,"tim")){
427 gBenchmark->Stop("PHOSDigitizer");
429 message = " took %f seconds for Digitizing %f seconds per event\n" ;
430 Info("Exec", message.Data(),
431 gBenchmark->GetCpuTime("PHOSDigitizer"),
432 gBenchmark->GetCpuTime("PHOSDigitizer")/nevents );
436 //____________________________________________________________________________
437 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
439 // Returns the shortest time among all time ticks
441 ticks->Sort() ; //Sort in accordance with times of ticks
443 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
444 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
447 while((t=(AliPHOSTick*) it.Next())){
448 if(t->GetTime() < time) //This tick starts before crossing
453 time = ctick->CrossingTime(fTimeThreshold) ;
458 //____________________________________________________________________________
459 Bool_t AliPHOSDigitizer::Init()
461 // Makes all memory allocations
463 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
465 Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ;
469 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
471 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
473 TString opt("Digits") ;
474 if(gime->VersionExists(opt) ) {
475 Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ;
479 // Post Digitizer to the white board
480 gime->PostDigitizer(this) ;
483 fInput = fManager->GetNinputs() ;
487 fInputFileNames = new TString[fInput] ;
488 fEventNames = new TString[fInput] ;
489 fInputFileNames[0] = GetTitle() ;
490 fEventNames[0] = fEventFolderName.Data() ;
492 for (index = 1 ; index < fInput ; index++) {
493 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
494 TString tempo = fManager->GetInputFolderName(index) ;
495 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added bt fManager
498 //to prevent cleaning of this object while GetEvent is called
499 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
504 //____________________________________________________________________________
505 void AliPHOSDigitizer::InitParameters()
507 // Set initial parameters for Digitizer
510 fEMCDigitThreshold = 0.012 ;
512 fCPVDigitThreshold = 0.09 ;
513 fTimeResolution = 0.5e-9 ;
514 fTimeSignalLength = 1.0e-9 ;
516 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
517 fADCpedestalEmc = 0.005 ; //
518 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
520 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
521 fADCpedestalCpv = 0.012 ; //
522 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
524 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
528 //__________________________________________________________________
529 void AliPHOSDigitizer::MixWith(const TString alirunFileName, const TString eventFolderName)
531 // Allows to produce digits by superimposing background and signal event.
532 // It is assumed, that headers file with SIGNAL events is opened in
534 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
535 // Thus we avoid writing (changing) huge and expensive
536 // backgound files: all output will be writen into SIGNAL, i.e.
537 // opened in constructor file.
539 // One can open as many files to mix with as one needs.
540 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
543 if( strcmp(fEventFolderName, "") == 0 )
547 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
550 // looking for file which contains AliRun
551 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
552 Error("MixWith", "File %s does not exist!", alirunFileName.Data()) ;
555 // looking for the file which contains SDigits
556 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
557 TString fileName( gime->GetSDigitsFileName() ) ;
558 if ( eventFolderName != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
559 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
560 if ( (gSystem->AccessPathName(fileName)) ) {
561 Error("MixWith", "The file %s does not exist!", fileName.Data()) ;
564 // need to increase the arrays
565 TString tempo = fInputFileNames[fInput-1] ;
566 delete [] fInputFileNames ;
567 fInputFileNames = new TString[fInput+1] ;
568 fInputFileNames[fInput-1] = tempo ;
570 tempo = fEventNames[fInput-1] ;
571 delete [] fEventNames ;
572 fEventNames = new TString[fInput+1] ;
573 fEventNames[fInput-1] = tempo ;
575 fInputFileNames[fInput] = alirunFileName ;
576 fEventNames[fInput] = eventFolderName ;
580 //__________________________________________________________________
581 void AliPHOSDigitizer::Print()const
583 // Print Digitizer's parameters
584 Info("Print", "\n------------------- %s -------------", GetName() ) ;
585 if( strcmp(fEventFolderName.Data(), "") != 0 ){
586 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
590 nStreams = GetNInputStreams() ;
595 for (index = 0 ; index < nStreams ; index++) {
596 TString tempo(fEventNames[index]) ;
598 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
599 TString fileName( gime->GetSDigitsFileName() ) ;
600 if ( fEventNames[index] != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
601 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
602 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
604 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
605 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
607 printf("\nWith following parameters:\n") ;
608 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
609 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
610 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
611 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
612 printf(" ---------------------------------------------------\n") ;
615 Info("Print", "AliPHOSDigitizer not initialized" ) ;
619 //__________________________________________________________________
620 void AliPHOSDigitizer::PrintDigits(Option_t * option)
622 // Print a table of digits
624 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
625 TClonesArray * digits = gime->Digits() ;
627 Info("PrintDigits", "%d", digits->GetEntriesFast()) ;
628 printf("\nevent %d", gAlice->GetEvNumber()) ;
629 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
632 if(strstr(option,"all")||strstr(option,"EMC")){
634 AliPHOSDigit * digit;
635 printf("\nEMC digits (with primaries):\n") ;
636 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
637 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
639 for (index = 0 ; (index < digits->GetEntriesFast()) &&
640 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
641 digit = (AliPHOSDigit * ) digits->At(index) ;
642 if(digit->GetNprimary() == 0)
644 printf("%6d %8d %6.5e %4d %2d :",
645 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
647 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
648 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
654 if(strstr(option,"all")||strstr(option,"CPV")){
656 //loop over CPV digits
657 AliPHOSDigit * digit;
658 printf("\nCPV digits (with primaries):\n") ;
659 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
660 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
662 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
663 digit = (AliPHOSDigit * ) digits->At(index) ;
664 if(digit->GetId() > maxEmc){
665 printf("%6d %8d %4d %2d :",
666 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
668 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
669 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
678 //__________________________________________________________________
679 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
680 { // Calculates the time signal generated by noise
681 //to be rewritten, now returns just big number
686 //__________________________________________________________________
687 void AliPHOSDigitizer::Unload()
691 for(i = 1 ; i < fInput ; i++){
692 TString tempo(fEventNames[i]) ;
694 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
695 gime->PhosLoader()->UnloadSDigits() ;
698 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
699 gime->PhosLoader()->UnloadDigits() ;
702 //____________________________________________________________________________
703 void AliPHOSDigitizer::WriteDigits()
706 // Makes TreeD in the output file.
707 // Check if branch already exists:
708 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
709 // already existing branches.
710 // else creates branch with Digits, named "PHOS", title "...",
711 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
712 // and names of files, from which digits are made.
714 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
715 const TClonesArray * digits = gime->Digits() ;
716 TTree * treeD = gime->TreeD();
718 // -- create Digits branch
719 Int_t bufferSize = 32000 ;
720 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
721 digitsBranch->SetTitle(fEventFolderName);
722 digitsBranch->Fill() ;
724 gime->WriteDigits("OVERWRITE");
725 gime->WriteDigitizer("OVERWRITE");