]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpPadRow.cxx
- Reordering includes from most specific to more general ones
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPadRow.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: AliMpPadRow.cxx,v 1.7 2006/03/17 11:38:43 ivana Exp $
18 // Category: sector
19 //
20 // Class AliMpPadRow
21 // ------------------
22 // Class describing a pad row composed of the pad row segments.
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
25
26 #include "AliMpPadRow.h"
27 #include "AliMpPadRowLSegment.h"
28 #include "AliMpPadRowRSegment.h"
29
30 #include "AliLog.h"
31
32 #include <Riostream.h>
33
34 ClassImp(AliMpPadRow)
35
36 //_____________________________________________________________________________
37 AliMpPadRow::AliMpPadRow(AliMpXDirection direction) 
38   : TObject(),
39     fDirection(direction), 
40     fID(0) 
41 {
42 /// Standard constructor
43 }
44
45 //_____________________________________________________________________________
46 AliMpPadRow::AliMpPadRow() 
47   : TObject(),
48     fDirection(kLeft), 
49     fID(0)
50 {
51 /// Default constructor
52 }
53
54 //_____________________________________________________________________________
55 AliMpPadRow::~AliMpPadRow() 
56 {
57 /// Destructor  
58
59   for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
60     delete fSegments[i];
61 }
62
63 //
64 // private methods
65 //
66
67 //_____________________________________________________________________________
68 Double_t AliMpPadRow::CurrentBorderX() const
69 {
70 /// Return the left/right x border 
71 /// (depending on the direction which the row segments are filled in).
72
73   if (GetNofPadRowSegments() == 0)
74       return fOffsetX;
75   else 
76     if (fDirection == kLeft)
77       return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
78     else  
79       return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
80 }
81
82 //
83 // public methods
84 //
85
86 //_____________________________________________________________________________
87 AliMpVPadRowSegment* 
88 AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
89                               Int_t nofPads)
90 {
91 /// Add a pad row segment.
92
93   AliMpVPadRowSegment* padRowSegment = 0;
94
95   if (fDirection == kLeft) {
96     padRowSegment 
97       = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
98   }    
99   else  {
100     padRowSegment 
101       = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
102   }     
103
104   // Set pad row segment offset
105   padRowSegment->SetOffsetX(CurrentBorderX());
106
107   // Adds the pad row segment
108 #ifdef WITH_STL
109   fSegments.push_back(padRowSegment);
110 #endif
111
112 #ifdef WITH_ROOT
113   fSegments.Add(padRowSegment);
114 #endif
115   
116   return padRowSegment;
117 }  
118   
119 //_____________________________________________________________________________
120 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
121 {
122 /// Find the row segment for the specified x position;
123 /// return 0 if no row segment is found.
124
125   for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
126     AliMpVPadRowSegment* rs = GetPadRowSegment(i);
127     if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
128       return rs;
129   }
130   
131   return 0;    
132 }    
133
134 //_____________________________________________________________________________
135 Double_t  AliMpPadRow::HalfSizeY() const
136 {
137 /// Return the half size in y
138
139   return GetPadRowSegment(0)->HalfSizeY();
140 }
141
142 //_____________________________________________________________________________
143 void  AliMpPadRow::SetID(Int_t id)
144 {
145 /// Set the ID.
146
147   fID = id;
148 }    
149
150 //_____________________________________________________________________________
151 void  AliMpPadRow::SetOffsetX(Double_t offsetX)
152 {
153 /// Set the x offset.
154
155   fOffsetX = offsetX;
156 }    
157
158 //_____________________________________________________________________________
159 Int_t AliMpPadRow::GetID() const 
160 {
161 /// Return the pad row ID.
162
163   return fID;
164 }  
165
166 //_____________________________________________________________________________
167 Int_t AliMpPadRow::GetNofPadRowSegments() const 
168 {
169 /// Return the number of pad row segments.
170
171 #ifdef WITH_STL
172   return fSegments.size();
173 #endif
174
175 #ifdef WITH_ROOT
176   return fSegments.GetEntriesFast();
177 #endif
178 }  
179
180 //_____________________________________________________________________________
181 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const 
182 {
183 /// Return the pad row segment with the specified number.
184
185   if (i<0 || i>=GetNofPadRowSegments()) {
186     AliWarningStream() << "Index outside range" << endl;
187     return 0;
188   }
189   
190 #ifdef WITH_STL
191   return fSegments[i];  
192 #endif
193
194 #ifdef WITH_ROOT
195   return (AliMpVPadRowSegment*)fSegments[i];  
196 #endif
197 }
198
199 //_____________________________________________________________________________
200 Int_t AliMpPadRow::GetNofPads() const 
201 {
202 /// Return the number of pads in this pad row.
203
204   Int_t nofPads=0;
205   for (Int_t i=0; i<GetNofPadRowSegments(); i++)
206     nofPads += GetPadRowSegment(i)->GetNofPads();
207
208   return nofPads;
209 }  
210