]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpVSegmentation.cxx
07348161a92546127a09d148f47da48b94246311
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpVSegmentation.cxx
1 // $Id$
2 // Category: basic
3 //
4 // Class AliMpVSegmentation
5 // ------------------------
6 // The abstract base class for the segmentation.
7 // Provides methods related to pads:
8 // conversion between pad indices, pad location, pad position;
9 // finding pad neighbour.
10 //
11 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
12
13 #include "AliMpVSegmentation.h"
14 #include "AliMpConstants.h"
15
16 ClassImp(AliMpVSegmentation)
17
18 //_____________________________________________________________________________
19 AliMpVSegmentation::AliMpVSegmentation() 
20   : TObject()
21 {
22 //
23 }
24
25 //_____________________________________________________________________________
26 AliMpVSegmentation::~AliMpVSegmentation() {
27 // 
28 }
29
30 //
31 // private methods
32 //
33
34 //_____________________________________________________________________________
35 AliMpPadPair AliMpVSegmentation::FindPads(const TVector2& position1, 
36                                           const TVector2& position2) const
37 {
38 // Returns a pair of pads with specified position.
39 // If both pads are identical, the second pad in pair is set to invalid.
40 // ---
41
42   AliMpPad pad1 = PadByPosition(position1, false);
43   AliMpPad pad2 = PadByPosition(position2, false);
44                                      
45   if (pad1 == pad2) pad2 = AliMpPad::Invalid();                              
46
47   return AliMpPadPair(pad1, pad2);
48 }  
49
50 //
51 // public methods
52 //
53
54 //_____________________________________________________________________________
55 AliMpPadPair AliMpVSegmentation::PadsUp(const AliMpPad& pad) const
56 {
57 // Returns a pair of pads neighbouring up to the specified pad.
58 // If there is only one neighbouring pad,
59 // the second pad in pair is invalid.
60 // ---
61
62   TVector2 position1 
63     = pad.Position()+ TVector2((-1.)*AliMpConstants::LengthStep(), 
64                                pad.Dimensions().Y()+ AliMpConstants::LengthStep());
65   TVector2 position2 
66     = pad.Position()+ TVector2(AliMpConstants::LengthStep(), 
67                                pad.Dimensions().Y()+ AliMpConstants::LengthStep());
68                                
69   return FindPads(position1, position2);
70 }
71
72 //_____________________________________________________________________________
73 AliMpPadPair AliMpVSegmentation::PadsDown(const AliMpPad& pad) const
74 {
75 // Returns a pair of pads neighbouring down to the specified pad.
76 // If there is only one neighbouring pad,
77 // the second pad in pair is invalid.
78 // ---
79
80   TVector2 position1 
81     = pad.Position()- TVector2(AliMpConstants::LengthStep(), 
82                                pad.Dimensions().Y()+ AliMpConstants::LengthStep());
83
84   TVector2 position2
85     = pad.Position()- TVector2((-1.)*AliMpConstants::LengthStep(), 
86                                pad.Dimensions().Y()+ AliMpConstants::LengthStep());
87                                      
88   return FindPads(position1, position2);
89 }
90
91 //_____________________________________________________________________________
92 AliMpPadPair AliMpVSegmentation::PadsLeft(const AliMpPad& pad) const
93 {
94 // Returns a pair of pads neighbouring left to the specified pad.
95 // If there is only one neighbouring pad,
96 // the second in pair is invalid.
97 // ---
98
99   TVector2 position1 
100     = pad.Position() - TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
101                                 AliMpConstants::LengthStep()); 
102   TVector2 position2
103     = pad.Position() - TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
104                                 (-1.)*AliMpConstants::LengthStep()); 
105
106   return FindPads(position1, position2);
107 }
108
109 //_____________________________________________________________________________
110 AliMpPadPair AliMpVSegmentation::PadsRight(const AliMpPad& pad) const
111 {
112 // Returns a pair of pads neighbouring right to the specified pad.
113 // If there is only one neighbouring pad,
114 // the second in pair is invalid.
115 // ---
116
117   TVector2 position1 
118     = pad.Position() + TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
119                                 (-1.)*AliMpConstants::LengthStep()); 
120   TVector2 position2
121     = pad.Position() + TVector2(pad.Dimensions().X() + AliMpConstants::LengthStep(),
122                                 AliMpConstants::LengthStep()); 
123                                      
124   return FindPads(position1, position2);
125 }
126