1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpMotif.cxx,v 1.8 2006/05/24 13:58:41 ivana Exp $
20 //-----------------------------------------------------------------------------
23 // Class that defines a motif with its unique ID
24 // and the motif type.
25 // Included in AliRoot: 2003/05/02
26 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 //-----------------------------------------------------------------------------
29 #include "AliMpMotif.h"
31 #include "AliMpConstants.h"
32 #include "AliMpEncodePair.h"
33 #include "AliMpMotifType.h"
39 //_____________________________________________________________________________
40 AliMpMotif::AliMpMotif()
45 /// Default constructor
48 //_____________________________________________________________________________
49 AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
50 Double_t dx, Double_t dy)
51 : AliMpVMotif(id,motifType),
55 /// Standard constructor. \n
56 /// The dimension in a given direction is calculated by
57 /// multiplying the total dimension by the number of pads
60 //_____________________________________________________________________________
61 AliMpMotif::~AliMpMotif()
67 //_____________________________________________________________________________
68 void AliMpMotif::GetPadDimensionsByIndices(MpPair_t localIndices,
69 Double_t& dx, Double_t& dy) const
71 /// Give the dimension of the specified pad in the motif
73 if ( GetMotifType()->HasPadByLocalIndices(localIndices) ) {
78 Warning("GetPadDimensionsByIndices","indices outside range");
84 //_____________________________________________________________________________
85 void AliMpMotif::GetPadDimensionsByIndices(Int_t ixLocal, Int_t iyLocal,
86 Double_t& dx, Double_t& dy) const
88 /// Give the dimension of the specified pad in the motif
90 GetPadDimensionsByIndices(AliMp::Pair(ixLocal, iyLocal), dx, dy);
93 //_____________________________________________________________________________
94 Double_t AliMpMotif::DimensionX() const
96 /// Give the x dimension of the motif
98 return GetMotifType()->GetNofPadsX()*fPadDimensionX;
101 //_____________________________________________________________________________
102 Double_t AliMpMotif::DimensionY() const
104 /// Give the y dimension of the motif
106 return GetMotifType()->GetNofPadsY()*fPadDimensionY;
109 //_____________________________________________________________________________
110 void AliMpMotif::PadPositionLocal(MpPair_t localIndices,
111 Double_t& posx, Double_t& posy ) const
113 /// Give the local position of the pad number (ix,iy)
114 /// (0,0 is the center of the motif)
116 PadPositionLocal(AliMp::PairFirst(localIndices),
117 AliMp::PairSecond(localIndices),
121 //_____________________________________________________________________________
122 void AliMpMotif::PadPositionLocal(Int_t ixLocal, Int_t iyLocal,
123 Double_t& posx, Double_t& posy) const
125 /// Give the local position of the pad number (ix,iy)
126 /// (0,0 is the center of the motif)
128 posx = (2.*ixLocal+1.)*fPadDimensionX - DimensionX();
129 posy = (2.*iyLocal+1.)*fPadDimensionY - DimensionY();
132 //_____________________________________________________________________________
133 MpPair_t AliMpMotif::PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
135 /// Return the pad indices from a given local position
136 /// or (-1,-1) if this position doesn't correspond to any valid
139 Double_t lowerLeftX = localPosX;
140 Double_t lowerLeftY = localPosY;
142 lowerLeftX += DimensionX();
143 lowerLeftY += DimensionY();
145 if ( lowerLeftX < - AliMpConstants::LengthTolerance() ||
146 lowerLeftY < - AliMpConstants::LengthTolerance() )
151 Int_t ix = (Int_t)(lowerLeftX/(2.*fPadDimensionX));
152 Int_t iy = (Int_t)(lowerLeftY/(2.*fPadDimensionY));
154 if ( ! GetMotifType()->FindConnectionByLocalIndices(ix,iy) )
159 return AliMp::Pair(ix,iy);