1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpRowSegmentLSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
20 // Class AliMpRowSegmentLSpecial
21 // -----------------------------
22 // Class describing a special inner row segment composed of the
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 #include <Riostream.h>
30 #include "AliMpRowSegmentLSpecial.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"
43 ClassImp(AliMpRowSegmentLSpecial)
46 //______________________________________________________________________________
47 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
48 : AliMpVRowSegmentSpecial(row, offsetX)
50 /// Standard constructor
53 //______________________________________________________________________________
54 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
55 : AliMpVRowSegmentSpecial()
57 /// Default constructor
60 //______________________________________________________________________________
61 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
70 //______________________________________________________________________________
72 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
74 /// Find the most right pad row segment with this motifPositionId.
76 AliMpVPadRowSegment* found = 0;
78 for (Int_t i=0; i<GetNofPadRows(); i++) {
79 AliMpPadRow* padRow = GetPadRow(i);
81 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
82 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
84 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
85 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
87 found = padRowSegment;
98 //______________________________________________________________________________
99 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
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.
106 // Find the first (left, down) pad row segment with this motifPositionId.
107 AliMpVPadRowSegment* downPadRowSegment
108 = FindPadRowSegment(motifPositionId);
109 AliMpVPadRowSegment* rightPadRowSegment
110 = FindMostRightPadRowSegment(motifPositionId);
112 // Check if the motifPositionId is present
113 if (!downPadRowSegment || !rightPadRowSegment) {
114 AliErrorStream() << "Outside row segment region" << endl;
118 // Check if both pad row segments have the same motif
119 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
120 AliFatal("Outside row segment region");
124 // Get position of found row segment
125 Double_t x = rightPadRowSegment->RightBorderX();
126 Double_t y = GetRow()->LowBorderY() ;
128 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
129 y += GetPadRow(i)->HalfSizeY()*2.;
131 // Add motifs dimensions
132 x -= downPadRowSegment->GetMotif()->Dimensions().X();
133 y += downPadRowSegment->GetMotif()->Dimensions().Y();
135 return TVector2(x, y);
142 //______________________________________________________________________________
143 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
145 /// Set low indices limit to the pad offset calculated
146 /// from the neighbour normal segment.
148 // Get the neighbour row segment
149 // (the first normal segment)
150 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
152 // Get the the pads offset of the neighbour row segment
153 // (the first normal segment)
154 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
156 // Find max nof pads in a row
157 Int_t maxNofPads = MaxNofPadsInRow();
160 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
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()));
168 //______________________________________________________________________________
169 Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
171 /// Return the x coordinate of the left row segment border
172 /// in the global coordinate system.
174 Double_t leftBorder = DBL_MAX;
175 for (Int_t i=0; i<GetNofPadRows(); i++) {
176 AliMpPadRow* padRow = GetPadRow(i);
178 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
180 if (border < leftBorder) leftBorder = border;
186 //______________________________________________________________________________
187 Double_t AliMpRowSegmentLSpecial::RightBorderX() const
189 /// Returns the x coordinate of the right row segment border
190 /// in the global coordinate system.
192 Double_t sameBorder = GetOffsetX();
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;
202 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
203 AliErrorStream() << "WrongBorder" << endl;
210 //______________________________________________________________________________
211 TVector2 AliMpRowSegmentLSpecial::Position() const
213 /// Return the position of the row segment centre.
214 /// The centre is defined as the centre of the rectangular
215 /// row segment envelope.
217 Double_t x = GetOffsetX() - Dimensions().X();
218 Double_t y = GetRow()->Position().Y();
220 return TVector2(x, y);
223 #include <Riostream.h>
224 //______________________________________________________________________________
225 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
226 const AliMpIntPair& indices)
228 /// Set global indices to i-th motif position and returns next index in x.
230 // Get motif position
231 AliMpMotifPosition* motifPosition
232 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
236 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
238 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
240 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
241 motifPosition->SetLowIndicesLimit(low);
244 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
245 motifPosition->SetLowIndicesLimit(
246 AliMpIntPair(low.GetFirst(),
247 motifPosition->GetLowIndicesLimit().GetSecond()));
249 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
250 motifPosition->SetLowIndicesLimit(
251 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
256 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
258 = motifPosition->GetLowIndicesLimit()
259 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
261 motifPosition->SetHighIndicesLimit(high);
263 // Increment index only if last motif position is processed
264 if (i != GetNofMotifs()-1)
265 return indices.GetFirst();
268 return indices.GetFirst() + MaxNofPadsInRow();
269 //return MaxNofPadsInRow();
271 //______________________________________________________________________________
272 void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
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.
279 Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
280 // the pads offset was already defined by Reader
283 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
286 Int_t iyl = AliMpConstants::StartPadIndex();
288 //if (constPadSizeDirection == kY) {
289 iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
293 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
294 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
296 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
297 iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
303 Int_t iyh = iyl + GetNofPadRows() - 1;
305 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
306 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));