]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpRowSegmentLSpecial.cxx
Extendened class description to include at least 5 subsequent lines required by rule...
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentLSpecial.cxx
1 // $Id$
2 // Category: sector
3 //
4 // Class AliMpRowSegmentLSpecial
5 // -----------------------------
6 // Class describing a special inner row segment composed of the 
7 // pad rows.
8 // Included in AliRoot: 2003/05/02
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
10
11 #include <TError.h>
12
13 #include "AliMpRowSegmentLSpecial.h"
14 #include "AliMpRow.h"
15 #include "AliMpPadRow.h"
16 #include "AliMpVPadRowSegment.h"
17 #include "AliMpMotif.h"
18 #include "AliMpMotifType.h"
19 #include "AliMpMotifMap.h"
20 #include "AliMpMotifPosition.h"
21 #include "AliMpConstants.h"
22
23 ClassImp(AliMpRowSegmentLSpecial)
24
25 //______________________________________________________________________________
26 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
27   : AliMpVRowSegmentSpecial(row, offsetX)
28 {
29 // 
30 }
31
32 //______________________________________________________________________________
33 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial() 
34   : AliMpVRowSegmentSpecial()
35 {
36 //
37 }
38
39 //______________________________________________________________________________
40 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial() 
41 {
42 //  
43 }
44
45 //
46 // private methods  
47 //
48
49 //______________________________________________________________________________
50 AliMpVPadRowSegment*  
51 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
52 {
53 // Find the most right pad row segment with this motifPositionId.
54 // ---
55
56   AliMpVPadRowSegment* found = 0;
57
58   for (Int_t i=0; i<GetNofPadRows(); i++) {
59     AliMpPadRow* padRow = GetPadRow(i);    
60
61     for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { 
62       AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
63
64       if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
65            (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
66            
67         found = padRowSegment;  
68     }
69   }
70
71   return found;         
72 }
73
74 //
75 // protected methods  
76 //
77
78 //______________________________________________________________________________
79 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
80 {
81 // Returns the coordinates of the motif specified with
82 // the given position identifier.
83 // !! Applicable only for motifs that have their most down pad in
84 // this row segment.
85 // ---
86
87   // Find the first (left, down) pad row segment with this motifPositionId.
88   AliMpVPadRowSegment* downPadRowSegment 
89     = FindPadRowSegment(motifPositionId);
90   AliMpVPadRowSegment* rightPadRowSegment 
91     = FindMostRightPadRowSegment(motifPositionId);
92   
93   // Check if the motifPositionId is present 
94   if (!downPadRowSegment || !rightPadRowSegment) {
95     Error("MotifCenter", "Outside row segment region");
96     return 0;
97   }
98
99   // Check if both pad row segments have the same motif 
100   if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
101     Fatal("MotifCenter", "Outside row segment region");
102     return 0;
103   }
104
105   // Get position of found row segment
106   Double_t x = rightPadRowSegment->RightBorderX();       
107   Double_t y = GetRow()->LowBorderY()  ;   
108   
109   for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
110     y += GetPadRow(i)->HalfSizeY()*2.;
111     
112   // Add motifs dimensions
113   x -= downPadRowSegment->GetMotif()->Dimensions().X();
114   y += downPadRowSegment->GetMotif()->Dimensions().Y();
115   
116   return TVector2(x, y);
117 }
118
119 //
120 // public methods  
121 //
122
123 //______________________________________________________________________________
124 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
125 {
126 // Sets low indices limit to the pad offset calculated
127 // from the neighbour normal segment.
128 // ---
129
130   // Get the neighbour row segment
131   // (the first normal segment)
132   AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
133
134   // Get the the pads offset of the neighbour row segment
135   // (the first normal segment)
136   AliMpIntPair offset = neighbour->GetLowIndicesLimit();
137   
138   // Find max nof pads in a row
139   Int_t maxNofPads = MaxNofPadsInRow();
140
141   // Set limits
142   SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
143
144   // Reset limits in the neighbour row segment
145   // (pad offset is now included in the special segment)  
146   neighbour->SetLowIndicesLimit(
147     AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
148 }
149
150 //______________________________________________________________________________
151 Double_t  AliMpRowSegmentLSpecial::LeftBorderX() const
152 {
153 // Returns the x coordinate of the left row segment border
154 // in global coordinate system.
155 // ---
156
157   Double_t leftBorder = DBL_MAX;
158   for (Int_t i=0; i<GetNofPadRows(); i++) {
159     AliMpPadRow* padRow = GetPadRow(i);
160     Double_t border 
161       = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
162       
163     if (border < leftBorder) leftBorder =  border;
164   }  
165   
166   return leftBorder;
167 }
168
169 //______________________________________________________________________________
170 Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
171 {
172 // Returns the x coordinate of the right row segment border
173 // in global coordinate system.
174 // ---
175
176   Double_t sameBorder = GetOffsetX();
177
178   // Consistence check  
179   Double_t rightBorder = -DBL_MAX;
180   for (Int_t i=0; i<GetNofPadRows(); i++) {
181     AliMpPadRow* padRow = GetPadRow(i);
182     Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
183     if (border > rightBorder) rightBorder =  border;
184   }  
185
186   if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04)  {
187     Error("RightBorderX", "WrongBorder");
188     return sameBorder;
189   }  
190   
191   return rightBorder;
192 }
193
194 //______________________________________________________________________________
195 TVector2 AliMpRowSegmentLSpecial::Position() const
196 {
197 // Returns the position of the row segment centre.
198 // The centre is defined as the centre of the rectangular
199 // row segment envelope.
200 // ---
201
202   Double_t x = GetOffsetX() - Dimensions().X();             
203   Double_t y = GetRow()->Position().Y();  
204     
205   return TVector2(x, y);   
206 }
207
208 //______________________________________________________________________________
209 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, 
210                                          const AliMpIntPair& indices)
211 {
212 // Sets global indices to i-th motif position and returns next index in x.
213 // ---
214
215   // Get motif position
216   AliMpMotifPosition* motifPosition
217     = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
218
219   // Low limit
220   AliMpIntPair low 
221     = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(), 
222                indices.GetSecond())
223       + FindRelativeLowIndicesOf(GetMotifPositionId(i));
224             
225   if (! motifPosition->GetHighIndicesLimit().IsValid()) {   
226      motifPosition->SetLowIndicesLimit(low);
227   } 
228   else {
229     if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
230       motifPosition->SetLowIndicesLimit(
231                         AliMpIntPair(low.GetFirst(),
232                                  motifPosition->GetLowIndicesLimit().GetSecond()));
233
234     if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
235        motifPosition->SetLowIndicesLimit(
236                          AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
237                                   low.GetSecond()));
238   }
239              
240   // High limit      
241   AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
242   AliMpIntPair high 
243     = motifPosition->GetLowIndicesLimit()
244       + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);            
245   motifPosition->SetHighIndicesLimit(high);
246   
247   // Increment index only if last motif position is processed 
248   if (i != GetNofMotifs()-1) 
249     return indices.GetFirst();
250     //return 0;
251   else
252     return indices.GetFirst() + MaxNofPadsInRow();  
253     //return MaxNofPadsInRow();  
254 }
255
256
257