AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpMotifSpecial.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: AliMpMotifSpecial.cxx,v 1.12 2006/05/24 13:58:41 ivana Exp $
18 // Category: motif
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpMotifSpecial
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 "AliMpMotifSpecial.h"
30 #include "AliMpMotifType.h"
31 #include "AliMpEncodePair.h"
32 #include "AliMpConstants.h"
33 
34 #include "AliLog.h"
35 
36 #include <TString.h>
37 #include <Riostream.h>
38 #include <TVector2.h>
39 
43 
44 Int_t AliMpMotifSpecial::fgkPadDimensions2Size = 5;
45 
46 //______________________________________________________________________________
48  AliMpMotifType *motifType)
49  : AliMpVMotif(id,motifType),
50  fDimensionX(0.),
51  fDimensionY(0.),
52  fPadDimensionsVector(),
53  fNofPadDimensions2(0),
54  fPadDimensions2X(fgkPadDimensions2Size),
55  fPadDimensions2Y(fgkPadDimensions2Size)
56 
57 {
59 }
60 
61 //______________________________________________________________________________
63  AliMpVMotif(),
64  fDimensionX(0.),
65  fDimensionY(0.),
66  fPadDimensionsVector(ioCtor),
67  fNofPadDimensions2(),
68  fPadDimensions2X(),
69  fPadDimensions2Y()
70 {
72 }
73 
74 
75 //______________________________________________________________________________
77 {
79 }
80 
81 
82 //
83 // public methods
84 //
85 
86 //______________________________________________________________________________
87 void
89  Double_t& dx, Double_t& dy) const
90 {
92 
94  AliMp::PairSecond(localIndices),
95  dx, dy);
96 }
97 
98 //______________________________________________________________________________
99 void
100 AliMpMotifSpecial::GetPadDimensionsByIndices(Int_t ixLocal, Int_t iyLocal,
101  Double_t& dx, Double_t& dy) const
102 {
104 
105  if ( GetMotifType()->HasPadByLocalIndices(ixLocal, iyLocal) ) {
106  if (!fPadDimensionsVector.GetValue(ixLocal, iyLocal)) {
107  Warning("GetPadDimensionsByIndices","Indices outside limits");
108  dx = 0.;
109  dy = 0.;
110  }
111  else {
112  dx = ((TVector2*)fPadDimensionsVector.GetValue(ixLocal, iyLocal))->X();
113  dy = ((TVector2*)fPadDimensionsVector.GetValue(ixLocal, iyLocal))->Y();
114  }
115  }
116  else {
117  Warning("GetPadDimensionsByIndices","Indices outside limits");
118  dx = 0.;
119  dy = 0.;
120  }
121 }
122 
123 //______________________________________________________________________________
125 {
127 
128  return fNofPadDimensions2;
129 }
130 
131 //______________________________________________________________________________
132 Double_t AliMpMotifSpecial::GetPadDimensionX(Int_t i) const
133 {
135 
136  if ( i < 0 || i > fNofPadDimensions2 ) {
137  AliFatal("Index outside limits.");
138  return 0;
139  }
140 
141  return fPadDimensions2X[i];
142 }
143 
144 //______________________________________________________________________________
145 Double_t AliMpMotifSpecial::GetPadDimensionY(Int_t i) const
146 {
148 
149  if ( i < 0 || i > fNofPadDimensions2 ) {
150  AliFatal("Index outside limits.");
151  return 0;
152  }
153 
154  return fPadDimensions2Y[i];
155 }
156 
157 //______________________________________________________________________________
159 {
161 
162  Int_t i,j;
163  fDimensionY = 0.;
164  fDimensionX = 0.;
165 
166  Double_t* tabSizeX = new Double_t[GetMotifType()->GetNofPadsY()];
167 
168  for ( j=0; j<GetMotifType()->GetNofPadsY(); ++j ) tabSizeX[j]=0.0;
169 
170  for ( i=0; i<GetMotifType()->GetNofPadsX(); ++i ) {
171  Double_t trSizeY=0.;
172  for ( j=0; j<GetMotifType()->GetNofPadsY(); ++j ) {
173  Double_t dimx, dimy;
174  GetPadDimensionsByIndices(i,j, dimx, dimy);
175  trSizeY += dimy;
176  tabSizeX[j] += dimx;
177  }
178  if ( trSizeY > fDimensionY ) fDimensionY = trSizeY;
179  }
180 
181  for ( j=0; j<GetMotifType()->GetNofPadsY(); ++j ) {
182  if ( tabSizeX[j] > fDimensionX ) fDimensionX = tabSizeX[j];
183  }
184 
185  delete [] tabSizeX;
186 }
187 
188 //______________________________________________________________________________
190 {
192 
193  return fDimensionX;
194 }
195 
196 //______________________________________________________________________________
198 {
200 
201  return fDimensionY;
202 }
203 
204 //______________________________________________________________________________
205 void
207  Double_t& posx, Double_t& posy) const
208 {
211 
212  return PadPositionLocal(AliMp::PairFirst(localIndices),
213  AliMp::PairSecond(localIndices),
214  posx, posy);
215 
216 }
217 
218 //______________________________________________________________________________
219 void
220 AliMpMotifSpecial::PadPositionLocal(Int_t ixLocal, Int_t iyLocal,
221  Double_t& posx, Double_t& posy) const
222 {
225 
226  Double_t dx0, dy0;
227  GetPadDimensionsByIndices(ixLocal, iyLocal, dx0, dy0);
228 
229  posx = dx0;
230  for ( Int_t i=0 ;i<ixLocal; ++i ) {
231  Double_t dxi, dyi;
232  GetPadDimensionsByIndices(i, iyLocal, dxi, dyi);
233  posx += 2.*dxi;
234  }
235 
236  posy = dy0;
237  for ( Int_t j=0; j<iyLocal; ++j ) {
238  Double_t dxi, dyi;
239  GetPadDimensionsByIndices(ixLocal, j, dxi, dyi);
240  posy += 2.*dyi;
241  }
242 
243  posx -= DimensionX();
244  posy -= DimensionY();
245 }
246 
247 //______________________________________________________________________________
248 MpPair_t
249 AliMpMotifSpecial::PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
250 {
258 
259 
260  // First : find the j index
261  Int_t j=0;
262  Double_t y = localPosY + DimensionY();
263 
264  while (j<GetMotifType()->GetNofPadsY()) {
265  Double_t padDimX, padDimY;
266  GetPadDimensionsByIndices(0, j, padDimX, padDimY);
267  y -= 2.*padDimY;
268  if ( y < 0. ) break;
269  j++;
270  }
271 
272  // Test if it's outside limits
273  if (j==GetMotifType()->GetNofPadsY()){
274  Warning("PadIndicesLocal","The position is outside the motif");
275  return -1;
276  }
277 
278 
279  // now find the i index, in the j_th row
280  Int_t i=0;
281  Double_t x = localPosX + DimensionX();
282 
283  while (i<GetMotifType()->GetNofPadsX()) {
284  Double_t padDimX, padDimY;
285  GetPadDimensionsByIndices(i, j, padDimX, padDimY);
286  x -= 2.*padDimX;
287  if ( x < 0. ) break;
288  i++;
289  }
290 
291 
292  // Test if it's outside limits
293 
294  if (i==GetMotifType()->GetNofPadsX()){
295  Warning("PadIndicesLocal","The position is outside the motif");
296  return -1;
297  }
298 
299  // then return the found (i,j)
300  return AliMp::Pair(i,j);
301 }
302 
303 //______________________________________________________________________________
305  Double_t dx, Double_t dy)
306 {
309 
310  SetPadDimensions(AliMp::PairFirst(localIndices),
311  AliMp::PairSecond(localIndices), dx, dy);
312 }
313 
314 //______________________________________________________________________________
315 void AliMpMotifSpecial::SetPadDimensions(Int_t ixLocal, Int_t iyLocal,
316  Double_t dx, Double_t dy)
317 {
320 
321  if ( ! GetMotifType()->HasPadByLocalIndices(ixLocal, iyLocal) ) {
322  Warning("SetPadDimensions","Pad indices outside limits");
323  return;
324  }
325 
326  // fill the dimensions map vector
327  TVector2* dimensionsObj = new TVector2(dx, dy);
328  fPadDimensionsVector.Add(ixLocal, iyLocal, dimensionsObj);
329 
330  // fill the vector of different pad dimensions
331  // only if these dimensions are not yet present
332  Bool_t isPresent = false;
333  for (Int_t i=0; i<GetNofPadDimensions(); i++) {
335  fPadDimensions2X[i], fPadDimensions2Y[i], dx, dy) )
336  isPresent = true;
337  }
338 
339  if (!isPresent) {
342  }
343 }
virtual Double_t DimensionY() const
Return y dimensions.
void SetPadDimensions(MpPair_t localIndices, Double_t dx, Double_t dy)
A special motif with varying pad dimensions.
virtual Double_t GetPadDimensionX(Int_t i) const
Return the i-th pad x dimension.
Double_t fDimensionX
motif x dimensions
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
virtual MpPair_t PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
Return local indices of the pad specified by local position.
AliMpMotifType * GetMotifType() const
Return the motif type.
Definition: AliMpVMotif.h:87
virtual Double_t DimensionX() const
Return x dimensions.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Double_t fDimensionY
motif y dimensions
virtual void GetPadDimensionsByIndices(MpPair_t localIndices, Double_t &dx, Double_t &dy) const
Return the dimensions of the pad specified by localIndices.
TArrayD fPadDimensions2Y
the vector of y of different pad dimensions
TArrayD fPadDimensions2X
the vector of x of different pad dimensions
Int_t GetNofPadsX() const
Return number of pads in x direction.
Int_t fNofPadDimensions2
number of different pad dimensions
Int_t GetNofPadsY() const
Return number of pads in y direction.
virtual Double_t GetPadDimensionY(Int_t i) const
Return the i-th pad y dimension.
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
virtual Int_t GetNofPadDimensions() const
Return the number of pad dimensions.
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
static Bool_t IsEqual(Double_t length1, Double_t length2)
Abstract base class for a motif with its unique ID and the motif type.
Definition: AliMpVMotif.h:24
AliMpExMap fPadDimensionsVector
the vector of pad dimensions
Int_t MpPair_t
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
AliMpMotifSpecial()
Not implemented.
Int_t PairSecond(MpPair_t pair)
Decode the second integer from encoded pair.
virtual void PadPositionLocal(MpPair_t localIndices, Double_t &posx, Double_t &posy) const
Fill local position of the pad specified by local indices.
Class that defines the motif properties.