]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | // $Id$ | |
17 | // $MpId: AliMpVSegmentation.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $ | |
18 | // Category: basic | |
19 | ||
20 | //----------------------------------------------------------------------------- | |
21 | // Class AliMpVSegmentation | |
22 | // ------------------------ | |
23 | // The abstract base class for the segmentation. | |
24 | // Provides methods related to pads: | |
25 | // conversion between pad indices, pad location, pad position; | |
26 | // finding pad neighbour. | |
27 | // | |
28 | // Included in AliRoot: 2003/05/02 | |
29 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
30 | // Laurent Aphecetche, SUBATECH | |
31 | //----------------------------------------------------------------------------- | |
32 | ||
33 | ||
34 | #include "AliMpVSegmentation.h" | |
35 | #include "AliMpArea.h" | |
36 | #include "AliMpConstants.h" | |
37 | ||
38 | #include "AliLog.h" | |
39 | ||
40 | #include "TVector2.h" | |
41 | #include "TObjArray.h" | |
42 | ||
43 | /// \cond CLASSIMP | |
44 | ClassImp(AliMpVSegmentation) | |
45 | /// \endcond | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMpVSegmentation::AliMpVSegmentation() | |
49 | : TObject() | |
50 | { | |
51 | /// Default constructor | |
52 | } | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliMpVSegmentation::~AliMpVSegmentation() | |
56 | { | |
57 | /// Destructor | |
58 | } | |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | AliMpPadPair AliMpVSegmentation::FindPads(const TVector2& position1, | |
62 | const TVector2& position2) const | |
63 | { | |
64 | /// Return a pair of pads with specified position. | |
65 | /// If both pads are identical, the second pad in pair is set to invalid. | |
66 | ||
67 | AliMpPad pad1 = PadByPosition(position1, false); | |
68 | AliMpPad pad2 = PadByPosition(position2, false); | |
69 | ||
70 | if (pad1 == pad2) pad2 = AliMpPad::Invalid(); | |
71 | ||
72 | return AliMpPadPair(pad1, pad2); | |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | Int_t | |
77 | AliMpVSegmentation::GetNeighbours(const AliMpPad& pad, | |
78 | TObjArray& neighbours, | |
79 | Bool_t includeSelf, | |
80 | Bool_t includeVoid) const | |
81 | { | |
82 | /// Returns the list of neighbours of pad | |
83 | static TVector2* testPositions(0x0); | |
84 | static const Int_t kNofTestPositions(11); | |
85 | static const Double_t kEpsilon(AliMpConstants::LengthTolerance()*2.0); | |
86 | static Int_t centerIndex(-1); | |
87 | ||
88 | // testPositions are the positions (L,T,R,B) relative to pad's center (O) | |
89 | // were we'll try to get a neighbouring pad, by getting a little | |
90 | // bit outside the pad itself. | |
91 | // Note that it's not symmetric as we assume that pad density | |
92 | // can always decrease when going from left to right (or from bottom to top) | |
93 | // | |
94 | // L--T--R | |
95 | // | | | |
96 | // L | | |
97 | // | O R | |
98 | // L | | |
99 | // | | | |
100 | // L-B-B-R | |
101 | // | |
102 | // The order in which we actually test the positions has some importance, | |
103 | // i.e. when using this information to compute status map later on. Here's | |
104 | // the sequence : | |
105 | // | |
106 | // 4-- 5-- 6 | |
107 | // | | | |
108 | // 3 | | |
109 | // | 0 7 | |
110 | // 2 | | |
111 | // | | | |
112 | // 1-10- 9-8 | |
113 | ||
114 | neighbours.Delete(); | |
115 | neighbours.SetOwner(kTRUE); | |
116 | ||
117 | if (!pad.IsValid()) return 0; | |
118 | ||
119 | if (!testPositions) | |
120 | { | |
121 | testPositions = new TVector2[kNofTestPositions]; | |
122 | Int_t n(0); | |
123 | // starting center | |
124 | centerIndex = 0; | |
125 | testPositions[n++] = TVector2(0,0); // O (pad center) | |
126 | // then left column (L), starting from bottom | |
127 | testPositions[n++] = TVector2(-1,-1); // 1 | |
128 | testPositions[n++] = TVector2(-1,-1/3.0); // 2 | |
129 | testPositions[n++] = TVector2(-1,1/3.0); // 3 | |
130 | testPositions[n++] = TVector2(-1,1); // 4 | |
131 | // top (T) | |
132 | testPositions[n++] = TVector2(0,1); // 5 | |
133 | // right column (R), starting from top | |
134 | testPositions[n++] = TVector2(1,1); // 6 | |
135 | testPositions[n++] = TVector2(1,0); // 7 | |
136 | testPositions[n++] = TVector2(1,-1); // 8 | |
137 | // bottom (B), starting from right | |
138 | testPositions[n++] = TVector2(1/3.0,-1); // 9 | |
139 | testPositions[n++] = TVector2(-1/3.0,-1); // 10 | |
140 | // pad center | |
141 | if ( n != kNofTestPositions ) { | |
142 | AliError("Test on number of test positions failed."); | |
143 | } | |
144 | } | |
145 | ||
146 | Int_t n(0); | |
147 | ||
148 | AliMpPad previous(AliMpPad::Invalid()); | |
149 | ||
150 | for ( Int_t i = 0; i < kNofTestPositions; ++i ) | |
151 | { | |
152 | if ( i == centerIndex && !includeSelf ) | |
153 | { | |
154 | if ( includeVoid ) | |
155 | { | |
156 | previous = AliMpPad::Invalid(); | |
157 | neighbours.Add(new AliMpPad(previous)); | |
158 | ++n; | |
159 | } | |
160 | continue; | |
161 | } | |
162 | ||
163 | TVector2 shift = testPositions[i]; | |
164 | TVector2 pos = pad.Position(); | |
165 | pos += TVector2((pad.Dimensions().X()+kEpsilon)*shift.X(), | |
166 | (pad.Dimensions().Y()+kEpsilon)*shift.Y()); | |
167 | ||
168 | ||
169 | AliMpPad p = PadByPosition(pos,kFALSE); | |
170 | ||
171 | if ( !p.IsValid() && !includeVoid ) continue; | |
172 | ||
173 | if ( p != previous || !previous.IsValid() ) | |
174 | { | |
175 | previous = p; | |
176 | neighbours.Add(new AliMpPad(p)); | |
177 | ++n; | |
178 | } | |
179 | } | |
180 | return n; | |
181 | } | |
182 | ||
183 | // | |
184 | // public methods | |
185 | // | |
186 | ||
187 | //_____________________________________________________________________________ | |
188 | AliMpPadPair AliMpVSegmentation::PadsUp(const AliMpPad& pad) const | |
189 | { | |
190 | /// Return a pair of pads neighbouring up to the specified pad. | |
191 | /// If there is only one neighbouring pad, | |
192 | /// the second pad in pair is invalid. | |
193 | ||
194 | TVector2 position1 | |
195 | = pad.Position()+ TVector2((-1.)*AliMpConstants::LengthStep(), | |
196 | pad.Dimensions().Y()+ AliMpConstants::LengthStep()); | |
197 | TVector2 position2 | |
198 | = pad.Position()+ TVector2(AliMpConstants::LengthStep(), | |
199 | pad.Dimensions().Y()+ AliMpConstants::LengthStep()); | |
200 | ||
201 | return FindPads(position1, position2); | |
202 | } | |
203 | ||
204 | //_____________________________________________________________________________ | |
205 | AliMpPadPair AliMpVSegmentation::PadsDown(const AliMpPad& pad) const | |
206 | { | |
207 | /// Return a pair of pads neighbouring down to the specified pad. | |
208 | /// If there is only one neighbouring pad, | |
209 | /// the second pad in pair is invalid. | |
210 | ||
211 | TVector2 position1 | |
212 | = pad.Position()- TVector2(AliMpConstants::LengthStep(), | |
213 | pad.Dimensions().Y()+ AliMpConstants::LengthStep()); | |
214 | ||
215 | TVector2 position2 | |
216 | = pad.Position()- TVector2((-1.)*AliMpConstants::LengthStep(), | |
217 | pad.Dimensions().Y()+ AliMpConstants::LengthStep()); | |
218 | ||
219 | return FindPads(position1, position2); | |
220 | } | |
221 | ||
222 | //_____________________________________________________________________________ | |
223 | AliMpPadPair AliMpVSegmentation::PadsLeft(const AliMpPad& pad) const | |
224 | { | |
225 | /// Return a pair of pads neighbouring left to the specified pad. | |
226 | /// If there is only one neighbouring pad, | |
227 | /// the second in pair is invalid. | |
228 | ||
229 | TVector2 position1 | |
230 | = pad.Position() - TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(), | |
231 | AliMpConstants::LengthStep()); | |
232 | TVector2 position2 | |
233 | = pad.Position() - TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(), | |
234 | (-1.)*AliMpConstants::LengthStep()); | |
235 | ||
236 | return FindPads(position1, position2); | |
237 | } | |
238 | ||
239 | //_____________________________________________________________________________ | |
240 | AliMpPadPair AliMpVSegmentation::PadsRight(const AliMpPad& pad) const | |
241 | { | |
242 | /// Return a pair of pads neighbouring right to the specified pad. | |
243 | /// If there is only one neighbouring pad, | |
244 | /// the second in pair is invalid. | |
245 | ||
246 | TVector2 position1 | |
247 | = pad.Position() + TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(), | |
248 | (-1.)*AliMpConstants::LengthStep()); | |
249 | TVector2 position2 | |
250 | = pad.Position() + TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(), | |
251 | AliMpConstants::LengthStep()); | |
252 | ||
253 | return FindPads(position1, position2); | |
254 | } | |
255 | ||
256 | //_____________________________________________________________________________ | |
257 | Bool_t | |
258 | AliMpVSegmentation::HasPadByIndices(const AliMpIntPair& indices) const | |
259 | { | |
260 | /// Default implementation. Must be overwritten if can be made more | |
261 | /// efficient in the child class | |
262 | ||
263 | return (PadByIndices(indices,kFALSE) != AliMpPad::Invalid()); | |
264 | } | |
265 | ||
266 | //_____________________________________________________________________________ | |
267 | Bool_t | |
268 | AliMpVSegmentation::HasPadByLocation(const AliMpIntPair& location) const | |
269 | { | |
270 | /// Default implementation. Must be overwritten if can be made more | |
271 | /// efficient in the child class | |
272 | ||
273 | return (PadByLocation(location,kFALSE) != AliMpPad::Invalid()); | |
274 | } | |
275 | ||
276 | //_____________________________________________________________________________ | |
277 | Bool_t | |
278 | AliMpVSegmentation::HasMotifPosition(Int_t manuId) const | |
279 | { | |
280 | /// Default implementation to know if we hold a given manu | |
281 | return ( MotifPosition(manuId) != 0x0 ); | |
282 | } | |
283 | ||
284 |