]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDsegmentArrayBase.cxx
Using sync TTimer instead of the a-sync one (C.Cheshkov)
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArrayBase.cxx
index ca55dfcde6f4fe6ac93ac3ec63ed875889122a75..a14ff9483abeb82c9cfbfd8f146220ae3f984645 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.1.4.3  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.1.4.2  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.5  2000/06/09 11:10:07  cblume
-Compiler warnings and coding conventions, next round
-
-Revision 1.4  2000/06/08 18:32:58  cblume
-Make code compliant to coding conventions
-
-Revision 1.3  2000/06/07 16:27:01  cblume
-Try to remove compiler warnings on Sun and HP
-
-Revision 1.2  2000/05/08 16:17:27  cblume
-Merge TRD-develop
-
-Revision 1.1.4.1  2000/05/08 14:55:03  cblume
-Bug fixes
-
-Revision 1.1  2000/02/28 19:02:56  cblume
-Add new TRD classes
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -95,14 +69,15 @@ 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;
   }
 
 }
 
 //_____________________________________________________________________________
 AliTRDsegmentArrayBase::AliTRDsegmentArrayBase(const AliTRDsegmentArrayBase &a)
+:TNamed(a)
 {
   //
   // AliTRDsegmentArrayBase copy constructor
@@ -124,9 +99,8 @@ AliTRDsegmentArrayBase::~AliTRDsegmentArrayBase()
     delete fSegment;
   }
 
-  if (fTree)      delete fTree;
+  //if (fTree)      delete fTree;
   if (fTreeIndex) delete fTreeIndex;
-  if (fClass)     delete fClass;
 
 }
 
@@ -167,10 +141,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;
@@ -203,7 +173,7 @@ Bool_t AliTRDsegmentArrayBase::SetClass(Text_t *classname)
 }
 
 //_____________________________________________________________________________
-AliTRDsegmentID * AliTRDsegmentArrayBase::NewSegment()
+AliTRDsegmentID *AliTRDsegmentArrayBase::NewSegment()
 {
   //
   // Create a new object according to the class information
@@ -277,7 +247,7 @@ Bool_t AliTRDsegmentArrayBase::MakeArray(Int_t n)
   if (fTreeIndex) delete fTreeIndex;  
 
   fSegment   = new TObjArray(n);
-  fTreeIndex = new AliTRDarrayI;
+  fTreeIndex = new AliTRDarrayI();
   fTreeIndex->Set(n);
   fNSegment  = n;
   if ((fSegment) && (fTreeIndex)) 
@@ -294,15 +264,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
@@ -313,7 +286,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;
 
@@ -356,7 +331,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);
   
@@ -368,7 +344,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;
@@ -397,7 +374,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;
 
@@ -451,7 +429,7 @@ Bool_t  AliTRDsegmentArrayBase::MakeDictionary(Int_t size)
 }
 
 //_____________________________________________________________________________
-const AliTRDsegmentID * AliTRDsegmentArrayBase::operator[](Int_t i)
+const AliTRDsegmentID * AliTRDsegmentArrayBase::operator[](Int_t i) const
 {
   //
   // Returns a segment with the given index <i>
@@ -470,6 +448,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);
 
 }