]>
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" | |
22 | ||
23 | ClassImp(AliMpRowSegmentRSpecial) | |
24 | ||
25 | //______________________________________________________________________________ | |
26 | AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX) | |
27 | : AliMpVRowSegmentSpecial(row, offsetX) | |
28 | { | |
29 | // | |
30 | } | |
31 | ||
32 | //______________________________________________________________________________ | |
33 | AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial() | |
34 | : AliMpVRowSegmentSpecial() | |
35 | { | |
36 | // | |
37 | } | |
38 | ||
39 | //______________________________________________________________________________ | |
40 | AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial() | |
41 | { | |
42 | // | |
43 | } | |
44 | ||
45 | // | |
46 | // private methods | |
47 | // | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliMpVPadRowSegment* | |
51 | AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const | |
52 | { | |
53 | // Find the most left pad row segment with this motifPositionId. | |
54 | // --- | |
55 | ||
56 | AliMpVPadRowSegment* found = 0; | |
57 | ||
58 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
59 | AliMpPadRow* padRow = GetPadRow(i); | |
60 | ||
61 | for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { | |
62 | AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j); | |
63 | ||
64 | if ( padRowSegment->GetMotifPositionId() == motifPositionId && | |
65 | (!found || padRowSegment->LeftBorderX() < found->LeftBorderX())) | |
66 | ||
67 | found = padRowSegment; | |
68 | } | |
69 | } | |
70 | ||
71 | return found; | |
72 | } | |
73 | ||
74 | //______________________________________________________________________________ | |
75 | void AliMpRowSegmentRSpecial::SetGlobalIndicesLow() | |
76 | { | |
77 | // ... | |
78 | ||
79 | // Last normal row segment in the row | |
80 | // (preceding this special row segment) | |
81 | AliMpVRowSegment* rowSegment | |
82 | = GetRow()->GetRowSegment(GetRow()->GetNofRowSegments()-2); | |
83 | ||
84 | // Set low indices limit to continue indices of the | |
85 | // preceding row segment | |
86 | Int_t ix = rowSegment->GetHighIndicesLimit().GetFirst() + 1; | |
87 | Int_t iy = rowSegment->GetLowIndicesLimit().GetSecond(); | |
88 | ||
89 | SetLowIndicesLimit(AliMpIntPair(ix, iy)); | |
90 | } | |
91 | ||
92 | // | |
93 | // protected methods | |
94 | // | |
95 | ||
96 | //______________________________________________________________________________ | |
97 | TVector2 AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId) const | |
98 | { | |
99 | // Returns the coordinates of the motif specified with | |
100 | // the given position identifier. | |
101 | // !! Applicable only for motifs that have their most down pad in | |
102 | // this row segment. | |
103 | // --- | |
104 | ||
105 | // Find the first (left, down) pad row segment with this motifPositionId. | |
106 | AliMpVPadRowSegment* downPadRowSegment | |
107 | = FindPadRowSegment(motifPositionId); | |
108 | AliMpVPadRowSegment* leftPadRowSegment | |
109 | = FindMostLeftPadRowSegment(motifPositionId); | |
110 | ||
111 | // Check if the motifPositionId is present | |
112 | if (!downPadRowSegment || !leftPadRowSegment) { | |
113 | Error("MotifCenter", "Outside row segment region"); | |
114 | return 0; | |
115 | } | |
116 | ||
117 | // Check if both pad row segments have the same motif | |
118 | if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) { | |
119 | Fatal("MotifCenter", "Outside row segment region"); | |
120 | return 0; | |
121 | } | |
122 | ||
123 | // Get position of found row segment | |
124 | Double_t x = leftPadRowSegment->LeftBorderX(); | |
125 | Double_t y = GetRow()->LowBorderY() ; | |
126 | ||
127 | for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++) | |
128 | y += GetPadRow(i)->HalfSizeY()*2.; | |
129 | ||
130 | // Add motifs dimensions | |
131 | x += downPadRowSegment->GetMotif()->Dimensions().X(); | |
132 | y += downPadRowSegment->GetMotif()->Dimensions().Y(); | |
133 | ||
134 | return TVector2(x, y); | |
135 | } | |
136 | ||
137 | // | |
138 | // public methods | |
139 | // | |
140 | ||
141 | //______________________________________________________________________________ | |
142 | Double_t AliMpRowSegmentRSpecial::LeftBorderX() const | |
143 | { | |
144 | // Returns the x coordinate of the left row segment border | |
145 | // in global coordinate system. | |
146 | // --- | |
147 | ||
148 | // The right edge of the last normal segment | |
149 | Double_t sameBorder = GetOffsetX(); | |
150 | ||
151 | // Consistence check | |
152 | Double_t leftBorder = DBL_MAX; | |
153 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
154 | AliMpPadRow* padRow = GetPadRow(i); | |
155 | Double_t border = padRow->GetPadRowSegment(0)->LeftBorderX(); | |
156 | if (border < leftBorder) leftBorder = border; | |
157 | } | |
158 | ||
159 | if (TMath::Abs(sameBorder - leftBorder) > 1.e-04) { | |
160 | Error("LeftBorderX", "WrongBorder"); | |
161 | return sameBorder; | |
162 | } | |
163 | ||
164 | return leftBorder; | |
165 | ||
166 | } | |
167 | ||
168 | //______________________________________________________________________________ | |
169 | Double_t AliMpRowSegmentRSpecial::RightBorderX() const | |
170 | { | |
171 | // Returns the x coordinate of the right row segment border | |
172 | // in global coordinate system. | |
173 | // --- | |
174 | ||
175 | Double_t rightBorder = -DBL_MAX; | |
176 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
177 | AliMpPadRow* padRow = GetPadRow(i); | |
178 | Double_t border | |
179 | = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1) | |
180 | ->RightBorderX(); | |
181 | ||
182 | if (border > rightBorder) rightBorder = border; | |
183 | } | |
184 | ||
185 | return rightBorder; | |
186 | } | |
187 | ||
188 | //______________________________________________________________________________ | |
189 | TVector2 AliMpRowSegmentRSpecial::Position() const | |
190 | { | |
191 | // Returns the position of the row segment centre. | |
192 | // The centre is defined as the centre of the rectangular | |
193 | // row segment envelope. | |
194 | // --- | |
195 | ||
196 | // The right edge of the last normal segment | |
197 | Double_t x = GetOffsetX() + Dimensions().X(); | |
198 | Double_t y = GetRow()->Position().Y(); | |
199 | ||
200 | return TVector2(x, y); | |
201 | } | |
202 | ||
203 | //______________________________________________________________________________ | |
204 | Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i, | |
205 | const AliMpIntPair& indices) | |
206 | { | |
207 | // Sets global indices to i-th motif position and returns next index in x. | |
208 | // --- | |
209 | ||
210 | // Update low indices limit for this row segment | |
211 | SetGlobalIndicesLow(); | |
212 | ||
213 | // Check for consistence | |
214 | if (GetLowIndicesLimit().GetFirst() != indices.GetFirst()) | |
215 | Fatal("SetIndicesToMotifPosition", "Inconsistent indices"); | |
216 | ||
217 | // Get motif position | |
218 | AliMpMotifPosition* motifPosition | |
219 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i)); | |
220 | ||
221 | // Low limit | |
222 | AliMpIntPair low = GetLowIndicesLimit(); | |
223 | ||
224 | if (! motifPosition->GetHighIndicesLimit().IsValid()) { | |
225 | motifPosition->SetLowIndicesLimit(low); | |
226 | } | |
227 | else { | |
228 | if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst()) | |
229 | motifPosition->SetLowIndicesLimit( | |
230 | AliMpIntPair(low.GetFirst(), | |
231 | motifPosition->GetLowIndicesLimit().GetSecond())); | |
232 | ||
233 | if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond()) | |
234 | motifPosition->SetLowIndicesLimit( | |
235 | AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(), | |
236 | low.GetSecond())); | |
237 | } | |
238 | ||
239 | // High limit | |
240 | AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType(); | |
241 | AliMpIntPair high | |
242 | = motifPosition->GetLowIndicesLimit() | |
243 | + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1); | |
244 | motifPosition->SetHighIndicesLimit(high); | |
245 | ||
246 | // No increment index needed (this is always the last element) | |
247 | return indices.GetFirst(); | |
248 | } | |
249 | ||
250 |