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 /// The pad density can only decrease when going from left to right except
71 /// for round slates where it is the opposite.
72 /// The pad density can only decrease when going from bottom to top but
73 /// to be symmetric we also consider the opposite.
74 /// The order in which we actually test the positions has some importance,
75 /// i.e. when using this information to compute status map later on. Here's
87 static const Int_t kNofTestPositions(12);
88 static Double_t shiftx[12] = {-1., -1., -1., -1., -1./3., 1./3., 1., 1., 1., 1., 1./3., -1./3.};
89 static Double_t shifty[12] = {-1., -1./3., 1./3., 1., 1., 1., 1., 1./3., -1./3., -1., -1., -1.};
91 static const Double_t kEpsilon(AliMpConstants::LengthTolerance()*2.0);
94 neighbours.SetOwner(kTRUE);
96 if ( ! pad.IsValid() ) return 0;
98 AliMpPad invalid(AliMpPad::Invalid());
99 AliMpPad *previous = &invalid;
102 // consider adding the pad itself
105 neighbours.Add(new AliMpPad(pad));
108 else if ( includeVoid )
110 neighbours.Add(new AliMpPad(invalid));
114 // add the neighbours (only once)
115 for ( Int_t i = 0; i < kNofTestPositions; ++i )
119 = PadByPosition(pad.GetPositionX() + ( pad.GetDimensionX() + kEpsilon )*shiftx[i],
120 pad.GetPositionY() + ( pad.GetDimensionY() + kEpsilon )*shifty[i],
123 if ( p.IsValid() && p != *previous )
125 previous = new AliMpPad(p);
126 neighbours.Add(previous);
129 else if ( includeVoid )
131 neighbours.Add(new AliMpPad(invalid));
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 );