]>
Commit | Line | Data |
---|---|---|
5919c40c | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
5919c40c | 17 | |
18 | //////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // AliTOFHitMap class | |
21 | // | |
22 | // hitmap enables fast check if the pad was already hit | |
23 | // The index of a AliTOFSDigit is saved in the each hitmap "cell" | |
24 | // (there is an offset +1, because the index can be zero and | |
25 | // zero means empty cell. | |
26 | // In TOF, number of strips varies according plate type, the highest | |
27 | // number is in plate C. For all plates is used this number, so | |
28 | // the size of the hitmap is a little bit greater than necessary, but | |
29 | // it simplifies the access algorithm. | |
30 | // | |
31 | // | |
32 | // Author: Jiri Chudoba (CERN), based on AliMUONHitMap | |
33 | // | |
34 | //////////////////////////////////////////////////////////////////////// | |
35 | ||
d076c8d5 | 36 | #include "AliLog.h" |
5919c40c | 37 | #include "AliTOFHitMap.h" |
0f4a7374 | 38 | #include "AliTOFGeometry.h" |
5919c40c | 39 | |
40 | ||
41 | #include <TClonesArray.h> | |
42 | ||
43 | ClassImp(AliTOFHitMap) | |
44 | ||
655e379f | 45 | AliTOFHitMap::AliTOFHitMap(): |
46 | fNSector(-1), | |
47 | fNplate(-1), | |
48 | fNstrip(-1), | |
49 | fNpx(-1), | |
50 | fNpz(-1), | |
51 | fSDigits(0x0), | |
52 | fMaxIndex(-1), | |
53 | fHitMap(0x0), | |
54 | fTOFGeometry(0x0) | |
5919c40c | 55 | { |
56 | // | |
57 | // Default ctor | |
58 | // | |
5919c40c | 59 | } |
60 | ||
61 | //////////////////////////////////////////////////////////////////////// | |
655e379f | 62 | AliTOFHitMap::AliTOFHitMap(TClonesArray *dig, AliTOFGeometry *tofGeom): |
63 | fNSector(-1), | |
64 | fNplate(-1), | |
65 | fNstrip(-1), | |
66 | fNpx(-1), | |
67 | fNpz(-1), | |
68 | fSDigits(dig), | |
69 | fMaxIndex(-1), | |
70 | fHitMap(0x0), | |
71 | fTOFGeometry(tofGeom) | |
5919c40c | 72 | { |
73 | // | |
74 | // ctor | |
75 | // | |
76 | ||
77 | // of course, these constants must not be hardwired | |
78 | // change later | |
79 | ||
0f4a7374 | 80 | fNSector = AliTOFGeometry::NSectors(); |
81 | fNplate = AliTOFGeometry::NPlates(); | |
d0eb8f39 | 82 | fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip(); |
0f4a7374 | 83 | fNpx = AliTOFGeometry::NpadX(); |
84 | fNpz = AliTOFGeometry::NpadZ(); | |
da3d3acd | 85 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; |
5919c40c | 86 | fHitMap = new Int_t[fMaxIndex]; |
5919c40c | 87 | Clear(); |
88 | } | |
89 | ||
90 | //////////////////////////////////////////////////////////////////////// | |
5c016a7b | 91 | AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & /*hitMap*/) |
655e379f | 92 | :TObject(), |
93 | fNSector(-1), | |
94 | fNplate(-1), | |
95 | fNstrip(-1), | |
96 | fNpx(-1), | |
97 | fNpz(-1), | |
98 | fSDigits(0x0), | |
99 | fMaxIndex(-1), | |
100 | fHitMap(0x0), | |
101 | fTOFGeometry(0x0) | |
5919c40c | 102 | { |
103 | // | |
104 | // Dummy copy constructor | |
105 | // | |
d3c7bfac | 106 | ; |
5919c40c | 107 | } |
108 | ||
109 | ||
110 | //////////////////////////////////////////////////////////////////////// | |
111 | AliTOFHitMap::~AliTOFHitMap() | |
112 | { | |
113 | // | |
114 | // Destructor | |
115 | // | |
d3c7bfac | 116 | delete[] fHitMap; |
117 | ||
afd804a3 | 118 | fTOFGeometry = 0x0; |
d3c7bfac | 119 | |
5919c40c | 120 | } |
121 | ||
122 | //////////////////////////////////////////////////////////////////////// | |
123 | void AliTOFHitMap::Clear(const char *) | |
124 | { | |
125 | // | |
126 | // Clear hitmap | |
127 | // | |
128 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
129 | } | |
130 | ||
131 | //////////////////////////////////////////////////////////////////////// | |
132 | Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const | |
133 | { | |
134 | // | |
135 | // Return checked indices for vol | |
136 | // | |
137 | Int_t index= | |
d3c7bfac | 138 | vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector |
139 | vol[1]*fNstrip*fNpx*fNpz+ // plate | |
140 | vol[2]*fNpx*fNpz+ // strip | |
141 | vol[3]*fNpz+ // padx | |
142 | vol[4]; // padz | |
5919c40c | 143 | |
144 | if (index >= fMaxIndex) { | |
d076c8d5 | 145 | AliError("CheckedIndex - input outside bounds"); |
5919c40c | 146 | return -1; |
147 | } else { | |
148 | return index; | |
149 | } | |
150 | } | |
151 | ||
152 | //////////////////////////////////////////////////////////////////////// | |
153 | void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit) | |
154 | { | |
155 | // | |
156 | // Assign digit to pad vol | |
157 | // | |
158 | ||
159 | // 0 means empty pad, we need to shift indeces by 1 | |
160 | fHitMap[CheckedIndex(vol)]=idigit+1; | |
161 | } | |
162 | ||
163 | //////////////////////////////////////////////////////////////////////// | |
164 | void AliTOFHitMap::SetHit(Int_t *vol) | |
165 | { | |
166 | // | |
167 | // Assign last digit to pad vol | |
168 | // | |
169 | ||
170 | // 0 means empty pad, we need to shift indeces by 1 | |
171 | fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1; | |
172 | } | |
173 | ||
174 | //////////////////////////////////////////////////////////////////////// | |
175 | Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const | |
176 | { | |
177 | // | |
178 | // Get contents of pad vol | |
179 | // | |
180 | ||
181 | // 0 means empty pad, we need to shift indeces by 1 | |
182 | return fHitMap[CheckedIndex(vol)]-1; | |
183 | } | |
184 | ||
185 | //////////////////////////////////////////////////////////////////////// | |
186 | TObject* AliTOFHitMap::GetHit(Int_t *vol) const | |
187 | { | |
188 | // | |
189 | // Get pointer to object at vol | |
190 | // return 0 if vol out of bounds | |
2f8510c7 | 191 | Int_t index=GetHitIndex(vol); |
5919c40c | 192 | return (index <0) ? 0 : fSDigits->UncheckedAt(index); |
193 | } | |
194 | ||
195 | //////////////////////////////////////////////////////////////////////// | |
196 | FlagType AliTOFHitMap::TestHit(Int_t *vol) const | |
197 | { | |
198 | // | |
199 | // Check if hit cell is empty, used or unused | |
200 | // | |
201 | Int_t inf=fHitMap[CheckedIndex(vol)]; | |
0085f44e | 202 | if (inf > 0) { |
5919c40c | 203 | return kUsed; |
204 | } else if (inf == 0) { | |
205 | return kEmpty; | |
206 | } else { | |
207 | return kUnused; | |
208 | } | |
209 | } | |
210 | ||
211 | //////////////////////////////////////////////////////////////////////// | |
5c016a7b | 212 | AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & /*rhs*/) |
5919c40c | 213 | { |
214 | // Dummy assignment operator | |
215 | return *this; | |
216 | } |