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