1 #ifndef ALIITSUSENSMAP_H
2 #define ALIITSUSENSMAP_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 //***********************************************************************
8 // It consist of a TClonesArray of objects
9 // and B-tree for fast sorted access
10 // This array can be accessed via 2 indexed
11 // it is used at digitization level by
12 // all the ITS subdetectors
14 // The items should be added to the map like this:
15 // map->RegisterItem( new(map->GetFree()) ItemConstructor(...) );
17 // ***********************************************************************
18 #include <TClonesArray.h>
22 class AliITSUSensMap: public TObject
26 enum {kDisableBit=BIT(14)};
29 AliITSUSensMap(const char* className, UInt_t dim0,UInt_t dim1);
30 virtual ~AliITSUSensMap();
31 AliITSUSensMap(const AliITSUSensMap &source);
32 AliITSUSensMap& operator=(const AliITSUSensMap &source);
33 void Clear(Option_t* option = "");
34 void DeleteItem(UInt_t i,UInt_t j);
35 void DeleteItem(TObject* obj);
37 void SetDimensions(UInt_t dim0,UInt_t dim1) {fDim0 = dim0; fDim1 = dim1;}
38 void GetMaxIndex(UInt_t &ni,UInt_t &nj) const {ni=fDim0;nj=fDim1;}
39 Int_t GetMaxIndex() const {return fDim0*fDim1;}
40 Int_t GetEntries() const {return fBTree->GetEntries();}
41 Int_t GetEntriesUnsorted() const {return fItems->GetEntriesFast();}
42 void GetMapIndex(UInt_t index,UInt_t &i,UInt_t &j) const {return GetCell(index, i,j);}
43 TObject* GetItem(UInt_t i,UInt_t j) {SetUniqueID(GetIndex(i,j)); return fBTree->FindObject(this);}
44 TObject* GetItem(UInt_t index) {SetUniqueID(index); return fBTree->FindObject(this);}
45 TObject* GetItem(const TObject* obj) {return fBTree->FindObject(obj);}
46 TObject* At(Int_t i) const {return fBTree->At(i);} //!!! Access in sorted order !!!
47 TObject* AtUnsorted(Int_t i) const {return fItems->At(i);} //!!! Access in unsorted order !!!
48 TObject* RegisterItem(TObject* obj) {fBTree->Add(obj); return obj;}
49 TObject* GetFree() {return (*fItems)[fItems->GetEntriesFast()];}
51 void GetCell(UInt_t index,UInt_t &i,UInt_t &j) const;
52 UInt_t GetIndex(UInt_t i,UInt_t j) const {return j+i*fDim1;}
54 TClonesArray* GetItems() const {return fItems;}
55 TBtree* GetItemsBTree() const {return fBTree;}
57 Bool_t IsSortable() const {return kTRUE;}
58 Bool_t IsEqual(const TObject* obj) const {return GetUniqueID()==obj->GetUniqueID();}
59 Int_t Compare(const TObject* obj) const {return (GetUniqueID()<obj->GetUniqueID()) ? -1 : ((GetUniqueID()>obj->GetUniqueID()) ? 1 : 0 );}
61 static Bool_t IsDisabled(TObject* obj) {return obj ? obj->TestBit(kDisableBit) : kFALSE;}
62 static void Disable(TObject* obj) {if (obj) obj->SetBit(kDisableBit);}
63 static void Enable(TObject* obj) {if (obj) obj->ResetBit(kDisableBit);}
67 UInt_t fDim0; // 1st dimension of the matrix
68 UInt_t fDim1; // 2nd dimention of the matrix
69 TClonesArray* fItems; // pListItems array
70 TBtree* fBTree; // tree for ordered access
72 ClassDef(AliITSUSensMap,1) // list of sensor signals (should be sortable objects)