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