]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CONTAINERS/AliSegmentArray.h
ddc408b3ccc1ab00e7ba5f6fe45b6c95d7390b24
[u/mrichter/AliRoot.git] / CONTAINERS / AliSegmentArray.h
1 #ifndef ALISEGMENTARRAY_H
2 #define ALISEGMENTARRAY_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ////////////////////////////////////////////////
9 //  Manager class general Alice segment 
10 //  segment is for example one pad row in TPC //
11 ////////////////////////////////////////////////
12
13 #include "TNamed.h"
14 #include "TError.h"
15 #include "TObjArray.h"
16
17 class TTree;
18 class TBranch;
19 class TFile;
20 class AliArrayI;
21 class AliSegmentID;
22  
23 class AliSegmentArray: public TNamed{
24 public:
25   AliSegmentArray();
26   AliSegmentArray(Text_t *classname, Int_t n);  // 
27   virtual ~AliSegmentArray();
28   Bool_t  SetClass(Text_t *classname);  //set class of stored object 
29   const AliSegmentID * At(Int_t i); //return pointer to segment with index i 
30   const AliSegmentID * operator[](Int_t i); //return pointer to segment with index i
31
32   Bool_t AddSegment(AliSegmentID *segment); // add segment to array
33   AliSegmentID * AddSegment(Int_t index);   //create objet and set index
34   Bool_t   MakeArray(Int_t n);       //make array of pointers to Segments
35   void ClearSegment(Int_t index); //remove segment from active   
36   virtual AliSegmentID * NewSegment(); //dynamicaly create new segment 
37   //input output functions
38   TTree * GetTree(){return fTree;}      //return pointer to connected tree
39   
40   virtual void MakeTree(char *file=0);              //Make tree with the name
41   virtual Bool_t ConnectTree(const char * treeName); //connect tree from current directory 
42   virtual AliSegmentID * LoadSegment(Int_t index);//load segment with index to the memory
43   virtual AliSegmentID * LoadEntry(Int_t index); //load segment entry from position index in tree
44   virtual void StoreSegment(Int_t index);//write segmen persistent  
45   Bool_t  MakeDictionary(Int_t size);//create index table for tree
46   TClass * GetClass() {return fClass;}
47   
48 protected:
49   AliSegmentArray(const AliSegmentArray &segment); //copy constructor
50   AliSegmentArray &operator = (const AliSegmentArray & segment); //assignment operator
51   TObjArray  * fSegment;  //!pointer to array of pointers to segment
52   AliArrayI    * fTreeIndex; //!pointers(index) table in tree
53   Int_t      fNSegment; //number of alocated segments   
54   TTree    * fTree;   //!tree with segment objects
55   TBranch  * fBranch; //!total branch 
56 private: 
57   TClass  *   fClass;    //!class type of included objects 
58   ClassDef(AliSegmentArray,1) 
59 };
60
61
62
63 inline const AliSegmentID*  AliSegmentArray::operator[](Int_t i)
64 {
65   //
66   //return segment with given index
67   //
68   if ( (i<0) || (i>=fNSegment)) return 0; 
69   return (AliSegmentID *)(fSegment->At(i));
70   
71 }
72
73 inline const AliSegmentID*  AliSegmentArray::At(Int_t i)
74 {
75   //
76   //return segment with given index
77   //
78   if ( (i<0) || (i>=fNSegment)) return 0; 
79   return (AliSegmentID *)(fSegment->At(i));
80 }
81
82 #endif //ALISEGMENTARRAY_H