]>
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$ | |
0f60374b | 17 | // $MpId: AliMpSlat.cxx,v 1.3 2005/10/28 15:25:09 ivana Exp $ |
dee1d5f1 | 18 | |
19 | #include "AliMpSlat.h" | |
20 | ||
21 | #include "AliLog.h" | |
22 | #include "AliMpConnection.h" | |
23 | #include "AliMpMotif.h" | |
24 | #include "AliMpMotifPosition.h" | |
25 | #include "AliMpMotifType.h" | |
26 | #include "AliMpPCB.h" | |
27 | #include "AliMpSlatPadIterator.h" | |
28 | ||
29 | #include "Riostream.h" | |
30 | ||
31 | #include "TArrayI.h" | |
32 | ||
33 | ClassImp(AliMpSlat) | |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliMpSlat::AliMpSlat() | |
37 | : TObject(), | |
38 | fId(""), | |
19b51aad | 39 | fPlaneType(kNonBendingPlane), |
dee1d5f1 | 40 | fDX(0), |
41 | fDY(0), | |
42 | fNofPadsX(0), | |
19b51aad | 43 | fMaxNofPadsY(0), |
44 | fManuMap() | |
dee1d5f1 | 45 | { |
46 | // | |
47 | // Empty ctor. | |
48 | // | |
49 | AliDebug(1,Form("this=%p Empty ctor",this)); | |
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
19b51aad | 53 | AliMpSlat::AliMpSlat(const char* id, AliMpPlaneType bendingOrNonBending) |
dee1d5f1 | 54 | : TObject(), |
55 | fId(id), | |
19b51aad | 56 | fPlaneType(bendingOrNonBending), |
dee1d5f1 | 57 | fDX(0), |
58 | fDY(0), | |
59 | fNofPadsX(0), | |
19b51aad | 60 | fMaxNofPadsY(0), |
0f60374b | 61 | //#ifdef WITH_ROOT |
19b51aad | 62 | fManuMap(kTRUE) |
0f60374b | 63 | //#else |
64 | // fManuMap() | |
65 | //#endif | |
dee1d5f1 | 66 | { |
67 | // | |
68 | // Normal ctor | |
69 | // | |
70 | AliDebug(1,Form("this=%p id=%s",this,id)); | |
71 | } | |
72 | ||
73 | //_____________________________________________________________________________ | |
74 | AliMpSlat::~AliMpSlat() | |
75 | { | |
76 | // | |
77 | // Dtor. | |
78 | // | |
79 | AliDebug(1,Form("this=%p fId=%s",this,fId.Data())); | |
80 | } | |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | void | |
84 | AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList) | |
85 | { | |
86 | // | |
87 | // Adds a PCB to this slat. The manuList speficy the ids of the manu | |
88 | // that compose the PCB. The manuList ordering is important, as the | |
89 | // assumption is that it's ordered counter-clockwise, starting from | |
90 | // the lower-left of the PCB. | |
91 | // | |
92 | Int_t ixOffset = 0; | |
93 | if ( GetSize() ) | |
94 | { | |
95 | ixOffset = GetPCB(GetSize()-1)->Ixmax()+1; | |
96 | } | |
19b51aad | 97 | else |
98 | { | |
99 | ixOffset = pcbType->Ixmin(); | |
100 | } | |
dee1d5f1 | 101 | Double_t xOffset = DX()*2; |
102 | AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset); | |
103 | #ifdef WITH_ROOT | |
104 | fPCBs.AddLast(pcb); | |
105 | #else | |
106 | fPCBs.push_back(pcb); | |
107 | #endif | |
19b51aad | 108 | fDY = TMath::Max(pcb->DY(),fDY); |
dee1d5f1 | 109 | fDX += pcb->DX(); |
110 | fNofPadsX += pcb->GetNofPadsX(); | |
111 | fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY()); | |
112 | for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i ) | |
113 | { | |
114 | AliMpMotifPosition* mp = pcb->GetMotifPosition(i); | |
115 | Int_t manuID = mp->GetID(); | |
116 | // Before inserting a new key, check if it's already there | |
0f60374b | 117 | //#ifdef WITH_ROOT |
19b51aad | 118 | TObject* there = fManuMap.GetValue(manuID); |
dee1d5f1 | 119 | if ( there == 0 ) |
120 | { | |
19b51aad | 121 | fManuMap.Add(manuID,(TObject*)mp); |
dee1d5f1 | 122 | } |
123 | else | |
124 | { | |
125 | AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType->GetID())); | |
126 | } | |
0f60374b | 127 | //#else |
128 | // fManuMap[manuID] = mp; | |
129 | //#endif | |
dee1d5f1 | 130 | } |
19b51aad | 131 | fPosition.Set(DX(),DY()); |
dee1d5f1 | 132 | } |
133 | ||
134 | //_____________________________________________________________________________ | |
135 | TVector2 | |
136 | AliMpSlat::Dimensions() const | |
137 | { | |
138 | // | |
139 | // Returns the half-sizes of the slat. | |
140 | // | |
141 | return TVector2(DX(),DY()); | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | Double_t | |
146 | AliMpSlat::DX() const | |
147 | { | |
148 | // | |
149 | // Returns the x-half-size of the slat. | |
150 | // | |
151 | return fDX; | |
152 | } | |
153 | ||
154 | //_____________________________________________________________________________ | |
155 | Double_t | |
156 | AliMpSlat::DY() const | |
157 | { | |
158 | // | |
159 | // Returns the y-half-size of the slat. | |
160 | // | |
161 | return fDY; | |
162 | } | |
163 | ||
164 | //_____________________________________________________________________________ | |
165 | AliMpMotifPosition* | |
166 | AliMpSlat::FindMotifPosition(Int_t manuID) const | |
167 | { | |
168 | // | |
169 | // Returns the motifPosition referenced by it manuID | |
170 | // | |
0f60374b | 171 | //#ifdef WITH_ROOT |
19b51aad | 172 | TObject* rv = fManuMap.GetValue(manuID); |
dee1d5f1 | 173 | if ( rv ) |
174 | { | |
175 | return (AliMpMotifPosition*)(rv); | |
176 | } | |
177 | else | |
178 | { | |
179 | return 0; | |
180 | } | |
0f60374b | 181 | //#else |
182 | // std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID); | |
183 | // if ( it != fManuMap.end() ) | |
184 | // { | |
185 | // return it->second; | |
186 | // } | |
187 | // else | |
188 | // { | |
189 | // return 0; | |
190 | // } | |
191 | //#endif | |
dee1d5f1 | 192 | } |
193 | ||
194 | //_____________________________________________________________________________ | |
195 | AliMpMotifPosition* | |
196 | AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const | |
197 | { | |
198 | // | |
199 | // 1. Find the PCB containing ix (iy not needed for this) | |
200 | // 2. Forward the request to the PCB, using pcb local indices. | |
201 | // | |
202 | const AliMpPCB* pcb = FindPCB(ix); | |
203 | if ( pcb ) | |
204 | { | |
205 | return pcb->FindMotifPosition(ix,iy); | |
206 | } | |
207 | else | |
208 | { | |
209 | return 0; | |
210 | } | |
211 | } | |
212 | ||
213 | //_____________________________________________________________________________ | |
214 | AliMpMotifPosition* | |
215 | AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const | |
216 | { | |
217 | // | |
218 | // Returns the motifPosition containing position (x,y) | |
219 | // | |
220 | const AliMpPCB* pcb = FindPCB(x,y); | |
221 | if (pcb) | |
222 | { | |
223 | return pcb->FindMotifPosition(x,y); | |
224 | } | |
225 | else | |
226 | { | |
227 | return 0; | |
228 | } | |
229 | } | |
230 | ||
231 | //_____________________________________________________________________________ | |
232 | AliMpPCB* | |
233 | AliMpSlat::FindPCB(Int_t ix) const | |
234 | { | |
235 | // | |
236 | // Returns the PCB containing x-integer-position ix | |
237 | // | |
238 | for ( Size_t i = 0; i < GetSize(); ++i ) | |
239 | { | |
240 | AliMpPCB* pcb = GetPCB(i); | |
241 | if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() ) | |
242 | { | |
243 | return pcb; | |
244 | } | |
245 | } | |
246 | return 0; | |
247 | } | |
248 | ||
249 | //_____________________________________________________________________________ | |
250 | Int_t | |
251 | AliMpSlat::FindPCBIndex(Int_t ix) const | |
252 | { | |
253 | // | |
254 | // Returns the index of the PCB containing x-integer-position ix. | |
255 | // | |
256 | for ( Size_t i = 0; i < GetSize(); ++i ) | |
257 | { | |
258 | AliMpPCB* pcb = GetPCB(i); | |
259 | if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() ) | |
260 | { | |
261 | return i; | |
262 | } | |
263 | } | |
264 | return -1; | |
265 | } | |
266 | ||
267 | //_____________________________________________________________________________ | |
268 | AliMpPCB* | |
269 | AliMpSlat::FindPCB(Double_t x, Double_t y) const | |
270 | { | |
271 | // | |
272 | // Returns the PCB containing position (x,y) | |
273 | // | |
274 | for ( Size_t i = 0; i < GetSize(); ++i ) | |
275 | { | |
276 | AliMpPCB* pcb = GetPCB(i); | |
277 | if ( x >= pcb->Xmin() && x < pcb->Xmax() && | |
278 | y >= pcb->Ymin() && y < pcb->Ymax() ) | |
279 | { | |
280 | return pcb; | |
281 | } | |
282 | } | |
283 | return 0; | |
284 | } | |
285 | ||
286 | //_____________________________________________________________________________ | |
287 | Int_t | |
288 | AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const | |
289 | { | |
290 | // | |
291 | // Returns the index of the PCB containing position (x,y) | |
292 | // | |
293 | for ( Size_t i = 0; i < GetSize(); ++i ) | |
294 | { | |
295 | AliMpPCB* pcb = GetPCB(i); | |
296 | if ( x >= pcb->Xmin() && x < pcb->Xmax() && | |
297 | y >= pcb->Ymin() && y < pcb->Ymax() ) | |
298 | { | |
299 | return i; | |
300 | } | |
301 | } | |
302 | return -1; | |
303 | } | |
304 | ||
19b51aad | 305 | //_____________________________________________________________________________ |
306 | void | |
307 | AliMpSlat::ForcePosition(const TVector2& pos) | |
308 | { | |
309 | // | |
310 | // Force the position to be different from (DX(),DY()). | |
311 | // Normally only used by triggerSlats (for layers). | |
312 | // Beware that this method must be called once all PCB have been added, | |
313 | // as the Add() method resets the position. | |
314 | // | |
315 | fPosition = pos; | |
316 | } | |
317 | ||
318 | //_____________________________________________________________________________ | |
319 | void | |
320 | AliMpSlat::GetAllElectronicCardNumbers(TArrayI& ecn) const | |
321 | { | |
322 | ecn.Set(GetNofElectronicCards()); | |
0f60374b | 323 | //#ifdef WITH_ROOT |
19b51aad | 324 | TExMapIter it(fManuMap.GetIterator()); |
325 | Long_t key; | |
326 | Long_t value; | |
327 | Int_t n(0); | |
328 | while ( it.Next(key,value) == kTRUE ) | |
329 | { | |
330 | ecn.AddAt((Int_t)(key),n); | |
331 | ++n; | |
332 | } | |
0f60374b | 333 | //#else |
334 | // missing here | |
335 | //#endif | |
19b51aad | 336 | } |
337 | ||
dee1d5f1 | 338 | //_____________________________________________________________________________ |
339 | const char* | |
340 | AliMpSlat::GetID() const | |
341 | { | |
342 | // | |
343 | // Returns the name of this slat. | |
344 | // | |
345 | return fId.Data(); | |
346 | } | |
347 | ||
348 | //_____________________________________________________________________________ | |
349 | Int_t | |
350 | AliMpSlat::GetMaxNofPadsY() const | |
351 | { | |
352 | // | |
353 | // Returns the maximum number of pads to be found in this slat y-direction. | |
354 | // | |
355 | return fMaxNofPadsY; | |
356 | } | |
357 | ||
16e8fffd | 358 | //_____________________________________________________________________________ |
359 | Int_t | |
360 | AliMpSlat::GetMaxPadIndexX() const | |
361 | { | |
362 | AliMpPCB* last = GetPCB(GetSize()-1); | |
363 | if (last) | |
364 | { | |
365 | return last->Ixmax(); | |
366 | } | |
367 | return 0; | |
368 | } | |
369 | ||
19b51aad | 370 | //_____________________________________________________________________________ |
371 | const char* | |
372 | AliMpSlat::GetName() const | |
373 | { | |
374 | TString name(GetID()); | |
375 | if ( fPlaneType == kBendingPlane ) | |
376 | { | |
377 | name += ".Bending"; | |
378 | } | |
379 | else if ( fPlaneType == kNonBendingPlane ) | |
380 | { | |
381 | name += ".NonBending"; | |
382 | } | |
383 | else | |
384 | { | |
385 | name += ".Invalid"; | |
386 | } | |
387 | return name.Data(); | |
388 | } | |
389 | ||
390 | //_____________________________________________________________________________ | |
391 | Int_t | |
392 | AliMpSlat::GetNofElectronicCards() const | |
393 | { | |
394 | return fManuMap.GetSize(); | |
395 | } | |
396 | ||
dee1d5f1 | 397 | //_____________________________________________________________________________ |
398 | Int_t | |
399 | AliMpSlat::GetNofPadsX() const | |
400 | { | |
401 | // | |
402 | // Returns the number of pad in x-direction. | |
403 | // | |
404 | return fNofPadsX; | |
405 | } | |
406 | ||
407 | //_____________________________________________________________________________ | |
408 | AliMpPCB* | |
409 | AliMpSlat::GetPCB(AliMpSlat::Size_t i) const | |
410 | { | |
411 | // | |
412 | // Returns the i-th PCB of this slat. | |
413 | // | |
414 | #ifdef WITH_ROOT | |
415 | if ( i >= fPCBs.GetEntriesFast() ) return 0; | |
416 | return (AliMpPCB*)fPCBs[i]; | |
417 | #else | |
418 | if ( i >= fPCBs.size() ) return 0; | |
419 | return fPCBs[i]; | |
420 | #endif | |
421 | } | |
422 | ||
423 | //_____________________________________________________________________________ | |
424 | AliMpSlat::Size_t | |
425 | AliMpSlat::GetSize() const | |
426 | { | |
427 | // | |
428 | // Returns the number of PCB in this slat. | |
429 | // | |
430 | #ifdef WITH_ROOT | |
431 | return fPCBs.GetEntriesFast(); | |
432 | #else | |
433 | return fPCBs.size(); | |
434 | #endif | |
435 | } | |
436 | ||
19b51aad | 437 | //_____________________________________________________________________________ |
438 | TVector2 | |
439 | AliMpSlat::Position() const | |
440 | { | |
441 | return fPosition; | |
442 | } | |
443 | ||
dee1d5f1 | 444 | //_____________________________________________________________________________ |
445 | void | |
446 | AliMpSlat::Print(Option_t* option) const | |
447 | { | |
448 | // | |
449 | // Prints the slat characteristics. | |
450 | // | |
451 | cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")" | |
19b51aad | 452 | << " POS = " << Position().X() << "," << Position().Y() |
453 | << " NPADSX = " << GetNofPadsX() | |
454 | << " MAXNPADSY = " << GetMaxNofPadsY() | |
455 | << " NPCBs=" << GetSize() << endl; | |
456 | ||
457 | TString soption(option); | |
dee1d5f1 | 458 | |
19b51aad | 459 | if ( soption.Contains("P") ) |
dee1d5f1 | 460 | { |
461 | for ( Size_t i = 0; i < GetSize() ; ++i ) | |
462 | { | |
463 | cout << " "; | |
464 | if ( option ) | |
465 | { | |
466 | fPCBs[i]->Print(option+1); | |
467 | } | |
468 | else | |
469 | { | |
470 | fPCBs[i]->Print(); | |
471 | } | |
472 | } | |
473 | } | |
19b51aad | 474 | |
475 | if ( soption.Contains("M") || soption.Contains("L") ) | |
476 | { | |
477 | cout << fManuMap.GetSize() << " "; | |
478 | cout << "Electronic card (manu or local board) Ids : "; | |
479 | ||
480 | TExMapIter iter(fManuMap.GetIterator()); | |
481 | Long_t key, value; | |
482 | while ( iter.Next(key,value) ) | |
483 | { | |
484 | cout << key << " "; | |
485 | } | |
486 | cout << endl; | |
487 | } | |
dee1d5f1 | 488 | } |