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