]>
Commit | Line | Data |
---|---|---|
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 | ||
35 | /// \cond CLASSIMP | |
36 | ClassImp(AliMpMotif) | |
37 | /// \endcond | |
38 | ||
39 | //_____________________________________________________________________________ | |
40 | AliMpMotif::AliMpMotif() | |
41 | : AliMpVMotif(), | |
42 | fPadDimensionX(0.), | |
43 | fPadDimensionY(0.) | |
44 | { | |
45 | /// Default constructor | |
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 | { | |
55 | /// Standard constructor. \n | |
56 | /// The dimension in a given direction is calculated by | |
57 | /// multiplying the total dimension by the number of pads | |
58 | ||
59 | } | |
60 | //_____________________________________________________________________________ | |
61 | AliMpMotif::~AliMpMotif() | |
62 | { | |
63 | /// Destructor | |
64 | } | |
65 | ||
66 | ||
67 | //_____________________________________________________________________________ | |
68 | void AliMpMotif::GetPadDimensionsByIndices(MpPair_t localIndices, | |
69 | Double_t& dx, Double_t& dy) const | |
70 | { | |
71 | /// Give the dimension of the specified pad in the motif | |
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 | { | |
88 | /// Give the dimension of the specified pad in the motif | |
89 | ||
90 | GetPadDimensionsByIndices(AliMp::Pair(ixLocal, iyLocal), dx, dy); | |
91 | } | |
92 | ||
93 | //_____________________________________________________________________________ | |
94 | Double_t AliMpMotif::DimensionX() const | |
95 | { | |
96 | /// Give the x dimension of the motif | |
97 | ||
98 | return GetMotifType()->GetNofPadsX()*fPadDimensionX; | |
99 | } | |
100 | ||
101 | //_____________________________________________________________________________ | |
102 | Double_t AliMpMotif::DimensionY() const | |
103 | { | |
104 | /// Give the y dimension of the motif | |
105 | ||
106 | return GetMotifType()->GetNofPadsY()*fPadDimensionY; | |
107 | } | |
108 | ||
109 | //_____________________________________________________________________________ | |
110 | void AliMpMotif::PadPositionLocal(MpPair_t localIndices, | |
111 | Double_t& posx, Double_t& posy ) const | |
112 | { | |
113 | /// Give the local position of the pad number (ix,iy) | |
114 | /// (0,0 is the center of the motif) | |
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 | { | |
125 | /// Give the local position of the pad number (ix,iy) | |
126 | /// (0,0 is the center of the motif) | |
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 | { | |
135 | /// Return the pad indices from a given local position | |
136 | /// or (-1,-1) if this position doesn't correspond to any valid | |
137 | /// connection | |
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 | } |