AliRoot Core  edcc906 (edcc906)
AliMpMotif.cxx
Go to the documentation of this file.
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 
16 // $Id$
17 // $MpId: AliMpMotif.cxx,v 1.8 2006/05/24 13:58:41 ivana Exp $
18 // Category: motif
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpMotif
22 // ----------------
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 //-----------------------------------------------------------------------------
28 
29 #include "AliMpMotif.h"
30 
31 #include "AliMpConstants.h"
32 #include "AliMpEncodePair.h"
33 #include "AliMpMotifType.h"
34 
36 ClassImp(AliMpMotif)
38 
39 //_____________________________________________________________________________
41  : AliMpVMotif(),
42  fPadDimensionX(0.),
43  fPadDimensionY(0.)
44 {
46 }
47 
48 //_____________________________________________________________________________
49 AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
50  Double_t dx, Double_t dy)
51  : AliMpVMotif(id,motifType),
52  fPadDimensionX(dx),
53  fPadDimensionY(dy)
54 {
58 
59 }
60 
61 //_____________________________________________________________________________
62 TObject* AliMpMotif::Clone(const char* newid) const {
63 
64  AliMpMotif* n = new AliMpMotif(TString(newid),static_cast<AliMpMotifType*>(GetMotifType()->Clone()),
66  return n;
67 }
68 
69 //_____________________________________________________________________________
71 {
73 }
74 
75 
76 //_____________________________________________________________________________
78  Double_t& dx, Double_t& dy) const
79 {
81 
82  if ( GetMotifType()->HasPadByLocalIndices(localIndices) ) {
83  dx = fPadDimensionX;
84  dy = fPadDimensionY;
85  }
86  else {
87  Warning("GetPadDimensionsByIndices","indices outside range");
88  dx = 0.;
89  dy = 0.;
90  }
91 }
92 
93 //_____________________________________________________________________________
94 void AliMpMotif::GetPadDimensionsByIndices(Int_t ixLocal, Int_t iyLocal,
95  Double_t& dx, Double_t& dy) const
96 {
98 
99  GetPadDimensionsByIndices(AliMp::Pair(ixLocal, iyLocal), dx, dy);
100 }
101 
102 //_____________________________________________________________________________
103 Double_t AliMpMotif::DimensionX() const
104 {
106 
108 }
109 
110 //_____________________________________________________________________________
111 Double_t AliMpMotif::DimensionY() const
112 {
114 
116 }
117 
118 //_____________________________________________________________________________
120  Double_t& posx, Double_t& posy ) const
121 {
124 
125  PadPositionLocal(AliMp::PairFirst(localIndices),
126  AliMp::PairSecond(localIndices),
127  posx, posy);
128 }
129 
130 //_____________________________________________________________________________
131 void AliMpMotif::PadPositionLocal(Int_t ixLocal, Int_t iyLocal,
132  Double_t& posx, Double_t& posy) const
133 {
136 
137  posx = (2.*ixLocal+1.)*fPadDimensionX - DimensionX();
138  posy = (2.*iyLocal+1.)*fPadDimensionY - DimensionY();
139 }
140 
141 //_____________________________________________________________________________
142 MpPair_t AliMpMotif::PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
143 {
147 
148  Double_t lowerLeftX = localPosX;
149  Double_t lowerLeftY = localPosY;
150 
151  lowerLeftX += DimensionX();
152  lowerLeftY += DimensionY();
153 
154  if ( lowerLeftX < - AliMpConstants::LengthTolerance() ||
155  lowerLeftY < - AliMpConstants::LengthTolerance() )
156  {
157  return -1;
158  }
159 
160  Int_t ix = (Int_t)(lowerLeftX/(2.*fPadDimensionX));
161  Int_t iy = (Int_t)(lowerLeftY/(2.*fPadDimensionY));
162 
163  if ( ! GetMotifType()->FindConnectionByLocalIndices(ix,iy) )
164  {
165  return -1;
166  }
167 
168  return AliMp::Pair(ix,iy);
169 }
Double_t fPadDimensionX
pad dimensions (halflength x, y size)
Definition: AliMpMotif.h:61
virtual Double_t GetPadDimensionX(Int_t=0) const
Return the pad x dimension.
Definition: AliMpMotif.h:74
virtual Double_t DimensionY() const
Return y dimensions.
Definition: AliMpMotif.cxx:111
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
AliMpConnection * FindConnectionByLocalIndices(MpPair_t localIndices) const
AliMpMotifType * GetMotifType() const
Return the motif type.
Definition: AliMpVMotif.h:87
virtual Double_t GetPadDimensionY(Int_t=0) const
Return the pad y dimension.
Definition: AliMpMotif.h:78
static Double_t LengthTolerance()
Return the length precision for tests.
Int_t GetNofPadsX() const
Return number of pads in x direction.
Double_t fPadDimensionY
pad dimensions (halflength x, y size)
Definition: AliMpMotif.h:62
Int_t GetNofPadsY() const
Return number of pads in y direction.
virtual ~AliMpMotif()
Definition: AliMpMotif.cxx:70
virtual Double_t DimensionX() const
Return x dimensions.
Definition: AliMpMotif.cxx:103
Abstract base class for a motif with its unique ID and the motif type.
Definition: AliMpVMotif.h:24
Int_t MpPair_t
virtual void PadPositionLocal(MpPair_t localIndices, Double_t &posx, Double_t &posy) const
Fill local position of the pad specified by local indices.
Definition: AliMpMotif.cxx:119
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
virtual void GetPadDimensionsByIndices(MpPair_t localIndices, Double_t &dx, Double_t &dy) const
Return the dimensions of the pad specified by localIndices.
Definition: AliMpMotif.cxx:77
Int_t PairSecond(MpPair_t pair)
Decode the second integer from encoded pair.
A motif with its unique ID and the motif type.
Definition: AliMpMotif.h:23
virtual MpPair_t PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
Return local indices of the pad specified by local position.
Definition: AliMpMotif.cxx:142
TObject * Clone(const char *newid) const
Definition: AliMpMotif.cxx:62
Class that defines the motif properties.