]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRowSegmentLSpecial.cxx
New LinkDef (cmake)
[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//______________________________________________________________________________
102TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
103{
dee1d5f1 104/// Return the coordinates of the motif specified with
105/// the given position identifier. \n
106/// !! Applicable only for motifs that have their most down pad in
107/// this row segment.
ea4cae7a 108
109 // Find the first (left, down) pad row segment with this motifPositionId.
110 AliMpVPadRowSegment* downPadRowSegment
111 = FindPadRowSegment(motifPositionId);
112 AliMpVPadRowSegment* rightPadRowSegment
113 = FindMostRightPadRowSegment(motifPositionId);
114
115 // Check if the motifPositionId is present
116 if (!downPadRowSegment || !rightPadRowSegment) {
2c605e66 117 AliErrorStream() << "Outside row segment region" << endl;
ea4cae7a 118 return 0;
119 }
120
121 // Check if both pad row segments have the same motif
122 if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
2c605e66 123 AliFatal("Outside row segment region");
ea4cae7a 124 return 0;
125 }
126
127 // Get position of found row segment
128 Double_t x = rightPadRowSegment->RightBorderX();
129 Double_t y = GetRow()->LowBorderY() ;
130
131 for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
132 y += GetPadRow(i)->HalfSizeY()*2.;
133
134 // Add motifs dimensions
135 x -= downPadRowSegment->GetMotif()->Dimensions().X();
136 y += downPadRowSegment->GetMotif()->Dimensions().Y();
137
138 return TVector2(x, y);
139}
140
141//
142// public methods
143//
144
145//______________________________________________________________________________
146void AliMpRowSegmentLSpecial::UpdatePadsOffset()
147{
dee1d5f1 148/// Set low indices limit to the pad offset calculated
149/// from the neighbour normal segment.
ea4cae7a 150
151 // Get the neighbour row segment
152 // (the first normal segment)
153 AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
154
155 // Get the the pads offset of the neighbour row segment
156 // (the first normal segment)
168e9c4d 157 MpPair_t offset = neighbour->GetLowIndicesLimit();
ea4cae7a 158
159 // Find max nof pads in a row
160 Int_t maxNofPads = MaxNofPadsInRow();
161
162 // Set limits
168e9c4d 163 SetLowIndicesLimit(offset - AliMp::Pair(maxNofPads, 0));
ea4cae7a 164
165 // Reset limits in the neighbour row segment
166 // (pad offset is now included in the special segment)
168e9c4d 167 neighbour->SetLowIndicesLimit(0, neighbour->GetLowLimitIy());
ea4cae7a 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//______________________________________________________________________________
168e9c4d 227Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
ea4cae7a 228{
dee1d5f1 229/// Set global indices to i-th motif position and returns next index in x.
ea4cae7a 230
231 // Get motif position
232 AliMpMotifPosition* motifPosition
233 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
234
235 // Low limit
168e9c4d 236 MpPair_t low
237 = AliMp::Pair(GetLowLimitIx() + AliMpConstants::StartPadIndex(),
238 AliMp::PairSecond(indices))
ea4cae7a 239 + FindRelativeLowIndicesOf(GetMotifPositionId(i));
240
168e9c4d 241 if (! motifPosition->IsHighLimitValid()) {
ea4cae7a 242 motifPosition->SetLowIndicesLimit(low);
243 }
244 else {
168e9c4d 245 if ( motifPosition->GetLowLimitIx() > AliMp::PairFirst(low) )
ea4cae7a 246 motifPosition->SetLowIndicesLimit(
168e9c4d 247 AliMp::PairFirst(low),
248 motifPosition->GetLowLimitIy());
ea4cae7a 249
168e9c4d 250 if ( motifPosition->GetLowLimitIy() > AliMp::PairSecond(low) )
ea4cae7a 251 motifPosition->SetLowIndicesLimit(
168e9c4d 252 motifPosition->GetLowLimitIx(),
253 AliMp::PairSecond(low) );
ea4cae7a 254 }
255
256 // High limit
257 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
168e9c4d 258 MpPair_t high
ea4cae7a 259 = motifPosition->GetLowIndicesLimit()
168e9c4d 260 + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
580c28fd 261
ea4cae7a 262 motifPosition->SetHighIndicesLimit(high);
580c28fd 263
ea4cae7a 264 // Increment index only if last motif position is processed
168e9c4d 265 if ( i != GetNofMotifs()-1 )
266 return AliMp::PairFirst(indices);
ea4cae7a 267 //return 0;
268 else
168e9c4d 269 return AliMp::PairFirst(indices) + MaxNofPadsInRow();
ea4cae7a 270 //return MaxNofPadsInRow();
271}
580c28fd 272//______________________________________________________________________________
273void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
274{
dee1d5f1 275/// Set indices limits
276/// The limits are defined as the limits of the smallest rectangle which
277/// includes all pads of this special row segment.
580c28fd 278
279 // Low ix
168e9c4d 280 Int_t ixl = GetLowLimitIx() + AliMpConstants::StartPadIndex();
580c28fd 281 // the pads offset was already defined by Reader
282
283 // High ix
284 Int_t ixh = ixl + MaxNofPadsInRow() - 1;
285
286 // Low iy
287 Int_t iyl = AliMpConstants::StartPadIndex();
288 if (rowBefore) {
289 //if (constPadSizeDirection == kY) {
168e9c4d 290 iyl = rowBefore->GetHighLimitIy()+1;
580c28fd 291 //}
292 /*
293 else {
294 AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
295 AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
296 if (!motPos)
297 Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
168e9c4d 298 iyl = motPos->GetHighLimitIy()+1;
580c28fd 299 }
300 */
301 }
302
303 // High iy
304 Int_t iyh = iyl + GetNofPadRows() - 1;
305
168e9c4d 306 SetLowIndicesLimit(ixl, iyl);
307 SetHighIndicesLimit(ixh, iyh);
580c28fd 308}
309
ea4cae7a 310
311
312