]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDsegmentArray.cxx
Remove initialization of the tracklet pointer to get rid of compiler warning
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArray.cxx
index 15306ccd9a7b717c8b80e7ee3a693c9548713be0..9c40402dc04c363d42d11f961b235677c91cceeb 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-*/
+/* $Id$ */
 
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  Alice segment manager class                                           //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <TTree.h>
+
+#include "AliLog.h"
 
-#include "AliTRD.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDsegmentArray.h"
+#include "AliTRDdataArray.h"
 
 ClassImp(AliTRDsegmentArray)
 
 //_____________________________________________________________________________
-AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase()
+AliTRDsegmentArray::AliTRDsegmentArray()
+  :AliTRDsegmentArrayBase()
 {
   //
   // Default constructor
@@ -37,21 +42,55 @@ AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase()
 }
 
 //_____________________________________________________________________________
-AliTRDsegmentArray::AliTRDsegmentArray(Int_t n)
-                   :AliTRDsegmentArrayBase("AliTRDdataArray",n)
+AliTRDsegmentArray::AliTRDsegmentArray(const char *classname, Int_t n)
+  :AliTRDsegmentArrayBase(classname,n)
 {
   //
   // Constructor creating an array of AliTRDdataArray of size <n>
   //
 
-  AliTRDdataArray *DataArray;  
+  AliTRDdataArray *dataArray;  
 
   for (Int_t i = 0; i < n; i++) {
-    DataArray = (AliTRDdataArray *) AddSegment(i);
+    dataArray = (AliTRDdataArray *) AddSegment(i);
   }
 
 }
 
+//_____________________________________________________________________________
+AliTRDsegmentArray::AliTRDsegmentArray(AliTRDsegmentArray &a)
+  :AliTRDsegmentArrayBase(a)
+{
+  //
+  // AliTRDsegmentArray copy constructor
+  //
+
+  a.Copy(*this);
+
+}
+
+//_____________________________________________________________________________
+AliTRDsegmentArray::~AliTRDsegmentArray()
+{
+  //
+  // AliTRDsegmentArray destructor
+  //
+
+  Delete();
+
+}
+
+//_____________________________________________________________________________
+void AliTRDsegmentArray::Copy(TObject &a) const
+{
+  //
+  // Copy function
+  //
+
+  AliTRDsegmentArrayBase::Copy(a);
+
+}
+
 //_____________________________________________________________________________
 void AliTRDsegmentArray::Delete()
 {
@@ -66,30 +105,36 @@ void AliTRDsegmentArray::Delete()
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname)
+Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname, TTree *tree)
 {
   //
   // Loads all segments of the array from the branch <branchname> of
-  // the digits tree
+  // the digits tree <tree>
   //
 
-  // Connect the digits tree
-  fTree = gAlice->TreeD();
-  if (!fTree) return kFALSE;
+  fTree = tree;
+
+  if (!fTree) {
+    AliError("Digits tree is not defined\n");
+    return kFALSE;
+  }
 
   // Get the branch
   fBranch = fTree->GetBranch(branchname);
-  if (!fBranch) return kFALSE;
+  if (!fBranch) {
+    AliError(Form("Branch %s is not defined\n",branchname));
+    return kFALSE;
+  }
 
   // Loop through all segments and read them from the tree
   Bool_t status = kTRUE;
   for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) {
-    AliTRDdataArray *DataArray = (AliTRDdataArray *) fSegment->At(iSegment);
-    if (!DataArray) {
+    AliTRDdataArray *dataArray = (AliTRDdataArray *) fSegment->At(iSegment);
+    if (!dataArray) {
       status = kFALSE;
       break;    
     }
-    fBranch->SetAddress(&DataArray);
+    fBranch->SetAddress(&dataArray);
     fBranch->GetEntry(iSegment);
   }
 
@@ -98,31 +143,37 @@ Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname)
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname)
+Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname, TTree *tree)
 {
   //
   // Stores all segments of the array in the branch <branchname> of 
-  // the digits tree
+  // the digits tree <tree>
   //
 
-  // Connect the digits tree
-  fTree = gAlice->TreeD();
-  if (!fTree) return kFALSE;
+  fTree = tree;
+
+  if (!fTree) {
+    AliError("Digits tree is not defined\n");
+    return kFALSE;
+  }
 
   // Get the branch
   fBranch = fTree->GetBranch(branchname);
-  if (!fBranch) return kFALSE;
+  if (!fBranch) {
+    AliError(Form("Branch %s is not defined\n",branchname));
+    return kFALSE;
+  }
 
   // Loop through all segments and fill them into the tree
   Bool_t status = kTRUE;
   for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) {
-    const AliTRDdataArray *DataArray = 
+    const AliTRDdataArray *kDataArray = 
          (AliTRDdataArray *) AliTRDsegmentArrayBase::At(iSegment);
-    if (!DataArray) {
+    if (!kDataArray) {
       status = kFALSE;
       break;
     }
-    fBranch->SetAddress(&DataArray);
+    fBranch->SetAddress(&kDataArray);
     fBranch->Fill();
   }
 
@@ -131,7 +182,7 @@ Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname)
 }
 
 //_____________________________________________________________________________
-AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det)
+AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det) const
 {
   //
   // Returns the data array for a given detector
@@ -142,25 +193,15 @@ AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det)
 }
 
 //_____________________________________________________________________________
-AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla, Int_t cha, Int_t sec)
+AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla
+                                                , Int_t cha
+                                                , Int_t sec) const
 {
   //
   // Returns the data array for a given detector
   //
 
-  if (gAlice) {
-
-    AliTRDgeometry *Geo = ((AliTRD*) gAlice->GetDetector("TRD"))->GetGeometry();  
-    Int_t det = Geo->GetDetector(pla,cha,sec);
-    return GetDataArray(det);
-
-  }
-  else {
-
-    printf("AliTRDsegmentArray::GetDigits -- ");
-    printf("gAlice is not defined\n");
-    return NULL;
-
-  }
+  Int_t det = AliTRDgeometry::GetDetector(pla,cha,sec);
+  return GetDataArray(det);
 
 }