]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 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 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpVSegmentation.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $ |
5f91c9e8 | 18 | // Category: basic |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 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 | // | |
dbe945cc | 28 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 29 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
c49cb542 | 30 | // Laurent Aphecetche, SUBATECH |
3d1463c8 | 31 | //----------------------------------------------------------------------------- |
32 | ||
5f91c9e8 | 33 | |
34 | #include "AliMpVSegmentation.h" | |
c49cb542 | 35 | #include "AliMpArea.h" |
5f91c9e8 | 36 | #include "AliMpConstants.h" |
37 | ||
c49cb542 | 38 | #include "AliLog.h" |
39 | ||
40 | #include "TVector2.h" | |
41 | #include "TObjArray.h" | |
42 | ||
13985652 | 43 | /// \cond CLASSIMP |
5f91c9e8 | 44 | ClassImp(AliMpVSegmentation) |
13985652 | 45 | /// \endcond |
5f91c9e8 | 46 | |
47 | //_____________________________________________________________________________ | |
48 | AliMpVSegmentation::AliMpVSegmentation() | |
49 | : TObject() | |
50 | { | |
dee1d5f1 | 51 | /// Default constructor |
5f91c9e8 | 52 | } |
53 | ||
54 | //_____________________________________________________________________________ | |
dee1d5f1 | 55 | AliMpVSegmentation::~AliMpVSegmentation() |
56 | { | |
57 | /// Destructor | |
5f91c9e8 | 58 | } |
59 | ||
5f91c9e8 | 60 | //_____________________________________________________________________________ |
61 | AliMpPadPair AliMpVSegmentation::FindPads(const TVector2& position1, | |
62 | const TVector2& position2) const | |
63 | { | |
dee1d5f1 | 64 | /// Return a pair of pads with specified position. |
65 | /// If both pads are identical, the second pad in pair is set to invalid. | |
5f91c9e8 | 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 | ||
c49cb542 | 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 | |
c6da08f6 | 92 | // can always decrease when going from left to right (or from bottom to top) |
c49cb542 | 93 | // |
c6da08f6 | 94 | // L--T--R |
c49cb542 | 95 | // | | |
96 | // L | | |
97 | // | O R | |
98 | // L | | |
99 | // | | | |
c6da08f6 | 100 | // L-B-B-R |
c49cb542 | 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 | // | |
c6da08f6 | 106 | // 4-- 5-- 6 |
107 | // | | | |
108 | // 3 | | |
109 | // | 0 7 | |
110 | // 2 | | |
111 | // | | | |
112 | // 1-10- 9-8 | |
c49cb542 | 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 | |
c6da08f6 | 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 | |
c49cb542 | 133 | // right column (R), starting from top |
c6da08f6 | 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 | |
c49cb542 | 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 | ||
5f91c9e8 | 183 | // |
184 | // public methods | |
185 | // | |
186 | ||
187 | //_____________________________________________________________________________ | |
188 | AliMpPadPair AliMpVSegmentation::PadsUp(const AliMpPad& pad) const | |
189 | { | |
dee1d5f1 | 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. | |
5f91c9e8 | 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 | { | |
dee1d5f1 | 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. | |
5f91c9e8 | 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 | { | |
dee1d5f1 | 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. | |
5f91c9e8 | 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 | { | |
dee1d5f1 | 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. | |
5f91c9e8 | 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 |