- if(fManager)
- treeD = fManager->GetTreeD() ;
- else
- treeD = gAlice->TreeD();
-
- // create new branches
- // -- generate file name if necessary
- char * file =0;
- if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
- file = new char[strlen(gAlice->GetBaseFile())+20] ;
- sprintf(file,"%s/EMCAL.Digits.root",gAlice->GetBaseFile()) ;
- }
-
- TDirectory *cwd = gDirectory;
- // -- create Digits branch
- Int_t bufferSize = 32000 ;
- TBranch * digitsBranch = treeD->Branch("EMCAL",&digits,bufferSize);
- digitsBranch->SetTitle(GetName());
- if (file) {
- digitsBranch->SetFile(file);
- TIter next( digitsBranch->GetListOfBranches());
- TBranch * sbr ;
- while ((sbr=(TBranch*)next())) {
- sbr->SetFile(file);
- }
- cwd->cd();
- }
-
- // -- Create Digitizer branch
- Int_t splitlevel = 0 ;
- AliEMCALDigitizer * d = gime->Digitizer(GetName()) ;
- TBranch * digitizerBranch = treeD->Branch("AliEMCALDigitizer", "AliEMCALDigitizer", &d,bufferSize,splitlevel);
- digitizerBranch->SetTitle(GetName());
- if (file) {
- digitizerBranch->SetFile(file);
- TIter next( digitizerBranch->GetListOfBranches());
- TBranch * sbr;
- while ((sbr=(TBranch*)next())) {
- sbr->SetFile(file);
- }
- cwd->cd();
- }
-
- digitsBranch->Fill() ;
- digitizerBranch->Fill() ;
-
- treeD->Write(0,kOverwrite) ;
+ if(fManager)
+ treeD = fManager->GetTreeD() ;
+ else {
+ if (!gAlice->TreeD() )
+ gAlice->MakeTree("D",fSplitFile);
+ treeD = gAlice->TreeD();
+ }
+
+ // -- create Digits branch
+ Int_t bufferSize = 32000 ;
+ TBranch * digitsBranch = treeD->Branch("EMCAL",&digits,bufferSize);
+ digitsBranch->SetTitle(GetName());
+
+ // -- Create Digitizer branch
+ Int_t splitlevel = 0 ;
+ AliEMCALDigitizer * d = gime->Digitizer(GetName()) ;
+ TBranch * digitizerBranch = treeD->Branch("AliEMCALDigitizer", "AliEMCALDigitizer", &d,bufferSize,splitlevel);
+ digitizerBranch->SetTitle(GetName());
+
+ digitsBranch->Fill() ;
+ digitizerBranch->Fill() ;
+ treeD->AutoSave() ;