]>
Commit | Line | Data |
---|---|---|
451f5018 | 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 */ | |
5 | ||
6 | //*********************************************************************** | |
7 | // | |
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 | |
13 | // | |
14 | // The items should be added to the map like this: | |
15 | // map->RegisterItem( new(map->GetFree()) ItemConstructor(...) ); | |
16 | // | |
17 | // *********************************************************************** | |
18 | #include <TClonesArray.h> | |
19 | #include <TBtree.h> | |
20 | ||
63966cff | 21 | #define _ROWWISE_SORT_ |
451f5018 | 22 | |
23 | class AliITSUSensMap: public TObject | |
24 | { | |
25 | ||
26 | public: | |
27 | enum {kDisableBit=BIT(14)}; | |
28 | // | |
29 | AliITSUSensMap(); | |
30 | AliITSUSensMap(const char* className, UInt_t dim0,UInt_t dim1); | |
31 | virtual ~AliITSUSensMap(); | |
32 | AliITSUSensMap(const AliITSUSensMap &source); | |
33 | AliITSUSensMap& operator=(const AliITSUSensMap &source); | |
34 | void Clear(Option_t* option = ""); | |
35 | void DeleteItem(UInt_t i,UInt_t j); | |
36 | void DeleteItem(TObject* obj); | |
37 | // | |
38 | void SetDimensions(UInt_t dim0,UInt_t dim1) {fDim0 = dim0; fDim1 = dim1;} | |
39 | void GetMaxIndex(UInt_t &ni,UInt_t &nj) const {ni=fDim0;nj=fDim1;} | |
40 | Int_t GetMaxIndex() const {return fDim0*fDim1;} | |
41 | Int_t GetEntries() const {return fBTree->GetEntries();} | |
42 | Int_t GetEntriesUnsorted() const {return fItems->GetEntriesFast();} | |
43 | void GetMapIndex(UInt_t index,UInt_t &i,UInt_t &j) const {return GetCell(index, i,j);} | |
02d6eccc | 44 | TObject* GetItem(UInt_t i,UInt_t j) {SetUniqueID(GetIndex(i,j)); return fBTree->FindObject(this);} |
45 | TObject* GetItem(UInt_t index) {SetUniqueID(index); return fBTree->FindObject(this);} | |
451f5018 | 46 | TObject* GetItem(const TObject* obj) {return fBTree->FindObject(obj);} |
47 | TObject* At(Int_t i) const {return fBTree->At(i);} //!!! Access in sorted order !!! | |
48 | TObject* AtUnsorted(Int_t i) const {return fItems->At(i);} //!!! Access in unsorted order !!! | |
49 | TObject* RegisterItem(TObject* obj) {fBTree->Add(obj); return obj;} | |
50 | TObject* GetFree() {return (*fItems)[fItems->GetEntriesFast()];} | |
51 | // | |
52 | void GetCell(UInt_t index,UInt_t &i,UInt_t &j) const; | |
63966cff | 53 | UInt_t GetIndex(UInt_t i,UInt_t j) const; |
451f5018 | 54 | // |
55 | TClonesArray* GetItems() const {return fItems;} | |
56 | TBtree* GetItemsBTree() const {return fBTree;} | |
57 | // | |
02d6eccc | 58 | Bool_t IsSortable() const {return kTRUE;} |
59 | Bool_t IsEqual(const TObject* obj) const {return GetUniqueID()==obj->GetUniqueID();} | |
60 | Int_t Compare(const TObject* obj) const {return (GetUniqueID()<obj->GetUniqueID()) ? -1 : ((GetUniqueID()>obj->GetUniqueID()) ? 1 : 0 );} | |
61 | // | |
451f5018 | 62 | static Bool_t IsDisabled(TObject* obj) {return obj ? obj->TestBit(kDisableBit) : kFALSE;} |
63 | static void Disable(TObject* obj) {if (obj) obj->SetBit(kDisableBit);} | |
64 | static void Enable(TObject* obj) {if (obj) obj->ResetBit(kDisableBit);} | |
65 | // | |
451f5018 | 66 | protected: |
67 | // | |
68 | UInt_t fDim0; // 1st dimension of the matrix | |
69 | UInt_t fDim1; // 2nd dimention of the matrix | |
70 | TClonesArray* fItems; // pListItems array | |
71 | TBtree* fBTree; // tree for ordered access | |
451f5018 | 72 | // |
73 | ClassDef(AliITSUSensMap,1) // list of sensor signals (should be sortable objects) | |
74 | }; | |
63966cff | 75 | |
76 | inline UInt_t AliITSUSensMap::GetIndex(UInt_t i,UInt_t j) const | |
77 | { | |
78 | // linearized ID of digit | |
79 | #ifdef _ROWWISE_SORT_ | |
80 | return j*fDim0+i; // sorted in row, then in column | |
81 | #else | |
82 | return j+i*fDim1; // sorted in column, then in row | |
83 | #endif | |
84 | } | |
85 | ||
451f5018 | 86 | #endif |