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 //_________________________________________________________________________
19 //*-- Author : Dmitri Peressounko (SUBATECH & Kurchatov Institute)
20 //////////////////////////////////////////////////////////////////////////////
21 // This TTask performs digitization of Summable digits (in the PHOS case it is just
22 // the sum of contributions from all primary particles into a given cell).
23 // In addition it performs mixing of summable digits from different events.
24 // The name of the TTask is also the title of the branch that will contain
25 // the created SDigits
26 // The title of the TTAsk is the name of the file that contains the hits from
27 // which the SDigits are created
29 // For each event two branches are created in TreeD:
30 // "PHOS" - list of digits
31 // "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
33 // Note, that one can set a title for new digits branch, and repeat digitization with
34 // another set of parameters.
37 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
38 // root[1] d->ExecuteTask()
39 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
40 // //Digitizes SDigitis in all events found in file galice.root
42 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;
43 // // Will read sdigits from galice1.root
44 // root[3] d1->MixWith("galice2.root")
45 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
46 // // Reads another set of sdigits from galice2.root
47 // root[3] d1->MixWith("galice3.root")
48 // // Reads another set of sdigits from galice3.root
49 // root[4] d->ExecuteTask("deb timing")
50 // // Reads SDigits from files galice1.root, galice2.root ....
51 // // mixes them and stores produced Digits in file galice1.root
52 // // deb - prints number of produced digits
53 // // deb all - prints list of produced digits
54 // // timing - prints time used for digitization
57 // --- ROOT system ---
63 #include "TObjString.h"
64 #include "TGeometry.h"
65 #include "TBenchmark.h"
67 // --- Standard library ---
70 // --- AliRoot header files ---
73 #include "AliHeader.h"
74 #include "AliStream.h"
75 #include "AliRunDigitizer.h"
76 #include "AliPHOSDigit.h"
78 #include "AliPHOSGetter.h"
79 #include "AliPHOSDigitizer.h"
80 #include "AliPHOSSDigitizer.h"
81 #include "AliPHOSGeometry.h"
82 #include "AliPHOSTick.h"
84 ClassImp(AliPHOSDigitizer)
87 //____________________________________________________________________________
88 AliPHOSDigitizer::AliPHOSDigitizer()
93 fDefaultInit = kTRUE ;
96 //____________________________________________________________________________
97 AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name)
101 SetTitle(headerFile) ;
103 fManager = 0 ; // We work in the standalong mode
107 fDefaultInit = kFALSE ;
111 //____________________________________________________________________________
112 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * ard):AliDigitizer(ard)
115 SetTitle("aliroot") ;
118 fDefaultInit = kTRUE ;
121 //____________________________________________________________________________
122 AliPHOSDigitizer::~AliPHOSDigitizer()
125 // fDefaultInit = kTRUE if Digitizer created by default ctor (to get just the parameters)
128 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
130 // remove the task from the folder list
131 gime->RemoveTask("S",GetName()) ;
132 gime->RemoveTask("D",GetName()) ;
134 // remove the Digits from the folder list
135 gime->RemoveObjects("D", GetName()) ;
137 // remove the SDigits from the folder list
138 gime->RemoveSDigits() ;
147 //____________________________________________________________________________
148 void AliPHOSDigitizer::Digitize(const Int_t event)
151 // Makes the digitization of the collected summable digits.
152 // It first creates the array of all PHOS modules
153 // filled with noise (different for EMC, CPV and PPSD) and
154 // then adds contributions from SDigits.
155 // This design avoids scanning over the list of digits to add
156 // contribution to new SDigits only.
158 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
159 TClonesArray * digits = gime->Digits(GetName()) ;
163 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
164 //Making digits with noise, first EMC
165 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
169 TString name = geom->GetName() ;
171 nCPV = nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*
172 geom->GetNModules() ;
174 digits->Expand(nCPV) ;
176 // get first the sdigitizer from the tasks list (must have same name as the digitizer)
177 const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName());
179 cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ;
183 // loop through the sdigits posted to the White Board and add them to the noise
184 TCollection * folderslist = gime->SDigitsFolder()->GetListOfFolders() ;
185 TIter next(folderslist) ;
186 TFolder * folder = 0 ;
187 TClonesArray * sdigits = 0 ;
189 TObjArray * sdigArray = new TObjArray(2) ;
190 while ( (folder = (TFolder*)next()) ) {
191 if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) {
192 TString fileName(folder->GetName()) ;
193 fileName.ReplaceAll("_","/") ;
194 cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits "
195 << GetName() << " from " << fileName << endl ;
196 sdigArray->AddAt(sdigits, input) ;
201 //Find the first crystall with signal
202 Int_t nextSig = 200000 ;
204 for(i=0; i<input; i++){
205 sdigits = (TClonesArray *)sdigArray->At(i) ;
206 if ( !sdigits->GetEntriesFast() )
208 Int_t curNext = ((AliPHOSDigit *)sdigits->At(0))->GetId() ;
209 if(curNext < nextSig)
213 TArrayI index(input) ;
214 index.Reset() ; //Set all indexes to zero
216 AliPHOSDigit * digit ;
217 AliPHOSDigit * curSDigit ;
219 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
221 //Put Noise contribution
222 for(absID = 1; absID <= nEMC; absID++){
223 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
224 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
225 //look if we have to add signal?
226 digit = (AliPHOSDigit *) digits->At(absID-1) ;
229 //Add SDigits from all inputs
232 Float_t a = digit->GetAmp() ;
233 Float_t b = TMath::Abs( a /fTimeSignalLength) ;
234 //Mark the beginnign of the signal
235 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
236 //Mark the end of the ignal
237 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
240 for(i=0; i<input; i++){
241 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
242 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
245 //May be several digits will contribute from the same input
246 while(curSDigit && curSDigit->GetId() == absID){
247 //Shift primary to separate primaries belonging different inputs
248 Int_t primaryoffset ;
250 primaryoffset = fManager->GetMask(i) ;
252 primaryoffset = 10000000*i ;
253 curSDigit->ShiftPrimary(primaryoffset) ;
255 a = curSDigit->GetAmp() ;
256 b = a /fTimeSignalLength ;
257 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
258 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
260 *digit = *digit + *curSDigit ; //add energies
263 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
264 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
270 //calculate and set time
271 Float_t time = FrontEdgeTime(ticks) ;
272 digit->SetTime(time) ;
274 //Find next signal module
276 for(i=0; i<input; i++){
277 sdigits = ((TClonesArray *)sdigArray->At(i)) ;
278 Int_t curNext = nextSig ;
279 if(sdigits->GetEntriesFast() > index[i] ){
280 curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ;
283 if(curNext < nextSig) nextSig = curNext ;
292 //Now CPV digits (different noise and no timing)
293 for(absID = nEMC+1; absID <= nCPV; absID++){
294 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
295 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
296 //look if we have to add signal?
298 digit = (AliPHOSDigit *) digits->At(absID-1) ;
299 //Add SDigits from all inputs
300 for(i=0; i<input; i++){
301 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
302 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
306 //May be several digits will contribute from the same input
307 while(curSDigit && curSDigit->GetId() == absID){
308 //Shift primary to separate primaries belonging different inputs
309 Int_t primaryoffset ;
311 primaryoffset = fManager->GetMask(i) ;
313 primaryoffset = 10000000*i ;
314 curSDigit->ShiftPrimary(primaryoffset) ;
317 *digit = *digit + *curSDigit ;
319 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
320 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
326 //Find next signal module
328 for(i=0; i<input; i++){
329 sdigits = (TClonesArray *)sdigArray->At(i) ;
330 Int_t curNext = nextSig ;
331 if(sdigits->GetEntriesFast() > index[i] )
332 curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ;
333 if(curNext < nextSig) nextSig = curNext ;
338 delete sdigArray ; //We should not delete its contents
342 //remove digits below thresholds
343 for(i = 0; i < nEMC ; i++){
344 digit = (AliPHOSDigit*) digits->At(i) ;
345 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
346 digits->RemoveAt(i) ;
348 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
352 for(i = nEMC; i < nCPV ; i++)
353 if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(i))->GetAmp()) < fCPVDigitThreshold)
354 digits->RemoveAt(i) ;
358 Int_t ndigits = digits->GetEntriesFast() ;
359 digits->Expand(ndigits) ;
361 //Set indexes in list of digits and make true digitization of the energy
362 for (i = 0 ; i < ndigits ; i++) {
363 AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ;
364 digit->SetIndexInList(i) ;
365 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
366 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
370 //____________________________________________________________________________
371 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
374 if(absId <= fEmcCrystals){ //digitize as EMC
375 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
376 if(chanel > fNADCemc ) chanel = fNADCemc ;
378 else{ //Digitize as CPV
379 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
380 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
384 //____________________________________________________________________________
385 void AliPHOSDigitizer::Exec(Option_t *option)
389 if(strcmp(GetName(), "") == 0 )
391 if (strstr(option,"print")) {
396 if(strstr(option,"tim"))
397 gBenchmark->Start("PHOSDigitizer");
399 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
406 treeD = fManager->GetTreeD() ;
407 nevents = 1 ; // Will process only one event
410 gAlice->GetEvent(0) ;
411 nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
412 treeD=gAlice->TreeD() ;
416 //Check, if this branch already exits
418 TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ;
420 TBranch * branch = 0 ;
421 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
423 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
424 if ( (strcmp(branch->GetName(), "PHOS")==0) &&
425 (strcmp(branch->GetTitle(), GetName())==0) )
428 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) &&
429 (strcmp(branch->GetTitle(), GetName())==0) )
430 digitizerfound = kTRUE ;
434 cerr << "WARNING: AliPHOSDigitizer -> Digits branch with name " << GetName()
435 << " already exits" << endl ;
438 if ( digitizerfound ) {
439 cerr << "WARNING: AliPHOSDigitizer -> Digitizer branch with name " << GetName()
440 << " already exits" << endl ;
447 for(ievent = 0; ievent < nevents; ievent++){
452 for(input = 0 ; input < fManager->GetNinputs(); input ++){
453 TTree * treeS = fManager->GetInputTreeS(input) ;
455 cerr << "AliPHOSDigitizer::Exec -> No Input " << endl ;
458 gime->ReadTreeS(treeS,input) ;
463 gime->Event(ievent,"S") ;
465 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
467 WriteDigits(ievent) ;
469 if(strstr(option,"deb"))
472 //increment the total number of Digits per run
473 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
476 if(strstr(option,"tim")){
477 gBenchmark->Stop("PHOSDigitizer");
478 cout << "AliPHOSDigitizer:" << endl ;
479 cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for Digitizing "
480 << gBenchmark->GetCpuTime("PHOSDigitizer")/nevents << " seconds per event " << endl ;
486 //____________________________________________________________________________
487 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks)
489 ticks->Sort() ; //Sort in accordance with times of ticks
491 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
492 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
495 while((t=(AliPHOSTick*) it.Next())){
496 if(t->GetTime() < time) //This tick starts before crossing
501 time = ctick->CrossingTime(fTimeThreshold) ;
506 //____________________________________________________________________________
507 Bool_t AliPHOSDigitizer::Init()
510 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ;
512 cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ;
516 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
518 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
520 // Post Digits to the white board
521 gime->PostDigits(GetName() ) ;
523 // Post Digitizer to the white board
524 gime->PostDigitizer(this) ;
526 //Mark that we will use current header file
528 gime->PostSDigits(GetName(),GetTitle()) ;
529 gime->PostSDigitizer(GetName(),GetTitle()) ;
534 //____________________________________________________________________________
535 void AliPHOSDigitizer::InitParameters()
538 fEMCDigitThreshold = 0.012 ;
540 fCPVDigitThreshold = 0.09 ;
541 fTimeResolution = 0.5e-9 ;
542 fTimeSignalLength = 1.0e-9 ;
544 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
545 fADCpedestalEmc = 0.005 ; //
546 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
548 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
549 fADCpedestalCpv = 0.012 ; //
550 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
552 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
556 //__________________________________________________________________
557 void AliPHOSDigitizer::MixWith(const char* headerFile)
559 // Allows to produce digits by superimposing background and signal event.
560 // It is assumed, that headers file with SIGNAL events is opened in
562 // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed
563 // Thus we avoid writing (changing) huge and expensive
564 // backgound files: all output will be writen into SIGNAL, i.e.
565 // opened in constructor file.
567 // One can open as many files to mix with as one needs.
568 // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
571 if( strcmp(GetName(), "") == 0 )
575 cout << "Can not use this method under AliRunDigitizer " << endl ;
579 // check if the specified SDigits do not already exist on the White Board:
580 // //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
582 TString path = "Folders/RunMC/Event/Data/PHOS/SDigits" ;
586 if ( gROOT->FindObjectAny(path.Data()) ) {
587 cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ;
591 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
592 gime->PostSDigits(GetName(),headerFile) ;
594 // check if the requested file is already open or exist and if SDigits Branch exist
595 TFile * file = (TFile*)gROOT->FindObject(headerFile);
597 file = new TFile(headerFile, "READ") ;
599 cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ;
606 //__________________________________________________________________
607 void AliPHOSDigitizer::SetSplitFile(const TString splitFileName)
609 // Diverts the Digits in a file separate from the hits file
611 // I guess it is not going to work if we do merging
613 cerr << "ERROR: AliPHOSDigitizer::SetSplitFile -> Not yet available in case of merging activated " << endl ;
617 TDirectory * cwd = gDirectory ;
618 if ( !(gAlice->GetTreeDFileName() == splitFileName) ) {
619 if (gAlice->GetTreeDFile() )
620 gAlice->GetTreeDFile()->Close() ;
623 fSplitFile = gAlice->InitTreeFile("D",splitFileName.Data());
625 gAlice->Write(0, TObject::kOverwrite);
627 TTree *treeE = gAlice->TreeE();
629 cerr << "ERROR: AliPHOSDigitizer::SetSplitFile -> No TreeE found "<<endl;
634 AliHeader *header = new AliHeader();
635 treeE->SetBranchAddress("Header", &header);
636 treeE->SetBranchStatus("*",1);
637 TTree *treeENew = treeE->CloneTree();
638 treeENew->Write(0, TObject::kOverwrite);
641 TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
643 cerr << "ERROR: AliPHOSDigitizer::SetSplitFile -> AliceGeom was not found in the input file "<<endl;
646 AliceGeom->Write(0, TObject::kOverwrite);
648 gAlice->MakeTree("D",fSplitFile);
650 cout << "INFO: AliPHOSDigitizer::SetSPlitMode -> Digits will be stored in " << splitFileName.Data() << endl ;
653 //__________________________________________________________________
654 void AliPHOSDigitizer::Print(Option_t* option)const {
655 // Print Digitizer's parameters
656 if( strcmp(GetName(), "") != 0 ){
658 cout << "------------------- "<< GetName() << " -------------" << endl ;
659 const AliRunDigitizer * rd = Manager() ;
661 Int_t ninput = rd->GetInputStreams()->GetEntries() ;
663 const AliStream * st = 0 ;
665 for (index = 0 ; index < ninput ; index++) {
666 st = static_cast<AliStream*>(rd->GetInputStreams()->At(index)) ;
668 out = st->GetFileNames()->At(0)->GetName() ;
669 cout << "Adding SDigits " << GetName() << " from " << st->GetFileNames()->At(0)->GetName() << endl ;
672 cout << "Writing digits to " << out.Data() << endl ;
675 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
676 gime->Folder("sdigits") ;
677 cout << "Digitizing sDigits from file(s): " <<endl ;
678 TCollection * folderslist = gime->Folder("sdigits")->GetListOfFolders() ;
679 TIter next(folderslist) ;
680 TFolder * folder = 0 ;
682 while ( (folder = (TFolder*)next()) ) {
683 if ( folder->FindObject(GetName()) )
684 cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ;
687 cout << "Writing digits to " << GetTitle() << endl ;
690 cout << "With following parameters: " << endl ;
691 cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ;
692 cout << " Threshold in EMC (fEMCDigitThreshold) = " << fEMCDigitThreshold << endl ; ;
693 cout << " Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ;
694 cout << " Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ;
695 cout << "---------------------------------------------------" << endl ;
698 cout << "AliPHOSDigitizer not initialized " << endl ;
702 //__________________________________________________________________
703 void AliPHOSDigitizer::PrintDigits(Option_t * option){
704 // Print a table of digits
706 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
707 TClonesArray * digits = gime->Digits() ;
709 cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ;
710 cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ;
712 if(strstr(option,"all")||strstr(option,"EMC")){
715 AliPHOSDigit * digit;
716 cout << "EMC digits (with primaries): " << endl ;
717 cout << "Digit Id Amplitude Index Nprim Primaries list " << endl;
718 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
720 for (index = 0 ; (index < digits->GetEntriesFast()) &&
721 (((AliPHOSDigit * ) digits->At(index))->GetId() <= maxEmc) ; index++) {
722 digit = (AliPHOSDigit * ) digits->At(index) ;
723 if(digit->GetNprimary() == 0) continue;
724 cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " "
725 << setw(6) << digit->GetIndexInList() << " "
726 << setw(5) << digit->GetNprimary() <<" ";
729 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
730 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
736 if(strstr(option,"all")||strstr(option,"CPV")){
738 //loop over CPV digits
739 AliPHOSDigit * digit;
740 cout << "CPV digits: " << endl ;
741 cout << "Digit Id Amplitude Index Nprim Primaries list " << endl;
742 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
744 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
745 digit = (AliPHOSDigit * ) digits->At(index) ;
746 if(digit->GetId() > maxEmc){
747 cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " "
748 << setw(6) << digit->GetIndexInList() << " "
749 << setw(5) << digit->GetNprimary() <<" ";
752 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
753 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
761 //__________________________________________________________________
762 void AliPHOSDigitizer::SetSDigitsBranch(const char* title)
764 // we set title (comment) of the SDigits branch in the first! header file
765 if( strcmp(GetName(), "") == 0 )
768 AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ;
771 //__________________________________________________________________
772 Float_t AliPHOSDigitizer::TimeOfNoise(void)
773 { // Calculates the time signal generated by noise
774 //to be rewritten, now returns just big number
778 //____________________________________________________________________________
779 void AliPHOSDigitizer::Reset()
781 // sets current event number to the first simulated event
783 if( strcmp(GetName(), "") == 0 )
787 // for(inputs = 0; inputs < fNinputs ;inputs++)
788 // fIevent->AddAt(-1, inputs ) ;
792 //____________________________________________________________________________
793 void AliPHOSDigitizer::WriteDigits(Int_t event)
796 // Makes TreeD in the output file.
797 // Check if branch already exists:
798 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
799 // already existing branches.
800 // else creates branch with Digits, named "PHOS", title "...",
801 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
802 // and names of files, from which digits are made.
804 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
805 const TClonesArray * digits = gime->Digits(GetName()) ;
810 treeD = fManager->GetTreeD() ;
812 if (!gAlice->TreeD() )
813 gAlice->MakeTree("D", fSplitFile);
814 treeD = gAlice->TreeD();
818 // -- create Digits branch
819 Int_t bufferSize = 32000 ;
820 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
821 digitsBranch->SetTitle(GetName());
823 // -- Create Digitizer branch
824 Int_t splitlevel = 0 ;
825 AliPHOSDigitizer * d = gime->Digitizer(GetName()) ;
826 TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel);
827 digitizerBranch->SetTitle(GetName());
829 digitsBranch->Fill() ;
830 digitizerBranch->Fill() ;