]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDsegmentArray.cxx
Update of raw data reading by Christian
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArray.cxx
index 4c6973b910a4758317d6abe5429259ff24273f34..9c40402dc04c363d42d11f961b235677c91cceeb 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.4  2000/06/27 13:08:50  cblume
-Changed to Copy(TObject &A) to appease the HP-compiler
+/* $Id$ */
 
-Revision 1.3  2000/06/08 18:32:58  cblume
-Make code compliant to coding conventions
-
-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:32  cblume
-Add new TRD classes
-
-*/
-
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-//  Alice segment manager class                                              //
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  Alice segment manager class                                           //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
 
 #include <TTree.h>
 
-#include "AliTRD.h"
+#include "AliLog.h"
+
 #include "AliTRDgeometry.h"
 #include "AliTRDsegmentArray.h"
+#include "AliTRDdataArray.h"
 
 ClassImp(AliTRDsegmentArray)
 
 //_____________________________________________________________________________
-AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase()
+AliTRDsegmentArray::AliTRDsegmentArray()
+  :AliTRDsegmentArrayBase()
 {
   //
   // Default constructor
@@ -56,8 +42,8 @@ AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase()
 }
 
 //_____________________________________________________________________________
-AliTRDsegmentArray::AliTRDsegmentArray(Text_t *classname, Int_t n)
-                   :AliTRDsegmentArrayBase(classname,n)
+AliTRDsegmentArray::AliTRDsegmentArray(const char *classname, Int_t n)
+  :AliTRDsegmentArrayBase(classname,n)
 {
   //
   // Constructor creating an array of AliTRDdataArray of size <n>
@@ -73,6 +59,7 @@ AliTRDsegmentArray::AliTRDsegmentArray(Text_t *classname, Int_t n)
 
 //_____________________________________________________________________________
 AliTRDsegmentArray::AliTRDsegmentArray(AliTRDsegmentArray &a)
+  :AliTRDsegmentArrayBase(a)
 {
   //
   // AliTRDsegmentArray copy constructor
@@ -88,10 +75,13 @@ AliTRDsegmentArray::~AliTRDsegmentArray()
   //
   // AliTRDsegmentArray destructor
   //
+
+  Delete();
+
 }
 
 //_____________________________________________________________________________
-void AliTRDsegmentArray::Copy(TObject &a)
+void AliTRDsegmentArray::Copy(TObject &a) const
 {
   //
   // Copy function
@@ -115,20 +105,26 @@ 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;
@@ -147,20 +143,26 @@ 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;
@@ -180,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
@@ -191,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);
 
 }