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.4 2005/08/26 15:43:36 ivana Exp $
20 // Class AliMpVSegmentation
21 // ------------------------
22 // The abstract base class for the segmentation.
23 // Provides methods related to pads:
24 // conversion between pad indices, pad location, pad position;
25 // finding pad neighbour.
27 // Included in AliRoot: 2003/05/02
28 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
30 #include "AliMpVSegmentation.h"
31 #include "AliMpConstants.h"
33 ClassImp(AliMpVSegmentation)
35 //_____________________________________________________________________________
36 AliMpVSegmentation::AliMpVSegmentation()
39 /// Default constructor
42 //_____________________________________________________________________________
43 AliMpVSegmentation::~AliMpVSegmentation()
52 //_____________________________________________________________________________
53 AliMpPadPair AliMpVSegmentation::FindPads(const TVector2& position1,
54 const TVector2& position2) const
56 /// Return a pair of pads with specified position.
57 /// If both pads are identical, the second pad in pair is set to invalid.
59 AliMpPad pad1 = PadByPosition(position1, false);
60 AliMpPad pad2 = PadByPosition(position2, false);
62 if (pad1 == pad2) pad2 = AliMpPad::Invalid();
64 return AliMpPadPair(pad1, pad2);
71 //_____________________________________________________________________________
72 AliMpPadPair AliMpVSegmentation::PadsUp(const AliMpPad& pad) const
74 /// Return a pair of pads neighbouring up to the specified pad.
75 /// If there is only one neighbouring pad,
76 /// the second pad in pair is invalid.
79 = pad.Position()+ TVector2((-1.)*AliMpConstants::LengthStep(),
80 pad.Dimensions().Y()+ AliMpConstants::LengthStep());
82 = pad.Position()+ TVector2(AliMpConstants::LengthStep(),
83 pad.Dimensions().Y()+ AliMpConstants::LengthStep());
85 return FindPads(position1, position2);
88 //_____________________________________________________________________________
89 AliMpPadPair AliMpVSegmentation::PadsDown(const AliMpPad& pad) const
91 /// Return a pair of pads neighbouring down to the specified pad.
92 /// If there is only one neighbouring pad,
93 /// the second pad in pair is invalid.
96 = pad.Position()- TVector2(AliMpConstants::LengthStep(),
97 pad.Dimensions().Y()+ AliMpConstants::LengthStep());
100 = pad.Position()- TVector2((-1.)*AliMpConstants::LengthStep(),
101 pad.Dimensions().Y()+ AliMpConstants::LengthStep());
103 return FindPads(position1, position2);
106 //_____________________________________________________________________________
107 AliMpPadPair AliMpVSegmentation::PadsLeft(const AliMpPad& pad) const
109 /// Return a pair of pads neighbouring left to the specified pad.
110 /// If there is only one neighbouring pad,
111 /// the second in pair is invalid.
114 = pad.Position() - TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
115 AliMpConstants::LengthStep());
117 = pad.Position() - TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
118 (-1.)*AliMpConstants::LengthStep());
120 return FindPads(position1, position2);
123 //_____________________________________________________________________________
124 AliMpPadPair AliMpVSegmentation::PadsRight(const AliMpPad& pad) const
126 /// Return a pair of pads neighbouring right to the specified pad.
127 /// If there is only one neighbouring pad,
128 /// the second in pair is invalid.
131 = pad.Position() + TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
132 (-1.)*AliMpConstants::LengthStep());
134 = pad.Position() + TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
135 AliMpConstants::LengthStep());
137 return FindPads(position1, position2);