AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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 //_____________________________________________________________________________
62 {
64 }
65 
66 
67 //_____________________________________________________________________________
69  Double_t& dx, Double_t& dy) const
70 {
72 
73  if ( GetMotifType()->HasPadByLocalIndices(localIndices) ) {
74  dx = fPadDimensionX;
75  dy = fPadDimensionY;
76  }
77  else {
78  Warning("GetPadDimensionsByIndices","indices outside range");
79  dx = 0.;
80  dy = 0.;
81  }
82 }
83 
84 //_____________________________________________________________________________
85 void AliMpMotif::GetPadDimensionsByIndices(Int_t ixLocal, Int_t iyLocal,
86  Double_t& dx, Double_t& dy) const
87 {
89 
90  GetPadDimensionsByIndices(AliMp::Pair(ixLocal, iyLocal), dx, dy);
91 }
92 
93 //_____________________________________________________________________________
94 Double_t AliMpMotif::DimensionX() const
95 {
97 
99 }
100 
101 //_____________________________________________________________________________
102 Double_t AliMpMotif::DimensionY() const
103 {
105 
107 }
108 
109 //_____________________________________________________________________________
111  Double_t& posx, Double_t& posy ) const
112 {
115 
116  PadPositionLocal(AliMp::PairFirst(localIndices),
117  AliMp::PairSecond(localIndices),
118  posx, posy);
119 }
120 
121 //_____________________________________________________________________________
122 void AliMpMotif::PadPositionLocal(Int_t ixLocal, Int_t iyLocal,
123  Double_t& posx, Double_t& posy) const
124 {
127 
128  posx = (2.*ixLocal+1.)*fPadDimensionX - DimensionX();
129  posy = (2.*iyLocal+1.)*fPadDimensionY - DimensionY();
130 }
131 
132 //_____________________________________________________________________________
133 MpPair_t AliMpMotif::PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
134 {
138 
139  Double_t lowerLeftX = localPosX;
140  Double_t lowerLeftY = localPosY;
141 
142  lowerLeftX += DimensionX();
143  lowerLeftY += DimensionY();
144 
145  if ( lowerLeftX < - AliMpConstants::LengthTolerance() ||
146  lowerLeftY < - AliMpConstants::LengthTolerance() )
147  {
148  return -1;
149  }
150 
151  Int_t ix = (Int_t)(lowerLeftX/(2.*fPadDimensionX));
152  Int_t iy = (Int_t)(lowerLeftY/(2.*fPadDimensionY));
153 
154  if ( ! GetMotifType()->FindConnectionByLocalIndices(ix,iy) )
155  {
156  return -1;
157  }
158 
159  return AliMp::Pair(ix,iy);
160 }
Double_t fPadDimensionX
pad dimensions (halflength x, y size)
Definition: AliMpMotif.h:59
virtual Double_t DimensionY() const
Return y dimensions.
Definition: AliMpMotif.cxx:102
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
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
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:60
Int_t GetNofPadsY() const
Return number of pads in y direction.
virtual ~AliMpMotif()
Definition: AliMpMotif.cxx:61
virtual Double_t DimensionX() const
Return x dimensions.
Definition: AliMpMotif.cxx:94
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:110
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:68
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:133
Class that defines the motif properties.