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 "TBenchmark.h"
66 // --- Standard library ---
69 // --- AliRoot header files ---
72 #include "AliRunDigitizer.h"
73 #include "AliPHOSDigit.h"
75 #include "AliPHOSGetter.h"
76 #include "AliPHOSDigitizer.h"
77 #include "AliPHOSSDigitizer.h"
78 #include "AliPHOSGeometry.h"
79 #include "AliPHOSTick.h"
81 ClassImp(AliPHOSDigitizer)
84 //____________________________________________________________________________
85 AliPHOSDigitizer::AliPHOSDigitizer()
90 fEMCDigitThreshold = 0.01 ;
92 fCPVDigitThreshold = 0.09 ;
93 fTimeResolution = 0.5e-9 ;
94 fTimeSignalLength = 1.0e-9 ;
96 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
97 fADCpedestalEmc = 0.005 ; //
98 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
100 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
101 fADCpedestalCpv = 0.012 ; //
102 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
104 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
105 fARD = 0 ; // We work in the standalong mode
108 //____________________________________________________________________________
109 AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name)
113 SetTitle(headerFile) ;
114 fARD = 0 ; // We work in the standalong mode
119 //____________________________________________________________________________
120 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * ard)
124 SetName(""); //Will call init in the digitizing
125 SetTitle("aliroot") ;
128 //____________________________________________________________________________
129 AliPHOSDigitizer::~AliPHOSDigitizer()
136 //____________________________________________________________________________
137 void AliPHOSDigitizer::Digitize(const Int_t event)
140 // Makes the digitization of the collected summable digits.
141 // It first creates the array of all PHOS modules
142 // filled with noise (different for EMC, CPV and PPSD) and
143 // then adds contributions from SDigits.
144 // This design avoids scanning over the list of digits to add
145 // contribution to new SDigits only.
147 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
148 TClonesArray * digits = gime->Digits(GetName()) ;
149 AliPHOSSDigitizer * sdiz = gime->SDigitizer(GetName()) ;
153 const AliPHOSGeometry *geom = gime->PHOSGeometry() ;
155 //Making digits with noise, first EMC
156 Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
160 TString name = geom->GetName() ;
162 nCPV = nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*
163 geom->GetNModules() ;
165 digits->Expand(nCPV) ;
168 // sdigitize random gaussian noise and add it to all cells (EMCA+CPV+PPSD)
169 // get first the sdigitizer from the tasks list (must have same name as the digitizer)
170 const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName());
172 cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ;
176 // loop through the sdigits posted to the White Board and add them to the noise
177 TCollection * folderslist = gime->SDigitsFolder()->GetListOfFolders() ;
178 TIter next(folderslist) ;
179 TFolder * folder = 0 ;
180 TClonesArray * sdigits = 0 ;
182 TObjArray * sdigArray = new TObjArray(2) ;
183 while ( (folder = (TFolder*)next()) )
184 if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) {
185 cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits "
186 << GetName() << " from " << folder->GetName() << endl ;
187 sdigArray->AddAt(sdigits, input) ;
191 //Find the first crystall with signal
192 Int_t nextSig = 200000 ;
194 for(i=0; i<input; i++){
195 sdigits = (TClonesArray *)sdigArray->At(i) ;
196 if ( !sdigits->GetEntriesFast() )
198 Int_t curNext = ((AliPHOSDigit *)sdigits->At(0))->GetId() ;
199 if(curNext < nextSig)
203 TArrayI index(input) ;
204 index.Reset() ; //Set all indexes to zero
206 AliPHOSDigit * digit ;
207 AliPHOSDigit * curSDigit ;
209 TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
211 //Put Noise contribution
212 for(absID = 1; absID <= nEMC; absID++){
213 Float_t noise = gRandom->Gaus(0., fPinNoise) ;
214 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
215 //look if we have to add signal?
217 //Add SDigits from all inputs
218 digit = (AliPHOSDigit *) digits->At(absID-1) ;
222 Float_t a = digit->GetAmp() ;
223 Float_t b = TMath::Abs( a /fTimeSignalLength) ;
224 //Mark the beginnign of the signal
225 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);
226 //Mark the end of the ignal
227 new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b);
230 for(i=0; i<input; i++){
231 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
232 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
235 //May be several digits will contribute from the same input
236 while(curSDigit && curSDigit->GetId() == absID){
237 //Shift primary to separate primaries belonging different inputs
238 Int_t primaryoffset ;
240 primaryoffset = fARD->GetMask(i) ;
242 primaryoffset = 10000000*i ;
243 curSDigit->ShiftPrimary(primaryoffset) ;
245 a = curSDigit->GetAmp() ;
246 b = a /fTimeSignalLength ;
247 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);
248 new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
250 *digit = *digit + *curSDigit ; //add energies
253 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
254 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
260 //calculate and set time
261 Float_t time = FrontEdgeTime(ticks) ;
262 digit->SetTime(time) ;
264 //Find next signal module
266 for(i=0; i<input; i++){
267 sdigits = ((TClonesArray *)sdigArray->At(i)) ;
268 Int_t curNext = nextSig ;
269 if(sdigits->GetEntriesFast() > index[i] ){
270 curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ;
273 if(curNext < nextSig) nextSig = curNext ;
282 //Now CPV digits (different noise and no timing)
283 for(absID = nEMC+1; absID <= nCPV; absID++){
284 Float_t noise = gRandom->Gaus(0., fCPVNoise) ;
285 new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
286 //look if we have to add signal?
288 digit = (AliPHOSDigit *) digits->At(absID-1) ;
289 //Add SDigits from all inputs
290 for(i=0; i<input; i++){
291 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
292 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
296 //May be several digits will contribute from the same input
297 while(curSDigit && curSDigit->GetId() == absID){
298 //Shift primary to separate primaries belonging different inputs
299 Int_t primaryoffset ;
301 primaryoffset = fARD->GetMask(i) ;
303 primaryoffset = 10000000*i ;
304 curSDigit->ShiftPrimary(primaryoffset) ;
307 *digit = *digit + *curSDigit ;
309 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
310 curSDigit = (AliPHOSDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
316 //Find next signal module
318 for(i=0; i<input; i++){
319 sdigits = (TClonesArray *)sdigArray->At(i) ;
320 Int_t curNext = nextSig ;
321 if(sdigits->GetEntriesFast() > index[i] )
322 curNext = ((AliPHOSDigit *) sdigits->At(index[i]))->GetId() ;
323 if(curNext < nextSig) nextSig = curNext ;
328 delete sdigArray ; //We should not delete its contents
332 //remove digits below thresholds
333 for(i = 0; i < nEMC ; i++){
334 digit = (AliPHOSDigit*) digits->At(i) ;
335 if(sDigitizer->Calibrate( digit->GetAmp() ) < fEMCDigitThreshold)
336 digits->RemoveAt(i) ;
338 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
342 for(i = nEMC; i < nCPV ; i++)
343 if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(i))->GetAmp()) < fCPVDigitThreshold)
344 digits->RemoveAt(i) ;
348 Int_t ndigits = digits->GetEntriesFast() ;
349 digits->Expand(ndigits) ;
351 //Set indexes in list of digits and make true digitization of the energy
352 for (i = 0 ; i < ndigits ; i++) {
353 AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ;
354 digit->SetIndexInList(i) ;
355 Float_t energy = sdiz->Calibrate(digit->GetAmp()) ;
356 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
360 //____________________________________________________________________________
361 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
364 if(absId <= fEmcCrystals){ //digitize as EMC
365 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;
366 if(chanel > fNADCemc ) chanel = fNADCemc ;
368 else{ //Digitize as CPV
369 chanel = (Int_t) TMath::Ceil((energy - fADCpedestalCpv)/fADCchanelCpv) ;
370 if(chanel > fNADCcpv ) chanel = fNADCcpv ;
374 //____________________________________________________________________________
375 void AliPHOSDigitizer::Exec(Option_t *option)
379 if( strcmp(GetName(), "") == 0 )
382 if (strstr(option,"print")) {
387 if(strstr(option,"tim"))
388 gBenchmark->Start("PHOSDigitizer");
390 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
397 treeD = fARD->GetTreeD() ;
398 nevents = 1 ; // Will process only one event
401 gAlice->GetEvent(0) ;
402 nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
403 treeD=gAlice->TreeD() ;
406 cerr << " AliPHOSDigitizer :: Can not find TreeD " << endl ;
410 //Check, if this branch already exits
411 TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ;
413 TBranch * branch = 0 ;
414 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
416 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
417 if ( (strcmp(branch->GetName(), "PHOS")==0) &&
418 (strcmp(branch->GetTitle(), GetName())==0) )
421 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) &&
422 (strcmp(branch->GetTitle(), GetName())==0) )
423 digitizerfound = kTRUE ;
427 cerr << "WARNING: AliPHOSDigitizer -> Digits branch with name " << GetName()
428 << " already exits" << endl ;
431 if ( digitizerfound ) {
432 cerr << "WARNING: AliPHOSDigitizer -> Digitizer branch with name " << GetName()
433 << " already exits" << endl ;
439 for(ievent = 0; ievent < nevents; ievent++){
443 for(input = 0 ; input < fARD->GetNinputs(); input ++){
444 TTree * treeS = fARD->GetInputTreeS(input) ;
446 cerr << "AliPHOSDigitizer -> No Input " << endl ;
449 gime->ReadTreeS(treeS,input) ;
453 gime->Event(ievent,"S") ;
455 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
457 WriteDigits(ievent) ;
459 if(strstr(option,"deb"))
462 //increment the total number of Digits per run
463 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
466 if(strstr(option,"tim")){
467 gBenchmark->Stop("PHOSDigitizer");
468 cout << "AliPHOSDigitizer:" << endl ;
469 cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for Digitizing "
470 << gBenchmark->GetCpuTime("PHOSDigitizer")/nevents << " seconds per event " << endl ;
476 //____________________________________________________________________________
477 Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks)
479 ticks->Sort() ; //Sort in accordance with times of ticks
481 AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
482 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
485 while((t=(AliPHOSTick*) it.Next())){
486 if(t->GetTime() < time) //This tick starts before crossing
491 time = ctick->CrossingTime(fTimeThreshold) ;
495 //____________________________________________________________________________
496 Bool_t AliPHOSDigitizer::Init()
499 fEMCDigitThreshold = 0.01 ;
501 fCPVDigitThreshold = 0.09 ;
502 fTimeResolution = 0.5e-9 ;
503 fTimeSignalLength = 1.0e-9 ;
505 fADCchanelEmc = 0.0015; // width of one ADC channel in GeV
506 fADCpedestalEmc = 0.005 ; //
507 fNADCemc = (Int_t) TMath::Power(2,16) ; // number of channels in EMC ADC
509 fADCchanelCpv = 0.0012 ; // width of one ADC channel in CPV 'popugais'
510 fADCpedestalCpv = 0.012 ; //
511 fNADCcpv = (Int_t) TMath::Power(2,12); // number of channels in CPV ADC
513 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
517 if( strcmp(GetTitle(), "") == 0 )
518 SetTitle("galice.root") ;
520 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ;
522 cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ;
526 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
527 fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
529 // create a folder on the white board //YSAlice/WhiteBoard/Digits/PHOS/headerFile/digitsTitle
530 gime->PostDigits(GetName() ) ;
532 //add Task to //YSAlice/tasks/Digitizer/PHOS
533 gime->PostDigitizer(this) ;
535 //Mark that we will use current header file
537 gime->PostSDigits(GetName(),GetTitle()) ;
538 gime->PostSDigitizer(GetName(),GetTitle()) ;
543 //__________________________________________________________________
544 void AliPHOSDigitizer::MixWith(const char* headerFile)
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(GetName(), "") == 0 )
562 cout << "Can not use this method under AliRunDigitizer " << endl ;
566 // check if the specified SDigits do not already exist on the White Board:
567 // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/sDigitsTitle
569 TString path = "YSAlice/WhiteBoard/SDigits/PHOS/" ;
573 if ( gROOT->FindObjectAny(path.Data()) ) {
574 cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ;
578 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
579 gime->PostSDigits(GetName(),headerFile) ;
581 // check if the requested file is already open or exist and if SDigits Branch exist
582 TFile * file = (TFile*)gROOT->FindObject(headerFile);
584 file = new TFile(headerFile, "READ") ;
586 cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ;
593 //__________________________________________________________________
594 void AliPHOSDigitizer::Print(Option_t* option)const {
595 // Print Digitizer's parameters
596 if( strcmp(GetName(), "") != 0 ){
598 cout << "------------------- "<< GetName() << " -------------" << endl ;
599 cout << "Digitizing sDigits from file(s): " <<endl ;
601 TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ;
602 TIter next(folderslist) ;
603 TFolder * folder = 0 ;
605 while ( (folder = (TFolder*)next()) ) {
606 if ( folder->FindObject(GetName()) )
607 cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ;
610 cout << "Writing digits to " << GetTitle() << endl ;
613 cout << "With following parameters: " << endl ;
614 cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ;
615 cout << " Threshold in EMC (fEMCDigitThreshold) = " << fEMCDigitThreshold << endl ; ;
616 cout << " Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ;
617 cout << " Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ;
618 cout << "---------------------------------------------------" << endl ;
621 cout << "AliPHOSDigitizer not initialized " << endl ;
625 //__________________________________________________________________
626 void AliPHOSDigitizer::PrintDigits(Option_t * option){
627 // Print a table of digits
629 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
630 TClonesArray * digits = gime->Digits() ;
632 cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ;
633 cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ;
635 if(strstr(option,"all")||strstr(option,"EMC")){
638 AliPHOSDigit * digit;
639 cout << "EMC digits (with primaries): " << endl ;
640 cout << "Digit Id Amplitude Index Nprim Primaries list " << endl;
641 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
643 for (index = 0 ; (index < digits->GetEntriesFast()) &&
644 (((AliPHOSDigit * ) digits->At(index))->GetId() <= maxEmc) ; index++) {
645 digit = (AliPHOSDigit * ) digits->At(index) ;
646 if(digit->GetNprimary() == 0) continue;
647 cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " "
648 << setw(6) << digit->GetIndexInList() << " "
649 << setw(5) << digit->GetNprimary() <<" ";
652 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
653 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
659 if(strstr(option,"all")||strstr(option,"CPV")){
661 //loop over CPV digits
662 AliPHOSDigit * digit;
663 cout << "CPV digits: " << endl ;
664 cout << "Digit Id Amplitude Index Nprim Primaries list " << endl;
665 Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
667 for (index = 0 ; index < digits->GetEntriesFast(); index++) {
668 digit = (AliPHOSDigit * ) digits->At(index) ;
669 if(digit->GetId() > maxEmc){
670 cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " "
671 << setw(6) << digit->GetIndexInList() << " "
672 << setw(5) << digit->GetNprimary() <<" ";
675 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
676 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
684 //__________________________________________________________________
685 void AliPHOSDigitizer::SetSDigitsBranch(const char* title)
687 // we set title (comment) of the SDigits branch in the first! header file
688 if( strcmp(GetName(), "") == 0 )
691 AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ;
694 //__________________________________________________________________
695 Float_t AliPHOSDigitizer::TimeOfNoise(void)
696 { // Calculates the time signal generated by noise
697 //to be rewritten, now returns just big number
701 //____________________________________________________________________________
702 void AliPHOSDigitizer::Reset()
704 // sets current event number to the first simulated event
706 if( strcmp(GetName(), "") == 0 )
710 // for(inputs = 0; inputs < fNinputs ;inputs++)
711 // fIevent->AddAt(-1, inputs ) ;
715 //____________________________________________________________________________
716 void AliPHOSDigitizer::WriteDigits(Int_t event)
719 // Makes TreeD in the output file.
720 // Check if branch already exists:
721 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
722 // already existing branches.
723 // else creates branch with Digits, named "PHOS", title "...",
724 // and branch "AliPHOSDigitizer", with the same title to keep all the parameters
725 // and names of files, from which digits are made.
727 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
728 TClonesArray * digits = gime->Digits(GetName()) ;
733 treeD = fARD->GetTreeD() ;
735 treeD = gAlice->TreeD();
737 // create new branches
738 // -- generate file name if necessary
740 if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
741 file = new char[strlen(gAlice->GetBaseFile())+20] ;
742 sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ;
745 TDirectory *cwd = gDirectory;
746 // -- create Digits branch
747 Int_t bufferSize = 32000 ;
748 TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
749 digitsBranch->SetTitle(GetName());
751 digitsBranch->SetFile(file);
752 TIter next( digitsBranch->GetListOfBranches());
754 while ((sbr=(TBranch*)next())) {
760 // -- Create Digitizer branch
761 Int_t splitlevel = 0 ;
762 AliPHOSDigitizer * d = gime->Digitizer(GetName()) ;
763 TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel);
764 digitizerBranch->SetTitle(GetName());
766 digitizerBranch->SetFile(file);
767 TIter next( digitizerBranch->GetListOfBranches());
769 while ((sbr=(TBranch*)next())) {
775 digitsBranch->Fill() ;
776 digitizerBranch->Fill() ;
778 treeD->Write(0,kOverwrite) ;