]>
Commit | Line | Data |
---|---|---|
ea4cae7a | 1 | // $Id$ |
2 | // Category: sector | |
3 | // | |
4 | // Class AliMpRowSegmentRSpecial | |
5 | // ----------------------------- | |
6 | // Class describing a special outer row segment composed of the | |
7 | // pad rows. | |
dbe945cc | 8 | // Included in AliRoot: 2003/05/02 |
ea4cae7a | 9 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
10 | ||
11 | #include <TError.h> | |
12 | #include <Riostream.h> | |
13 | ||
14 | #include "AliMpRowSegmentRSpecial.h" | |
15 | #include "AliMpRow.h" | |
16 | #include "AliMpPadRow.h" | |
17 | #include "AliMpVPadRowSegment.h" | |
18 | #include "AliMpMotif.h" | |
19 | #include "AliMpMotifType.h" | |
20 | #include "AliMpMotifMap.h" | |
21 | #include "AliMpMotifPosition.h" | |
580c28fd | 22 | #include "AliMpConstants.h" |
ea4cae7a | 23 | |
24 | ClassImp(AliMpRowSegmentRSpecial) | |
25 | ||
26 | //______________________________________________________________________________ | |
27 | AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX) | |
28 | : AliMpVRowSegmentSpecial(row, offsetX) | |
29 | { | |
30 | // | |
31 | } | |
32 | ||
33 | //______________________________________________________________________________ | |
34 | AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial() | |
35 | : AliMpVRowSegmentSpecial() | |
36 | { | |
37 | // | |
38 | } | |
39 | ||
40 | //______________________________________________________________________________ | |
41 | AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial() | |
42 | { | |
43 | // | |
44 | } | |
45 | ||
46 | // | |
47 | // private methods | |
48 | // | |
49 | ||
50 | //______________________________________________________________________________ | |
51 | AliMpVPadRowSegment* | |
52 | AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const | |
53 | { | |
54 | // Find the most left pad row segment with this motifPositionId. | |
55 | // --- | |
56 | ||
57 | AliMpVPadRowSegment* found = 0; | |
58 | ||
59 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
60 | AliMpPadRow* padRow = GetPadRow(i); | |
61 | ||
62 | for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { | |
63 | AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j); | |
64 | ||
65 | if ( padRowSegment->GetMotifPositionId() == motifPositionId && | |
66 | (!found || padRowSegment->LeftBorderX() < found->LeftBorderX())) | |
67 | ||
68 | found = padRowSegment; | |
69 | } | |
70 | } | |
71 | ||
72 | return found; | |
73 | } | |
74 | ||
75 | //______________________________________________________________________________ | |
76 | void AliMpRowSegmentRSpecial::SetGlobalIndicesLow() | |
77 | { | |
78 | // ... | |
79 | ||
80 | // Last normal row segment in the row | |
81 | // (preceding this special row segment) | |
82 | AliMpVRowSegment* rowSegment | |
83 | = GetRow()->GetRowSegment(GetRow()->GetNofRowSegments()-2); | |
84 | ||
85 | // Set low indices limit to continue indices of the | |
86 | // preceding row segment | |
87 | Int_t ix = rowSegment->GetHighIndicesLimit().GetFirst() + 1; | |
88 | Int_t iy = rowSegment->GetLowIndicesLimit().GetSecond(); | |
89 | ||
90 | SetLowIndicesLimit(AliMpIntPair(ix, iy)); | |
91 | } | |
92 | ||
93 | // | |
94 | // protected methods | |
95 | // | |
96 | ||
97 | //______________________________________________________________________________ | |
98 | TVector2 AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId) const | |
99 | { | |
100 | // Returns the coordinates of the motif specified with | |
101 | // the given position identifier. | |
102 | // !! Applicable only for motifs that have their most down pad in | |
103 | // this row segment. | |
104 | // --- | |
105 | ||
106 | // Find the first (left, down) pad row segment with this motifPositionId. | |
107 | AliMpVPadRowSegment* downPadRowSegment | |
108 | = FindPadRowSegment(motifPositionId); | |
109 | AliMpVPadRowSegment* leftPadRowSegment | |
110 | = FindMostLeftPadRowSegment(motifPositionId); | |
111 | ||
112 | // Check if the motifPositionId is present | |
113 | if (!downPadRowSegment || !leftPadRowSegment) { | |
114 | Error("MotifCenter", "Outside row segment region"); | |
115 | return 0; | |
116 | } | |
117 | ||
118 | // Check if both pad row segments have the same motif | |
119 | if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) { | |
120 | Fatal("MotifCenter", "Outside row segment region"); | |
121 | return 0; | |
122 | } | |
123 | ||
124 | // Get position of found row segment | |
125 | Double_t x = leftPadRowSegment->LeftBorderX(); | |
126 | Double_t y = GetRow()->LowBorderY() ; | |
127 | ||
128 | for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++) | |
129 | y += GetPadRow(i)->HalfSizeY()*2.; | |
130 | ||
131 | // Add motifs dimensions | |
132 | x += downPadRowSegment->GetMotif()->Dimensions().X(); | |
133 | y += downPadRowSegment->GetMotif()->Dimensions().Y(); | |
134 | ||
135 | return TVector2(x, y); | |
136 | } | |
137 | ||
138 | // | |
139 | // public methods | |
140 | // | |
141 | ||
142 | //______________________________________________________________________________ | |
143 | Double_t AliMpRowSegmentRSpecial::LeftBorderX() const | |
144 | { | |
145 | // Returns the x coordinate of the left row segment border | |
146 | // in global coordinate system. | |
147 | // --- | |
148 | ||
149 | // The right edge of the last normal segment | |
150 | Double_t sameBorder = GetOffsetX(); | |
151 | ||
152 | // Consistence check | |
153 | Double_t leftBorder = DBL_MAX; | |
154 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
155 | AliMpPadRow* padRow = GetPadRow(i); | |
156 | Double_t border = padRow->GetPadRowSegment(0)->LeftBorderX(); | |
157 | if (border < leftBorder) leftBorder = border; | |
158 | } | |
159 | ||
160 | if (TMath::Abs(sameBorder - leftBorder) > 1.e-04) { | |
161 | Error("LeftBorderX", "WrongBorder"); | |
162 | return sameBorder; | |
163 | } | |
164 | ||
165 | return leftBorder; | |
166 | ||
167 | } | |
168 | ||
169 | //______________________________________________________________________________ | |
170 | Double_t AliMpRowSegmentRSpecial::RightBorderX() const | |
171 | { | |
172 | // Returns the x coordinate of the right row segment border | |
173 | // in global coordinate system. | |
174 | // --- | |
175 | ||
176 | Double_t rightBorder = -DBL_MAX; | |
177 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
178 | AliMpPadRow* padRow = GetPadRow(i); | |
179 | Double_t border | |
180 | = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1) | |
181 | ->RightBorderX(); | |
182 | ||
183 | if (border > rightBorder) rightBorder = border; | |
184 | } | |
185 | ||
186 | return rightBorder; | |
187 | } | |
188 | ||
189 | //______________________________________________________________________________ | |
190 | TVector2 AliMpRowSegmentRSpecial::Position() const | |
191 | { | |
192 | // Returns the position of the row segment centre. | |
193 | // The centre is defined as the centre of the rectangular | |
194 | // row segment envelope. | |
195 | // --- | |
196 | ||
197 | // The right edge of the last normal segment | |
198 | Double_t x = GetOffsetX() + Dimensions().X(); | |
199 | Double_t y = GetRow()->Position().Y(); | |
200 | ||
201 | return TVector2(x, y); | |
202 | } | |
203 | ||
204 | //______________________________________________________________________________ | |
205 | Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i, | |
206 | const AliMpIntPair& indices) | |
207 | { | |
208 | // Sets global indices to i-th motif position and returns next index in x. | |
209 | // --- | |
210 | ||
211 | // Update low indices limit for this row segment | |
212 | SetGlobalIndicesLow(); | |
580c28fd | 213 | |
ea4cae7a | 214 | // Check for consistence |
215 | if (GetLowIndicesLimit().GetFirst() != indices.GetFirst()) | |
216 | Fatal("SetIndicesToMotifPosition", "Inconsistent indices"); | |
217 | ||
218 | // Get motif position | |
219 | AliMpMotifPosition* motifPosition | |
220 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i)); | |
580c28fd | 221 | |
222 | // Set limits only once | |
223 | if ( motifPosition->GetHighIndicesLimit().IsValid() ) | |
224 | return indices.GetFirst();; | |
ea4cae7a | 225 | |
226 | // Low limit | |
580c28fd | 227 | // |
228 | Int_t ixl = GetLowIndicesLimit().GetFirst(); | |
229 | Int_t iyl = GetLowIndicesLimit().GetSecond(); | |
230 | ||
231 | // Find the most down pad row segment with this motifPositionId. | |
232 | AliMpVPadRowSegment* padRowSegment = FindPadRowSegment(GetMotifPositionId(i)); | |
233 | Int_t padRowID = padRowSegment->GetPadRow()->GetID(); | |
234 | iyl += padRowID; | |
235 | ||
236 | // Add pads offset of this motif position in the row segment | |
237 | for (Int_t im=0; im<i; im++) { | |
238 | AliMpVPadRowSegment* rs = GetPadRow(padRowID)->GetPadRowSegment(im); | |
239 | if ( rs->GetMotifPositionId() == GetMotifPositionId(i) ) break; | |
240 | ixl += rs->GetNofPads(); | |
241 | } | |
242 | motifPosition->SetLowIndicesLimit(AliMpIntPair(ixl, iyl)); | |
ea4cae7a | 243 | |
580c28fd | 244 | // High limit |
245 | // | |
ea4cae7a | 246 | AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType(); |
247 | AliMpIntPair high | |
248 | = motifPosition->GetLowIndicesLimit() | |
249 | + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1); | |
250 | motifPosition->SetHighIndicesLimit(high); | |
580c28fd | 251 | |
ea4cae7a | 252 | // No increment index needed (this is always the last element) |
253 | return indices.GetFirst(); | |
254 | } | |
255 | ||
580c28fd | 256 | //______________________________________________________________________________ |
257 | void AliMpRowSegmentRSpecial::SetGlobalIndices(AliMpRow* rowBefore) | |
258 | { | |
259 | // Sets indices limits. | |
260 | // The limits are defined as the limits of the smallest rectangle which | |
261 | // includes all pads of this special row segment. | |
262 | // --- | |
263 | ||
264 | // Get first motif position | |
265 | AliMpMotifPosition* firstMotifPosition | |
266 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(0)); | |
267 | ||
268 | // Low ix | |
269 | Int_t ixl = firstMotifPosition->GetLowIndicesLimit().GetFirst(); | |
270 | // We have to take the motif position limit | |
271 | // as it can overlap over more rows and the indices | |
272 | // of the right border of the precedent normal segment | |
273 | // differ from one row to another | |
274 | ||
275 | // High ix | |
276 | Int_t ixh = ixl + MaxNofPadsInRow() - 1; | |
277 | ||
278 | // Low iy | |
279 | Int_t iyl = AliMpConstants::StartPadIndex(); | |
280 | if (rowBefore) { | |
281 | //if (constPadSizeDirection == kY) { | |
282 | iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1; | |
283 | //} | |
284 | /* | |
285 | else { | |
286 | AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl); | |
287 | AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl); | |
288 | if (!motPos) | |
289 | Fatal("SetGlobalIndices", "Motif position in rowBefore not found."); | |
290 | iyl = motPos->GetHighIndicesLimit().GetSecond()+1; | |
291 | } | |
292 | */ | |
293 | } | |
294 | ||
295 | // High iy | |
296 | Int_t iyh = iyl + GetNofPadRows() - 1; | |
297 | ||
298 | SetLowIndicesLimit(AliMpIntPair(ixl, iyl)); | |
299 | SetHighIndicesLimit(AliMpIntPair(ixh, iyh)); | |
300 | } | |
301 | ||
ea4cae7a | 302 |