AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpVSegmentation.cxx
Go to the documentation of this file.
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: AliMpVSegmentation.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $
18 // Category: basic
19 
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.
27 //
28 // Included in AliRoot: 2003/05/02
29 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
30 // Laurent Aphecetche, SUBATECH
31 //-----------------------------------------------------------------------------
32 
33 
34 #include "AliMpVSegmentation.h"
35 #include "AliMpArea.h"
36 #include "AliMpConstants.h"
37 
38 #include "AliLog.h"
39 
40 #include "TObjArray.h"
41 
45 
46 //_____________________________________________________________________________
48  : TObject()
49 {
51 }
52 
53 //_____________________________________________________________________________
55 {
57 }
58 
59 //_____________________________________________________________________________
60 Int_t
62  TObjArray& neighbours,
63  Bool_t includeSelf,
64  Bool_t includeVoid) const
65 {
86 
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.};
90 
91  static const Double_t kEpsilon(AliMpConstants::LengthTolerance()*2.0);
92 
93  neighbours.Delete();
94  neighbours.SetOwner(kTRUE);
95 
96  if ( ! pad.IsValid() ) return 0;
97 
98  AliMpPad invalid(AliMpPad::Invalid());
99  AliMpPad *previous = &invalid;
100  Int_t n(0);
101 
102  // consider adding the pad itself
103  if ( includeSelf )
104  {
105  neighbours.Add(new AliMpPad(pad));
106  ++n;
107  }
108  else if ( includeVoid )
109  {
110  neighbours.Add(new AliMpPad(invalid));
111  ++n;
112  }
113 
114  // add the neighbours (only once)
115  for ( Int_t i = 0; i < kNofTestPositions; ++i )
116  {
117 
118  AliMpPad p
119  = PadByPosition(pad.GetPositionX() + ( pad.GetDimensionX() + kEpsilon )*shiftx[i],
120  pad.GetPositionY() + ( pad.GetDimensionY() + kEpsilon )*shifty[i],
121  kFALSE);
122 
123  if ( p.IsValid() && p != *previous )
124  {
125  previous = new AliMpPad(p);
126  neighbours.Add(previous);
127  ++n;
128  }
129  else if ( includeVoid )
130  {
131  neighbours.Add(new AliMpPad(invalid));
132  ++n;
133  }
134 
135  }
136 
137  return n;
138 
139 }
140 
141 //
142 // public methods
143 //
144 
145 //_____________________________________________________________________________
146 Bool_t
147 AliMpVSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
148 {
151 
152  return ( PadByIndices(ix, iy, kFALSE) != AliMpPad::Invalid() );
153 }
154 
155 //_____________________________________________________________________________
156 Bool_t
157 AliMpVSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
158 {
161 
162  return (PadByLocation(manuId, manuChannel, kFALSE) != AliMpPad::Invalid());
163 }
164 
165 //_____________________________________________________________________________
166 Bool_t
168 {
170  return ( MotifPosition(manuId) != 0x0 );
171 }
172 
173 
const Double_t kEpsilon
virtual Bool_t HasMotifPosition(Int_t manuId) const =0
Whether or not we have a given manu.
#define TObjArray
virtual AliMpMotifPosition * MotifPosition(Int_t manuId) const =0
Return the position of a given manu (aka motifPosition)
virtual Bool_t HasPadByIndices(Int_t ix, Int_t iy) const
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
static AliMpPad Invalid()
Return invalid pad.
Definition: AliMpPad.h:57
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static Double_t LengthTolerance()
Return the length precision for tests.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
virtual Bool_t HasPadByLocation(Int_t manuId, Int_t manuChannel) const
Return true if the pad with given location exists.
The abstract base class for the segmentation.
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
virtual Int_t GetNeighbours(const AliMpPad &pad, TObjArray &neighbours, Bool_t includeSelf=kFALSE, Bool_t includeVoid=kFALSE) const =0
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
virtual AliMpPad PadByLocation(Int_t manuId, Int_t manuChannel, Bool_t warning=true) const =0
Find pad by location.
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84