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 //-----------------------------------------------------------------------------
21 // Class AliMpRowSegmentLSpecial
22 // -----------------------------
23 // Class describing a special inner row segment composed of the
25 // Included in AliRoot: 2003/05/02
26 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 //-----------------------------------------------------------------------------
29 #include <Riostream.h>
32 #include "AliMpRowSegmentLSpecial.h"
34 #include "AliMpPadRow.h"
35 #include "AliMpVPadRowSegment.h"
36 #include "AliMpMotif.h"
37 #include "AliMpMotifType.h"
38 #include "AliMpMotifMap.h"
39 #include "AliMpMotifPosition.h"
40 #include "AliMpConstants.h"
45 ClassImp(AliMpRowSegmentLSpecial)
48 //______________________________________________________________________________
49 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
50 : AliMpVRowSegmentSpecial(row, offsetX)
52 /// Standard constructor
55 //______________________________________________________________________________
56 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
57 : AliMpVRowSegmentSpecial()
59 /// Default constructor
62 //______________________________________________________________________________
63 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
72 //______________________________________________________________________________
74 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
76 /// Find the most right pad row segment with this motifPositionId.
78 AliMpVPadRowSegment* found = 0;
80 for (Int_t i=0; i<GetNofPadRows(); i++) {
81 AliMpPadRow* padRow = GetPadRow(i);
83 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
84 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
86 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
87 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
89 found = padRowSegment;
100 //______________________________________________________________________________
101 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
103 /// Return the coordinates of the motif specified with
104 /// the given position identifier. \n
105 /// !! Applicable only for motifs that have their most down pad in
106 /// this row segment.
108 // Find the first (left, down) pad row segment with this motifPositionId.
109 AliMpVPadRowSegment* downPadRowSegment
110 = FindPadRowSegment(motifPositionId);
111 AliMpVPadRowSegment* rightPadRowSegment
112 = FindMostRightPadRowSegment(motifPositionId);
114 // Check if the motifPositionId is present
115 if (!downPadRowSegment || !rightPadRowSegment) {
116 AliErrorStream() << "Outside row segment region" << endl;
120 // Check if both pad row segments have the same motif
121 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
122 AliFatal("Outside row segment region");
126 // Get position of found row segment
127 Double_t x = rightPadRowSegment->RightBorderX();
128 Double_t y = GetRow()->LowBorderY() ;
130 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
131 y += GetPadRow(i)->HalfSizeY()*2.;
133 // Add motifs dimensions
134 x -= downPadRowSegment->GetMotif()->Dimensions().X();
135 y += downPadRowSegment->GetMotif()->Dimensions().Y();
137 return TVector2(x, y);
144 //______________________________________________________________________________
145 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
147 /// Set low indices limit to the pad offset calculated
148 /// from the neighbour normal segment.
150 // Get the neighbour row segment
151 // (the first normal segment)
152 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
154 // Get the the pads offset of the neighbour row segment
155 // (the first normal segment)
156 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
158 // Find max nof pads in a row
159 Int_t maxNofPads = MaxNofPadsInRow();
162 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
164 // Reset limits in the neighbour row segment
165 // (pad offset is now included in the special segment)
166 neighbour->SetLowIndicesLimit(
167 AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
170 //______________________________________________________________________________
171 Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
173 /// Return the x coordinate of the left row segment border
174 /// in the global coordinate system.
176 Double_t leftBorder = DBL_MAX;
177 for (Int_t i=0; i<GetNofPadRows(); i++) {
178 AliMpPadRow* padRow = GetPadRow(i);
180 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
182 if (border < leftBorder) leftBorder = border;
188 //______________________________________________________________________________
189 Double_t AliMpRowSegmentLSpecial::RightBorderX() const
191 /// Returns the x coordinate of the right row segment border
192 /// in the global coordinate system.
194 Double_t sameBorder = GetOffsetX();
197 Double_t rightBorder = -DBL_MAX;
198 for (Int_t i=0; i<GetNofPadRows(); i++) {
199 AliMpPadRow* padRow = GetPadRow(i);
200 Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
201 if (border > rightBorder) rightBorder = border;
204 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
205 AliErrorStream() << "WrongBorder" << endl;
212 //______________________________________________________________________________
213 TVector2 AliMpRowSegmentLSpecial::Position() const
215 /// Return the position of the row segment centre.
216 /// The centre is defined as the centre of the rectangular
217 /// row segment envelope.
219 Double_t x = GetOffsetX() - Dimensions().X();
220 Double_t y = GetRow()->Position().Y();
222 return TVector2(x, y);
225 #include <Riostream.h>
226 //______________________________________________________________________________
227 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
228 const AliMpIntPair& indices)
230 /// Set global indices to i-th motif position and returns next index in x.
232 // Get motif position
233 AliMpMotifPosition* motifPosition
234 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
238 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
240 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
242 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
243 motifPosition->SetLowIndicesLimit(low);
246 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
247 motifPosition->SetLowIndicesLimit(
248 AliMpIntPair(low.GetFirst(),
249 motifPosition->GetLowIndicesLimit().GetSecond()));
251 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
252 motifPosition->SetLowIndicesLimit(
253 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
258 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
260 = motifPosition->GetLowIndicesLimit()
261 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
263 motifPosition->SetHighIndicesLimit(high);
265 // Increment index only if last motif position is processed
266 if (i != GetNofMotifs()-1)
267 return indices.GetFirst();
270 return indices.GetFirst() + MaxNofPadsInRow();
271 //return MaxNofPadsInRow();
273 //______________________________________________________________________________
274 void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
276 /// Set indices limits
277 /// The limits are defined as the limits of the smallest rectangle which
278 /// includes all pads of this special row segment.
281 Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
282 // the pads offset was already defined by Reader
285 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
288 Int_t iyl = AliMpConstants::StartPadIndex();
290 //if (constPadSizeDirection == kY) {
291 iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
295 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
296 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
298 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
299 iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
305 Int_t iyh = iyl + GetNofPadRows() - 1;
307 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
308 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));