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