]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRowSegmentLSpecial.cxx
Fixing Doxygen warnings
[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"
168e9c4d 41#include "AliMpEncodePair.h"
ea4cae7a 42
2c605e66 43#include "AliLog.h"
44
13985652 45/// \cond CLASSIMP
ea4cae7a 46ClassImp(AliMpRowSegmentLSpecial)
13985652 47/// \endcond
ea4cae7a 48
49//______________________________________________________________________________
50AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
51 : AliMpVRowSegmentSpecial(row, offsetX)
52{
dee1d5f1 53/// Standard constructor
ea4cae7a 54}
55
56//______________________________________________________________________________
57AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial()
58 : AliMpVRowSegmentSpecial()
59{
dee1d5f1 60/// Default constructor
ea4cae7a 61}
62
63//______________________________________________________________________________
64AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial()
65{
dee1d5f1 66/// Destructor
ea4cae7a 67}
68
69//
70// private methods
71//
72
73//______________________________________________________________________________
74AliMpVPadRowSegment*
75AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
76{
dee1d5f1 77/// Find the most right pad row segment with this motifPositionId.
ea4cae7a 78
79 AliMpVPadRowSegment* found = 0;
80
81 for (Int_t i=0; i<GetNofPadRows(); i++) {
82 AliMpPadRow* padRow = GetPadRow(i);
83
84 for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
85 AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
86
87 if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
88 (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
89
90 found = padRowSegment;
91 }
92 }
93
94 return found;
95}
96
97//
98// protected methods
99//
100
101//______________________________________________________________________________
6e97fbb8 102void AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId,
103 Double_t& x, Double_t& y) const
ea4cae7a 104{
6e97fbb8 105/// Fill the coordinates of the motif specified with
dee1d5f1 106/// the given position identifier. \n
107/// !! Applicable only for motifs that have their most down pad in
108/// this row segment.
ea4cae7a 109
110 // Find the first (left, down) pad row segment with this motifPositionId.
111 AliMpVPadRowSegment* downPadRowSegment
112 = FindPadRowSegment(motifPositionId);
113 AliMpVPadRowSegment* rightPadRowSegment
114 = FindMostRightPadRowSegment(motifPositionId);
115
116 // Check if the motifPositionId is present
117 if (!downPadRowSegment || !rightPadRowSegment) {
2c605e66 118 AliErrorStream() << "Outside row segment region" << endl;
6e97fbb8 119 return;
ea4cae7a 120 }
121
122 // Check if both pad row segments have the same motif
123 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
2c605e66 124 AliFatal("Outside row segment region");
6e97fbb8 125 return;
ea4cae7a 126 }
127
128 // Get position of found row segment
6e97fbb8 129 x = rightPadRowSegment->RightBorderX();
130 y = GetRow()->LowBorderY() ;
ea4cae7a 131
132 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
133 y += GetPadRow(i)->HalfSizeY()*2.;
134
135 // Add motifs dimensions
6e97fbb8 136 x -= downPadRowSegment->GetMotif()->DimensionX();
137 y += downPadRowSegment->GetMotif()->DimensionY();
ea4cae7a 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)
168e9c4d 156 MpPair_t offset = neighbour->GetLowIndicesLimit();
ea4cae7a 157
158 // Find max nof pads in a row
159 Int_t maxNofPads = MaxNofPadsInRow();
160
161 // Set limits
168e9c4d 162 SetLowIndicesLimit(offset - AliMp::Pair(maxNofPads, 0));
ea4cae7a 163
164 // Reset limits in the neighbour row segment
165 // (pad offset is now included in the special segment)
168e9c4d 166 neighbour->SetLowIndicesLimit(0, neighbour->GetLowLimitIy());
ea4cae7a 167}
168
169//______________________________________________________________________________
170Double_t AliMpRowSegmentLSpecial::LeftBorderX() const
171{
dee1d5f1 172/// Return the x coordinate of the left row segment border
173/// in the global coordinate system.
ea4cae7a 174
175 Double_t leftBorder = DBL_MAX;
176 for (Int_t i=0; i<GetNofPadRows(); i++) {
177 AliMpPadRow* padRow = GetPadRow(i);
178 Double_t border
179 = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
180
181 if (border < leftBorder) leftBorder = border;
182 }
183
184 return leftBorder;
185}
186
187//______________________________________________________________________________
188Double_t AliMpRowSegmentLSpecial::RightBorderX() const
189{
dee1d5f1 190/// Returns the x coordinate of the right row segment border
191/// in the global coordinate system.
ea4cae7a 192
193 Double_t sameBorder = GetOffsetX();
194
195 // Consistence check
196 Double_t rightBorder = -DBL_MAX;
197 for (Int_t i=0; i<GetNofPadRows(); i++) {
198 AliMpPadRow* padRow = GetPadRow(i);
199 Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
200 if (border > rightBorder) rightBorder = border;
201 }
202
203 if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
2c605e66 204 AliErrorStream() << "WrongBorder" << endl;
ea4cae7a 205 return sameBorder;
206 }
207
208 return rightBorder;
209}
210
211//______________________________________________________________________________
6e97fbb8 212Double_t AliMpRowSegmentLSpecial::GetPositionX() const
ea4cae7a 213{
6e97fbb8 214/// Return the x position of the row segment centre.
dee1d5f1 215/// The centre is defined as the centre of the rectangular
216/// row segment envelope.
ea4cae7a 217
6e97fbb8 218 return GetOffsetX() - GetDimensionX();
219}
220
221//______________________________________________________________________________
222Double_t AliMpRowSegmentLSpecial::GetPositionY() const
223{
224/// Return the y position of the row segment centre.
225/// The centre is defined as the centre of the rectangular
226/// row segment envelope.
227
228 return GetRow()->GetPositionY();
ea4cae7a 229}
230
580c28fd 231#include <Riostream.h>
ea4cae7a 232//______________________________________________________________________________
168e9c4d 233Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
ea4cae7a 234{
dee1d5f1 235/// Set global indices to i-th motif position and returns next index in x.
ea4cae7a 236
237 // Get motif position
238 AliMpMotifPosition* motifPosition
239 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
240
241 // Low limit
168e9c4d 242 MpPair_t low
243 = AliMp::Pair(GetLowLimitIx() + AliMpConstants::StartPadIndex(),
244 AliMp::PairSecond(indices))
ea4cae7a 245 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
246
168e9c4d 247 if (! motifPosition->IsHighLimitValid()) {
ea4cae7a 248 motifPosition->SetLowIndicesLimit(low);
249 }
250 else {
168e9c4d 251 if ( motifPosition->GetLowLimitIx() > AliMp::PairFirst(low) )
ea4cae7a 252 motifPosition->SetLowIndicesLimit(
168e9c4d 253 AliMp::PairFirst(low),
254 motifPosition->GetLowLimitIy());
ea4cae7a 255
168e9c4d 256 if ( motifPosition->GetLowLimitIy() > AliMp::PairSecond(low) )
ea4cae7a 257 motifPosition->SetLowIndicesLimit(
168e9c4d 258 motifPosition->GetLowLimitIx(),
259 AliMp::PairSecond(low) );
ea4cae7a 260 }
261
262 // High limit
263 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
168e9c4d 264 MpPair_t high
ea4cae7a 265 = motifPosition->GetLowIndicesLimit()
168e9c4d 266 + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
580c28fd 267
ea4cae7a 268 motifPosition->SetHighIndicesLimit(high);
580c28fd 269
ea4cae7a 270 // Increment index only if last motif position is processed
168e9c4d 271 if ( i != GetNofMotifs()-1 )
272 return AliMp::PairFirst(indices);
ea4cae7a 273 //return 0;
274 else
168e9c4d 275 return AliMp::PairFirst(indices) + MaxNofPadsInRow();
ea4cae7a 276 //return MaxNofPadsInRow();
277}
580c28fd 278//______________________________________________________________________________
279void AliMpRowSegmentLSpecial::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 // Low ix
168e9c4d 286 Int_t ixl = GetLowLimitIx() + AliMpConstants::StartPadIndex();
580c28fd 287 // the pads offset was already defined by Reader
288
289 // High ix
290 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
291
292 // Low iy
293 Int_t iyl = AliMpConstants::StartPadIndex();
294 if (rowBefore) {
295 //if (constPadSizeDirection == kY) {
168e9c4d 296 iyl = rowBefore->GetHighLimitIy()+1;
580c28fd 297 //}
298 /*
299 else {
300 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
301 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
302 if (!motPos)
303 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
168e9c4d 304 iyl = motPos->GetHighLimitIy()+1;
580c28fd 305 }
306 */
307 }
308
309 // High iy
310 Int_t iyh = iyl + GetNofPadRows() - 1;
311
168e9c4d 312 SetLowIndicesLimit(ixl, iyl);
313 SetHighIndicesLimit(ixh, iyh);
580c28fd 314}
315
ea4cae7a 316
317
318