]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDsegmentArrayBase.cxx
coding conventions corrections
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArrayBase.cxx
index 76c6d26ee93fe82555de796b331aa47ae5916c90..8ceb9e7a7b2a6bff779eaefecf4998f942ba22ff 100644 (file)
 
 /*
 $Log$
+Revision 1.12.6.1  2002/06/10 15:28:58  hristov
+Merged with v3-08-02
+
+Revision 1.13  2002/03/28 14:59:07  cblume
+Coding conventions
+
+Revision 1.12  2002/02/12 16:06:45  cblume
+Remove delete fTree
+
+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
+
+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
 
@@ -35,14 +74,14 @@ Add new TRD classes
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include  <TROOT.h>
+#include <TROOT.h>
 #include <TTree.h>
-#include "TClonesArray.h"
-#include "TDirectory.h"
-#include "AliTRDarrayI.h"
-#include "TError.h"
-#include "TClass.h"
+#include <TClonesArray.h>
+#include <TDirectory.h>
+#include <TError.h>
+#include <TClass.h>
 
+#include "AliTRDarrayI.h"
 #include "AliTRDsegmentID.h"
 #include "AliTRDsegmentArrayBase.h"
 
@@ -60,6 +99,7 @@ AliTRDsegmentArrayBase::AliTRDsegmentArrayBase():TNamed()
   fTreeIndex = 0;
   fTree      = 0;
   fClass     = 0;
+  fBranch    = 0;
 
 }
 
@@ -77,24 +117,25 @@ AliTRDsegmentArrayBase::AliTRDsegmentArrayBase(Text_t *classname, Int_t n)
   fTreeIndex = 0;
   fTree      = 0;
   fClass     = 0;
+  fBranch    = 0;
 
   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(AliTRDsegmentArrayBase &a)
+AliTRDsegmentArrayBase::AliTRDsegmentArrayBase(const AliTRDsegmentArrayBase &a)
 {
   //
   // AliTRDsegmentArrayBase copy constructor
   //
   
-  a.Copy(*this);
+  ((AliTRDsegmentArrayBase &) a).Copy(*this);
 
 }
 
@@ -110,14 +151,26 @@ AliTRDsegmentArrayBase::~AliTRDsegmentArrayBase()
     delete fSegment;
   }
 
-  if (fTree)      delete fTree;
+  //if (fTree)      delete fTree;
   if (fTreeIndex) delete fTreeIndex;
-  if (fClass)     delete fClass;
 
 }
 
 //_____________________________________________________________________________
-void AliTRDsegmentArrayBase::Copy(AliTRDsegmentArrayBase &a)
+AliTRDsegmentArrayBase &AliTRDsegmentArrayBase
+                        ::operator=(const AliTRDsegmentArrayBase &a)
+{
+  //
+  // Assignment operator
+  //
+
+  if (this != &a) ((AliTRDsegmentArrayBase &) a).Copy(*this);
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+void AliTRDsegmentArrayBase::Copy(TObject &a)
 {
   //
   // Copy function
@@ -125,11 +178,11 @@ void AliTRDsegmentArrayBase::Copy(AliTRDsegmentArrayBase &a)
 
   TNamed::Copy(a);
 
-  fSegment->Copy(*a.fSegment);
-  fTreeIndex->Copy(*a.fTreeIndex);
-  fClass->Copy(*a.fClass);
+  fSegment->Copy(*((AliTRDsegmentArrayBase &) a).fSegment);
+  fTreeIndex->Copy(*((AliTRDsegmentArrayBase &) a).fTreeIndex);
+  fClass->Copy(*((AliTRDsegmentArrayBase &) a).fClass);
 
-  a.fNSegment = fNSegment;
+  ((AliTRDsegmentArrayBase &) a).fNSegment = fNSegment;
 
 }
 
@@ -140,10 +193,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;
@@ -176,7 +225,7 @@ Bool_t AliTRDsegmentArrayBase::SetClass(Text_t *classname)
 }
 
 //_____________________________________________________________________________
-AliTRDsegmentID * AliTRDsegmentArrayBase::NewSegment()
+AliTRDsegmentID *AliTRDsegmentArrayBase::NewSegment()
 {
   //
   // Create a new object according to the class information
@@ -250,7 +299,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)) 
@@ -267,15 +316,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
@@ -286,7 +338,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;
 
@@ -329,7 +383,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);
   
@@ -341,7 +396,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;
@@ -370,7 +426,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;
 
@@ -424,7 +481,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>
@@ -436,13 +493,14 @@ const AliTRDsegmentID * AliTRDsegmentArrayBase::operator[](Int_t i)
 }
 
 //_____________________________________________________________________________
-const AliTRDsegmentID *AliTRDsegmentArrayBase::At(Int_t i)
+const AliTRDsegmentID *AliTRDsegmentArrayBase::At(Int_t i) const
 {
   //
   // Returns a segment with the given index <i>
   //
 
   if ((i < 0) || (i >= fNSegment)) return 0; 
-  return (AliTRDsegmentID *)((*fSegment)[i]);
+  //PH  return (AliTRDsegmentID *)((*fSegment)[i]);
+  return (AliTRDsegmentID *) fSegment->At(i);
 
 }