]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpMotif.cxx
Commenting out StdoutToAliDebug which is, with the current AliLog
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotif.cxx
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.8 2006/05/24 13:58:41 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
29 #include "AliMpConstants.h"
30 #include "AliMpIntPair.h"
31 #include "AliMpMotifType.h"
32
33 /// \cond CLASSIMP
34 ClassImp(AliMpMotif)
35 /// \endcond
36
37 //_____________________________________________________________________________
38 AliMpMotif::AliMpMotif()
39   : AliMpVMotif(),
40     fPadDimensions(TVector2(0.,0.))
41 {
42   /// Default constructor
43 }
44
45 //_____________________________________________________________________________
46 AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
47                        const TVector2& padDimension)
48   : AliMpVMotif(id,motifType),
49     fPadDimensions(padDimension)
50 {
51   /// Standard constructor.                                                \n
52   /// The dimension in a given direction is calculated by
53   /// multiplying the total dimension by the number of pads
54
55 }
56 //_____________________________________________________________________________
57 AliMpMotif::~AliMpMotif()
58 {
59   /// Destructor
60 }
61
62
63 //_____________________________________________________________________________
64 TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
65 {
66   /// Give the dimension of the specified pad in the motif
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 //_____________________________________________________________________________
77 TVector2 AliMpMotif::Dimensions() const
78 {
79   /// Give the dimension of the motif
80
81   return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
82                 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
83 }
84
85 //_____________________________________________________________________________
86 TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const 
87 {
88   /// Give the local position of the pad number (ix,iy)
89   /// (0,0 is the center of the motif)
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 //_____________________________________________________________________________
97 AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
98 {
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
102
103   TVector2 lowerLeft(localPos);
104   
105   lowerLeft += Dimensions();
106
107   if ( lowerLeft.X() < - AliMpConstants::LengthTolerance() || 
108        lowerLeft.Y() < - AliMpConstants::LengthTolerance() ) 
109     {
110       return AliMpIntPair::Invalid();
111     }
112
113   Int_t ix = (Int_t)(lowerLeft.X()/(2.*fPadDimensions.X()));
114   Int_t iy = (Int_t)(lowerLeft.Y()/(2.*fPadDimensions.Y()));
115   
116   if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy)))
117   {
118     return AliMpIntPair::Invalid();
119   }
120   return AliMpIntPair(ix,iy);
121 }