]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 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$ | |
63bcb3c3 | 17 | // $MpId: AliMpSlatSegmentation.cxx,v 1.7 2006/03/02 16:35:20 ivana Exp $ |
dee1d5f1 | 18 | |
1964cd2e | 19 | // Caution !! |
20 | // Implementation note. | |
21 | // The position(s) used in the interface are supposed to be relative | |
22 | // to the slat center (AliMpSlat::Position()), whereas internally | |
23 | // the x,y are relative to bottom-left corner. | |
24 | ||
dee1d5f1 | 25 | #include "AliMpSlatSegmentation.h" |
26 | ||
27 | #include "AliLog.h" | |
1964cd2e | 28 | #include "AliMpArea.h" |
dee1d5f1 | 29 | #include "AliMpConnection.h" |
30 | #include "AliMpMotif.h" | |
31 | #include "AliMpMotifPosition.h" | |
32 | #include "AliMpMotifType.h" | |
33 | #include "AliMpPCB.h" | |
34 | #include "AliMpSlat.h" | |
35 | #include "AliMpSlatPadIterator.h" | |
36 | ||
37 | ClassImp(AliMpSlatSegmentation) | |
38 | ||
39 | //_____________________________________________________________________________ | |
40 | AliMpSlatSegmentation::AliMpSlatSegmentation() | |
41 | : AliMpVSegmentation(), | |
42 | fkSlat(0) | |
43 | { | |
44 | // | |
45 | // Default ctor. Not to be used really. | |
46 | // | |
47 | AliDebug(1,Form("this=%p Empty ctor",this)); | |
48 | } | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat) | |
52 | : AliMpVSegmentation(), | |
53 | fkSlat(slat) | |
54 | { | |
55 | // | |
56 | // Normal ctor. | |
57 | // | |
58 | AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat)); | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMpSlatSegmentation::~AliMpSlatSegmentation() | |
63 | { | |
64 | // | |
65 | // Dtor (empty). | |
66 | // | |
0b91d34d | 67 | // Int_t i(0);//just to be able to put a breakpoint in gdb |
dee1d5f1 | 68 | AliDebug(1,Form("this=%p",this)); |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | AliMpVPadIterator* | |
73 | AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const | |
74 | { | |
75 | // | |
76 | // Returns an iterator to loop over the pad contained within given area. | |
77 | // | |
1964cd2e | 78 | AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions()); |
63bcb3c3 | 79 | AliDebug(3,Form("Converted input area wrt to slat center : " |
80 | "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : " | |
81 | "%7.2f,%7.2f->%7.2f,%7.2f ", | |
82 | area.LeftBorder(),area.DownBorder(), | |
83 | area.RightBorder(),area.UpBorder(), | |
84 | a.LeftBorder(),a.DownBorder(), | |
85 | a.RightBorder(),a.UpBorder())); | |
86 | ||
1964cd2e | 87 | return new AliMpSlatPadIterator(fkSlat,a); |
dee1d5f1 | 88 | } |
89 | ||
63bcb3c3 | 90 | //_____________________________________________________________________________ |
91 | TVector2 | |
92 | AliMpSlatSegmentation::Dimensions() const | |
93 | { | |
94 | return Slat()->Dimensions(); | |
95 | } | |
96 | ||
97 | //_____________________________________________________________________________ | |
98 | void | |
99 | AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const | |
100 | { | |
101 | Slat()->GetAllMotifPositionsIDs(ecn); | |
102 | } | |
103 | ||
1faed5a9 | 104 | //_____________________________________________________________________________ |
105 | const char* | |
106 | AliMpSlatSegmentation::GetName() const | |
107 | { | |
108 | TString name("SlatSegmentation"); | |
109 | if ( fkSlat) | |
110 | { | |
111 | name += "."; | |
112 | name += fkSlat->GetName(); | |
113 | } | |
114 | return name.Data(); | |
115 | } | |
116 | ||
dee1d5f1 | 117 | //_____________________________________________________________________________ |
118 | Bool_t | |
119 | AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const | |
120 | { | |
121 | // | |
122 | // Test if this slat has a pad located at the position referenced | |
123 | // by the integer indices. | |
124 | // | |
125 | ||
126 | return PadByIndices(indices,kFALSE) != AliMpPad::Invalid(); | |
127 | } | |
128 | ||
129 | //_____________________________________________________________________________ | |
130 | Int_t | |
131 | AliMpSlatSegmentation::MaxPadIndexX() | |
132 | { | |
133 | // | |
134 | // Returns the value of the largest pad index in x-direction. | |
135 | // | |
136 | ||
16e8fffd | 137 | return fkSlat->GetMaxPadIndexX(); |
dee1d5f1 | 138 | } |
139 | ||
140 | //_____________________________________________________________________________ | |
141 | Int_t | |
142 | AliMpSlatSegmentation::MaxPadIndexY() | |
143 | { | |
144 | // | |
145 | // Returns the value of the largest pad index in y-direction. | |
146 | // | |
147 | ||
148 | return fkSlat->GetMaxNofPadsY()-1; | |
149 | } | |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | AliMpPad | |
153 | AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location, | |
154 | Bool_t warning) const | |
155 | { | |
156 | // | |
157 | // Returns the pad specified by its location, where location is the | |
158 | // pair (ManuID,ManuChannel). | |
159 | // If warning=kTRUE and the pad does not exist, a warning message is | |
160 | // printed. | |
161 | // | |
162 | // AliMpPad::Invalid() is returned if there's no pad at the given location. | |
163 | // | |
164 | Int_t manuID = location.GetFirst(); | |
165 | ||
166 | AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID); | |
167 | ||
168 | if (!motifPos) | |
169 | { | |
170 | if (warning) | |
171 | { | |
172 | AliWarning(Form("Manu ID %d not found in slat %s", | |
173 | manuID, fkSlat->GetID())); | |
1faed5a9 | 174 | } |
175 | return AliMpPad::Invalid(); | |
dee1d5f1 | 176 | } |
177 | AliMpVMotif* motif = motifPos->GetMotif(); | |
178 | AliMpIntPair localIndices = | |
179 | motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond()); | |
180 | ||
181 | if (!localIndices.IsValid()) | |
182 | { | |
183 | if (warning) | |
184 | { | |
185 | AliWarning(Form("The pad number %d doesn't exists", | |
186 | location.GetSecond())); | |
187 | } | |
188 | return AliMpPad::Invalid(); | |
189 | } | |
190 | ||
191 | return AliMpPad(location, | |
192 | motifPos->GlobalIndices(localIndices), | |
1faed5a9 | 193 | motifPos->Position() |
194 | + motif->PadPositionLocal(localIndices) | |
195 | - fkSlat->Position(), | |
196 | motif->GetPadDimensions(localIndices)); | |
dee1d5f1 | 197 | } |
198 | ||
199 | //_____________________________________________________________________________ | |
200 | AliMpPad | |
201 | AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices, | |
202 | Bool_t warning) const | |
203 | { | |
204 | // | |
205 | // Returns the pad specified by its integer indices. | |
206 | // If warning=kTRUE and the pad does not exist, a warning message is | |
207 | // printed. | |
208 | // | |
209 | // AliMpPad::Invalid() is returned if there's no pad at the given location. | |
210 | // | |
211 | // | |
212 | // FIXME: except for the FindMotifPosition below, this method | |
213 | // is exactly as the one in AliMpSectorSegmentation. | |
214 | // See if we can merge them somehow. | |
215 | ||
216 | AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(), | |
217 | indices.GetSecond()); | |
218 | if (!motifPos) | |
219 | { | |
220 | if ( warning ) | |
221 | { | |
222 | AliWarning(Form("No motif found containing pad location (%d,%d)", | |
223 | indices.GetFirst(),indices.GetSecond())); | |
224 | } | |
225 | return AliMpPad::Invalid(); | |
226 | } | |
227 | ||
228 | AliMpVMotif* motif = motifPos->GetMotif(); | |
229 | AliMpMotifType* motifType = motif->GetMotifType(); | |
230 | AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit()); | |
1faed5a9 | 231 | AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices); |
dee1d5f1 | 232 | |
233 | if (!connection) | |
234 | { | |
235 | if ( warning ) | |
236 | { | |
237 | AliWarning(Form("No connection for pad location (%d,%d)", | |
238 | indices.GetFirst(),indices.GetSecond())); | |
1faed5a9 | 239 | } |
240 | return AliMpPad::Invalid(); | |
dee1d5f1 | 241 | } |
242 | ||
243 | return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()), | |
244 | indices, | |
1faed5a9 | 245 | motifPos->Position() |
246 | + motif->PadPositionLocal(localIndices) | |
247 | - fkSlat->Position(), | |
248 | motif->GetPadDimensions(localIndices)); | |
dee1d5f1 | 249 | } |
250 | ||
251 | //_____________________________________________________________________________ | |
252 | AliMpPad | |
253 | AliMpSlatSegmentation::PadByPosition(const TVector2& position, | |
254 | Bool_t warning) const | |
255 | { | |
256 | // | |
257 | // Returns the pad specified by its (floating point) position. | |
258 | // If warning=kTRUE and the pad does not exist, a warning message is | |
259 | // printed. | |
260 | // | |
261 | // AliMpPad::Invalid() is returned if there's no pad at the given location. | |
262 | // | |
263 | ||
1964cd2e | 264 | TVector2 blPos(position+fkSlat->Position()); // position relative to |
265 | // bottom-left of the slat. | |
266 | ||
267 | AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y()); | |
dee1d5f1 | 268 | |
269 | if (!motifPos) | |
270 | { | |
271 | if (warning) | |
272 | { | |
1964cd2e | 273 | AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm " |
274 | " outside limits",fkSlat->GetID(), | |
275 | position.X(),position.Y(), | |
276 | blPos.X(),blPos.Y())); | |
dee1d5f1 | 277 | } |
278 | return AliMpPad::Invalid(); | |
279 | } | |
280 | ||
281 | AliMpVMotif* motif = motifPos->GetMotif(); | |
282 | AliMpIntPair localIndices | |
1964cd2e | 283 | = motif->PadIndicesLocal(blPos-motifPos->Position()); |
dee1d5f1 | 284 | |
285 | AliMpConnection* connect = | |
286 | motif->GetMotifType()->FindConnectionByLocalIndices(localIndices); | |
287 | ||
288 | if (!connect) | |
289 | { | |
290 | if (warning) | |
291 | { | |
1faed5a9 | 292 | AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits", |
293 | fkSlat->GetID(),localIndices.GetFirst(), | |
294 | localIndices.GetSecond(),motif->GetID().Data())); | |
dee1d5f1 | 295 | } |
296 | return AliMpPad::Invalid(); | |
297 | } | |
298 | ||
299 | return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()), | |
300 | motifPos->GlobalIndices(localIndices), | |
1faed5a9 | 301 | motifPos->Position() |
302 | + motif->PadPositionLocal(localIndices) | |
303 | - fkSlat->Position(), | |
304 | motif->GetPadDimensions(localIndices)); | |
dee1d5f1 | 305 | } |
306 | ||
63bcb3c3 | 307 | //_____________________________________________________________________________ |
308 | AliMpPlaneType | |
309 | AliMpSlatSegmentation::PlaneType() const | |
310 | { | |
311 | return Slat()->PlaneType(); | |
312 | } | |
313 | ||
314 | //_____________________________________________________________________________ | |
315 | void | |
316 | AliMpSlatSegmentation::Print(Option_t* opt) const | |
317 | { | |
318 | fkSlat->Print(opt); | |
319 | } | |
320 | ||
dee1d5f1 | 321 | //_____________________________________________________________________________ |
322 | const AliMpSlat* | |
323 | AliMpSlatSegmentation::Slat() const | |
324 | { | |
325 | // | |
326 | // Returns the pointer to the referenced slat. | |
327 | // | |
328 | ||
329 | return fkSlat; | |
330 | } |