]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpVSegmentation.cxx
Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpVSegmentation.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: AliMpVSegmentation.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $
5f91c9e8 18// Category: basic
3d1463c8 19
20//-----------------------------------------------------------------------------
5f91c9e8 21// Class AliMpVSegmentation
22// ------------------------
23// The abstract base class for the segmentation.
24// Provides methods related to pads:
25// conversion between pad indices, pad location, pad position;
26// finding pad neighbour.
27//
dbe945cc 28// Included in AliRoot: 2003/05/02
5f91c9e8 29// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
c49cb542 30// Laurent Aphecetche, SUBATECH
3d1463c8 31//-----------------------------------------------------------------------------
32
5f91c9e8 33
34#include "AliMpVSegmentation.h"
c49cb542 35#include "AliMpArea.h"
5f91c9e8 36#include "AliMpConstants.h"
37
c49cb542 38#include "AliLog.h"
39
40#include "TVector2.h"
41#include "TObjArray.h"
42
13985652 43/// \cond CLASSIMP
5f91c9e8 44ClassImp(AliMpVSegmentation)
13985652 45/// \endcond
5f91c9e8 46
47//_____________________________________________________________________________
48AliMpVSegmentation::AliMpVSegmentation()
49 : TObject()
50{
dee1d5f1 51/// Default constructor
5f91c9e8 52}
53
54//_____________________________________________________________________________
dee1d5f1 55AliMpVSegmentation::~AliMpVSegmentation()
56{
57/// Destructor
5f91c9e8 58}
59
c49cb542 60//_____________________________________________________________________________
61Int_t
62AliMpVSegmentation::GetNeighbours(const AliMpPad& pad,
63 TObjArray& neighbours,
64 Bool_t includeSelf,
65 Bool_t includeVoid) const
66{
67 /// Returns the list of neighbours of pad
68 static TVector2* testPositions(0x0);
69 static const Int_t kNofTestPositions(11);
70 static const Double_t kEpsilon(AliMpConstants::LengthTolerance()*2.0);
71 static Int_t centerIndex(-1);
72
73 // testPositions are the positions (L,T,R,B) relative to pad's center (O)
74 // were we'll try to get a neighbouring pad, by getting a little
75 // bit outside the pad itself.
76 // Note that it's not symmetric as we assume that pad density
c6da08f6 77 // can always decrease when going from left to right (or from bottom to top)
c49cb542 78 //
c6da08f6 79 // L--T--R
c49cb542 80 // | |
81 // L |
82 // | O R
83 // L |
84 // | |
c6da08f6 85 // L-B-B-R
c49cb542 86 //
87 // The order in which we actually test the positions has some importance,
88 // i.e. when using this information to compute status map later on. Here's
89 // the sequence :
90 //
c6da08f6 91 // 4-- 5-- 6
92 // | |
93 // 3 |
94 // | 0 7
95 // 2 |
96 // | |
97 // 1-10- 9-8
c49cb542 98
99 neighbours.Delete();
100 neighbours.SetOwner(kTRUE);
101
102 if (!pad.IsValid()) return 0;
103
104 if (!testPositions)
105 {
106 testPositions = new TVector2[kNofTestPositions];
107 Int_t n(0);
108 // starting center
109 centerIndex = 0;
110 testPositions[n++] = TVector2(0,0); // O (pad center)
111 // then left column (L), starting from bottom
c6da08f6 112 testPositions[n++] = TVector2(-1,-1); // 1
113 testPositions[n++] = TVector2(-1,-1/3.0); // 2
114 testPositions[n++] = TVector2(-1,1/3.0); // 3
115 testPositions[n++] = TVector2(-1,1); // 4
116 // top (T)
117 testPositions[n++] = TVector2(0,1); // 5
c49cb542 118 // right column (R), starting from top
c6da08f6 119 testPositions[n++] = TVector2(1,1); // 6
120 testPositions[n++] = TVector2(1,0); // 7
121 testPositions[n++] = TVector2(1,-1); // 8
122 // bottom (B), starting from right
123 testPositions[n++] = TVector2(1/3.0,-1); // 9
124 testPositions[n++] = TVector2(-1/3.0,-1); // 10
c49cb542 125 // pad center
126 if ( n != kNofTestPositions ) {
127 AliError("Test on number of test positions failed.");
128 }
129 }
130
131 Int_t n(0);
132
133 AliMpPad previous(AliMpPad::Invalid());
134
135 for ( Int_t i = 0; i < kNofTestPositions; ++i )
136 {
137 if ( i == centerIndex && !includeSelf )
138 {
139 if ( includeVoid )
140 {
141 previous = AliMpPad::Invalid();
142 neighbours.Add(new AliMpPad(previous));
143 ++n;
144 }
145 continue;
146 }
147
148 TVector2 shift = testPositions[i];
149 TVector2 pos = pad.Position();
150 pos += TVector2((pad.Dimensions().X()+kEpsilon)*shift.X(),
151 (pad.Dimensions().Y()+kEpsilon)*shift.Y());
152
153
154 AliMpPad p = PadByPosition(pos,kFALSE);
155
156 if ( !p.IsValid() && !includeVoid ) continue;
157
158 if ( p != previous || !previous.IsValid() )
159 {
160 previous = p;
161 neighbours.Add(new AliMpPad(p));
162 ++n;
163 }
164 }
165 return n;
166}
167
5f91c9e8 168//
169// public methods
170//
171
3635f34f 172//_____________________________________________________________________________
173Bool_t
168e9c4d 174AliMpVSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
3635f34f 175{
176 /// Default implementation. Must be overwritten if can be made more
177 /// efficient in the child class
178
168e9c4d 179 return ( PadByIndices(ix, iy, kFALSE) != AliMpPad::Invalid() );
3635f34f 180}
181
182//_____________________________________________________________________________
183Bool_t
168e9c4d 184AliMpVSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
3635f34f 185{
186 /// Default implementation. Must be overwritten if can be made more
187 /// efficient in the child class
188
168e9c4d 189 return (PadByLocation(manuId, manuChannel, kFALSE) != AliMpPad::Invalid());
3635f34f 190}
191
192//_____________________________________________________________________________
193Bool_t
194AliMpVSegmentation::HasMotifPosition(Int_t manuId) const
195{
196 /// Default implementation to know if we hold a given manu
197 return ( MotifPosition(manuId) != 0x0 );
198}
199
200