]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpRowSegmentLSpecial.cxx
Updated comments for Doxygen - corrected warnings
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentLSpecial.cxx
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: AliMpRowSegmentLSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
18 // Category: sector
19 //
20 // Class AliMpRowSegmentLSpecial
21 // -----------------------------
22 // Class describing a special inner row segment composed of the 
23 // pad rows.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26
27 #include "AliMpRowSegmentLSpecial.h"
28 #include "AliMpRow.h"
29 #include "AliMpPadRow.h"
30 #include "AliMpVPadRowSegment.h"
31 #include "AliMpMotif.h"
32 #include "AliMpMotifType.h"
33 #include "AliMpMotifMap.h"
34 #include "AliMpMotifPosition.h"
35 #include "AliMpConstants.h"
36
37 #include "AliLog.h"
38
39 #include <Riostream.h>
40
41 /// \cond CLASSIMP
42 ClassImp(AliMpRowSegmentLSpecial)
43 /// \endcond
44
45 //______________________________________________________________________________
46 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial(AliMpRow* row, Double_t offsetX)
47   : AliMpVRowSegmentSpecial(row, offsetX)
48 {
49 /// Standard constructor
50 }
51
52 //______________________________________________________________________________
53 AliMpRowSegmentLSpecial::AliMpRowSegmentLSpecial() 
54   : AliMpVRowSegmentSpecial()
55 {
56 /// Default constructor
57 }
58
59 //______________________________________________________________________________
60 AliMpRowSegmentLSpecial::~AliMpRowSegmentLSpecial() 
61 {
62 /// Destructor  
63 }
64
65 //
66 // private methods  
67 //
68
69 //______________________________________________________________________________
70 AliMpVPadRowSegment*  
71 AliMpRowSegmentLSpecial::FindMostRightPadRowSegment(Int_t motifPositionId) const
72 {
73 /// Find the most right pad row segment with this motifPositionId.
74
75   AliMpVPadRowSegment* found = 0;
76
77   for (Int_t i=0; i<GetNofPadRows(); i++) {
78     AliMpPadRow* padRow = GetPadRow(i);    
79
80     for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { 
81       AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
82
83       if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
84            (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
85            
86         found = padRowSegment;  
87     }
88   }
89
90   return found;         
91 }
92
93 //
94 // protected methods  
95 //
96
97 //______________________________________________________________________________
98 TVector2 AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId) const
99 {
100 /// Return the coordinates of the motif specified with
101 /// the given position identifier.                                           \n
102 /// !! Applicable only for motifs that have their most down pad in
103 /// this row segment.
104
105   // Find the first (left, down) pad row segment with this motifPositionId.
106   AliMpVPadRowSegment* downPadRowSegment 
107     = FindPadRowSegment(motifPositionId);
108   AliMpVPadRowSegment* rightPadRowSegment 
109     = FindMostRightPadRowSegment(motifPositionId);
110   
111   // Check if the motifPositionId is present 
112   if (!downPadRowSegment || !rightPadRowSegment) {
113     AliErrorStream() << "Outside row segment region" << endl;
114     return 0;
115   }
116
117   // Check if both pad row segments have the same motif 
118   if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
119     AliFatal("Outside row segment region");
120     return 0;
121   }
122
123   // Get position of found row segment
124   Double_t x = rightPadRowSegment->RightBorderX();       
125   Double_t y = GetRow()->LowBorderY()  ;   
126   
127   for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
128     y += GetPadRow(i)->HalfSizeY()*2.;
129     
130   // Add motifs dimensions
131   x -= downPadRowSegment->GetMotif()->Dimensions().X();
132   y += downPadRowSegment->GetMotif()->Dimensions().Y();
133   
134   return TVector2(x, y);
135 }
136
137 //
138 // public methods  
139 //
140
141 //______________________________________________________________________________
142 void AliMpRowSegmentLSpecial::UpdatePadsOffset()
143 {
144 /// Set low indices limit to the pad offset calculated
145 /// from the neighbour normal segment.
146
147   // Get the neighbour row segment
148   // (the first normal segment)
149   AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
150
151   // Get the the pads offset of the neighbour row segment
152   // (the first normal segment)
153   AliMpIntPair offset = neighbour->GetLowIndicesLimit();
154   
155   // Find max nof pads in a row
156   Int_t maxNofPads = MaxNofPadsInRow();
157
158   // Set limits
159   SetLowIndicesLimit(offset - AliMpIntPair(maxNofPads, 0));
160
161   // Reset limits in the neighbour row segment
162   // (pad offset is now included in the special segment)  
163   neighbour->SetLowIndicesLimit(
164     AliMpIntPair(0, neighbour->GetLowIndicesLimit().GetSecond()));
165 }
166
167 //______________________________________________________________________________
168 Double_t  AliMpRowSegmentLSpecial::LeftBorderX() const
169 {
170 /// Return the x coordinate of the left row segment border
171 /// in the global coordinate system.
172
173   Double_t leftBorder = DBL_MAX;
174   for (Int_t i=0; i<GetNofPadRows(); i++) {
175     AliMpPadRow* padRow = GetPadRow(i);
176     Double_t border 
177       = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
178       
179     if (border < leftBorder) leftBorder =  border;
180   }  
181   
182   return leftBorder;
183 }
184
185 //______________________________________________________________________________
186 Double_t  AliMpRowSegmentLSpecial::RightBorderX() const
187 {
188 /// Returns the x coordinate of the right row segment border
189 /// in the global coordinate system.
190
191   Double_t sameBorder = GetOffsetX();
192
193   // Consistence check  
194   Double_t rightBorder = -DBL_MAX;
195   for (Int_t i=0; i<GetNofPadRows(); i++) {
196     AliMpPadRow* padRow = GetPadRow(i);
197     Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
198     if (border > rightBorder) rightBorder =  border;
199   }  
200
201   if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04)  {
202     AliErrorStream() << "WrongBorder" << endl;
203     return sameBorder;
204   }  
205   
206   return rightBorder;
207 }
208
209 //______________________________________________________________________________
210 TVector2 AliMpRowSegmentLSpecial::Position() const
211 {
212 /// Return the position of the row segment centre.
213 /// The centre is defined as the centre of the rectangular
214 /// row segment envelope.
215
216   Double_t x = GetOffsetX() - Dimensions().X();             
217   Double_t y = GetRow()->Position().Y();  
218     
219   return TVector2(x, y);   
220 }
221
222 #include <Riostream.h>
223 //______________________________________________________________________________
224 Int_t AliMpRowSegmentLSpecial::SetIndicesToMotifPosition(Int_t i, 
225                                          const AliMpIntPair& indices)
226 {
227 /// Set global indices to i-th motif position and returns next index in x.
228
229   // Get motif position
230   AliMpMotifPosition* motifPosition
231     = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
232
233   // Low limit
234   AliMpIntPair low 
235     = AliMpIntPair(GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex(), 
236                indices.GetSecond())
237       + FindRelativeLowIndicesOf(GetMotifPositionId(i));
238             
239   if (! motifPosition->GetHighIndicesLimit().IsValid()) {   
240      motifPosition->SetLowIndicesLimit(low);
241   } 
242   else {
243     if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
244       motifPosition->SetLowIndicesLimit(
245                         AliMpIntPair(low.GetFirst(),
246                                  motifPosition->GetLowIndicesLimit().GetSecond()));
247
248     if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
249        motifPosition->SetLowIndicesLimit(
250                          AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
251                                   low.GetSecond()));
252   }
253              
254   // High limit      
255   AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
256   AliMpIntPair high 
257     = motifPosition->GetLowIndicesLimit()
258       + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);  
259                 
260   motifPosition->SetHighIndicesLimit(high);
261
262   // Increment index only if last motif position is processed 
263   if (i != GetNofMotifs()-1) 
264     return indices.GetFirst();
265     //return 0;
266   else
267     return indices.GetFirst() + MaxNofPadsInRow();  
268     //return MaxNofPadsInRow();  
269 }
270 //______________________________________________________________________________
271 void AliMpRowSegmentLSpecial::SetGlobalIndices(AliMpRow* rowBefore)
272 {
273 /// Set indices limits
274 /// The limits are defined as the limits of the smallest rectangle which
275 /// includes all pads of this special row segment.
276
277   // Low ix
278   Int_t ixl = GetLowIndicesLimit().GetFirst() + AliMpConstants::StartPadIndex();
279       // the pads offset was already defined by Reader
280
281   // High ix
282   Int_t ixh = ixl + MaxNofPadsInRow() - 1;
283
284   // Low iy
285   Int_t iyl = AliMpConstants::StartPadIndex();
286   if (rowBefore) {
287     //if (constPadSizeDirection == kY) {
288       iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
289     //} 
290     /*
291     else {
292       AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);   
293       AliMpMotifPosition* motPos =  rowBefore->FindMotifPosition(seg, ixl);
294       if (!motPos) 
295         Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
296       iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
297     }
298     */
299   }  
300
301   // High iy
302   Int_t iyh = iyl + GetNofPadRows() - 1;
303   
304   SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
305   SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
306 }  
307
308
309
310