]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUSensMap.h
An example Config.C for ITSU pileup studies in pp
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSensMap.h
CommitLineData
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>
63966cff 20#define _ROWWISE_SORT_
451f5018 21
22class AliITSUSensMap: public TObject
23{
24
25 public:
26 enum {kDisableBit=BIT(14)};
27 //
28 AliITSUSensMap();
b2679935 29 AliITSUSensMap(const char* className, UInt_t dimCol,UInt_t dimRow,UInt_t dimCycle=1);
451f5018 30 virtual ~AliITSUSensMap();
31 AliITSUSensMap(const AliITSUSensMap &source);
32 AliITSUSensMap& operator=(const AliITSUSensMap &source);
33 void Clear(Option_t* option = "");
fbcb7a55 34 void DeleteItem(UInt_t col,UInt_t row, Int_t cycle);
451f5018 35 void DeleteItem(TObject* obj);
36 //
b2679935 37 void SetDimensions(UInt_t dimCol,UInt_t dimRow,UInt_t dimCycle=1);
fbcb7a55 38 void GetMaxIndex(UInt_t &col,UInt_t &row,UInt_t &cycle) const {col=fDimCol; row=fDimRow; cycle=fDimCycle;}
1cdd0456 39 Int_t GetMaxIndex() const {return fDimCol*fDimRow*(fDimCycle*2+1);}
451f5018 40 Int_t GetEntries() const {return fBTree->GetEntries();}
41 Int_t GetEntriesUnsorted() const {return fItems->GetEntriesFast();}
fbcb7a55 42 void GetMapIndex(UInt_t index,UInt_t &col,UInt_t &row,Int_t &cycle) const {return GetCell(index,fDimCol,fDimRow,fDimCycle,col,row,cycle);}
43 void GetCell(UInt_t index,UInt_t &col,UInt_t &row,Int_t &cycle) const {return GetCell(index,fDimCol,fDimRow,fDimCycle,col,row,cycle);}
44 TObject* GetItem(UInt_t col,UInt_t row,Int_t cycle) {SetUniqueID(GetIndex(col,row,cycle)); return fBTree->FindObject(this);}
02d6eccc 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 //
fbcb7a55 52 UInt_t GetIndex(UInt_t col,UInt_t row,Int_t cycle=0) const;
451f5018 53 //
54 TClonesArray* GetItems() const {return fItems;}
55 TBtree* GetItemsBTree() const {return fBTree;}
56 //
02d6eccc 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 );}
60 //
451f5018 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);}
fbcb7a55 64 static void GetCell(UInt_t index,UInt_t dcol,UInt_t drow,UInt_t dcycle,UInt_t &col,UInt_t &row,Int_t &cycle);
451f5018 65 //
451f5018 66 protected:
67 //
fbcb7a55 68 UInt_t fDimCol; // 1st dimension of the matrix, col index may span from 0 to fDimCol
69 UInt_t fDimRow; // 2nd dimention of the matrix, row index may span from 0 to fDimRow
70 UInt_t fDimCycle; // readout cycle range, may span from -fDimCycle to fDimCycle
451f5018 71 TClonesArray* fItems; // pListItems array
72 TBtree* fBTree; // tree for ordered access
451f5018 73 //
74 ClassDef(AliITSUSensMap,1) // list of sensor signals (should be sortable objects)
75};
63966cff 76
fbcb7a55 77//______________________________________________________________________
78inline UInt_t AliITSUSensMap::GetIndex(UInt_t col,UInt_t row, Int_t cycle) const
63966cff 79{
80 // linearized ID of digit
fbcb7a55 81 UInt_t cyclePos = cycle+fDimCycle; // cycle may span from -fDimCycle to fDimCycle
63966cff 82#ifdef _ROWWISE_SORT_
fbcb7a55 83 return fDimCol*(cyclePos*fDimRow+row)+col; // sorted in row, then in column
63966cff 84#else
fbcb7a55 85 return fDimRow*(cyclePos*fDimCol+col)+row; // sorted in column, then in row
63966cff 86#endif
87}
88
fbcb7a55 89//______________________________________________________________________
90inline void AliITSUSensMap::GetCell(UInt_t index,UInt_t dcol,UInt_t drow,UInt_t dcycle,UInt_t &col,UInt_t &row,Int_t &cycle)
91{
92 // returns the i,j index numbers from the linearized index computed with GetIndex
93 UInt_t dcr = dcol*drow;
94 cycle = int(index/dcr) - dcycle;
95 index %= dcr;
96#ifdef _ROWWISE_SORT_
97 col = index%dcol; // sorted in row, then in column
98 row = index/dcol;
99#else
100 col = index/drow; // sorted in column, then in row
101 row = index%drow;
102#endif
103}
104
105
451f5018 106#endif