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