]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CONTAINERS/AliSegmentArray.h
1e64d9311ad9c25796cdd2d32b7b343234f8ccca
[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 AliArrayI;
20 class AliSegmentID;
21  
22 class AliSegmentArray: public TNamed{
23 public:
24   AliSegmentArray();
25   AliSegmentArray(Text_t *classname, Int_t n);  // 
26   virtual ~AliSegmentArray();
27   Bool_t  SetClass(Text_t *classname);  //set class of stored object 
28   const AliSegmentID * At(Int_t i); //return pointer to segment with index i 
29   const AliSegmentID * operator[](Int_t i); //return pointer to segment with index i
30
31   Bool_t AddSegment(AliSegmentID *segment); // add segment to array
32   AliSegmentID * AddSegment(Int_t index);   //create objet and set index
33   Bool_t   MakeArray(Int_t n);       //make array of pointers to Segments
34   void ClearSegment(Int_t index); //remove segment from active   
35   virtual AliSegmentID * NewSegment(); //dynamicaly create new segment 
36   //input output functions
37   TTree * GetTree(){return fTree;}      //return pointer to connected tree
38   
39   virtual void MakeTree();              //Make tree with the name
40   virtual Bool_t ConnectTree(const char * treeName); //connect tree from current directory 
41   virtual AliSegmentID * LoadSegment(Int_t index);//load segment with index to the memory
42   virtual AliSegmentID * LoadEntry(Int_t index); //load segment entry from position index in tree
43   virtual void StoreSegment(Int_t index);//write segmen persistent  
44   Bool_t  MakeDictionary(Int_t size);//create index table for tree
45   TClass * GetClass() {return fClass;}
46   
47 protected:
48   AliSegmentArray(const AliSegmentArray &segment); //copy constructor
49   AliSegmentArray &operator = (const AliSegmentArray & segment); //assignment operator
50   TObjArray  * fSegment;  //!pointer to array of pointers to segment
51   AliArrayI    * fTreeIndex; //!pointers(index) table in tree
52   Int_t      fNSegment; //number of alocated segments   
53   TTree    * fTree;   //!tree with segment objects
54   TBranch  * fBranch; //!total branch 
55 private: 
56   TClass  *   fClass;    //!class type of included objects 
57   ClassDef(AliSegmentArray,1) 
58 };
59
60
61
62 inline const AliSegmentID*  AliSegmentArray::operator[](Int_t i)
63 {
64   //
65   //return segment with given index
66   //
67   if ( (i<0) || (i>=fNSegment)) return 0; 
68   return (AliSegmentID *)(fSegment->At(i));
69   
70 }
71
72 inline const AliSegmentID*  AliSegmentArray::At(Int_t i)
73 {
74   //
75   //return segment with given index
76   //
77   if ( (i<0) || (i>=fNSegment)) return 0; 
78   return (AliSegmentID *)(fSegment->At(i));
79 }
80
81 #endif //ALISEGMENTARRAY_H