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"
40 #include "TObjArray.h"
43 ClassImp(AliMpVSegmentation)
46 //_____________________________________________________________________________
47 AliMpVSegmentation::AliMpVSegmentation()
50 /// Default constructor
53 //_____________________________________________________________________________
54 AliMpVSegmentation::~AliMpVSegmentation()
59 //_____________________________________________________________________________
61 AliMpVSegmentation::GetNeighbours(const AliMpPad& pad,
62 TObjArray& neighbours,
64 Bool_t includeVoid) const
66 /// Returns the list of neighbours of pad
67 /// testPositions are the positions (L,T,R,B) relative to pad's center (O)
68 /// were we'll try to get a neighbouring pad, by getting a little
69 /// bit outside the pad itself.
70 /// Note that it's not symmetric as we assume that pad density
71 /// can always decrease when going from left to right (or from bottom to top)
81 /// The order in which we actually test the positions has some importance,
82 /// i.e. when using this information to compute status map later on. Here's
94 static Double_t shiftx[11] = { 0, -1, -1, -1, -1, 0, 1, 1, 1, 1/3.0, -1/3.0 };
95 static Double_t shifty[11] = { 0, -1, -1/3.0, 1/3.0, 1, 1, 1, 0, -1, -1, -1 };
97 static const Int_t kNofTestPositions(11);
98 static const Double_t kEpsilon(AliMpConstants::LengthTolerance()*2.0);
99 static Int_t centerIndex(-1);
103 neighbours.SetOwner(kTRUE);
105 if ( ! pad.IsValid() ) return 0;
109 AliMpPad previous(AliMpPad::Invalid());
111 for ( Int_t i = 0; i < kNofTestPositions; ++i )
113 if ( i == centerIndex && !includeSelf )
117 previous = AliMpPad::Invalid();
118 neighbours.Add(new AliMpPad(previous));
125 = PadByPosition(pad.GetPositionX() + ( pad.GetDimensionX() + kEpsilon )*shiftx[i],
126 pad.GetPositionY() + ( pad.GetDimensionY() + kEpsilon )*shifty[i],
129 if ( ! p.IsValid() && ! includeVoid ) continue;
131 if ( p != previous || ! previous.IsValid() )
134 neighbours.Add(new AliMpPad(p));
145 //_____________________________________________________________________________
147 AliMpVSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
149 /// Default implementation. Must be overwritten if can be made more
150 /// efficient in the child class
152 return ( PadByIndices(ix, iy, kFALSE) != AliMpPad::Invalid() );
155 //_____________________________________________________________________________
157 AliMpVSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
159 /// Default implementation. Must be overwritten if can be made more
160 /// efficient in the child class
162 return (PadByLocation(manuId, manuChannel, kFALSE) != AliMpPad::Invalid());
165 //_____________________________________________________________________________
167 AliMpVSegmentation::HasMotifPosition(Int_t manuId) const
169 /// Default implementation to know if we hold a given manu
170 return ( MotifPosition(manuId) != 0x0 );