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