]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRowSegment.cxx
Removing implementation of protected copy constructor &
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegment.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
5f91c9e8 16// $Id$
13985652 17// $MpId: AliMpRowSegment.cxx,v 1.10 2006/05/24 13:58:46 ivana Exp $
5f91c9e8 18// Category: sector
19//
20// Class AliMpRowSegment
21// ---------------------
22// Class describing a row segment composed of the
23// the identic motifs.
dbe945cc 24// Included in AliRoot: 2003/05/02
5f91c9e8 25// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26
5f91c9e8 27#include "AliMpRowSegment.h"
28#include "AliMpRow.h"
29#include "AliMpVMotif.h"
30#include "AliMpMotifType.h"
31#include "AliMpMotifTypePadIterator.h"
32#include "AliMpMotifMap.h"
33#include "AliMpMotifPosition.h"
580c28fd 34#include "AliMpConstants.h"
5f91c9e8 35
2c605e66 36#include <TMath.h>
37#include <Riostream.h>
38
13985652 39/// \cond CLASSIMP
5f91c9e8 40ClassImp(AliMpRowSegment)
13985652 41/// \endcond
5f91c9e8 42
43//_____________________________________________________________________________
44AliMpRowSegment::AliMpRowSegment(AliMpRow* row, AliMpVMotif* motif,
45 AliMpIntPair padOffset,
46 Int_t nofMotifs,
47 Int_t motifPositionId, Int_t motifPositionDId)
48 : AliMpVRowSegment(),
49 fNofMotifs(nofMotifs),
50 fPadOffset(padOffset),
51 fOffset(TVector2()),
52 fRow(row),
53 fMotif(motif),
54 fMotifPositionId(motifPositionId),
55 fMotifPositionDId(motifPositionDId)
56{
dee1d5f1 57/// Standard constructor
58
5f91c9e8 59 // Keep pad offset in the low indices limits
60 SetLowIndicesLimit(padOffset);
61}
62
63//_____________________________________________________________________________
64AliMpRowSegment::AliMpRowSegment()
65 : AliMpVRowSegment(),
66 fNofMotifs(0),
67 fPadOffset(AliMpIntPair()),
68 fOffset(TVector2()),
69 fRow(0),
70 fMotif(0),
71 fMotifPositionId(0),
72 fMotifPositionDId(0)
73{
dee1d5f1 74/// Default constructor
5f91c9e8 75}
76
77//_____________________________________________________________________________
dee1d5f1 78AliMpRowSegment::~AliMpRowSegment()
79{
80/// Destructor
5f91c9e8 81}
82
83//
84// private methods
85//
86
87//_____________________________________________________________________________
88Double_t AliMpRowSegment::FirstMotifCenterX() const
89{
dee1d5f1 90/// Return the x coordinate of the first motif center
91/// in the global coordinate system.
5f91c9e8 92
93 return fOffset.X();
94}
95
96//_____________________________________________________________________________
97Double_t AliMpRowSegment::LastMotifCenterX() const
98{
dee1d5f1 99/// Return the x coordinate of the last motif center
100/// in the global coordinate system.
5f91c9e8 101
102 return fOffset.X() + 2.*(fNofMotifs-1)*fMotif->Dimensions().X();
103}
104
105//_____________________________________________________________________________
106Double_t AliMpRowSegment::MotifCenterX(Int_t motifPositionId) const
107{
dee1d5f1 108/// Return the x coordinate of the motif specified with
109/// the given position identifier.
5f91c9e8 110
111 // Check if x is in the row segment range
112 if (! HasMotifPosition(motifPositionId)) {
2c605e66 113 AliErrorStream() << "Outside row segment region" << endl;
5f91c9e8 114 return 0;
115 }
116
117 // Find the position number in the segment
118 Int_t num = (motifPositionId - fMotifPositionId) * fMotifPositionDId;
119
120 return fOffset.X() + num*(fMotif->Dimensions().X() * 2.0);
121}
122
123//_____________________________________________________________________________
124Double_t AliMpRowSegment::MotifCenterY(Int_t motifPositionId) const
125{
dee1d5f1 126/// Return the y coordinate of the motif specified with
127/// the given position identifier.
5f91c9e8 128
129 // Check if x is in the row segment range
130 if (! HasMotifPosition(motifPositionId)) {
2c605e66 131 AliErrorStream() << "Outside row segment region" << endl;
5f91c9e8 132 return 0;
133 }
134
135 return GetRow()->Position().Y() + fOffset.Y();
136}
137
138//_____________________________________________________________________________
139Bool_t AliMpRowSegment::IsInside(const TVector2& position, Bool_t warn) const
140{
dee1d5f1 141/// Check if the position is inside some motif of this row segment.
5f91c9e8 142
143 Double_t minY = GetRow()->Position().Y() + fOffset.Y() - fMotif->Dimensions().Y();
144 Double_t maxY = GetRow()->Position().Y() + fOffset.Y() + fMotif->Dimensions().Y();
145
146 if ( position.X() < LeftBorderX() || position.X() > RightBorderX() ||
147 position.Y() < minY || position.Y() > maxY ) {
148
2c605e66 149 if (warn)
150 AliWarningStream() << "Outside row segment region" << endl;
5f91c9e8 151 return false;
152 }
153 else
154 return true;
155}
156
157//
158// public methods
159//
160
161//_____________________________________________________________________________
162Double_t AliMpRowSegment::LeftBorderX() const
163{
dee1d5f1 164/// Return the x coordinate of the left row segment border
165/// in the global coordinate system.
5f91c9e8 166
167 return FirstMotifCenterX() - fMotif->Dimensions().X();
168}
169
170//_____________________________________________________________________________
171Double_t AliMpRowSegment::RightBorderX() const
172{
dee1d5f1 173/// Return the x coordinate of the right row segment border
174/// in the global coordinate system.
5f91c9e8 175
176 return LastMotifCenterX() + fMotif->Dimensions().X();
177}
178
179//_____________________________________________________________________________
180Double_t AliMpRowSegment::HalfSizeY() const
181{
dee1d5f1 182/// Return the size in y of this row segment.
5f91c9e8 183
184 return fMotif->Dimensions().Y() + fOffset.Y();
185}
186
187//_____________________________________________________________________________
188AliMpVMotif* AliMpRowSegment::FindMotif(const TVector2& position) const
189{
dee1d5f1 190/// Return the motif of this row;
5f91c9e8 191
192 if (IsInside(position, false))
193 return fMotif;
194 else
195 return 0;
196}
197
198//_____________________________________________________________________________
199Int_t AliMpRowSegment::FindMotifPositionId(const TVector2& position) const
200{
dee1d5f1 201/// Return the motif position identified for the given
202/// geometric position.
5f91c9e8 203
204 if (!IsInside(position, false)) return 0;
205
206 // Find the position number in the segment
207 Int_t num
208 = Int_t((position.X() - LeftBorderX()) / (fMotif->Dimensions().X() * 2.0));
209
210 // Calculate the position Id
211 return fMotifPositionId + num*fMotifPositionDId;
212}
213
214//_____________________________________________________________________________
215Bool_t AliMpRowSegment::HasMotifPosition(Int_t motifPositionId) const
216{
dee1d5f1 217/// Return true if the motif specified with the given position identifier
218/// is in this segment.
5f91c9e8 219
220 Int_t minId = TMath::Min(fMotifPositionId,
221 fMotifPositionId + (fNofMotifs-1)*fMotifPositionDId);
222 Int_t maxId = TMath::Max(fMotifPositionId,
223 fMotifPositionId + (fNofMotifs-1)*fMotifPositionDId);
224
225 if (motifPositionId >= minId && motifPositionId <= maxId) {
226 return true;
227 }
228 else
229 return false;
230}
231
232//_____________________________________________________________________________
233TVector2 AliMpRowSegment::MotifCenter(Int_t motifPositionId) const
234{
dee1d5f1 235/// Return the coordinates of the motif specified with
236/// the given position identifier.
5f91c9e8 237
238 return TVector2(MotifCenterX(motifPositionId), MotifCenterY(motifPositionId));
239}
240
241//_____________________________________________________________________________
242TVector2 AliMpRowSegment::Position() const
243{
dee1d5f1 244/// Return the position of the row segment centre.
5f91c9e8 245
246 Double_t x = (LeftBorderX() + RightBorderX())/2.;
247 Double_t y = GetRow()->Position().Y();
248
249 return TVector2(x, y);
250}
251
252
253//_____________________________________________________________________________
254TVector2 AliMpRowSegment::Dimensions() const
255{
dee1d5f1 256/// Return the halflengths of the row segment in x, y.
5f91c9e8 257// ---
258
259 Double_t x = (RightBorderX() - LeftBorderX())/2.;
260 Double_t y = GetRow()->Dimensions().Y();
261
262 return TVector2(x, y);
263}
264
265//_____________________________________________________________________________
266void AliMpRowSegment::SetOffset(const TVector2& offset)
267{
dee1d5f1 268/// Calculate offset from given offset and
269/// stored offset in pads.
5f91c9e8 270
271 AliMpMotifTypePadIterator iter(fMotif->GetMotifType());
272 iter.First();
273 AliMpIntPair localPos = iter.CurrentItem().GetIndices();
274
275 Double_t offsetX
276 = offset.X()
277 + 2.*fPadOffset.GetFirst() * fMotif->GetPadDimensions(localPos).X()
278 + fMotif->Dimensions().X();
279
280 Double_t offsetY
281 = offset.Y()
282 + fPadOffset.GetSecond() * fMotif->GetPadDimensions(localPos).Y();
283
284 fOffset = TVector2(offsetX, offsetY);
285}
286
580c28fd 287#include <Riostream.h>
5f91c9e8 288//_____________________________________________________________________________
580c28fd 289void AliMpRowSegment::SetGlobalIndices(AliMpRow* /*rowBefore*/)
5f91c9e8 290{
dee1d5f1 291/// Set global indices limits.
5f91c9e8 292
580c28fd 293 // The low/high indices limits has to be taken as the highest/lowest from all
294 // motif positions
295 Int_t ixl = 9999;
296 Int_t iyl = 9999;
297 Int_t ixh = AliMpConstants::StartPadIndex();
298 Int_t iyh = AliMpConstants::StartPadIndex();
299
300 for (Int_t i=0; i<GetNofMotifs(); i++) {
301
302 AliMpMotifPosition* mPos
303 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
304
305 // Check if the motif positions has the limits set
306 if ( !mPos->HasValidIndices() )
307 Fatal("SetGlobalIndices",
308 "Indices of motif positions have to be set first.");
5f91c9e8 309
580c28fd 310 if ( mPos->GetLowIndicesLimit().GetFirst() < ixl )
311 ixl = mPos->GetLowIndicesLimit().GetFirst();
312
313 if ( mPos->GetLowIndicesLimit().GetSecond() < iyl )
314 iyl = mPos->GetLowIndicesLimit().GetSecond();
315
316 if ( mPos->GetHighIndicesLimit().GetFirst() > ixh )
317 ixh = mPos->GetHighIndicesLimit().GetFirst();
318
319 if ( mPos->GetHighIndicesLimit().GetSecond() > iyh )
320 iyh = mPos->GetHighIndicesLimit().GetSecond();
321 }
322
323 SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
324 SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
5f91c9e8 325}
326
327//_____________________________________________________________________________
ffb47139 328Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i,
329 const AliMpIntPair& indices)
5f91c9e8 330{
dee1d5f1 331/// Set global indices to i-th motif position and returns next index
332/// in x.
5f91c9e8 333
334 // Get motif position
335 AliMpMotifPosition* motifPosition
336 = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
337
338 // Low limit
339 AliMpIntPair low = indices + AliMpIntPair(0, GetLowIndicesLimit().GetSecond());
340 motifPosition->SetLowIndicesLimit(low);
341
342 // High limit
343 AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
344 AliMpIntPair high
345 = motifPosition->GetLowIndicesLimit()
346 + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
347 motifPosition->SetHighIndicesLimit(high);
348
349 // Return next index in x
350 return high.GetFirst()+1;
351 // return motifType->GetNofPadsX();
352}
353
354
355//_____________________________________________________________________________
356AliMpRow* AliMpRowSegment::GetRow() const
357{
dee1d5f1 358/// Return the row.which this row segment belongs to.
5f91c9e8 359
360 return fRow;
361}
362
363//_____________________________________________________________________________
364Int_t AliMpRowSegment::GetNofMotifs() const
365{
dee1d5f1 366/// Return number of motifs in this this row segment.
5f91c9e8 367
368 return fNofMotifs;
369}
370
371//_____________________________________________________________________________
372Int_t AliMpRowSegment::GetMotifPositionId(Int_t i) const
373{
dee1d5f1 374/// Return number of motifs in this this row segment.
5f91c9e8 375
376 return fMotifPositionId + i*fMotifPositionDId;
377}
378
379//_____________________________________________________________________________
ffb47139 380AliMpVMotif* AliMpRowSegment::GetMotif(Int_t /*i*/) const
5f91c9e8 381{
dee1d5f1 382/// Return the motif of this row segment.
5f91c9e8 383
384 return fMotif;
385}