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 "AliMpRowSegmentLSpecial.h"
29 #include "AliMpPadRow.h"
30 #include "AliMpVPadRowSegment.h"
31 #include "AliMpMotif.h"
32 #include "AliMpMotifType.h"
33 #include "AliMpMotifMap.h"
34 #include "AliMpMotifPosition.h"
35 #include "AliMpConstants.h"
39 #include <Riostream.h>
42 ClassImp(AliMpRowSegmentLSpecial)
45 //______________________________________________________________________________
46 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
47 : AliMpVRowSegmentSpecial(row, offsetX)
49 /// Standard constructor
52 //______________________________________________________________________________
53 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
54 : AliMpVRowSegmentSpecial()
56 /// Default constructor
59 //______________________________________________________________________________
60 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
69 //______________________________________________________________________________
71 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
73 /// Find the most right pad row segment with this motifPositionId.
75 AliMpVPadRowSegment* found = 0;
77 for (Int_t i=0; i<GetNofPadRows(); i++) {
78 AliMpPadRow* padRow = GetPadRow(i);
80 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
81 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
83 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
84 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
86 found = padRowSegment;
97 //______________________________________________________________________________
98 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
100 /// Return the coordinates of the motif specified with
101 /// the given position identifier. \n
102 /// !! Applicable only for motifs that have their most down pad in
103 /// this row segment.
105 // Find the first (left, down) pad row segment with this motifPositionId.
106 AliMpVPadRowSegment* downPadRowSegment
107 = FindPadRowSegment(motifPositionId);
108 AliMpVPadRowSegment* rightPadRowSegment
109 = FindMostRightPadRowSegment(motifPositionId);
111 // Check if the motifPositionId is present
112 if (!downPadRowSegment || !rightPadRowSegment) {
113 AliErrorStream() << "Outside row segment region" << endl;
117 // Check if both pad row segments have the same motif
118 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
119 AliFatal("Outside row segment region");
123 // Get position of found row segment
124 Double_t x = rightPadRowSegment->RightBorderX();
125 Double_t y = GetRow()->LowBorderY() ;
127 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
128 y += GetPadRow(i)->HalfSizeY()*2.;
130 // Add motifs dimensions
131 x -= downPadRowSegment->GetMotif()->Dimensions().X();
132 y += downPadRowSegment->GetMotif()->Dimensions().Y();
134 return TVector2(x, y);
141 //______________________________________________________________________________
142 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
144 /// Set low indices limit to the pad offset calculated
145 /// from the neighbour normal segment.
147 // Get the neighbour row segment
148 // (the first normal segment)
149 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
151 // Get the the pads offset of the neighbour row segment
152 // (the first normal segment)
153 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
155 // Find max nof pads in a row
156 Int_t maxNofPads = MaxNofPadsInRow();
159 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
161 // Reset limits in the neighbour row segment
162 // (pad offset is now included in the special segment)
163 neighbour->SetLowIndicesLimit(
164 AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
167 //______________________________________________________________________________
168 Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
170 /// Return the x coordinate of the left row segment border
171 /// in the global coordinate system.
173 Double_t leftBorder = DBL_MAX;
174 for (Int_t i=0; i<GetNofPadRows(); i++) {
175 AliMpPadRow* padRow = GetPadRow(i);
177 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
179 if (border < leftBorder) leftBorder = border;
185 //______________________________________________________________________________
186 Double_t AliMpRowSegmentLSpecial::RightBorderX() const
188 /// Returns the x coordinate of the right row segment border
189 /// in the global coordinate system.
191 Double_t sameBorder = GetOffsetX();
194 Double_t rightBorder = -DBL_MAX;
195 for (Int_t i=0; i<GetNofPadRows(); i++) {
196 AliMpPadRow* padRow = GetPadRow(i);
197 Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
198 if (border > rightBorder) rightBorder = border;
201 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
202 AliErrorStream() << "WrongBorder" << endl;
209 //______________________________________________________________________________
210 TVector2 AliMpRowSegmentLSpecial::Position() const
212 /// Return the position of the row segment centre.
213 /// The centre is defined as the centre of the rectangular
214 /// row segment envelope.
216 Double_t x = GetOffsetX() - Dimensions().X();
217 Double_t y = GetRow()->Position().Y();
219 return TVector2(x, y);
222 #include <Riostream.h>
223 //______________________________________________________________________________
224 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
225 const AliMpIntPair& indices)
227 /// Set global indices to i-th motif position and returns next index in x.
229 // Get motif position
230 AliMpMotifPosition* motifPosition
231 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
235 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
237 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
239 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
240 motifPosition->SetLowIndicesLimit(low);
243 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
244 motifPosition->SetLowIndicesLimit(
245 AliMpIntPair(low.GetFirst(),
246 motifPosition->GetLowIndicesLimit().GetSecond()));
248 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
249 motifPosition->SetLowIndicesLimit(
250 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
255 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
257 = motifPosition->GetLowIndicesLimit()
258 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
260 motifPosition->SetHighIndicesLimit(high);
262 // Increment index only if last motif position is processed
263 if (i != GetNofMotifs()-1)
264 return indices.GetFirst();
267 return indices.GetFirst() + MaxNofPadsInRow();
268 //return MaxNofPadsInRow();
270 //______________________________________________________________________________
271 void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
273 /// Set indices limits
274 /// The limits are defined as the limits of the smallest rectangle which
275 /// includes all pads of this special row segment.
278 Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
279 // the pads offset was already defined by Reader
282 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
285 Int_t iyl = AliMpConstants::StartPadIndex();
287 //if (constPadSizeDirection == kY) {
288 iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
292 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
293 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
295 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
296 iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
302 Int_t iyh = iyl + GetNofPadRows() - 1;
304 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
305 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));