Correct use of ROOT_INCLUDE_DIR
[u/mrichter/AliRoot.git] / MUON / MUONmapping / 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"
168e9c4d 32#include "AliMpEncodePair.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(),
6e97fbb8 42 fPadDimensionX(0.),
43 fPadDimensionY(0.)
5f91c9e8 44{
dee1d5f1 45 /// Default constructor
5f91c9e8 46}
47
48//_____________________________________________________________________________
49AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
6e97fbb8 50 Double_t dx, Double_t dy)
5f91c9e8 51 : AliMpVMotif(id,motifType),
6e97fbb8 52 fPadDimensionX(dx),
53 fPadDimensionY(dy)
5f91c9e8 54{
dee1d5f1 55 /// Standard constructor. \n
56 /// The dimension in a given direction is calculated by
57 /// multiplying the total dimension by the number of pads
5f91c9e8 58
59}
2998a151 60//_____________________________________________________________________________
61AliMpMotif::~AliMpMotif()
62{
dee1d5f1 63 /// Destructor
2998a151 64}
65
5f91c9e8 66
67//_____________________________________________________________________________
6e97fbb8 68void AliMpMotif::GetPadDimensionsByIndices(MpPair_t localIndices,
69 Double_t& dx, Double_t& dy) const
5f91c9e8 70{
dee1d5f1 71 /// Give the dimension of the specified pad in the motif
5f91c9e8 72
6e97fbb8 73 if ( GetMotifType()->HasPadByLocalIndices(localIndices) ) {
74 dx = fPadDimensionX;
75 dy = fPadDimensionY;
76 }
5f91c9e8 77 else {
168e9c4d 78 Warning("GetPadDimensionsByIndices","indices outside range");
6e97fbb8 79 dx = 0.;
80 dy = 0.;
5f91c9e8 81 }
82}
83
84//_____________________________________________________________________________
6e97fbb8 85void AliMpMotif::GetPadDimensionsByIndices(Int_t ixLocal, Int_t iyLocal,
86 Double_t& dx, Double_t& dy) const
168e9c4d 87{
88 /// Give the dimension of the specified pad in the motif
89
6e97fbb8 90 GetPadDimensionsByIndices(AliMp::Pair(ixLocal, iyLocal), dx, dy);
168e9c4d 91}
92
93//_____________________________________________________________________________
6e97fbb8 94Double_t AliMpMotif::DimensionX() const
5f91c9e8 95{
6e97fbb8 96 /// Give the x dimension of the motif
5f91c9e8 97
6e97fbb8 98 return GetMotifType()->GetNofPadsX()*fPadDimensionX;
5f91c9e8 99}
100
101//_____________________________________________________________________________
6e97fbb8 102Double_t AliMpMotif::DimensionY() const
103{
104 /// Give the y dimension of the motif
105
106 return GetMotifType()->GetNofPadsY()*fPadDimensionY;
107}
108
109//_____________________________________________________________________________
110void AliMpMotif::PadPositionLocal(MpPair_t localIndices,
111 Double_t& posx, Double_t& posy ) const
168e9c4d 112{
113 /// Give the local position of the pad number (ix,iy)
114 /// (0,0 is the center of the motif)
115
6e97fbb8 116 PadPositionLocal(AliMp::PairFirst(localIndices),
117 AliMp::PairSecond(localIndices),
118 posx, posy);
168e9c4d 119}
120
121//_____________________________________________________________________________
6e97fbb8 122void AliMpMotif::PadPositionLocal(Int_t ixLocal, Int_t iyLocal,
123 Double_t& posx, Double_t& posy) const
5f91c9e8 124{
dee1d5f1 125 /// Give the local position of the pad number (ix,iy)
126 /// (0,0 is the center of the motif)
5f91c9e8 127
6e97fbb8 128 posx = (2.*ixLocal+1.)*fPadDimensionX - DimensionX();
129 posy = (2.*iyLocal+1.)*fPadDimensionY - DimensionY();
5f91c9e8 130}
131
132//_____________________________________________________________________________
6e97fbb8 133MpPair_t AliMpMotif::PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
5f91c9e8 134{
dee1d5f1 135 /// Return the pad indices from a given local position
136 /// or (-1,-1) if this position doesn't correspond to any valid
137 /// connection
5f91c9e8 138
6e97fbb8 139 Double_t lowerLeftX = localPosX;
140 Double_t lowerLeftY = localPosY;
6926db95 141
6e97fbb8 142 lowerLeftX += DimensionX();
143 lowerLeftY += DimensionY();
dee1d5f1 144
6e97fbb8 145 if ( lowerLeftX < - AliMpConstants::LengthTolerance() ||
146 lowerLeftY < - AliMpConstants::LengthTolerance() )
dee1d5f1 147 {
168e9c4d 148 return -1;
dee1d5f1 149 }
150
6e97fbb8 151 Int_t ix = (Int_t)(lowerLeftX/(2.*fPadDimensionX));
152 Int_t iy = (Int_t)(lowerLeftY/(2.*fPadDimensionY));
5f91c9e8 153
168e9c4d 154 if ( ! GetMotifType()->FindConnectionByLocalIndices(ix,iy) )
081259f6 155 {
168e9c4d 156 return -1;
5f91c9e8 157 }
168e9c4d 158
159 return AliMp::Pair(ix,iy);
5f91c9e8 160}