]>
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 | ||
f8014e68 | 36 | #include <Riostream.h> |
5919c40c | 37 | #include <TMath.h> |
38 | ||
39 | #include "AliTOFHitMap.h" | |
40 | #include "AliTOFSDigit.h" | |
41 | #include "AliTOFConstants.h" | |
42 | ||
43 | ||
44 | #include <TClonesArray.h> | |
45 | ||
46 | ClassImp(AliTOFHitMap) | |
47 | ||
48 | AliTOFHitMap::AliTOFHitMap() | |
49 | { | |
50 | // | |
51 | // Default ctor | |
52 | // | |
53 | fHitMap = 0; | |
54 | fSDigits = 0; | |
55 | } | |
56 | ||
57 | //////////////////////////////////////////////////////////////////////// | |
58 | AliTOFHitMap::AliTOFHitMap(TClonesArray *dig) | |
59 | { | |
60 | // | |
61 | // ctor | |
62 | // | |
63 | ||
64 | // of course, these constants must not be hardwired | |
65 | // change later | |
66 | ||
67 | fNSector = AliTOFConstants::fgkNSectors; | |
68 | fNplate = AliTOFConstants::fgkNPlates; | |
69 | fNstrip = AliTOFConstants::fgkNStripC; | |
70 | fNpx = AliTOFConstants::fgkNpadX; | |
71 | fNpy = AliTOFConstants::fgkNpadZ; | |
72 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpy; | |
73 | fHitMap = new Int_t[fMaxIndex]; | |
74 | fSDigits = dig; | |
75 | Clear(); | |
76 | } | |
77 | ||
78 | //////////////////////////////////////////////////////////////////////// | |
79 | AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & hitMap) | |
80 | { | |
81 | // | |
82 | // Dummy copy constructor | |
83 | // | |
84 | ; | |
85 | } | |
86 | ||
87 | ||
88 | //////////////////////////////////////////////////////////////////////// | |
89 | AliTOFHitMap::~AliTOFHitMap() | |
90 | { | |
91 | // | |
92 | // Destructor | |
93 | // | |
94 | if (fHitMap) delete[] fHitMap; | |
95 | } | |
96 | ||
97 | //////////////////////////////////////////////////////////////////////// | |
98 | void AliTOFHitMap::Clear(const char *) | |
99 | { | |
100 | // | |
101 | // Clear hitmap | |
102 | // | |
103 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
104 | } | |
105 | ||
106 | //////////////////////////////////////////////////////////////////////// | |
107 | Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const | |
108 | { | |
109 | // | |
110 | // Return checked indices for vol | |
111 | // | |
112 | Int_t index= | |
113 | (vol[0]-1)*fNplate*fNstrip*fNpx*fNpy+ // sector | |
114 | (vol[1]-1)*fNstrip*fNpx*fNpy+ // plate | |
115 | (vol[2]-1)*fNpx*fNpy+ // strip | |
116 | (vol[3]-1)*fNpy+ // padx | |
117 | (vol[4]-1); // pady (=padz) | |
118 | ||
119 | if (index >= fMaxIndex) { | |
120 | Error("AliTOFHitMap","CheckedIndex - input outside bounds"); | |
121 | return -1; | |
122 | } else { | |
123 | return index; | |
124 | } | |
125 | } | |
126 | ||
127 | //////////////////////////////////////////////////////////////////////// | |
128 | void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit) | |
129 | { | |
130 | // | |
131 | // Assign digit to pad vol | |
132 | // | |
133 | ||
134 | // 0 means empty pad, we need to shift indeces by 1 | |
135 | fHitMap[CheckedIndex(vol)]=idigit+1; | |
136 | } | |
137 | ||
138 | //////////////////////////////////////////////////////////////////////// | |
139 | void AliTOFHitMap::SetHit(Int_t *vol) | |
140 | { | |
141 | // | |
142 | // Assign last digit to pad vol | |
143 | // | |
144 | ||
145 | // 0 means empty pad, we need to shift indeces by 1 | |
146 | fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1; | |
147 | } | |
148 | ||
149 | //////////////////////////////////////////////////////////////////////// | |
150 | Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const | |
151 | { | |
152 | // | |
153 | // Get contents of pad vol | |
154 | // | |
155 | ||
156 | // 0 means empty pad, we need to shift indeces by 1 | |
157 | return fHitMap[CheckedIndex(vol)]-1; | |
158 | } | |
159 | ||
160 | //////////////////////////////////////////////////////////////////////// | |
161 | TObject* AliTOFHitMap::GetHit(Int_t *vol) const | |
162 | { | |
163 | // | |
164 | // Get pointer to object at vol | |
165 | // return 0 if vol out of bounds | |
2f8510c7 | 166 | Int_t index=GetHitIndex(vol); |
5919c40c | 167 | return (index <0) ? 0 : fSDigits->UncheckedAt(index); |
168 | } | |
169 | ||
170 | //////////////////////////////////////////////////////////////////////// | |
171 | FlagType AliTOFHitMap::TestHit(Int_t *vol) const | |
172 | { | |
173 | // | |
174 | // Check if hit cell is empty, used or unused | |
175 | // | |
176 | Int_t inf=fHitMap[CheckedIndex(vol)]; | |
0085f44e | 177 | if (inf > 0) { |
5919c40c | 178 | return kUsed; |
179 | } else if (inf == 0) { | |
180 | return kEmpty; | |
181 | } else { | |
182 | return kUnused; | |
183 | } | |
184 | } | |
185 | ||
186 | //////////////////////////////////////////////////////////////////////// | |
187 | AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & rhs) | |
188 | { | |
189 | // Dummy assignment operator | |
190 | return *this; | |
191 | } | |
192 | ||
193 | ||
194 | ||
195 | ||
196 |