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