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, TString eventFolderName):
94 AliDigitizer("PHOS"+AliConfig::fgkDigitizerTaskName, alirunFileName),
95 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
100 fDefaultInit = kFALSE ;
101 fManager = 0 ; // We work in the standalong mode
104 //____________________________________________________________________________
105 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
110 SetName(d.GetName()) ;
111 SetTitle(d.GetTitle()) ;
112 fPinNoise = d.fPinNoise ;
113 fEMCDigitThreshold = d.fEMCDigitThreshold ;
114 fCPVNoise = d.fCPVNoise ;
115 fCPVDigitThreshold = d.fCPVDigitThreshold ;
116 fTimeResolution = d.fTimeResolution ;
117 fTimeThreshold = d.fTimeThreshold ;
118 fTimeSignalLength = d.fTimeSignalLength ;
119 fADCchanelEmc = d.fADCchanelEmc ;
120 fADCpedestalEmc = d.fADCpedestalEmc ;
121 fNADCemc = d.fNADCemc ;
122 fADCchanelCpv = d.fADCchanelCpv ;
123 fADCpedestalCpv = d.fADCpedestalCpv ;
124 fNADCcpv = d.fNADCcpv ;
125 fEventFolderName = d.fEventFolderName;
128 //____________________________________________________________________________
129 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
130 AliDigitizer(rd,"PHOS"+AliConfig::fgkDigitizerTaskName),
133 // ctor Init() is called by RunDigitizer
135 fEventFolderName = fManager->GetInputFolderName(0) ;
136 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
138 fDefaultInit = kFALSE ;
141 //____________________________________________________________________________
142 AliPHOSDigitizer::~AliPHOSDigitizer()
145 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(),fEventFolderName);
146 gime->PhosLoader()->CleanDigitizer();
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, CPV and PPSD) 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(), fEventFolderName) ;
164 Int_t ReadEvent = event ;
166 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
167 Info("Digitize", "Adding event %d from input stream 0", ReadEvent) ;
168 gime->Event(ReadEvent, "S") ;
169 TClonesArray * digits = gime->Digits() ;
172 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
173 //Making digits with noise, first EMC
174 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
179 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
181 digits->Expand(nCPV) ;
183 // get first the sdigitizer from the tasks list
184 if ( !gime->SDigitizer() )
185 gime->LoadSDigitizer();
186 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
189 Fatal("Digitize", "SDigitizer with name %s %s not found", fEventFolderName.Data(), GetTitle() ) ;
191 //take all the inputs to add together and load the SDigits
192 TObjArray * sdigArray = new TObjArray(fInput) ;
193 sdigArray->AddAt(gime->SDigits(), 0) ;
195 for(i = 1 ; i < fInput ; i++){
196 TString tempo(fEventNames[i]) ;
198 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
200 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
201 Info("Digitize", "Adding event %d from input stream %d", ReadEvent, i) ;
202 gime->Event(ReadEvent,"S");
203 sdigArray->AddAt(gime->SDigits(), i) ;
206 //Find the first crystall with signal
207 Int_t nextSig = 200000 ;
208 TClonesArray * sdigits ;
209 for(i = 0 ; i < fInput ; i++){
210 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
211 if ( !sdigits->GetEntriesFast() )
213 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
214 if(curNext < nextSig)
218 TArrayI index(fInput) ;
219 index.Reset() ; //Set all indexes to zero
221 AliPHOSDigit * digit ;
222 AliPHOSDigit * curSDigit ;
224 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
226 //Put Noise contribution
227 for(absID = 1 ; absID <= nEMC ; absID++){
228 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
229 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
230 //look if we have to add signal?
231 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
234 //Add SDigits from all inputs
237 Float_t a = digit->GetAmp() ;
238 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
239 //Mark the beginning of the signal
240 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
241 //Mark the end of the ignal
242 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
245 for(i = 0 ; i < fInput ; i++){
246 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
247 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
250 //May be several digits will contribute from the same input
251 while(curSDigit && curSDigit->GetId() == absID){
252 //Shift primary to separate primaries belonging different inputs
253 Int_t primaryoffset ;
255 primaryoffset = fManager->GetMask(i) ;
257 primaryoffset = 10000000*i ;
258 curSDigit->ShiftPrimary(primaryoffset) ;
260 a = curSDigit->GetAmp() ;
261 b = a /fTimeSignalLength ;
262 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
263 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
265 *digit = *digit + *curSDigit ; //add energies
268 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
269 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
275 //calculate and set time
276 Float_t time = FrontEdgeTime(ticks) ;
277 digit->SetTime(time) ;
279 //Find next signal module
281 for(i = 0 ; i < fInput ; i++){
282 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
283 Int_t curNext = nextSig ;
284 if(sdigits->GetEntriesFast() > index[i] ){
285 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
287 if(curNext < nextSig) nextSig = curNext ;
295 //Now CPV digits (different noise and no timing)
296 for(absID = nEMC+1; absID <= nCPV; absID++){
297 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
298 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
299 //look if we have to add signal?
301 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
302 //Add SDigits from all inputs
303 for(i = 0 ; i < fInput ; i++){
304 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
305 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
309 //May be several digits will contribute from the same input
310 while(curSDigit && curSDigit->GetId() == absID){
311 //Shift primary to separate primaries belonging different inputs
312 Int_t primaryoffset ;
314 primaryoffset = fManager->GetMask(i) ;
316 primaryoffset = 10000000*i ;
317 curSDigit->ShiftPrimary(primaryoffset) ;
320 *digit = *digit + *curSDigit ;
322 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
323 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
329 //Find next signal module
331 for(i = 0 ; i < fInput ; i++){
332 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
333 Int_t curNext = nextSig ;
334 if(sdigits->GetEntriesFast() > index[i] )
335 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
336 if(curNext < nextSig) nextSig = curNext ;
342 delete sdigArray ; //We should not delete its contents
344 //remove digits below thresholds
345 for(i = 0 ; i < nEMC ; i++){
346 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
347 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
348 digits->RemoveAt(i) ;
350 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
354 for(i = nEMC; i < nCPV ; i++)
355 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
356 digits->RemoveAt(i) ;
360 Int_t ndigits = digits->GetEntriesFast() ;
361 digits->Expand(ndigits) ;
363 //Set indexes in list of digits and make true digitization of the energy
364 for (i = 0 ; i < ndigits ; i++) {
365 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
366 digit->SetIndexInList(i) ;
367 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
368 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
372 //____________________________________________________________________________
373 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
375 // Returns digitized value of the energy in a cell absId
378 if(absId <= fEmcCrystals){ //digitize as EMC
379 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
380 if(chanel > fNADCemc ) chanel = fNADCemc ;
382 else{ //Digitize as CPV
383 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
384 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
389 //____________________________________________________________________________
390 void AliPHOSDigitizer::Exec(Option_t *option)
392 // Steering method to process digitization for events
393 // in the range from fFirstEvent to fLastEvent.
394 // This range is optionally set by SetEventRange().
395 // if fLastEvent=-1, then process events until the end.
396 // by default fLastEvent = fFirstEvent (process only one event)
398 if (!fInit) { // to prevent overwrite existing file
399 Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
403 if (strstr(option,"print")) {
408 if(strstr(option,"tim"))
409 gBenchmark->Start("PHOSDigitizer");
412 // fInput = fManager->GetNinputs() ;
414 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
416 if (fLastEvent == -1)
417 fLastEvent = gime->MaxEvent() - 1 ;
419 Int_t nEvents = fLastEvent - fFirstEvent + 1;
423 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
425 gime->Event(ievent,"S") ;
427 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
431 if(strstr(option,"deb"))
434 //increment the total number of Digits per run
435 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
438 if(strstr(option,"tim")){
439 gBenchmark->Stop("PHOSDigitizer");
441 message = " took %f seconds for Digitizing %f seconds per event\n" ;
442 Info("Exec", message.Data(),
443 gBenchmark->GetCpuTime("PHOSDigitizer"),
444 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents );
448 //____________________________________________________________________________
449 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
451 // Returns the shortest time among all time ticks
453 ticks->Sort() ; //Sort in accordance with times of ticks
455 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
456 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
459 while((t=(AliPHOSTick*) it.Next())){
460 if(t->GetTime() < time) //This tick starts before crossing
465 time = ctick->CrossingTime(fTimeThreshold) ;
470 //____________________________________________________________________________
471 Bool_t AliPHOSDigitizer::Init()
473 // Makes all memory allocations
475 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
477 Fatal("Init" ,"Could not obtain the Getter object for file %s and event %s !", GetTitle(), fEventFolderName.Data()) ;
481 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
483 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
485 TString opt("Digits") ;
486 if(gime->VersionExists(opt) ) {
487 Error( "Init", "Give a version name different from %s", fEventFolderName.Data() ) ;
491 // Post Digitizer to the white board
492 gime->PostDigitizer(this) ;
495 fLastEvent = fFirstEvent ;
497 fInput = fManager->GetNinputs() ;
501 fInputFileNames = new TString[fInput] ;
502 fEventNames = new TString[fInput] ;
503 fInputFileNames[0] = GetTitle() ;
504 fEventNames[0] = fEventFolderName.Data() ;
506 for (index = 1 ; index < fInput ; index++) {
507 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
508 TString tempo = fManager->GetInputFolderName(index) ;
509 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
512 //to prevent cleaning of this object while GetEvent is called
513 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
518 //____________________________________________________________________________
519 void AliPHOSDigitizer::InitParameters()
521 // Set initial parameters Digitizer
524 fEMCDigitThreshold = 0.012 ;
526 fCPVDigitThreshold = 0.09 ;
527 fTimeResolution = 0.5e-9 ;
528 fTimeSignalLength = 1.0e-9 ;
530 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
531 fADCpedestalEmc = 0.005 ; //
532 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
534 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
535 fADCpedestalCpv = 0.012 ; //
536 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
538 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
539 SetEventRange(0,-1) ;
543 //__________________________________________________________________
544 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
546 // Allows to produce digits by superimposing background and signal event.
547 // It is assumed, that headers file with SIGNAL events is opened in
549 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
550 // Thus we avoid writing (changing) huge and expensive
551 // backgound files: all output will be writen into SIGNAL, i.e.
552 // opened in constructor file.
554 // One can open as many files to mix with as one needs.
555 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
558 if( strcmp(fEventFolderName, "") == 0 )
562 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
565 // looking for file which contains AliRun
566 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
567 Error("MixWith", "File %s does not exist!", alirunFileName.Data()) ;
570 // looking for the file which contains SDigits
571 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
572 TString fileName( gime->GetSDigitsFileName() ) ;
573 if ( eventFolderName != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
574 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
575 if ( (gSystem->AccessPathName(fileName)) ) {
576 Error("MixWith", "The file %s does not exist!", fileName.Data()) ;
579 // need to increase the arrays
580 TString tempo = fInputFileNames[fInput-1] ;
581 delete [] fInputFileNames ;
582 fInputFileNames = new TString[fInput+1] ;
583 fInputFileNames[fInput-1] = tempo ;
585 tempo = fEventNames[fInput-1] ;
586 delete [] fEventNames ;
587 fEventNames = new TString[fInput+1] ;
588 fEventNames[fInput-1] = tempo ;
590 fInputFileNames[fInput] = alirunFileName ;
591 fEventNames[fInput] = eventFolderName ;
595 //__________________________________________________________________
596 void AliPHOSDigitizer::Print()const
598 // Print Digitizer's parameters
599 Info("Print", "\n------------------- %s -------------", GetName() ) ;
600 if( strcmp(fEventFolderName.Data(), "") != 0 ){
601 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
605 nStreams = GetNInputStreams() ;
610 for (index = 0 ; index < nStreams ; index++) {
611 TString tempo(fEventNames[index]) ;
613 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
614 TString fileName( gime->GetSDigitsFileName() ) ;
615 if ( fEventNames[index] != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name
616 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
617 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
619 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
620 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
622 printf("\nWith following parameters:\n") ;
623 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
624 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
625 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
626 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
627 printf(" ---------------------------------------------------\n") ;
630 Info("Print", "AliPHOSDigitizer not initialized" ) ;
634 //__________________________________________________________________
635 void AliPHOSDigitizer::PrintDigits(Option_t * option)
637 // Print a table of digits
639 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
640 TClonesArray * digits = gime->Digits() ;
642 Info("PrintDigits", "%d", digits->GetEntriesFast()) ;
643 printf("\nevent %d", gAlice->GetEvNumber()) ;
644 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
647 if(strstr(option,"all")||strstr(option,"EMC")){
649 AliPHOSDigit * digit;
650 printf("\nEMC digits (with primaries):\n") ;
651 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
652 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
654 for (index = 0 ; (index < digits->GetEntriesFast()) &&
655 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
656 digit = (AliPHOSDigit * ) digits->At(index) ;
657 if(digit->GetNprimary() == 0)
659 printf("%6d %8d %6.5e %4d %2d :",
660 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
662 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
663 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
669 if(strstr(option,"all")||strstr(option,"CPV")){
671 //loop over CPV digits
672 AliPHOSDigit * digit;
673 printf("\nCPV digits (with primaries):\n") ;
674 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
675 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
677 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
678 digit = (AliPHOSDigit * ) digits->At(index) ;
679 if(digit->GetId() > maxEmc){
680 printf("%6d %8d %4d %2d :",
681 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
683 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
684 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
693 //__________________________________________________________________
694 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
695 { // Calculates the time signal generated by noise
696 //to be rewritten, now returns just big number
701 //__________________________________________________________________
702 void AliPHOSDigitizer::Unload()
706 for(i = 1 ; i < fInput ; i++){
707 TString tempo(fEventNames[i]) ;
709 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
710 gime->PhosLoader()->UnloadSDigits() ;
713 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
714 gime->PhosLoader()->UnloadDigits() ;
717 //____________________________________________________________________________
718 void AliPHOSDigitizer::WriteDigits()
721 // Makes TreeD in the output file.
722 // Check if branch already exists:
723 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
724 // already existing branches.
725 // else creates branch with Digits, named "PHOS", title "...",
726 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
727 // and names of files, from which digits are made.
729 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
730 const TClonesArray * digits = gime->Digits() ;
731 TTree * treeD = gime->TreeD();
733 // -- create Digits branch
734 Int_t bufferSize = 32000 ;
735 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
736 digitsBranch->SetTitle(fEventFolderName);
737 digitsBranch->Fill() ;
739 gime->WriteDigits("OVERWRITE");
740 gime->WriteDigitizer("OVERWRITE");