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 **************************************************************************/
18 /* History of cvs commits:
23 //_________________________________________________________________________
24 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
25 //////////////////////////////////////////////////////////////////////////////
26 // This TTask performs digitization of Summable digits (in the PHOS case it is just
27 // the sum of contributions from all primary particles into a given cell).
28 // In addition it performs mixing of summable digits from different events.
29 // The name of the TTask is also the title of the branch that will contain
30 // the created SDigits
31 // The title of the TTAsk is the name of the file that contains the hits from
32 // which the SDigits are created
34 // For each event two branches are created in TreeD:
35 // "PHOS" - list of digits
36 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
38 // Note, that one can set a title for new digits branch, and repeat digitization with
39 // another set of parameters.
42 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
43 // root[1] d->ExecuteTask()
44 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
45 // //Digitizes SDigitis in all events found in file galice.root
47 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
48 // // Will read sdigits from galice1.root
49 // root[3] d1->MixWith("galice2.root")
50 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
51 // // Reads another set of sdigits from galice2.root
52 // root[3] d1->MixWith("galice3.root")
53 // // Reads another set of sdigits from galice3.root
54 // root[4] d->ExecuteTask("deb timing")
55 // // Reads SDigits from files galice1.root, galice2.root ....
56 // // mixes them and stores produced Digits in file galice1.root
57 // // deb - prints number of produced digits
58 // // deb all - prints list of produced digits
59 // // timing - prints time used for digitization
62 // --- ROOT system ---
65 #include "TBenchmark.h"
68 // --- Standard library ---
70 // --- AliRoot header files ---
72 #include "AliRunDigitizer.h"
73 #include "AliPHOSDigit.h"
74 #include "AliPHOSGetter.h"
75 #include "AliPHOSDigitizer.h"
76 #include "AliPHOSSDigitizer.h"
77 #include "AliPHOSGeometry.h"
78 #include "AliPHOSTick.h"
80 ClassImp(AliPHOSDigitizer)
83 //____________________________________________________________________________
84 AliPHOSDigitizer::AliPHOSDigitizer():AliDigitizer("",""),
91 fDefaultInit = kTRUE ;
92 fManager = 0 ; // We work in the standalong mode
93 fEventFolderName = "" ;
96 //____________________________________________________________________________
97 AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
98 TString eventFolderName):
99 AliDigitizer("PHOS"+AliConfig::Instance()->GetDigitizerTaskName(),
101 fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
106 fDefaultInit = kFALSE ;
107 fManager = 0 ; // We work in the standalong mode
110 //____________________________________________________________________________
111 AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d)
116 SetName(d.GetName()) ;
117 SetTitle(d.GetTitle()) ;
118 fPinNoise = d.fPinNoise ;
119 fEMCDigitThreshold = d.fEMCDigitThreshold ;
120 fCPVNoise = d.fCPVNoise ;
121 fCPVDigitThreshold = d.fCPVDigitThreshold ;
122 fTimeResolution = d.fTimeResolution ;
123 fTimeThreshold = d.fTimeThreshold ;
124 fTimeSignalLength = d.fTimeSignalLength ;
125 fADCchanelEmc = d.fADCchanelEmc ;
126 fADCpedestalEmc = d.fADCpedestalEmc ;
127 fNADCemc = d.fNADCemc ;
128 fADCchanelCpv = d.fADCchanelCpv ;
129 fADCpedestalCpv = d.fADCpedestalCpv ;
130 fNADCcpv = d.fNADCcpv ;
131 fEventFolderName = d.fEventFolderName;
134 //____________________________________________________________________________
135 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd):
136 AliDigitizer(rd,"PHOS"+AliConfig::Instance()->GetDigitizerTaskName()),
139 // ctor Init() is called by RunDigitizer
141 fEventFolderName = fManager->GetInputFolderName(0) ;
142 SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
144 fDefaultInit = kFALSE ;
147 //____________________________________________________________________________
148 AliPHOSDigitizer::~AliPHOSDigitizer()
151 delete [] fInputFileNames ;
152 delete [] fEventNames ;
156 //____________________________________________________________________________
157 void AliPHOSDigitizer::Digitize(Int_t event)
160 // Makes the digitization of the collected summable digits.
161 // It first creates the array of all PHOS modules
162 // filled with noise (different for EMC, and CPV) and
163 // then adds contributions from SDigits.
164 // This design avoids scanning over the list of digits to add
165 // contribution to new SDigits only.
167 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
168 Int_t ReadEvent = event ;
170 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
171 AliInfo(Form("Adding event %d from input stream 0 %s %s",
172 ReadEvent, GetTitle(), fEventFolderName.Data())) ;
173 gime->Event(ReadEvent, "S") ;
174 TClonesArray * digits = gime->Digits() ;
177 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
178 //Making digits with noise, first EMC
179 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
184 nCPV = nEMC + geom->GetNumberOfCPVPadsZ() * geom->GetNumberOfCPVPadsPhi() * geom->GetNModules() ;
186 digits->Expand(nCPV) ;
188 // get first the sdigitizer from the tasks list
189 if ( !gime->SDigitizer() )
190 gime->LoadSDigitizer();
191 AliPHOSSDigitizer * sDigitizer = gime->SDigitizer();
194 AliFatal(Form("SDigitizer with name %s %s not found",
195 GetTitle(), fEventFolderName.Data() )) ;
197 //take all the inputs to add together and load the SDigits
198 TObjArray * sdigArray = new TObjArray(fInput) ;
199 sdigArray->AddAt(gime->SDigits(), 0) ;
201 for(i = 1 ; i < fInput ; i++){
202 TString tempo(fEventNames[i]) ;
204 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
206 ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
207 AliInfo(Form("Adding event %d from input stream %d %s %s",
208 ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
209 gime->Event(ReadEvent,"S");
210 sdigArray->AddAt(gime->SDigits(), i) ;
213 //Find the first crystall with signal
214 Int_t nextSig = 200000 ;
215 TClonesArray * sdigits ;
216 for(i = 0 ; i < fInput ; i++){
217 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
218 if ( !sdigits->GetEntriesFast() )
220 Int_t curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(0))->GetId() ;
221 if(curNext < nextSig)
225 TArrayI index(fInput) ;
226 index.Reset() ; //Set all indexes to zero
228 AliPHOSDigit * digit ;
229 AliPHOSDigit * curSDigit ;
231 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
233 //Put Noise contribution
234 for(absID = 1 ; absID <= nEMC ; absID++){
235 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
236 new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
237 //look if we have to add signal?
238 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
241 //Add SDigits from all inputs
244 Float_t a = digit->GetAmp() ;
245 Float_t b = TMath::Abs( a / fTimeSignalLength) ;
246 //Mark the beginning of the signal
247 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
248 //Mark the end of the ignal
249 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
252 for(i = 0 ; i < fInput ; i++){
253 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
254 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
257 //May be several digits will contribute from the same input
258 while(curSDigit && curSDigit->GetId() == absID){
259 //Shift primary to separate primaries belonging different inputs
260 Int_t primaryoffset ;
262 primaryoffset = fManager->GetMask(i) ;
264 primaryoffset = 10000000*i ;
265 curSDigit->ShiftPrimary(primaryoffset) ;
267 a = curSDigit->GetAmp() ;
268 b = a /fTimeSignalLength ;
269 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
270 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
272 *digit = *digit + *curSDigit ; //add energies
275 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
276 curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
282 //calculate and set time
283 Float_t time = FrontEdgeTime(ticks) ;
284 digit->SetTime(time) ;
286 //Find next signal module
288 for(i = 0 ; i < fInput ; i++){
289 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
290 Int_t curNext = nextSig ;
291 if(sdigits->GetEntriesFast() > index[i] ){
292 curNext = dynamic_cast<AliPHOSDigit *>(sdigits->At(index[i]))->GetId() ;
294 if(curNext < nextSig) nextSig = curNext ;
302 //Now CPV digits (different noise and no timing)
303 for(absID = nEMC+1; absID <= nCPV; absID++){
304 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
305 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
306 //look if we have to add signal?
308 digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
309 //Add SDigits from all inputs
310 for(i = 0 ; i < fInput ; i++){
311 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
312 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;
316 //May be several digits will contribute from the same input
317 while(curSDigit && curSDigit->GetId() == absID){
318 //Shift primary to separate primaries belonging different inputs
319 Int_t primaryoffset ;
321 primaryoffset = fManager->GetMask(i) ;
323 primaryoffset = 10000000*i ;
324 curSDigit->ShiftPrimary(primaryoffset) ;
327 *digit = *digit + *curSDigit ;
329 if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
330 curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i]) ) ;
336 //Find next signal module
338 for(i = 0 ; i < fInput ; i++){
339 sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
340 Int_t curNext = nextSig ;
341 if(sdigits->GetEntriesFast() > index[i] )
342 curNext = dynamic_cast<AliPHOSDigit *>( sdigits->At(index[i]) )->GetId() ;
343 if(curNext < nextSig) nextSig = curNext ;
349 delete sdigArray ; //We should not delete its contents
351 //remove digits below thresholds
352 for(i = 0 ; i < nEMC ; i++){
353 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
354 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
355 digits->RemoveAt(i) ;
357 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
361 for(i = nEMC; i < nCPV ; i++)
362 if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
363 digits->RemoveAt(i) ;
367 Int_t ndigits = digits->GetEntriesFast() ;
368 digits->Expand(ndigits) ;
370 //Set indexes in list of digits and make true digitization of the energy
371 for (i = 0 ; i < ndigits ; i++) {
372 digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
373 digit->SetIndexInList(i) ;
374 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
375 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
379 //____________________________________________________________________________
380 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
382 // Returns digitized value of the energy in a cell absId
385 if(absId <= fEmcCrystals){ //digitize as EMC
386 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
387 if(chanel > fNADCemc ) chanel = fNADCemc ;
389 else{ //Digitize as CPV
390 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
391 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
396 //____________________________________________________________________________
397 void AliPHOSDigitizer::Exec(Option_t *option)
399 // Steering method to process digitization for events
400 // in the range from fFirstEvent to fLastEvent.
401 // This range is optionally set by SetEventRange().
402 // if fLastEvent=-1, then process events until the end.
403 // by default fLastEvent = fFirstEvent (process only one event)
405 if (!fInit) { // to prevent overwrite existing file
406 AliError(Form("Give a version name different from %s",
407 fEventFolderName.Data() )) ;
411 if (strstr(option,"print")) {
416 if(strstr(option,"tim"))
417 gBenchmark->Start("PHOSDigitizer");
419 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
421 // Post Digitizer to the white board
422 gime->PostDigitizer(this) ;
424 if (fLastEvent == -1)
425 fLastEvent = gime->MaxEvent() - 1 ;
427 fLastEvent = fFirstEvent ;
429 Int_t nEvents = fLastEvent - fFirstEvent + 1;
433 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
435 gime->Event(ievent,"S") ;
437 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
441 if(strstr(option,"deb"))
444 //increment the total number of Digits per run
445 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
448 gime->PhosLoader()->CleanDigitizer();
450 if(strstr(option,"tim")){
451 gBenchmark->Stop("PHOSDigitizer");
453 message = " took %f seconds for Digitizing %f seconds per event\n" ;
454 AliInfo(Form( message.Data(),
455 gBenchmark->GetCpuTime("PHOSDigitizer"),
456 gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents ));
460 //____________________________________________________________________________
461 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
463 // Returns the shortest time among all time ticks
465 ticks->Sort() ; //Sort in accordance with times of ticks
467 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
468 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
471 while((t=(AliPHOSTick*) it.Next())){
472 if(t->GetTime() < time) //This tick starts before crossing
477 time = ctick->CrossingTime(fTimeThreshold) ;
482 //____________________________________________________________________________
483 Bool_t AliPHOSDigitizer::Init()
485 // Makes all memory allocations
487 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
489 AliFatal(Form("Could not obtain the Getter object for file %s and event %s !",
490 GetTitle(), fEventFolderName.Data()));
494 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
496 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
498 TString opt("Digits") ;
499 if(gime->VersionExists(opt) ) {
500 AliError(Form("Give a version name different from %s",
501 fEventFolderName.Data() )) ;
506 fLastEvent = fFirstEvent ;
508 fInput = fManager->GetNinputs() ;
512 fInputFileNames = new TString[fInput] ;
513 fEventNames = new TString[fInput] ;
514 fInputFileNames[0] = GetTitle() ;
515 fEventNames[0] = fEventFolderName.Data() ;
517 for (index = 1 ; index < fInput ; index++) {
518 fInputFileNames[index] = dynamic_cast<AliStream*>(fManager->GetInputStream(index))->GetFileName(0);
519 TString tempo = fManager->GetInputFolderName(index) ;
520 fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added by fManager
523 //to prevent cleaning of this object while GetEvent is called
524 gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
529 //____________________________________________________________________________
530 void AliPHOSDigitizer::InitParameters()
532 // Set initial parameters Digitizer
535 fEMCDigitThreshold = 0.012 ;
537 fCPVDigitThreshold = 0.09 ;
538 fTimeResolution = 0.5e-9 ;
539 fTimeSignalLength = 1.0e-9 ;
541 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
542 fADCpedestalEmc = 0.005 ; //
543 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
545 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
546 fADCpedestalCpv = 0.012 ; //
547 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
549 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
550 SetEventRange(0,-1) ;
554 //__________________________________________________________________
555 void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
557 // Allows to produce digits by superimposing background and signal event.
558 // It is assumed, that headers file with SIGNAL events is opened in
560 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
561 // Thus we avoid writing (changing) huge and expensive
562 // backgound files: all output will be writen into SIGNAL, i.e.
563 // opened in constructor file.
565 // One can open as many files to mix with as one needs.
566 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
569 if( strcmp(fEventFolderName, "") == 0 )
573 Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
576 // looking for file which contains AliRun
577 if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
578 AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
581 // looking for the file which contains SDigits
582 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
583 TString fileName( gime->GetSDigitsFileName() ) ;
584 if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
585 fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
586 if ( (gSystem->AccessPathName(fileName)) ) {
587 AliError(Form("The file %s does not exist!", fileName.Data())) ;
590 // need to increase the arrays
591 TString tempo = fInputFileNames[fInput-1] ;
592 delete [] fInputFileNames ;
593 fInputFileNames = new TString[fInput+1] ;
594 fInputFileNames[fInput-1] = tempo ;
596 tempo = fEventNames[fInput-1] ;
597 delete [] fEventNames ;
598 fEventNames = new TString[fInput+1] ;
599 fEventNames[fInput-1] = tempo ;
601 fInputFileNames[fInput] = alirunFileName ;
602 fEventNames[fInput] = eventFolderName ;
606 //__________________________________________________________________
607 void AliPHOSDigitizer::Print(const Option_t *)const
609 // Print Digitizer's parameters
610 AliInfo(Form("\n------------------- %s -------------", GetName() )) ;
611 if( strcmp(fEventFolderName.Data(), "") != 0 ){
612 printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
616 nStreams = GetNInputStreams() ;
621 for (index = 0 ; index < nStreams ; index++) {
622 TString tempo(fEventNames[index]) ;
624 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ;
625 TString fileName( gime->GetSDigitsFileName() ) ;
626 if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
627 fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
628 printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
630 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
631 printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
633 printf("\nWith following parameters:\n") ;
634 printf(" Electronics noise in EMC (fPinNoise) = %f\n", fPinNoise ) ;
635 printf(" Threshold in EMC (fEMCDigitThreshold) = %f\n", fEMCDigitThreshold ) ;
636 printf(" Noise in CPV (fCPVNoise) = %f\n", fCPVNoise ) ;
637 printf(" Threshold in CPV (fCPVDigitThreshold) = %f\n",fCPVDigitThreshold ) ;
638 printf(" ---------------------------------------------------\n") ;
641 AliInfo(Form("AliPHOSDigitizer not initialized" )) ;
645 //__________________________________________________________________
646 void AliPHOSDigitizer::PrintDigits(Option_t * option)
648 // Print a table of digits
650 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
651 TClonesArray * digits = gime->Digits() ;
653 AliInfo(Form("%d", digits->GetEntriesFast())) ;
654 printf("\nevent %d", gAlice->GetEvNumber()) ;
655 printf("\n Number of entries in Digits list %d", digits->GetEntriesFast() ) ;
658 if(strstr(option,"all")||strstr(option,"EMC")){
660 AliPHOSDigit * digit;
661 printf("\nEMC digits (with primaries):\n") ;
662 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
663 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
665 for (index = 0 ; (index < digits->GetEntriesFast()) &&
666 (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
667 digit = (AliPHOSDigit * ) digits->At(index) ;
668 if(digit->GetNprimary() == 0)
670 printf("%6d %8d %6.5e %4d %2d :",
671 digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
673 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
674 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
680 if(strstr(option,"all")||strstr(option,"CPV")){
682 //loop over CPV digits
683 AliPHOSDigit * digit;
684 printf("\nCPV digits (with primaries):\n") ;
685 printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
686 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
688 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
689 digit = (AliPHOSDigit * ) digits->At(index) ;
690 if(digit->GetId() > maxEmc){
691 printf("%6d %8d %4d %2d :",
692 digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;
694 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
695 printf("%d ",digit->GetPrimary(iprimary+1) ) ;
704 //__________________________________________________________________
705 Float_t AliPHOSDigitizer::TimeOfNoise(void) const
706 { // Calculates the time signal generated by noise
707 //PH Info("TimeOfNoise", "Change me") ;
708 return gRandom->Rndm() * 1.28E-5;
711 //__________________________________________________________________
712 void AliPHOSDigitizer::Unload()
716 for(i = 1 ; i < fInput ; i++){
717 TString tempo(fEventNames[i]) ;
719 AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
720 gime->PhosLoader()->UnloadSDigits() ;
723 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ;
724 gime->PhosLoader()->UnloadDigits() ;
727 //____________________________________________________________________________
728 void AliPHOSDigitizer::WriteDigits()
731 // Makes TreeD in the output file.
732 // Check if branch already exists:
733 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
734 // already existing branches.
735 // else creates branch with Digits, named "PHOS", title "...",
736 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
737 // and names of files, from which digits are made.
739 AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
740 const TClonesArray * digits = gime->Digits() ;
741 TTree * treeD = gime->TreeD();
743 // -- create Digits branch
744 Int_t bufferSize = 32000 ;
745 TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
746 digitsBranch->SetTitle(fEventFolderName);
747 digitsBranch->Fill() ;
749 gime->WriteDigits("OVERWRITE");
750 gime->WriteDigitizer("OVERWRITE");