]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDsegmentArrayBase.cxx
Pass status code in SetTrack.
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArrayBase.cxx
index 19ceb026c1a256d5a2e864219415c1800db64489..95cd8cd69055df02b9632060efcced15de4306ba 100644 (file)
 
 /*
 $Log$
+Revision 1.11  2001/11/19 08:44:08  cblume
+Fix bugs reported by Rene
+
+Revision 1.10  2001/08/30 09:31:22  hristov
+The operator[] is replaced by At() or AddAt() in case of TObjArray.
+
+Revision 1.9  2001/07/27 13:03:15  hristov
+Default Branch split level set to 99
+
+Revision 1.8  2001/01/26 19:56:57  hristov
+Major upgrade of AliRoot code
+
+Revision 1.7  2000/11/20 08:56:07  cblume
+Cleanup of data arrays
+
 Revision 1.6  2000/11/01 14:53:21  cblume
 Merge with TRD-develop
 
@@ -98,8 +113,8 @@ AliTRDsegmentArrayBase::AliTRDsegmentArrayBase(Text_t *classname, Int_t n)
   SetClass(classname);
 
   if (MakeArray(n) == kFALSE) {
-     Error("AliTRDsegmentArrayBase","Cannot allocate %d segments in memory",n);
-     return;
+    Error("AliTRDsegmentArrayBase","Cannot allocate %d segments in memory",n);
+    return;
   }
 
 }
@@ -127,9 +142,8 @@ AliTRDsegmentArrayBase::~AliTRDsegmentArrayBase()
     delete fSegment;
   }
 
-  if (fTree)      delete fTree;
+  //if (fTree)      delete fTree;
   if (fTreeIndex) delete fTreeIndex;
-  if (fClass)     delete fClass;
 
 }
 
@@ -170,10 +184,6 @@ Bool_t AliTRDsegmentArrayBase::SetClass(Text_t *classname)
   // Sets the classname of the stored object
   //
 
-  if (fClass   != 0) {
-    delete fClass;
-    fClass = 0;
-  }
   if (fTree    != 0) {
     delete fTree;
     fTree      = 0;
@@ -206,7 +216,7 @@ Bool_t AliTRDsegmentArrayBase::SetClass(Text_t *classname)
 }
 
 //_____________________________________________________________________________
-AliTRDsegmentID * AliTRDsegmentArrayBase::NewSegment()
+AliTRDsegmentID *AliTRDsegmentArrayBase::NewSegment()
 {
   //
   // Create a new object according to the class information
@@ -297,15 +307,18 @@ void AliTRDsegmentArrayBase::ClearSegment(Int_t index)
   // Remove a segment from the active memory    
   //
 
-  if ((*fSegment)[index]){
-    delete (*fSegment)[index]; // because problem with deleting TClonesArray
-    fSegment->RemoveAt(index);
+  //PH  if ((*fSegment)[index]){
+  //PH    delete (*fSegment)[index]; // because problem with deleting TClonesArray
+  //PH    fSegment->RemoveAt(index);
+  //PH  }
+  if (fSegment->At(index)){
+    delete fSegment->RemoveAt(index);
   }
 
 }
 
 //_____________________________________________________________________________
-void AliTRDsegmentArrayBase::MakeTree()
+void AliTRDsegmentArrayBase::MakeTree(char *file)
 {
   //
   // Create a tree for the segment
@@ -316,7 +329,9 @@ void AliTRDsegmentArrayBase::MakeTree()
   if (fTree) delete fTree;
   fTree   = new TTree("Segment Tree","Tree with segments");
 
-  fBranch = fTree->Branch("Segment",psegment->IsA()->GetName(),&psegment,64000,1);
+  fBranch = fTree->Branch("Segment",psegment->IsA()->GetName(),&psegment,64000);
+  if (file) 
+      fBranch->SetFile(file);      
 
   delete psegment;
 
@@ -359,7 +374,8 @@ AliTRDsegmentID *AliTRDsegmentArrayBase::LoadSegment(Int_t index)
   if (fTreeIndex == 0)        return 0;
   if (fBranch    == 0)        return 0;
   if (index > fTreeIndex->fN) return 0;
-  AliTRDsegmentID *s = (AliTRDsegmentID*) (*fSegment)[index];
+  //PH  AliTRDsegmentID *s = (AliTRDsegmentID*) (*fSegment)[index];
+  AliTRDsegmentID *s = (AliTRDsegmentID*) fSegment->At(index);
   if (s == 0) s = NewSegment();
   s->SetID(index);
   
@@ -371,7 +387,8 @@ AliTRDsegmentID *AliTRDsegmentArrayBase::LoadSegment(Int_t index)
       treeIndex--;   
     fBranch->SetAddress(&s);
     fTree->GetEvent(treeIndex);
-    (*fSegment)[index] = (TObject*) s;
+    //PH    (*fSegment)[index] = (TObject*) s;
+    fSegment->AddAt((TObject*) s, index);
   }
   else 
     return 0;
@@ -400,7 +417,8 @@ AliTRDsegmentID *AliTRDsegmentArrayBase::LoadEntry(Int_t index)
 
   Int_t nindex = s->GetID();
   ClearSegment(nindex);
-  (*fSegment)[nindex] = (TObject *) s;
+  //PH  (*fSegment)[nindex] = (TObject *) s;
+  fSegment->AddAt((TObject *) s, nindex);
 
   return s;
 
@@ -473,6 +491,7 @@ const AliTRDsegmentID *AliTRDsegmentArrayBase::At(Int_t i) const
   //
 
   if ((i < 0) || (i >= fNSegment)) return 0; 
-  return (AliTRDsegmentID *)((*fSegment)[i]);
+  //PH  return (AliTRDsegmentID *)((*fSegment)[i]);
+  return (AliTRDsegmentID *) fSegment->At(i);
 
 }