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