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(TString alirunFileName,
94 TString eventFolderName):
95 AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(),
97 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
102 fDefaultInit = kFALSE ;
103 fManager = 0 ; // We work in the standalong mode
106 //____________________________________________________________________________
107 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
112 SetName(d.GetName()) ;
113 SetTitle(d.GetTitle()) ;
114 fPinNoise = d.fPinNoise ;
115 fEMCDigitThreshold = d.fEMCDigitThreshold ;
116 fCPVNoise = d.fCPVNoise ;
117 fCPVDigitThreshold = d.fCPVDigitThreshold ;
118 fTimeResolution = d.fTimeResolution ;
119 fTimeThreshold = d.fTimeThreshold ;
120 fTimeSignalLength = d.fTimeSignalLength ;
121 fADCchanelEmc = d.fADCchanelEmc ;
122 fADCpedestalEmc = d.fADCpedestalEmc ;
123 fNADCemc = d.fNADCemc ;
124 fADCchanelCpv = d.fADCchanelCpv ;
125 fADCpedestalCpv = d.fADCpedestalCpv ;
126 fNADCcpv = d.fNADCcpv ;
127 fEventFolderName = d.fEventFolderName;
130 //____________________________________________________________________________
131 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
132 AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()),
135 // ctor Init() is called by RunDigitizer
137 fEventFolderName = fManager->GetInputFolderName(0) ;
138 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
140 fDefaultInit = kFALSE ;
143 //____________________________________________________________________________
144 AliPHOSDigitizer::~AliPHOSDigitizer()
147 delete [] fInputFileNames ;
148 delete [] fEventNames ;
152 //____________________________________________________________________________
153 void AliPHOSDigitizer::Digitize(Int_t event)
156 // Makes the digitization of the collected summable digits.
157 // It first creates the array of all PHOS modules
158 // filled with noise (different for EMC, and CPV) and
159 // then adds contributions from SDigits.
160 // This design avoids scanning over the list of digits to add
161 // contribution to new SDigits only.
163 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
164 Int_t ReadEvent = event ;
166 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
167 AliInfo(Form("Adding event %d from input stream 0 %s %s",
168 ReadEvent, GetTitle(), fEventFolderName.Data())) ;
169 gime->Event(ReadEvent, "S") ;
170 TClonesArray * digits = gime->Digits() ;
173 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
174 //Making digits with noise, first EMC
175 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
180 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
182 digits->Expand(nCPV) ;
184 // get first the sdigitizer from the tasks list
185 if ( !gime->SDigitizer() )
186 gime->LoadSDigitizer();
187 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
190 AliFatal(Form("SDigitizer with name %s %s not found",
191 GetTitle(), fEventFolderName.Data() )) ;
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) ;
202 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
203 AliInfo(Form("Adding event %d from input stream %d %s %s",
204 ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
205 gime->Event(ReadEvent,"S");
206 sdigArray->AddAt(gime->SDigits(), i) ;
209 //Find the first crystall with signal
210 Int_t nextSig = 200000 ;
211 TClonesArray * sdigits ;
212 for(i = 0 ; i < fInput ; i++){
213 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
214 if ( !sdigits->GetEntriesFast() )
216 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
217 if(curNext < nextSig)
221 TArrayI index(fInput) ;
222 index.Reset() ; //Set all indexes to zero
224 AliPHOSDigit * digit ;
225 AliPHOSDigit * curSDigit ;
227 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
229 //Put Noise contribution
230 for(absID = 1 ; absID <= nEMC ; absID++){
231 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
232 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
233 //look if we have to add signal?
234 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
237 //Add SDigits from all inputs
240 Float_t a = digit->GetAmp() ;
241 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
242 //Mark the beginning of the signal
243 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
244 //Mark the end of the ignal
245 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
248 for(i = 0 ; i < fInput ; i++){
249 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
250 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
253 //May be several digits will contribute from the same input
254 while(curSDigit && curSDigit->GetId() == absID){
255 //Shift primary to separate primaries belonging different inputs
256 Int_t primaryoffset ;
258 primaryoffset = fManager->GetMask(i) ;
260 primaryoffset = 10000000*i ;
261 curSDigit->ShiftPrimary(primaryoffset) ;
263 a = curSDigit->GetAmp() ;
264 b = a /fTimeSignalLength ;
265 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
266 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
268 *digit = *digit + *curSDigit ; //add energies
271 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
272 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
278 //calculate and set time
279 Float_t time = FrontEdgeTime(ticks) ;
280 digit->SetTime(time) ;
282 //Find next signal module
284 for(i = 0 ; i < fInput ; i++){
285 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
286 Int_t curNext = nextSig ;
287 if(sdigits->GetEntriesFast() > index[i] ){
288 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
290 if(curNext < nextSig) nextSig = curNext ;
298 //Now CPV digits (different noise and no timing)
299 for(absID = nEMC+1; absID <= nCPV; absID++){
300 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
301 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
302 //look if we have to add signal?
304 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
305 //Add SDigits from all inputs
306 for(i = 0 ; i < fInput ; i++){
307 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
308 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
312 //May be several digits will contribute from the same input
313 while(curSDigit && curSDigit->GetId() == absID){
314 //Shift primary to separate primaries belonging different inputs
315 Int_t primaryoffset ;
317 primaryoffset = fManager->GetMask(i) ;
319 primaryoffset = 10000000*i ;
320 curSDigit->ShiftPrimary(primaryoffset) ;
323 *digit = *digit + *curSDigit ;
325 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
326 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
332 //Find next signal module
334 for(i = 0 ; i < fInput ; i++){
335 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
336 Int_t curNext = nextSig ;
337 if(sdigits->GetEntriesFast() > index[i] )
338 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
339 if(curNext < nextSig) nextSig = curNext ;
345 delete sdigArray ; //We should not delete its contents
347 //remove digits below thresholds
348 for(i = 0 ; i < nEMC ; i++){
349 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
350 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
351 digits->RemoveAt(i) ;
353 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
357 for(i = nEMC; i < nCPV ; i++)
358 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
359 digits->RemoveAt(i) ;
363 Int_t ndigits = digits->GetEntriesFast() ;
364 digits->Expand(ndigits) ;
366 //Set indexes in list of digits and make true digitization of the energy
367 for (i = 0 ; i < ndigits ; i++) {
368 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
369 digit->SetIndexInList(i) ;
370 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
371 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
375 //____________________________________________________________________________
376 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
378 // Returns digitized value of the energy in a cell absId
381 if(absId <= fEmcCrystals){ //digitize as EMC
382 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
383 if(chanel > fNADCemc ) chanel = fNADCemc ;
385 else{ //Digitize as CPV
386 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
387 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
392 //____________________________________________________________________________
393 void AliPHOSDigitizer::Exec(Option_t *option)
395 // Steering method to process digitization for events
396 // in the range from fFirstEvent to fLastEvent.
397 // This range is optionally set by SetEventRange().
398 // if fLastEvent=-1, then process events until the end.
399 // by default fLastEvent = fFirstEvent (process only one event)
401 if (!fInit) { // to prevent overwrite existing file
402 AliError(Form("Give a version name different from %s",
403 fEventFolderName.Data() )) ;
407 if (strstr(option,"print")) {
412 if(strstr(option,"tim"))
413 gBenchmark->Start("PHOSDigitizer");
415 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
417 // Post Digitizer to the white board
418 gime->PostDigitizer(this) ;
420 if (fLastEvent == -1)
421 fLastEvent = gime->MaxEvent() - 1 ;
423 fLastEvent = fFirstEvent ;
425 Int_t nEvents = fLastEvent - fFirstEvent + 1;
429 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
431 gime->Event(ievent,"S") ;
433 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
437 if(strstr(option,"deb"))
440 //increment the total number of Digits per run
441 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
444 gime->PhosLoader()->CleanDigitizer();
446 if(strstr(option,"tim")){
447 gBenchmark->Stop("PHOSDigitizer");
449 message = " took %f seconds for Digitizing %f seconds per event\n" ;
450 AliInfo(Form( message.Data(),
451 gBenchmark->GetCpuTime("PHOSDigitizer"),
452 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents ));
456 //____________________________________________________________________________
457 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
459 // Returns the shortest time among all time ticks
461 ticks->Sort() ; //Sort in accordance with times of ticks
463 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
464 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
467 while((t=(AliPHOSTick*) it.Next())){
468 if(t->GetTime() < time) //This tick starts before crossing
473 time = ctick->CrossingTime(fTimeThreshold) ;
478 //____________________________________________________________________________
479 Bool_t AliPHOSDigitizer::Init()
481 // Makes all memory allocations
483 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
485 AliFatal(Form("Could not obtain the Getter object for file %s and event %s !",
486 GetTitle(), fEventFolderName.Data()));
490 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
492 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
494 TString opt("Digits") ;
495 if(gime->VersionExists(opt) ) {
496 AliError(Form("Give a version name different from %s",
497 fEventFolderName.Data() )) ;
502 fLastEvent = fFirstEvent ;
504 fInput = fManager->GetNinputs() ;
508 fInputFileNames = new TString[fInput] ;
509 fEventNames = new TString[fInput] ;
510 fInputFileNames[0] = GetTitle() ;
511 fEventNames[0] = fEventFolderName.Data() ;
513 for (index = 1 ; index < fInput ; index++) {
514 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
515 TString tempo = fManager->GetInputFolderName(index) ;
516 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
519 //to prevent cleaning of this object while GetEvent is called
520 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
525 //____________________________________________________________________________
526 void AliPHOSDigitizer::InitParameters()
528 // Set initial parameters Digitizer
531 fEMCDigitThreshold = 0.012 ;
533 fCPVDigitThreshold = 0.09 ;
534 fTimeResolution = 0.5e-9 ;
535 fTimeSignalLength = 1.0e-9 ;
537 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
538 fADCpedestalEmc = 0.005 ; //
539 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
541 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
542 fADCpedestalCpv = 0.012 ; //
543 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
545 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
546 SetEventRange(0,-1) ;
550 //__________________________________________________________________
551 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
553 // Allows to produce digits by superimposing background and signal event.
554 // It is assumed, that headers file with SIGNAL events is opened in
556 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
557 // Thus we avoid writing (changing) huge and expensive
558 // backgound files: all output will be writen into SIGNAL, i.e.
559 // opened in constructor file.
561 // One can open as many files to mix with as one needs.
562 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
565 if( strcmp(fEventFolderName, "") == 0 )
569 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
572 // looking for file which contains AliRun
573 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
574 AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
577 // looking for the file which contains SDigits
578 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
579 TString fileName( gime->GetSDigitsFileName() ) ;
580 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
581 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
582 if ( (gSystem->AccessPathName(fileName)) ) {
583 AliError(Form("The file %s does not exist!", fileName.Data())) ;
586 // need to increase the arrays
587 TString tempo = fInputFileNames[fInput-1] ;
588 delete [] fInputFileNames ;
589 fInputFileNames = new TString[fInput+1] ;
590 fInputFileNames[fInput-1] = tempo ;
592 tempo = fEventNames[fInput-1] ;
593 delete [] fEventNames ;
594 fEventNames = new TString[fInput+1] ;
595 fEventNames[fInput-1] = tempo ;
597 fInputFileNames[fInput] = alirunFileName ;
598 fEventNames[fInput] = eventFolderName ;
602 //__________________________________________________________________
603 void AliPHOSDigitizer::Print()const
605 // Print Digitizer's parameters
606 AliInfo(Form("\n------------------- %s -------------", GetName() )) ;
607 if( strcmp(fEventFolderName.Data(), "") != 0 ){
608 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
612 nStreams = GetNInputStreams() ;
617 for (index = 0 ; index < nStreams ; index++) {
618 TString tempo(fEventNames[index]) ;
620 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
621 TString fileName( gime->GetSDigitsFileName() ) ;
622 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
623 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
624 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
626 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
627 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
629 printf("\nWith following parameters:\n") ;
630 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
631 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
632 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
633 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
634 printf(" ---------------------------------------------------\n") ;
637 AliInfo(Form("AliPHOSDigitizer not initialized" )) ;
641 //__________________________________________________________________
642 void AliPHOSDigitizer::PrintDigits(Option_t * option)
644 // Print a table of digits
646 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
647 TClonesArray * digits = gime->Digits() ;
649 AliInfo(Form("%d", digits->GetEntriesFast())) ;
650 printf("\nevent %d", gAlice->GetEvNumber()) ;
651 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
654 if(strstr(option,"all")||strstr(option,"EMC")){
656 AliPHOSDigit * digit;
657 printf("\nEMC digits (with primaries):\n") ;
658 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
659 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
661 for (index = 0 ; (index < digits->GetEntriesFast()) &&
662 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
663 digit = (AliPHOSDigit * ) digits->At(index) ;
664 if(digit->GetNprimary() == 0)
666 printf("%6d %8d %6.5e %4d %2d :",
667 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
669 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
670 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
676 if(strstr(option,"all")||strstr(option,"CPV")){
678 //loop over CPV digits
679 AliPHOSDigit * digit;
680 printf("\nCPV digits (with primaries):\n") ;
681 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
682 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
684 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
685 digit = (AliPHOSDigit * ) digits->At(index) ;
686 if(digit->GetId() > maxEmc){
687 printf("%6d %8d %4d %2d :",
688 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
690 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
691 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
700 //__________________________________________________________________
701 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
702 { // Calculates the time signal generated by noise
703 //PH Info("TimeOfNoise", "Change me") ;
704 return gRandom->Rndm() * 1.28E-5;
707 //__________________________________________________________________
708 void AliPHOSDigitizer::Unload()
712 for(i = 1 ; i < fInput ; i++){
713 TString tempo(fEventNames[i]) ;
715 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
716 gime->PhosLoader()->UnloadSDigits() ;
719 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
720 gime->PhosLoader()->UnloadDigits() ;
723 //____________________________________________________________________________
724 void AliPHOSDigitizer::WriteDigits()
727 // Makes TreeD in the output file.
728 // Check if branch already exists:
729 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
730 // already existing branches.
731 // else creates branch with Digits, named "PHOS", title "...",
732 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
733 // and names of files, from which digits are made.
735 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
736 const TClonesArray * digits = gime->Digits() ;
737 TTree * treeD = gime->TreeD();
739 // -- create Digits branch
740 Int_t bufferSize = 32000 ;
741 TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
742 digitsBranch->SetTitle(fEventFolderName);
743 digitsBranch->Fill() ;
745 gime->WriteDigits("OVERWRITE");
746 gime->WriteDigitizer("OVERWRITE");