]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRowSegmentLSpecial.cxx
In Print(): added an option to print area borders
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentLSpecial.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: AliMpRowSegmentLSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
ea4cae7a 18// Category: sector
3d1463c8 19
20//-----------------------------------------------------------------------------
ea4cae7a 21// Class AliMpRowSegmentLSpecial
22// -----------------------------
23// Class describing a special inner 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
9edefa04 29#include <Riostream.h>
30#include <TMath.h>
31
ea4cae7a 32#include "AliMpRowSegmentLSpecial.h"
33#include "AliMpRow.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"
41
2c605e66 42#include "AliLog.h"
43
13985652 44/// \cond CLASSIMP
ea4cae7a 45ClassImp(AliMpRowSegmentLSpecial)
13985652 46/// \endcond
ea4cae7a 47
48//______________________________________________________________________________
49AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
50 : AliMpVRowSegmentSpecial(row, offsetX)
51{
dee1d5f1 52/// Standard constructor
ea4cae7a 53}
54
55//______________________________________________________________________________
56AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
57 : AliMpVRowSegmentSpecial()
58{
dee1d5f1 59/// Default constructor
ea4cae7a 60}
61
62//______________________________________________________________________________
63AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
64{
dee1d5f1 65/// Destructor
ea4cae7a 66}
67
68//
69// private methods
70//
71
72//______________________________________________________________________________
73AliMpVPadRowSegment*
74AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
75{
dee1d5f1 76/// Find the most right 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->RightBorderX() > found->RightBorderX()))
88
89 found = padRowSegment;
90 }
91 }
92
93 return found;
94}
95
96//
97// protected methods
98//
99
100//______________________________________________________________________________
101TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
102{
dee1d5f1 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.
ea4cae7a 107
108 // Find the first (left, down) pad row segment with this motifPositionId.
109 AliMpVPadRowSegment* downPadRowSegment
110 = FindPadRowSegment(motifPositionId);
111 AliMpVPadRowSegment* rightPadRowSegment
112 = FindMostRightPadRowSegment(motifPositionId);
113
114 // Check if the motifPositionId is present
115 if (!downPadRowSegment || !rightPadRowSegment) {
2c605e66 116 AliErrorStream() << "Outside row segment region" << endl;
ea4cae7a 117 return 0;
118 }
119
120 // Check if both pad row segments have the same motif
121 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
2c605e66 122 AliFatal("Outside row segment region");
ea4cae7a 123 return 0;
124 }
125
126 // Get position of found row segment
127 Double_t x = rightPadRowSegment->RightBorderX();
128 Double_t y = GetRow()->LowBorderY() ;
129
130 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
131 y += GetPadRow(i)->HalfSizeY()*2.;
132
133 // Add motifs dimensions
134 x -= downPadRowSegment->GetMotif()->Dimensions().X();
135 y += downPadRowSegment->GetMotif()->Dimensions().Y();
136
137 return TVector2(x, y);
138}
139
140//
141// public methods
142//
143
144//______________________________________________________________________________
145void AliMpRowSegmentLSpecial::UpdatePadsOffset()
146{
dee1d5f1 147/// Set low indices limit to the pad offset calculated
148/// from the neighbour normal segment.
ea4cae7a 149
150 // Get the neighbour row segment
151 // (the first normal segment)
152 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
153
154 // Get the the pads offset of the neighbour row segment
155 // (the first normal segment)
156 AliMpIntPair offset = neighbour->GetLowIndicesLimit();
157
158 // Find max nof pads in a row
159 Int_t maxNofPads = MaxNofPadsInRow();
160
161 // Set limits
162 SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
163
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()));
168}
169
170//______________________________________________________________________________
171Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
172{
dee1d5f1 173/// Return the x coordinate of the left row segment border
174/// in the global coordinate system.
ea4cae7a 175
176 Double_t leftBorder = DBL_MAX;
177 for (Int_t i=0; i<GetNofPadRows(); i++) {
178 AliMpPadRow* padRow = GetPadRow(i);
179 Double_t border
180 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
181
182 if (border < leftBorder) leftBorder = border;
183 }
184
185 return leftBorder;
186}
187
188//______________________________________________________________________________
189Double_t AliMpRowSegmentLSpecial::RightBorderX() const
190{
dee1d5f1 191/// Returns the x coordinate of the right row segment border
192/// in the global coordinate system.
ea4cae7a 193
194 Double_t sameBorder = GetOffsetX();
195
196 // Consistence check
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;
202 }
203
204 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
2c605e66 205 AliErrorStream() << "WrongBorder" << endl;
ea4cae7a 206 return sameBorder;
207 }
208
209 return rightBorder;
210}
211
212//______________________________________________________________________________
213TVector2 AliMpRowSegmentLSpecial::Position() const
214{
dee1d5f1 215/// Return the position of the row segment centre.
216/// The centre is defined as the centre of the rectangular
217/// row segment envelope.
ea4cae7a 218
219 Double_t x = GetOffsetX() - Dimensions().X();
220 Double_t y = GetRow()->Position().Y();
221
222 return TVector2(x, y);
223}
224
580c28fd 225#include <Riostream.h>
ea4cae7a 226//______________________________________________________________________________
227Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i,
228 const AliMpIntPair& indices)
229{
dee1d5f1 230/// Set global indices to i-th motif position and returns next index in x.
ea4cae7a 231
232 // Get motif position
233 AliMpMotifPosition* motifPosition
234 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
235
236 // Low limit
237 AliMpIntPair low
238 = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(),
239 indices.GetSecond())
240 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
241
242 if (! motifPosition->GetHighIndicesLimit().IsValid()) {
243 motifPosition->SetLowIndicesLimit(low);
244 }
245 else {
246 if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
247 motifPosition->SetLowIndicesLimit(
248 AliMpIntPair(low.GetFirst(),
249 motifPosition->GetLowIndicesLimit().GetSecond()));
250
251 if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
252 motifPosition->SetLowIndicesLimit(
253 AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
254 low.GetSecond()));
255 }
256
257 // High limit
258 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
259 AliMpIntPair high
260 = motifPosition->GetLowIndicesLimit()
580c28fd 261 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
262
ea4cae7a 263 motifPosition->SetHighIndicesLimit(high);
580c28fd 264
ea4cae7a 265 // Increment index only if last motif position is processed
266 if (i != GetNofMotifs()-1)
267 return indices.GetFirst();
268 //return 0;
269 else
270 return indices.GetFirst() + MaxNofPadsInRow();
271 //return MaxNofPadsInRow();
272}
580c28fd 273//______________________________________________________________________________
274void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
275{
dee1d5f1 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.
580c28fd 279
280 // Low ix
281 Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
282 // the pads offset was already defined by Reader
283
284 // High ix
285 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
286
287 // Low iy
288 Int_t iyl = AliMpConstants::StartPadIndex();
289 if (rowBefore) {
290 //if (constPadSizeDirection == kY) {
291 iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
292 //}
293 /*
294 else {
295 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
296 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
297 if (!motPos)
298 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
299 iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
300 }
301 */
302 }
303
304 // High iy
305 Int_t iyh = iyl + GetNofPadRows() - 1;
306
307 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
308 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
309}
310
ea4cae7a 311
312
313