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