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 ---
64 #include "TObjString.h"
65 #include "TGeometry.h"
66 #include "TBenchmark.h"
68 // --- Standard library ---
70 // --- AliRoot header files ---
72 #include "AliHeader.h"
73 #include "AliStream.h"
74 #include "AliRunDigitizer.h"
75 #include "AliPHOSDigit.h"
77 #include "AliPHOSGetter.h"
78 #include "AliPHOSDigitizer.h"
79 #include "AliPHOSSDigitizer.h"
80 #include "AliPHOSGeometry.h"
81 #include "AliPHOSTick.h"
83 ClassImp(AliPHOSDigitizer)
86 //____________________________________________________________________________
87 AliPHOSDigitizer::AliPHOSDigitizer():AliDigitizer("",""),
94 fDefaultInit = kTRUE ;
95 fManager = 0 ; // We work in the standalong mode
96 fEventFolderName = "" ;
99 //____________________________________________________________________________
100 AliPHOSDigitizer::AliPHOSDigitizer(const TString alirunFileName, const TString eventFolderName):
101 AliDigitizer("PHOS"+AliConfig::fgkDigitizerTaskName, alirunFileName),
102 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
108 fDefaultInit = kFALSE ;
109 fManager = 0 ; // We work in the standalong mode
112 //____________________________________________________________________________
113 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
117 SetName(d.GetName()) ;
118 SetTitle(d.GetTitle()) ;
119 fPinNoise = d.fPinNoise ;
120 fEMCDigitThreshold = d.fEMCDigitThreshold ;
121 fCPVNoise = d.fCPVNoise ;
122 fCPVDigitThreshold = d.fCPVDigitThreshold ;
123 fTimeResolution = d.fTimeResolution ;
124 fTimeThreshold = d.fTimeThreshold ;
125 fTimeSignalLength = d.fTimeSignalLength ;
126 fADCchanelEmc = d.fADCchanelEmc ;
127 fADCpedestalEmc = d.fADCpedestalEmc ;
128 fNADCemc = d.fNADCemc ;
129 fADCchanelCpv = d.fADCchanelCpv ;
130 fADCpedestalCpv = d.fADCpedestalCpv ;
131 fNADCcpv = d.fNADCcpv ;
132 fEventFolderName = d.fEventFolderName;
135 //____________________________________________________________________________
136 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
137 AliDigitizer(rd,"PHOS"+AliConfig::fgkDigitizerTaskName),
142 SetName(fManager->GetInputFolderName(0)) ;
143 // take title as name of stream 0
144 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
147 fDefaultInit = kFALSE ;
150 //____________________________________________________________________________
151 AliPHOSDigitizer::~AliPHOSDigitizer()
154 delete [] fInputFileNames ;
155 delete [] fEventNames ;
159 //____________________________________________________________________________
160 void AliPHOSDigitizer::Digitize(const Int_t event)
163 // Makes the digitization of the collected summable digits.
164 // It first creates the array of all PHOS modules
165 // filled with noise (different for EMC, CPV and PPSD) and
166 // then adds contributions from SDigits.
167 // This design avoids scanning over the list of digits to add
168 // contribution to new SDigits only.
170 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
171 TClonesArray * digits = gime->Digits() ;
174 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
175 //Making digits with noise, first EMC
176 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
181 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
183 digits->Expand(nCPV) ;
185 // get first the sdigitizer from the tasks list
186 if ( !gime->SDigitizer() )
187 gime->LoadSDigitizer();
188 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
191 Fatal("Digitize", "SDigitizer with name %s %s not found", fEventFolderName.Data(), GetTitle() ) ;
193 //take all the inputs to add together and load the SDigits
194 TObjArray * sdigArray = new TObjArray(fInput) ;
195 sdigArray->AddAt(gime->SDigits(), 0) ;
197 for(i = 1 ; i < fInput ; i++){
198 TString tempo(fEventNames[i]) ;
200 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
201 gime->Event(event,"S");
202 sdigArray->AddAt(gime->SDigits(), i) ;
205 //Find the first crystall with signal
206 Int_t nextSig = 200000 ;
207 TClonesArray * sdigits ;
208 for(i = 0 ; i < fInput ; i++){
209 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
210 if ( !sdigits->GetEntriesFast() )
212 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
213 if(curNext < nextSig)
217 TArrayI index(fInput) ;
218 index.Reset() ; //Set all indexes to zero
220 AliPHOSDigit * digit ;
221 AliPHOSDigit * curSDigit ;
223 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
225 //Put Noise contribution
226 for(absID = 1 ; absID <= nEMC ; absID++){
227 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
228 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
229 //look if we have to add signal?
230 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
233 //Add SDigits from all inputs
236 Float_t a = digit->GetAmp() ;
237 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
238 //Mark the beginning of the signal
239 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
240 //Mark the end of the ignal
241 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
244 for(i = 0 ; i < fInput ; i++){
245 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
246 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
249 //May be several digits will contribute from the same input
250 while(curSDigit && curSDigit->GetId() == absID){
251 //Shift primary to separate primaries belonging different inputs
252 Int_t primaryoffset ;
254 primaryoffset = fManager->GetMask(i) ;
256 primaryoffset = 10000000*i ;
257 curSDigit->ShiftPrimary(primaryoffset) ;
259 a = curSDigit->GetAmp() ;
260 b = a /fTimeSignalLength ;
261 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
262 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
264 *digit = *digit + *curSDigit ; //add energies
267 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
268 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
274 //calculate and set time
275 Float_t time = FrontEdgeTime(ticks) ;
276 digit->SetTime(time) ;
278 //Find next signal module
280 for(i = 0 ; i < fInput ; i++){
281 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
282 Int_t curNext = nextSig ;
283 if(sdigits->GetEntriesFast() > index[i] ){
284 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
286 if(curNext < nextSig) nextSig = curNext ;
294 //Now CPV digits (different noise and no timing)
295 for(absID = nEMC+1; absID <= nCPV; absID++){
296 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
297 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
298 //look if we have to add signal?
300 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
301 //Add SDigits from all inputs
302 for(i = 0 ; i < fInput ; i++){
303 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
304 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
308 //May be several digits will contribute from the same input
309 while(curSDigit && curSDigit->GetId() == absID){
310 //Shift primary to separate primaries belonging different inputs
311 Int_t primaryoffset ;
313 primaryoffset = fManager->GetMask(i) ;
315 primaryoffset = 10000000*i ;
316 curSDigit->ShiftPrimary(primaryoffset) ;
319 *digit = *digit + *curSDigit ;
321 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
322 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
328 //Find next signal module
330 for(i = 0 ; i < fInput ; i++){
331 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
332 Int_t curNext = nextSig ;
333 if(sdigits->GetEntriesFast() > index[i] )
334 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
335 if(curNext < nextSig) nextSig = curNext ;
341 delete sdigArray ; //We should not delete its contents
343 //remove digits below thresholds
344 for(i = 0 ; i < nEMC ; i++){
345 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
346 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
347 digits->RemoveAt(i) ;
349 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
353 for(i = nEMC; i < nCPV ; i++)
354 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
355 digits->RemoveAt(i) ;
359 Int_t ndigits = digits->GetEntriesFast() ;
360 digits->Expand(ndigits) ;
362 //Set indexes in list of digits and make true digitization of the energy
363 for (i = 0 ; i < ndigits ; i++) {
364 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
365 digit->SetIndexInList(i) ;
366 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
367 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
371 //____________________________________________________________________________
372 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
374 // Returns digitized value of the energy in a cell absId
377 if(absId <= fEmcCrystals){ //digitize as EMC
378 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
379 if(chanel > fNADCemc ) chanel = fNADCemc ;
381 else{ //Digitize as CPV
382 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
383 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
388 //____________________________________________________________________________
389 void AliPHOSDigitizer::Exec(Option_t *option)
393 if (!fInit) { // to prevent overwrite existing file
394 Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
398 if (strstr(option,"print")) {
403 if(strstr(option,"tim"))
404 gBenchmark->Start("PHOSDigitizer");
407 fInput = fManager->GetNinputs() ;
409 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
411 Int_t nevents = gime->MaxEvent() ;
415 for(ievent = 0; ievent < nevents; ievent++){
417 gime->Event(ievent,"S") ;
419 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
421 WriteDigits(ievent) ;
423 if(strstr(option,"deb"))
426 //increment the total number of Digits per run
427 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
430 if(strstr(option,"tim")){
431 gBenchmark->Stop("PHOSDigitizer");
433 message = " took %f seconds for Digitizing %f seconds per event\n" ;
434 Info("Exec", message.Data(),
435 gBenchmark->GetCpuTime("PHOSDigitizer"),
436 gBenchmark->GetCpuTime("PHOSDigitizer")/nevents );
440 //____________________________________________________________________________
441 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
443 // Returns the shortest time among all time ticks
445 ticks->Sort() ; //Sort in accordance with times of ticks
447 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
448 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
451 while((t=(AliPHOSTick*) it.Next())){
452 if(t->GetTime() < time) //This tick starts before crossing
457 time = ctick->CrossingTime(fTimeThreshold) ;
462 //____________________________________________________________________________
463 Bool_t AliPHOSDigitizer::Init()
465 // Makes all memory allocations
467 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
469 Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ;
473 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
475 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
477 TString opt("Digits") ;
478 if(gime->VersionExists(opt) ) {
479 Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ;
483 // Post Digitizer to the white board
484 gime->PostDigitizer(this) ;
487 fInput = fManager->GetNinputs() ;
491 fInputFileNames = new TString[fInput] ;
492 fEventNames = new TString[fInput] ;
493 fInputFileNames[0] = GetTitle() ;
494 fEventNames[0] = fEventFolderName.Data() ;
496 for (index = 1 ; index < fInput ; index++) {
497 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
498 TString tempo = fManager->GetInputFolderName(index) ;
499 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added bt fManager
502 //to prevent cleaning of this object while GetEvent is called
503 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
508 //____________________________________________________________________________
509 void AliPHOSDigitizer::InitParameters()
511 // Set initial parameters for Digitizer
514 fEMCDigitThreshold = 0.012 ;
516 fCPVDigitThreshold = 0.09 ;
517 fTimeResolution = 0.5e-9 ;
518 fTimeSignalLength = 1.0e-9 ;
520 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
521 fADCpedestalEmc = 0.005 ; //
522 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
524 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
525 fADCpedestalCpv = 0.012 ; //
526 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
528 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
532 //__________________________________________________________________
533 void AliPHOSDigitizer::MixWith(const TString alirunFileName, const TString eventFolderName)
535 // Allows to produce digits by superimposing background and signal event.
536 // It is assumed, that headers file with SIGNAL events is opened in
538 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
539 // Thus we avoid writing (changing) huge and expensive
540 // backgound files: all output will be writen into SIGNAL, i.e.
541 // opened in constructor file.
543 // One can open as many files to mix with as one needs.
544 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
547 if( strcmp(fEventFolderName, "") == 0 )
551 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
554 // looking for file which contains AliRun
555 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
556 Error("MixWith", "File %s does not exist!", alirunFileName.Data()) ;
559 // looking for the file which contains SDigits
560 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
561 TString fileName( gime->GetSDigitsFileName() ) ;
562 if ( eventFolderName != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
563 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
564 if ( (gSystem->AccessPathName(fileName)) ) {
565 Error("MixWith", "The file %s does not exist!", fileName.Data()) ;
568 // need to increase the arrays
569 TString tempo = fInputFileNames[fInput-1] ;
570 delete [] fInputFileNames ;
571 fInputFileNames = new TString[fInput+1] ;
572 fInputFileNames[fInput-1] = tempo ;
574 tempo = fEventNames[fInput-1] ;
575 delete [] fEventNames ;
576 fEventNames = new TString[fInput+1] ;
577 fEventNames[fInput-1] = tempo ;
579 fInputFileNames[fInput] = alirunFileName ;
580 fEventNames[fInput] = eventFolderName ;
584 //__________________________________________________________________
585 void AliPHOSDigitizer::Print()const
587 // Print Digitizer's parameters
588 Info("Print", "\n------------------- %s -------------", GetName() ) ;
589 if( strcmp(fEventFolderName.Data(), "") != 0 ){
590 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
594 nStreams = GetNInputStreams() ;
599 for (index = 0 ; index < nStreams ; index++) {
600 TString tempo(fEventNames[index]) ;
602 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
603 TString fileName( gime->GetSDigitsFileName() ) ;
604 if ( fEventNames[index] != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
605 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
606 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
608 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
609 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
611 printf("\nWith following parameters:\n") ;
612 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
613 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
614 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
615 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
616 printf(" ---------------------------------------------------\n") ;
619 Info("Print", "AliPHOSDigitizer not initialized" ) ;
623 //__________________________________________________________________
624 void AliPHOSDigitizer::PrintDigits(Option_t * option)
626 // Print a table of digits
628 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
629 TClonesArray * digits = gime->Digits() ;
631 Info("PrintDigits", "%d", digits->GetEntriesFast()) ;
632 printf("\nevent %d", gAlice->GetEvNumber()) ;
633 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
636 if(strstr(option,"all")||strstr(option,"EMC")){
638 AliPHOSDigit * digit;
639 printf("\nEMC digits (with primaries):\n") ;
640 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
641 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
643 for (index = 0 ; (index < digits->GetEntriesFast()) &&
644 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
645 digit = (AliPHOSDigit * ) digits->At(index) ;
646 if(digit->GetNprimary() == 0)
648 printf("%6d %8d %6.5e %4d %2d :",
649 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
651 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
652 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
658 if(strstr(option,"all")||strstr(option,"CPV")){
660 //loop over CPV digits
661 AliPHOSDigit * digit;
662 printf("\nCPV digits (with primaries):\n") ;
663 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
664 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
666 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
667 digit = (AliPHOSDigit * ) digits->At(index) ;
668 if(digit->GetId() > maxEmc){
669 printf("%6d %8d %4d %2d :",
670 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
672 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
673 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
682 //__________________________________________________________________
683 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
684 { // Calculates the time signal generated by noise
685 //to be rewritten, now returns just big number
690 //__________________________________________________________________
691 void AliPHOSDigitizer::Unload()
695 for(i = 1 ; i < fInput ; i++){
696 TString tempo(fEventNames[i]) ;
698 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
699 gime->PhosLoader()->UnloadSDigits() ;
702 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
703 gime->PhosLoader()->UnloadDigits() ;
706 //____________________________________________________________________________
707 void AliPHOSDigitizer::WriteDigits(Int_t event)
710 // Makes TreeD in the output file.
711 // Check if branch already exists:
712 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
713 // already existing branches.
714 // else creates branch with Digits, named "PHOS", title "...",
715 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
716 // and names of files, from which digits are made.
718 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
719 const TClonesArray * digits = gime->Digits() ;
720 TTree * treeD = gime->TreeD();
722 // -- create Digits branch
723 Int_t bufferSize = 32000 ;
724 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
725 digitsBranch->SetTitle(fEventFolderName);
726 digitsBranch->Fill() ;
728 gime->WriteDigits("OVERWRITE");
729 gime->WriteDigitizer("OVERWRITE");