]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - CONTAINERS/AliSegmentArray.cxx
Merging the VirtualMC branch to the main development branch (HEAD)
[u/mrichter/AliRoot.git] / CONTAINERS / AliSegmentArray.cxx
index b58fcce80e5d0f9cff991f6f746c281320ddb316..cc556d29677117a856279673fce39006eb4fefdf 100644 (file)
 
 /*
 $Log$
+Revision 1.7.6.1  2002/06/10 15:00:53  hristov
+Merged with v3-08-02
+
+Revision 1.8  2002/04/04 16:38:52  kowal2
+Digits and Sdigits go to separate files
+
+Revision 1.7  2001/10/21 18:22:54  hristov
+BranchOld replaced by Branch. It works correctly with Root 2.02.xx
+
+Revision 1.6  2001/08/30 09:25:24  hristov
+The operator[] is replaced by At() or AddAt() in case of TObjArray. A temporary replacement of Branch with BranchOld is introduced
+
+Revision 1.5  2001/07/27 13:03:11  hristov
+Default Branch split level set to 99
+
 Revision 1.4  2001/06/07 18:23:52  buncic
 TPC branches now correctly diverted into Digits.TPS.root file
 
@@ -56,6 +71,7 @@ New data structure handling
 #include "AliArrayI.h"
 #include "TError.h"
 #include "TClass.h"
+#include "TFile.h"
 
 #include "AliRun.h"
 #include "AliSegmentID.h"
@@ -76,6 +92,7 @@ AliSegmentArray::AliSegmentArray()
   fTreeIndex = 0;
   fTree  = 0;
   fClass = 0;
+  fBranch = 0;
 }
 
 AliSegmentArray::AliSegmentArray(Text_t *classname, Int_t n)
@@ -215,10 +232,12 @@ void AliSegmentArray::ClearSegment(Int_t index)
   //
   //remove segment from active memory    
   //
-  if ((*fSegment)[index]){
+  //PH  if ((*fSegment)[index]){
+  if (fSegment->At(index)){
     //    (*fSegment)[index]->Delete(); //not working for TClonesArray
-    delete (*fSegment)[index]; //because problem with deleting TClonesArray
-    fSegment->RemoveAt(index);
+    //PH    delete (*fSegment)[index]; //because problem with deleting TClonesArray
+    //PH    fSegment->RemoveAt(index);
+    delete fSegment->RemoveAt(index);
   }
 }
 
@@ -245,8 +264,9 @@ void AliSegmentArray::MakeTree(char *file)
   AliSegmentID * psegment = NewSegment();  
   if (fTree) delete fTree;
   fTree = new TTree("Segment Tree","Tree with segments");
-  fBranch = fTree->Branch("Segment",psegment->IsA()->GetName(),&psegment,64000);
-  if (file) {
+  //PH  fBranch = fTree->Branch("Segment",psegment->IsA()->GetName(),&psegment,64000);
+   fBranch = fTree->Branch("Segment",psegment->IsA()->GetName(),&psegment,64000,99);
+ if (file) {
         TString outFile = gAlice->GetBaseFile();
         outFile = outFile + "/" + file;
         fBranch->SetFile(outFile.Data());
@@ -262,6 +282,24 @@ void AliSegmentArray::MakeTree(char *file)
   delete psegment;
 }              
 
+////////////////////////////////////////////////////////////////////////
+TTree* AliSegmentArray::MakeTree(TFile *file)
+{
+  // 
+  //  create the whole tree in the file file
+  //
+  AliSegmentID * psegment = NewSegment();  
+  if (fTree) delete fTree;
+  TDirectory *wd = gDirectory;
+  file->cd();
+  fTree = new TTree("Segment Tree","Tree with segments");
+  fBranch = fTree->Branch("Segment",psegment->IsA()->GetName(),&psegment,64000,99);
+  wd->cd(); 
+  delete psegment;
+  return fTree;
+}              
+////////////////////////////////////////////////////////////////////////
+
 Bool_t  AliSegmentArray::MakeDictionary(Int_t size)
 {
   //
@@ -315,7 +353,8 @@ AliSegmentID *AliSegmentArray::LoadSegment(Int_t index)
   if (fTreeIndex ==0 ) return 0;
   if (fBranch==0) return 0;
   if (index>fTreeIndex->fN) return 0;
-  AliSegmentID *s = (AliSegmentID*)(*fSegment)[index];
+  //PH  AliSegmentID *s = (AliSegmentID*)(*fSegment)[index];
+  AliSegmentID *s = (AliSegmentID*)fSegment->At(index);
   if (s==0)  s=  NewSegment();
   s->SetID(index);
   //  new AliSegmentID(index);
@@ -326,7 +365,8 @@ AliSegmentID *AliSegmentArray::LoadSegment(Int_t index)
     else treeIndex--;   //I don't like it Int table I have index shifted by 1                 
     fBranch->SetAddress(&s);
     fTree->GetEvent(treeIndex);
-    (*fSegment)[index] = (TObject*) s;
+    //PH    (*fSegment)[index] = (TObject*) s;
+    fSegment->AddAt((TObject*) s, index);
   }
   else 
     return 0;
@@ -351,7 +391,8 @@ AliSegmentID *AliSegmentArray::LoadEntry(Int_t index)
     return 0;
   Int_t nindex = s->GetID();
   ClearSegment(nindex);
-  (*fSegment)[nindex] = (TObject*) s;
+  //PH  (*fSegment)[nindex] = (TObject*) s;
+  fSegment->AddAt((TObject*) s, nindex);
   return s;
 }