]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | //////////////////////////////////////////////////////////////////////// | |
18 | // | |
19 | // AliTOFDigitMap class | |
20 | // | |
21 | // digitmap enables fast check if the pad was already hit | |
22 | // The index of a AliTOFdigit is saved in the each hitmap "cell" | |
23 | // (there is an offset +1, because the index can be zero and | |
24 | // zero means empty cell. | |
25 | // In TOF, number of strips varies according plate type, the highest | |
26 | // number is in plate C. For all plates is used this number, so | |
27 | // the size of the digitmap is a little bit greater than necessary, but | |
28 | // it simplifies the access algorithm. | |
29 | // | |
30 | // | |
31 | // Author: F. Pierella based on AliTOFHitMap | |
32 | // | |
33 | //////////////////////////////////////////////////////////////////////// | |
34 | ||
35 | #include "TClonesArray.h" | |
36 | ||
37 | #include "AliTOFDigitMap.h" | |
38 | #include "AliTOFGeometry.h" | |
39 | ||
40 | ClassImp(AliTOFDigitMap) | |
41 | ||
42 | AliTOFDigitMap::AliTOFDigitMap() | |
43 | { | |
44 | // | |
45 | // Default ctor | |
46 | // | |
47 | fDigitMap = 0; | |
48 | fDigits = 0; | |
49 | ||
50 | fTOFGeometry = new AliTOFGeometry(); | |
51 | ||
52 | } | |
53 | ||
54 | //////////////////////////////////////////////////////////////////////// | |
55 | AliTOFDigitMap::AliTOFDigitMap(TClonesArray *dig, AliTOFGeometry *tofGeom) | |
56 | { | |
57 | // | |
58 | // ctor | |
59 | // | |
60 | // of course, these constants must not be hardwired | |
61 | // change later | |
62 | ||
63 | fTOFGeometry = tofGeom; | |
64 | ||
65 | fNSector = AliTOFGeometry::NSectors(); | |
66 | fNplate = AliTOFGeometry::NPlates(); | |
67 | fNstrip = fTOFGeometry->NMaxNstrip(); | |
68 | fNpx = AliTOFGeometry::NpadX(); | |
69 | fNpz = AliTOFGeometry::NpadZ(); | |
70 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; | |
71 | fDigitMap = new Int_t[fMaxIndex]; | |
72 | fDigits = dig; | |
73 | Clear(); | |
74 | } | |
75 | ||
76 | //////////////////////////////////////////////////////////////////////// | |
77 | AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/) | |
78 | :TObject() | |
79 | { | |
80 | // | |
81 | // Dummy copy constructor | |
82 | // | |
83 | ; | |
84 | ||
85 | } | |
86 | ||
87 | ||
88 | //////////////////////////////////////////////////////////////////////// | |
89 | AliTOFDigitMap::~AliTOFDigitMap() | |
90 | { | |
91 | // | |
92 | // Destructor | |
93 | // | |
94 | if (fDigitMap) delete[] fDigitMap; | |
95 | ||
96 | fTOFGeometry = 0; | |
97 | ||
98 | } | |
99 | ||
100 | //////////////////////////////////////////////////////////////////////// | |
101 | void AliTOFDigitMap::Clear(const char *) | |
102 | { | |
103 | // | |
104 | // Clear hitmap | |
105 | // | |
106 | memset(fDigitMap,0,sizeof(int)*fMaxIndex); | |
107 | } | |
108 | ||
109 | //////////////////////////////////////////////////////////////////////// | |
110 | Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const | |
111 | { | |
112 | // | |
113 | // Return checked indices for vol | |
114 | // | |
115 | Int_t index= | |
116 | vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector | |
117 | vol[1]*fNstrip*fNpx*fNpz+ // plate | |
118 | vol[2]*fNpx*fNpz+ // strip | |
119 | vol[3]*fNpz+ // padx | |
120 | vol[4]; // padz | |
121 | ||
122 | if (index >= fMaxIndex) { | |
123 | Error("AliTOFDigitMap","CheckedIndex - input outside bounds"); | |
124 | return -1; | |
125 | } else { | |
126 | return index; | |
127 | } | |
128 | } | |
129 | ||
130 | //////////////////////////////////////////////////////////////////////// | |
131 | void AliTOFDigitMap::SetHit(Int_t *vol, Int_t idigit) | |
132 | { | |
133 | // | |
134 | // Assign digit to pad vol | |
135 | // | |
136 | ||
137 | // 0 means empty pad, we need to shift indeces by 1 | |
138 | fDigitMap[CheckedIndex(vol)]=idigit+1; | |
139 | } | |
140 | ||
141 | //////////////////////////////////////////////////////////////////////// | |
142 | void AliTOFDigitMap::SetHit(Int_t *vol) | |
143 | { | |
144 | // | |
145 | // Assign last digit to pad vol | |
146 | // | |
147 | ||
148 | // 0 means empty pad, we need to shift indeces by 1 | |
149 | fDigitMap[CheckedIndex(vol)]=fDigits->GetLast()+1; | |
150 | } | |
151 | ||
152 | //////////////////////////////////////////////////////////////////////// | |
153 | Int_t AliTOFDigitMap::GetHitIndex(Int_t *vol) const | |
154 | { | |
155 | // | |
156 | // Get contents of pad vol | |
157 | // | |
158 | ||
159 | // 0 means empty pad, we need to shift indeces by 1 | |
160 | return fDigitMap[CheckedIndex(vol)]-1; | |
161 | } | |
162 | ||
163 | //////////////////////////////////////////////////////////////////////// | |
164 | TObject* AliTOFDigitMap::GetHit(Int_t *vol) const | |
165 | { | |
166 | // | |
167 | // Get pointer to object at vol | |
168 | // return 0 if vol out of bounds | |
169 | Int_t index=GetHitIndex(vol); | |
170 | return (index <0) ? 0 : fDigits->UncheckedAt(index); | |
171 | } | |
172 | ||
173 | //////////////////////////////////////////////////////////////////////// | |
174 | FlagType AliTOFDigitMap::TestHit(Int_t *vol) const | |
175 | { | |
176 | // | |
177 | // Check if hit cell is empty, used or unused | |
178 | // | |
179 | Int_t inf=fDigitMap[CheckedIndex(vol)]; | |
180 | if (inf > 0) { | |
181 | return kUsed; | |
182 | } else if (inf == 0) { | |
183 | return kEmpty; | |
184 | } else { | |
185 | return kUnused; | |
186 | } | |
187 | } | |
188 | ||
189 | //////////////////////////////////////////////////////////////////////// | |
190 | AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) | |
191 | { | |
192 | // Dummy assignment operator | |
193 | return *this; | |
194 | } |