]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRowSegmentRSpecial.cxx
Previous commit had the bad side-effect of changing the behaviour of Raw QA to comput...
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentRSpecial.cxx
CommitLineData
dee1d5f1 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
ea4cae7a 16// $Id$
13985652 17// $MpId: AliMpRowSegmentRSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
ea4cae7a 18// Category: sector
3d1463c8 19
20//-----------------------------------------------------------------------------
ea4cae7a 21// Class AliMpRowSegmentRSpecial
22// -----------------------------
23// Class describing a special outer row segment composed of the
24// pad rows.
dbe945cc 25// Included in AliRoot: 2003/05/02
ea4cae7a 26// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
3d1463c8 27//-----------------------------------------------------------------------------
ea4cae7a 28
ea4cae7a 29#include "AliMpRowSegmentRSpecial.h"
30#include "AliMpRow.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"
580c28fd 37#include "AliMpConstants.h"
ea4cae7a 38
97186a3f 39#include "AliLog.h"
40
41#include <Riostream.h>
42#include <TMath.h>
43
13985652 44/// \cond CLASSIMP
ea4cae7a 45ClassImp(AliMpRowSegmentRSpecial)
13985652 46/// \endcond
ea4cae7a 47
48//______________________________________________________________________________
49AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX)
50 : AliMpVRowSegmentSpecial(row, offsetX)
51{
dee1d5f1 52/// Standard constructor
ea4cae7a 53}
54
55//______________________________________________________________________________
56AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial()
57 : AliMpVRowSegmentSpecial()
58{
dee1d5f1 59/// Default constructor
ea4cae7a 60}
61
62//______________________________________________________________________________
63AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial()
64{
dee1d5f1 65/// Destructor
ea4cae7a 66}
67
68//
69// private methods
70//
71
72//______________________________________________________________________________
73AliMpVPadRowSegment*
74AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const
75{
dee1d5f1 76/// Find the most left pad row segment with this motifPositionId.
ea4cae7a 77
78 AliMpVPadRowSegment* found = 0;
79
80 for (Int_t i=0; i<GetNofPadRows(); i++) {
81 AliMpPadRow* padRow = GetPadRow(i);
82
83 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
84 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
85
86 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
87 (!found || padRowSegment->LeftBorderX() < found->LeftBorderX()))
88
89 found = padRowSegment;
90 }
91 }
92
93 return found;
94}
95
96//______________________________________________________________________________
97void AliMpRowSegmentRSpecial::SetGlobalIndicesLow()
98{
dee1d5f1 99/// Set global low indices
ea4cae7a 100
101 // Last normal row segment in the row
102 // (preceding this special row segment)
103 AliMpVRowSegment* rowSegment
104 = GetRow()->GetRowSegment(GetRow()->GetNofRowSegments()-2);
105
106 // Set low indices limit to continue indices of the
107 // preceding row segment
168e9c4d 108 Int_t ix = rowSegment->GetHighLimitIx() + 1;
109 Int_t iy = rowSegment->GetLowLimitIy();
ea4cae7a 110
168e9c4d 111 SetLowIndicesLimit(ix, iy);
ea4cae7a 112}
113
114//
115// protected methods
116//
117
118//______________________________________________________________________________
6e97fbb8 119void AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId,
120 Double_t& x, Double_t& y) const
ea4cae7a 121{
6e97fbb8 122/// Fill the coordinates of the motif specified with
dee1d5f1 123/// the given position identifier. \n
124/// !! Applicable only for motifs that have their most down pad in
125/// this row segment.
ea4cae7a 126
127 // Find the first (left, down) pad row segment with this motifPositionId.
128 AliMpVPadRowSegment* downPadRowSegment
129 = FindPadRowSegment(motifPositionId);
130 AliMpVPadRowSegment* leftPadRowSegment
131 = FindMostLeftPadRowSegment(motifPositionId);
132
133 // Check if the motifPositionId is present
134 if (!downPadRowSegment || !leftPadRowSegment) {
2c605e66 135 AliErrorStream() << "Outside row segment region" << endl;
6e97fbb8 136 return;
ea4cae7a 137 }
138
139 // Check if both pad row segments have the same motif
140 if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) {
2c605e66 141 AliFatal("Outside row segment region");
6e97fbb8 142 return;
ea4cae7a 143 }
144
145 // Get position of found row segment
6e97fbb8 146 x = leftPadRowSegment->LeftBorderX();
147 y = GetRow()->LowBorderY() ;
ea4cae7a 148
149 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
150 y += GetPadRow(i)->HalfSizeY()*2.;
151
152 // Add motifs dimensions
6e97fbb8 153 x += downPadRowSegment->GetMotif()->DimensionX();
154 y += downPadRowSegment->GetMotif()->DimensionY();
ea4cae7a 155}
156
157//
158// public methods
159//
160
161//______________________________________________________________________________
162Double_t AliMpRowSegmentRSpecial::LeftBorderX() const
163{
dee1d5f1 164/// Return the x coordinate of the left row segment border
165/// in the global coordinate system.
ea4cae7a 166
167 // The right edge of the last normal segment
168 Double_t sameBorder = GetOffsetX();
169
170 // Consistence check
171 Double_t leftBorder = DBL_MAX;
172 for (Int_t i=0; i<GetNofPadRows(); i++) {
173 AliMpPadRow* padRow = GetPadRow(i);
174 Double_t border = padRow->GetPadRowSegment(0)->LeftBorderX();
175 if (border < leftBorder) leftBorder = border;
176 }
177
178 if (TMath::Abs(sameBorder - leftBorder) > 1.e-04) {
2c605e66 179 AliErrorStream() << "WrongBorder" << endl;;
ea4cae7a 180 return sameBorder;
181 }
182
183 return leftBorder;
184
185}
186
187//______________________________________________________________________________
188Double_t AliMpRowSegmentRSpecial::RightBorderX() const
189{
dee1d5f1 190/// Return the x coordinate of the right row segment border
191/// in the global coordinate system.
ea4cae7a 192
193 Double_t rightBorder = -DBL_MAX;
194 for (Int_t i=0; i<GetNofPadRows(); i++) {
195 AliMpPadRow* padRow = GetPadRow(i);
196 Double_t border
197 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)
198 ->RightBorderX();
199
200 if (border > rightBorder) rightBorder = border;
201 }
202
203 return rightBorder;
204}
205
206//______________________________________________________________________________
6e97fbb8 207Double_t AliMpRowSegmentRSpecial::GetPositionX() const
ea4cae7a 208{
6e97fbb8 209/// Return the x position of the row segment centre.
dee1d5f1 210/// The centre is defined as the centre of the rectangular
211/// row segment envelope.
ea4cae7a 212
213 // The right edge of the last normal segment
6e97fbb8 214 return GetOffsetX() + GetDimensionX();
215}
216
217//______________________________________________________________________________
218Double_t AliMpRowSegmentRSpecial::GetPositionY() const
219{
220/// Return the y position of the row segment centre.
221/// The centre is defined as the centre of the rectangular
222/// row segment envelope.
223
224 // The right edge of the last normal segment
225 return GetRow()->GetPositionY();
ea4cae7a 226}
227
228//______________________________________________________________________________
168e9c4d 229Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
ea4cae7a 230{
dee1d5f1 231/// Set global indices to i-th motif position and returns next index in x.
ea4cae7a 232
233 // Update low indices limit for this row segment
234 SetGlobalIndicesLow();
580c28fd 235
ea4cae7a 236 // Check for consistence
168e9c4d 237 if ( GetLowLimitIx() != AliMp::PairFirst(indices) )
c3cd353e 238 AliFatal("Inconsistent indices");
ea4cae7a 239
240 // Get motif position
241 AliMpMotifPosition* motifPosition
242 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
580c28fd 243
244 // Set limits only once
168e9c4d 245 if ( motifPosition->IsHighLimitValid() )
246 return AliMp::PairFirst(indices);
ea4cae7a 247
248 // Low limit
580c28fd 249 //
168e9c4d 250 Int_t ixl = GetLowLimitIx();
251 Int_t iyl = GetLowLimitIy();
580c28fd 252
253 // Find the most down pad row segment with this motifPositionId.
254 AliMpVPadRowSegment* padRowSegment = FindPadRowSegment(GetMotifPositionId(i));
255 Int_t padRowID = padRowSegment->GetPadRow()->GetID();
256 iyl += padRowID;
257
258 // Add pads offset of this motif position in the row segment
168e9c4d 259 for ( Int_t im=0; im<i; im++ ) {
580c28fd 260 AliMpVPadRowSegment* rs = GetPadRow(padRowID)->GetPadRowSegment(im);
261 if ( rs->GetMotifPositionId() == GetMotifPositionId(i) ) break;
262 ixl += rs->GetNofPads();
263 }
168e9c4d 264 motifPosition->SetLowIndicesLimit(ixl, iyl);
ea4cae7a 265
580c28fd 266 // High limit
267 //
ea4cae7a 268 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
168e9c4d 269 MpPair_t high
ea4cae7a 270 = motifPosition->GetLowIndicesLimit()
168e9c4d 271 + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
ea4cae7a 272 motifPosition->SetHighIndicesLimit(high);
580c28fd 273
ea4cae7a 274 // No increment index needed (this is always the last element)
168e9c4d 275 return AliMp::PairFirst(indices);
ea4cae7a 276}
277
580c28fd 278//______________________________________________________________________________
279void AliMpRowSegmentRSpecial::SetGlobalIndices(AliMpRow* rowBefore)
280{
dee1d5f1 281/// Set indices limits.
282/// The limits are defined as the limits of the smallest rectangle which
283/// includes all pads of this special row segment.
580c28fd 284
285 // Get first motif position
286 AliMpMotifPosition* firstMotifPosition
287 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(0));
288
289 // Low ix
168e9c4d 290 Int_t ixl = firstMotifPosition->GetLowLimitIx();
580c28fd 291 // We have to take the motif position limit
292 // as it can overlap over more rows and the indices
293 // of the right border of the precedent normal segment
294 // differ from one row to another
295
296 // High ix
297 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
298
299 // Low iy
300 Int_t iyl = AliMpConstants::StartPadIndex();
301 if (rowBefore) {
302 //if (constPadSizeDirection == kY) {
168e9c4d 303 iyl = rowBefore->GetHighLimitIy()+1;
580c28fd 304 //}
305 /*
306 else {
307 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
308 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
309 if (!motPos)
310 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
168e9c4d 311 iyl = motPos->GetHighLimitIy()+1;
580c28fd 312 }
313 */
314 }
315
316 // High iy
317 Int_t iyh = iyl + GetNofPadRows() - 1;
318
168e9c4d 319 SetLowIndicesLimit(ixl, iyl);
320 SetHighIndicesLimit(ixh, iyh);
580c28fd 321}
322
ea4cae7a 323