4 // Class AliMpRowSegmentLSpecial
5 // -----------------------------
6 // Class describing a special inner row segment composed of the
8 // Included in AliRoot: 2003/05/02
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
13 #include "AliMpRowSegmentLSpecial.h"
15 #include "AliMpPadRow.h"
16 #include "AliMpVPadRowSegment.h"
17 #include "AliMpMotif.h"
18 #include "AliMpMotifType.h"
19 #include "AliMpMotifMap.h"
20 #include "AliMpMotifPosition.h"
21 #include "AliMpConstants.h"
23 ClassImp(AliMpRowSegmentLSpecial)
25 //______________________________________________________________________________
26 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
27 : AliMpVRowSegmentSpecial(row, offsetX)
32 //______________________________________________________________________________
33 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
34 : AliMpVRowSegmentSpecial()
39 //______________________________________________________________________________
40 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
49 //______________________________________________________________________________
51 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
53 // Find the most right pad row segment with this motifPositionId.
56 AliMpVPadRowSegment* found = 0;
58 for (Int_t i=0; i<GetNofPadRows(); i++) {
59 AliMpPadRow* padRow = GetPadRow(i);
61 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
62 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
64 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
65 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
67 found = padRowSegment;
78 //______________________________________________________________________________
79 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
81 // Returns the coordinates of the motif specified with
82 // the given position identifier.
83 // !! Applicable only for motifs that have their most down pad in
87 // Find the first (left, down) pad row segment with this motifPositionId.
88 AliMpVPadRowSegment* downPadRowSegment
89 = FindPadRowSegment(motifPositionId);
90 AliMpVPadRowSegment* rightPadRowSegment
91 = FindMostRightPadRowSegment(motifPositionId);
93 // Check if the motifPositionId is present
94 if (!downPadRowSegment || !rightPadRowSegment) {
95 Error("MotifCenter", "Outside row segment region");
99 // Check if both pad row segments have the same motif
100 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
101 Fatal("MotifCenter", "Outside row segment region");
105 // Get position of found row segment
106 Double_t x = rightPadRowSegment->RightBorderX();
107 Double_t y = GetRow()->LowBorderY() ;
109 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
110 y += GetPadRow(i)->HalfSizeY()*2.;
112 // Add motifs dimensions
113 x -= downPadRowSegment->GetMotif()->Dimensions().X();
114 y += downPadRowSegment->GetMotif()->Dimensions().Y();
116 return TVector2(x, y);
123 //______________________________________________________________________________
124 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
126 // Sets low indices limit to the pad offset calculated
127 // from the neighbour normal segment.
130 // Get the neighbour row segment
131 // (the first normal segment)
132 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
134 // Get the the pads offset of the neighbour row segment
135 // (the first normal segment)
136 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
138 // Find max nof pads in a row
139 Int_t maxNofPads = MaxNofPadsInRow();
142 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
144 // Reset limits in the neighbour row segment
145 // (pad offset is now included in the special segment)
146 neighbour->SetLowIndicesLimit(
147 AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
150 //______________________________________________________________________________
151 Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
153 // Returns the x coordinate of the left row segment border
154 // in global coordinate system.
157 Double_t leftBorder = DBL_MAX;
158 for (Int_t i=0; i<GetNofPadRows(); i++) {
159 AliMpPadRow* padRow = GetPadRow(i);
161 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
163 if (border < leftBorder) leftBorder = border;
169 //______________________________________________________________________________
170 Double_t AliMpRowSegmentLSpecial::RightBorderX() const
172 // Returns the x coordinate of the right row segment border
173 // in global coordinate system.
176 Double_t sameBorder = GetOffsetX();
179 Double_t rightBorder = -DBL_MAX;
180 for (Int_t i=0; i<GetNofPadRows(); i++) {
181 AliMpPadRow* padRow = GetPadRow(i);
182 Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
183 if (border > rightBorder) rightBorder = border;
186 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
187 Error("RightBorderX", "WrongBorder");
194 //______________________________________________________________________________
195 TVector2 AliMpRowSegmentLSpecial::Position() const
197 // Returns the position of the row segment centre.
198 // The centre is defined as the centre of the rectangular
199 // row segment envelope.
202 Double_t x = GetOffsetX() - Dimensions().X();
203 Double_t y = GetRow()->Position().Y();
205 return TVector2(x, y);
208 //______________________________________________________________________________
209 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
210 const AliMpIntPair& indices)
212 // Sets global indices to i-th motif position and returns next index in x.
215 // Get motif position
216 AliMpMotifPosition* motifPosition
217 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
221 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
223 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
225 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
226 motifPosition->SetLowIndicesLimit(low);
229 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
230 motifPosition->SetLowIndicesLimit(
231 AliMpIntPair(low.GetFirst(),
232 motifPosition->GetLowIndicesLimit().GetSecond()));
234 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
235 motifPosition->SetLowIndicesLimit(
236 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
241 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
243 = motifPosition->GetLowIndicesLimit()
244 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
245 motifPosition->SetHighIndicesLimit(high);
247 // Increment index only if last motif position is processed
248 if (i != GetNofMotifs()-1)
249 return indices.GetFirst();
252 return indices.GetFirst() + MaxNofPadsInRow();
253 //return MaxNofPadsInRow();