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