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