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.5 2005/08/26 15:43:36 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
29 #include "AliMpRowSegmentLSpecial.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"
39 ClassImp(AliMpRowSegmentLSpecial)
41 //______________________________________________________________________________
42 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
43 : AliMpVRowSegmentSpecial(row, offsetX)
45 /// Standard constructor
48 //______________________________________________________________________________
49 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
50 : AliMpVRowSegmentSpecial()
52 /// Default constructor
55 //______________________________________________________________________________
56 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
65 //______________________________________________________________________________
67 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
69 /// Find the most right pad row segment with this motifPositionId.
71 AliMpVPadRowSegment* found = 0;
73 for (Int_t i=0; i<GetNofPadRows(); i++) {
74 AliMpPadRow* padRow = GetPadRow(i);
76 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
77 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
79 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
80 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
82 found = padRowSegment;
93 //______________________________________________________________________________
94 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
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
101 // Find the first (left, down) pad row segment with this motifPositionId.
102 AliMpVPadRowSegment* downPadRowSegment
103 = FindPadRowSegment(motifPositionId);
104 AliMpVPadRowSegment* rightPadRowSegment
105 = FindMostRightPadRowSegment(motifPositionId);
107 // Check if the motifPositionId is present
108 if (!downPadRowSegment || !rightPadRowSegment) {
109 Error("MotifCenter", "Outside row segment region");
113 // Check if both pad row segments have the same motif
114 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
115 Fatal("MotifCenter", "Outside row segment region");
119 // Get position of found row segment
120 Double_t x = rightPadRowSegment->RightBorderX();
121 Double_t y = GetRow()->LowBorderY() ;
123 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
124 y += GetPadRow(i)->HalfSizeY()*2.;
126 // Add motifs dimensions
127 x -= downPadRowSegment->GetMotif()->Dimensions().X();
128 y += downPadRowSegment->GetMotif()->Dimensions().Y();
130 return TVector2(x, y);
137 //______________________________________________________________________________
138 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
140 /// Set low indices limit to the pad offset calculated
141 /// from the neighbour normal segment.
143 // Get the neighbour row segment
144 // (the first normal segment)
145 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
147 // Get the the pads offset of the neighbour row segment
148 // (the first normal segment)
149 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
151 // Find max nof pads in a row
152 Int_t maxNofPads = MaxNofPadsInRow();
155 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
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()));
163 //______________________________________________________________________________
164 Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
166 /// Return the x coordinate of the left row segment border
167 /// in the global coordinate system.
169 Double_t leftBorder = DBL_MAX;
170 for (Int_t i=0; i<GetNofPadRows(); i++) {
171 AliMpPadRow* padRow = GetPadRow(i);
173 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
175 if (border < leftBorder) leftBorder = border;
181 //______________________________________________________________________________
182 Double_t AliMpRowSegmentLSpecial::RightBorderX() const
184 /// Returns the x coordinate of the right row segment border
185 /// in the global coordinate system.
187 Double_t sameBorder = GetOffsetX();
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;
197 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
198 Error("RightBorderX", "WrongBorder");
205 //______________________________________________________________________________
206 TVector2 AliMpRowSegmentLSpecial::Position() const
208 /// Return the position of the row segment centre.
209 /// The centre is defined as the centre of the rectangular
210 /// row segment envelope.
212 Double_t x = GetOffsetX() - Dimensions().X();
213 Double_t y = GetRow()->Position().Y();
215 return TVector2(x, y);
218 #include <Riostream.h>
219 //______________________________________________________________________________
220 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
221 const AliMpIntPair& indices)
223 /// Set global indices to i-th motif position and returns next index in x.
225 // Get motif position
226 AliMpMotifPosition* motifPosition
227 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
231 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
233 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
235 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
236 motifPosition->SetLowIndicesLimit(low);
239 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
240 motifPosition->SetLowIndicesLimit(
241 AliMpIntPair(low.GetFirst(),
242 motifPosition->GetLowIndicesLimit().GetSecond()));
244 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
245 motifPosition->SetLowIndicesLimit(
246 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
251 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
253 = motifPosition->GetLowIndicesLimit()
254 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
256 motifPosition->SetHighIndicesLimit(high);
258 // Increment index only if last motif position is processed
259 if (i != GetNofMotifs()-1)
260 return indices.GetFirst();
263 return indices.GetFirst() + MaxNofPadsInRow();
264 //return MaxNofPadsInRow();
266 //______________________________________________________________________________
267 void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
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.
274 Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
275 // the pads offset was already defined by Reader
278 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
281 Int_t iyl = AliMpConstants::StartPadIndex();
283 //if (constPadSizeDirection == kY) {
284 iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
288 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
289 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
291 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
292 iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
298 Int_t iyh = iyl + GetNofPadRows() - 1;
300 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
301 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));