]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 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 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpMotif.cxx,v 1.8 2006/05/24 13:58:41 ivana Exp $ |
5f91c9e8 | 18 | // Category: motif |
19 | // | |
20 | // Class AliMpMotif | |
21 | // ---------------- | |
22 | // Class that defines a motif with its unique ID | |
23 | // and the motif type. | |
dbe945cc | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
26 | ||
27 | #include "AliMpMotif.h" | |
28 | #include "AliMpMotifType.h" | |
29 | #include "AliMpIntPair.h" | |
30 | ||
13985652 | 31 | /// \cond CLASSIMP |
5f91c9e8 | 32 | ClassImp(AliMpMotif) |
13985652 | 33 | /// \endcond |
5f91c9e8 | 34 | |
35 | //_____________________________________________________________________________ | |
36 | AliMpMotif::AliMpMotif() | |
37 | : AliMpVMotif(), | |
38 | fPadDimensions(TVector2(0.,0.)) | |
39 | { | |
dee1d5f1 | 40 | /// Default constructor |
5f91c9e8 | 41 | } |
42 | ||
43 | //_____________________________________________________________________________ | |
44 | AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType, | |
45 | const TVector2& padDimension) | |
46 | : AliMpVMotif(id,motifType), | |
47 | fPadDimensions(padDimension) | |
48 | { | |
dee1d5f1 | 49 | /// Standard constructor. \n |
50 | /// The dimension in a given direction is calculated by | |
51 | /// multiplying the total dimension by the number of pads | |
5f91c9e8 | 52 | |
53 | } | |
2998a151 | 54 | //_____________________________________________________________________________ |
55 | AliMpMotif::~AliMpMotif() | |
56 | { | |
dee1d5f1 | 57 | /// Destructor |
2998a151 | 58 | } |
59 | ||
5f91c9e8 | 60 | |
61 | //_____________________________________________________________________________ | |
62 | TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const | |
63 | { | |
dee1d5f1 | 64 | /// Give the dimension of the specified pad in the motif |
5f91c9e8 | 65 | |
66 | if (GetMotifType()->HasPad(localIndices)) | |
67 | return fPadDimensions; | |
68 | else { | |
69 | Warning("GetPadDimensions","indices outside range"); | |
70 | return TVector2(0.,0.); | |
71 | } | |
72 | } | |
73 | ||
74 | //_____________________________________________________________________________ | |
75 | TVector2 AliMpMotif::Dimensions() const | |
76 | { | |
dee1d5f1 | 77 | /// Give the dimension of the motif |
5f91c9e8 | 78 | |
79 | return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(), | |
80 | GetMotifType()->GetNofPadsY()*fPadDimensions.Y()); | |
81 | } | |
82 | ||
83 | //_____________________________________________________________________________ | |
84 | TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const | |
85 | { | |
dee1d5f1 | 86 | /// Give the local position of the pad number (ix,iy) |
87 | /// (0,0 is the center of the motif) | |
5f91c9e8 | 88 | |
89 | TVector2 dim=Dimensions(); | |
90 | return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(), | |
91 | (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y()); | |
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const | |
96 | { | |
dee1d5f1 | 97 | /// Return the pad indices from a given local position |
98 | /// or (-1,-1) if this position doesn't correspond to any valid | |
99 | /// connection | |
5f91c9e8 | 100 | |
101 | TVector2 lowerLeft = localPos+Dimensions(); | |
dee1d5f1 | 102 | |
103 | if ( lowerLeft.X() < 0 || lowerLeft.Y() < 0 ) | |
104 | { | |
105 | return AliMpIntPair::Invalid(); | |
106 | } | |
107 | ||
5f91c9e8 | 108 | Int_t ix = (Int_t)(lowerLeft.X()/(2.*fPadDimensions.X())); |
109 | Int_t iy = (Int_t)(lowerLeft.Y()/(2.*fPadDimensions.Y())); | |
110 | ||
111 | if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy))) { | |
112 | //Warning("PadIndicesLocal","Position outside motif"); | |
113 | return AliMpIntPair::Invalid(); | |
114 | } | |
115 | return AliMpIntPair(ix,iy); | |
116 | } |