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