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