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