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.6 2006/03/17 11:38:43 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>
41 ClassImp(AliMpRowSegmentLSpecial)
43 //______________________________________________________________________________
44 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
45 : AliMpVRowSegmentSpecial(row, offsetX)
47 /// Standard constructor
50 //______________________________________________________________________________
51 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
52 : AliMpVRowSegmentSpecial()
54 /// Default constructor
57 //______________________________________________________________________________
58 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
67 //______________________________________________________________________________
69 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
71 /// Find the most right pad row segment with this motifPositionId.
73 AliMpVPadRowSegment* found = 0;
75 for (Int_t i=0; i<GetNofPadRows(); i++) {
76 AliMpPadRow* padRow = GetPadRow(i);
78 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
79 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
81 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
82 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
84 found = padRowSegment;
95 //______________________________________________________________________________
96 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
98 /// Return the coordinates of the motif specified with
99 /// the given position identifier. \n
100 /// !! Applicable only for motifs that have their most down pad in
101 /// this row segment.
103 // Find the first (left, down) pad row segment with this motifPositionId.
104 AliMpVPadRowSegment* downPadRowSegment
105 = FindPadRowSegment(motifPositionId);
106 AliMpVPadRowSegment* rightPadRowSegment
107 = FindMostRightPadRowSegment(motifPositionId);
109 // Check if the motifPositionId is present
110 if (!downPadRowSegment || !rightPadRowSegment) {
111 AliErrorStream() << "Outside row segment region" << endl;
115 // Check if both pad row segments have the same motif
116 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
117 AliFatal("Outside row segment region");
121 // Get position of found row segment
122 Double_t x = rightPadRowSegment->RightBorderX();
123 Double_t y = GetRow()->LowBorderY() ;
125 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
126 y += GetPadRow(i)->HalfSizeY()*2.;
128 // Add motifs dimensions
129 x -= downPadRowSegment->GetMotif()->Dimensions().X();
130 y += downPadRowSegment->GetMotif()->Dimensions().Y();
132 return TVector2(x, y);
139 //______________________________________________________________________________
140 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
142 /// Set low indices limit to the pad offset calculated
143 /// from the neighbour normal segment.
145 // Get the neighbour row segment
146 // (the first normal segment)
147 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
149 // Get the the pads offset of the neighbour row segment
150 // (the first normal segment)
151 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
153 // Find max nof pads in a row
154 Int_t maxNofPads = MaxNofPadsInRow();
157 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
159 // Reset limits in the neighbour row segment
160 // (pad offset is now included in the special segment)
161 neighbour->SetLowIndicesLimit(
162 AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
165 //______________________________________________________________________________
166 Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
168 /// Return the x coordinate of the left row segment border
169 /// in the global coordinate system.
171 Double_t leftBorder = DBL_MAX;
172 for (Int_t i=0; i<GetNofPadRows(); i++) {
173 AliMpPadRow* padRow = GetPadRow(i);
175 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
177 if (border < leftBorder) leftBorder = border;
183 //______________________________________________________________________________
184 Double_t AliMpRowSegmentLSpecial::RightBorderX() const
186 /// Returns the x coordinate of the right row segment border
187 /// in the global coordinate system.
189 Double_t sameBorder = GetOffsetX();
192 Double_t rightBorder = -DBL_MAX;
193 for (Int_t i=0; i<GetNofPadRows(); i++) {
194 AliMpPadRow* padRow = GetPadRow(i);
195 Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
196 if (border > rightBorder) rightBorder = border;
199 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
200 AliErrorStream() << "WrongBorder" << endl;
207 //______________________________________________________________________________
208 TVector2 AliMpRowSegmentLSpecial::Position() const
210 /// Return the position of the row segment centre.
211 /// The centre is defined as the centre of the rectangular
212 /// row segment envelope.
214 Double_t x = GetOffsetX() - Dimensions().X();
215 Double_t y = GetRow()->Position().Y();
217 return TVector2(x, y);
220 #include <Riostream.h>
221 //______________________________________________________________________________
222 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
223 const AliMpIntPair& indices)
225 /// Set global indices to i-th motif position and returns next index in x.
227 // Get motif position
228 AliMpMotifPosition* motifPosition
229 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
233 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
235 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
237 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
238 motifPosition->SetLowIndicesLimit(low);
241 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
242 motifPosition->SetLowIndicesLimit(
243 AliMpIntPair(low.GetFirst(),
244 motifPosition->GetLowIndicesLimit().GetSecond()));
246 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
247 motifPosition->SetLowIndicesLimit(
248 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
253 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
255 = motifPosition->GetLowIndicesLimit()
256 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
258 motifPosition->SetHighIndicesLimit(high);
260 // Increment index only if last motif position is processed
261 if (i != GetNofMotifs()-1)
262 return indices.GetFirst();
265 return indices.GetFirst() + MaxNofPadsInRow();
266 //return MaxNofPadsInRow();
268 //______________________________________________________________________________
269 void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
271 /// Set indices limits
272 /// The limits are defined as the limits of the smallest rectangle which
273 /// includes all pads of this special row segment.
276 Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
277 // the pads offset was already defined by Reader
280 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
283 Int_t iyl = AliMpConstants::StartPadIndex();
285 //if (constPadSizeDirection == kY) {
286 iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
290 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
291 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
293 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
294 iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
300 Int_t iyh = iyl + GetNofPadRows() - 1;
302 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
303 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));