1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpVSegmentation.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $
20 //-----------------------------------------------------------------------------
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.
28 // Included in AliRoot: 2003/05/02
29 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
30 // Laurent Aphecetche, SUBATECH
31 //-----------------------------------------------------------------------------
34 #include "AliMpVSegmentation.h"
35 #include "AliMpArea.h"
36 #include "AliMpConstants.h"
41 #include "TObjArray.h"
44 ClassImp(AliMpVSegmentation)
47 //_____________________________________________________________________________
48 AliMpVSegmentation::AliMpVSegmentation()
51 /// Default constructor
54 //_____________________________________________________________________________
55 AliMpVSegmentation::~AliMpVSegmentation()
60 //_____________________________________________________________________________
62 AliMpVSegmentation::GetNeighbours(const AliMpPad& pad,
63 TObjArray& neighbours,
65 Bool_t includeVoid) const
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);
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
77 // can always decrease when going from left to right (or from bottom to top)
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
100 neighbours.SetOwner(kTRUE);
102 if (!pad.IsValid()) return 0;
106 testPositions = new TVector2[kNofTestPositions];
110 testPositions[n++] = TVector2(0,0); // O (pad center)
111 // then left column (L), starting from bottom
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
117 testPositions[n++] = TVector2(0,1); // 5
118 // right column (R), starting from top
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
126 if ( n != kNofTestPositions ) {
127 AliError("Test on number of test positions failed.");
133 AliMpPad previous(AliMpPad::Invalid());
135 for ( Int_t i = 0; i < kNofTestPositions; ++i )
137 if ( i == centerIndex && !includeSelf )
141 previous = AliMpPad::Invalid();
142 neighbours.Add(new AliMpPad(previous));
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());
154 AliMpPad p = PadByPosition(pos,kFALSE);
156 if ( !p.IsValid() && !includeVoid ) continue;
158 if ( p != previous || !previous.IsValid() )
161 neighbours.Add(new AliMpPad(p));
172 //_____________________________________________________________________________
174 AliMpVSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
176 /// Default implementation. Must be overwritten if can be made more
177 /// efficient in the child class
179 return ( PadByIndices(ix, iy, kFALSE) != AliMpPad::Invalid() );
182 //_____________________________________________________________________________
184 AliMpVSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
186 /// Default implementation. Must be overwritten if can be made more
187 /// efficient in the child class
189 return (PadByLocation(manuId, manuChannel, kFALSE) != AliMpPad::Invalid());
192 //_____________________________________________________________________________
194 AliMpVSegmentation::HasMotifPosition(Int_t manuId) const
196 /// Default implementation to know if we hold a given manu
197 return ( MotifPosition(manuId) != 0x0 );