]>
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: AliMpPCB.cxx,v 1.8 2006/05/24 13:58:50 ivana Exp $ |
dee1d5f1 | 18 | |
19 | #include "AliMpPCB.h" | |
20 | ||
21 | #include "AliMpMotif.h" | |
f35ac2f6 | 22 | #include "AliMpSlatMotifMap.h" |
dee1d5f1 | 23 | #include "AliMpMotifPosition.h" |
b7762666 | 24 | #include "AliMpMotifSpecial.h" |
dee1d5f1 | 25 | #include "AliMpMotifType.h" |
26 | #include "AliLog.h" | |
27 | ||
28 | #include "Riostream.h" | |
f35ac2f6 | 29 | #include "TList.h" |
30 | #include "TObjString.h" | |
b7762666 | 31 | #include "TMath.h" |
dee1d5f1 | 32 | #include <sstream> |
33 | ||
3d1463c8 | 34 | |
35 | //----------------------------------------------------------------------------- | |
85fec35d | 36 | /// \class AliMpPCB |
37 | /// | |
38 | /// A PCB for station 3,4 or 5 | |
39 | /// | |
40 | /// A PCB is a group of pads having the same size | |
41 | /// Pads are grouped in motifs, where 1 motif = 1 MANU | |
42 | /// | |
43 | /// The notion of PCB enveloppe is due to the fact that not all PCBs are | |
44 | /// "full" of pads, e.g. the rounded or short ones miss some pads, | |
45 | /// but the enveloppe is a virtual size that should be constant | |
46 | /// across the slats, and is 400x400 mm. | |
47 | /// It's a usefull notion to compute e.g. slat center in a uniform way, | |
48 | /// considering that a slat is N PCBs, of the same "virtual" size, that of | |
49 | /// the enveloppe. | |
50 | /// | |
51 | /// \author L. Aphecetche | |
3d1463c8 | 52 | //----------------------------------------------------------------------------- |
85fec35d | 53 | |
13985652 | 54 | /// \cond CLASSIMP |
dee1d5f1 | 55 | ClassImp(AliMpPCB) |
13985652 | 56 | /// \endcond |
dee1d5f1 | 57 | |
58 | //_____________________________________________________________________________ | |
59 | AliMpPCB::AliMpPCB() | |
ab31db03 | 60 | : TObject(), |
61 | fId(""), | |
62 | fPadSizeX(0), | |
63 | fPadSizeY(0), | |
64 | fEnveloppeSizeX(0), | |
65 | fEnveloppeSizeY(0), | |
66 | fXoffset(0), | |
67 | fActiveXmin(0), | |
68 | fActiveXmax(0), | |
69 | fIxmin(99999), | |
70 | fIxmax(0), | |
71 | fIymin(99999), | |
72 | fIymax(0), | |
f35ac2f6 | 73 | fMotifPositions(), |
74 | fNofPads(0), | |
75 | fMotifMap(0) | |
dee1d5f1 | 76 | { |
71a2d3aa | 77 | /// |
78 | /// Default ctor. | |
79 | /// | |
f35ac2f6 | 80 | #ifdef WITH_ROOT |
81 | fMotifPositions.SetOwner(kTRUE); | |
82 | #endif | |
83 | AliDebug(1,Form("this=%p",this)); | |
dee1d5f1 | 84 | } |
85 | ||
86 | //_____________________________________________________________________________ | |
f35ac2f6 | 87 | AliMpPCB::AliMpPCB(AliMpSlatMotifMap* motifMap, const char* id, Double_t padSizeX, Double_t padSizeY, |
dee1d5f1 | 88 | Double_t enveloppeSizeX, Double_t enveloppeSizeY) |
ab31db03 | 89 | : TObject(), |
90 | fId(id), | |
91 | fPadSizeX(padSizeX), | |
92 | fPadSizeY(padSizeY), | |
93 | fEnveloppeSizeX(enveloppeSizeX), | |
94 | fEnveloppeSizeY(enveloppeSizeY), | |
95 | fXoffset(0), | |
96 | fActiveXmin(0), | |
97 | fActiveXmax(0), | |
98 | fIxmin(99999), | |
99 | fIxmax(0), | |
100 | fIymin(99999), | |
101 | fIymax(0), | |
f35ac2f6 | 102 | fMotifPositions(), |
103 | fNofPads(0), | |
104 | fMotifMap(motifMap) | |
dee1d5f1 | 105 | { |
71a2d3aa | 106 | /// |
107 | /// Normal ctor. Must be fed with the PCB's name (id), the pad dimensions | |
108 | /// and the global dimension of the virtual enveloppe of the PCB | |
109 | /// (usually 400x400 mm) | |
f35ac2f6 | 110 | #ifdef WITH_ROOT |
111 | fMotifPositions.SetOwner(kTRUE); | |
112 | #endif | |
113 | AliDebug(1,Form("this=%p id=%s",this,id)); | |
dee1d5f1 | 114 | } |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | AliMpPCB::AliMpPCB(const AliMpPCB& o) | |
ab31db03 | 118 | : TObject(o), |
119 | fId(0), | |
120 | fPadSizeX(0), | |
121 | fPadSizeY(0), | |
122 | fEnveloppeSizeX(0), | |
123 | fEnveloppeSizeY(0), | |
124 | fXoffset(0), | |
125 | fActiveXmin(0), | |
126 | fActiveXmax(0), | |
127 | fIxmin(99999), | |
128 | fIxmax(0), | |
129 | fIymin(99999), | |
130 | fIymax(0), | |
f35ac2f6 | 131 | fMotifPositions(), |
132 | fNofPads(0), | |
133 | fMotifMap(0x0) | |
dee1d5f1 | 134 | { |
71a2d3aa | 135 | /// |
136 | /// Copy constructor | |
144129ae | 137 | |
f35ac2f6 | 138 | #ifdef WITH_ROOT |
139 | fMotifPositions.SetOwner(kTRUE); | |
140 | #endif | |
141 | AliDebug(1,Form("this=%p (copy ctor) : begin",this)); | |
dee1d5f1 | 142 | o.Copy(*this); |
f35ac2f6 | 143 | AliDebug(1,Form("this=%p (copy ctor) : end",this)); |
dee1d5f1 | 144 | } |
145 | ||
b7762666 | 146 | //_____________________________________________________________________________ |
147 | AliMpPCB::AliMpPCB(const char* id, AliMpMotifSpecial* ms) | |
ab31db03 | 148 | : TObject(), |
149 | fId(id), | |
150 | fPadSizeX(-1.0), | |
151 | fPadSizeY(-1.0), | |
152 | fEnveloppeSizeX(ms->Dimensions().X()*2.0), | |
153 | fEnveloppeSizeY(ms->Dimensions().Y()*2.0), | |
154 | fXoffset(0.0), | |
155 | fActiveXmin(0.0), | |
156 | fActiveXmax(fEnveloppeSizeX), | |
157 | fIxmin(0), | |
158 | fIxmax(ms->GetMotifType()->GetNofPadsX()-1), | |
159 | fIymin(0), | |
160 | fIymax(ms->GetMotifType()->GetNofPadsY()-1), | |
f35ac2f6 | 161 | fMotifPositions(), |
162 | fNofPads(ms->GetMotifType()->GetNofPads()), | |
163 | fMotifMap(0x0) | |
b7762666 | 164 | { |
71a2d3aa | 165 | /// |
166 | /// Very special ctor to be used by trigger stations only (and for a very | |
167 | /// specific case). | |
168 | /// | |
169 | /// Note that in this very case, we only allow one (special) motif per PCB. | |
170 | /// This limitation might not be justified, except that it's all we need | |
171 | /// so far ;-) | |
172 | /// | |
ab31db03 | 173 | |
f35ac2f6 | 174 | AliDebug(1,Form("this=%p (ctor special motif)",this)); |
175 | ||
176 | #ifdef WITH_ROOT | |
177 | fMotifPositions.SetOwner(kTRUE); | |
178 | #endif | |
b7762666 | 179 | TVector2 position(ms->Dimensions()); |
180 | AliMpMotifPosition* mp = new AliMpMotifPosition(-1,ms,position); | |
181 | mp->SetLowIndicesLimit(AliMpIntPair(fIxmin,fIymin)); | |
182 | mp->SetHighIndicesLimit(AliMpIntPair(fIxmax,fIymax)); | |
183 | #ifdef WITH_ROOT | |
f35ac2f6 | 184 | fMotifPositions.AddLast(mp); |
b7762666 | 185 | #else |
f35ac2f6 | 186 | fMotifPositions.push_back(mp); |
b7762666 | 187 | #endif |
188 | } | |
189 | ||
dee1d5f1 | 190 | //_____________________________________________________________________________ |
191 | AliMpPCB& | |
192 | AliMpPCB::operator=(const AliMpPCB& o) | |
193 | { | |
71a2d3aa | 194 | /// Assignment operator |
144129ae | 195 | |
f35ac2f6 | 196 | AliDebug(1,Form("this=%p (assignment op) : begin",this)); |
dee1d5f1 | 197 | o.Copy(*this); |
f35ac2f6 | 198 | AliDebug(1,Form("this=%p (assignment op) : end",this)); |
dee1d5f1 | 199 | return *this; |
200 | } | |
201 | ||
202 | //_____________________________________________________________________________ | |
203 | AliMpPCB::~AliMpPCB() | |
204 | { | |
71a2d3aa | 205 | /// |
206 | /// Dtor. | |
207 | /// | |
f35ac2f6 | 208 | AliDebug(1,Form("this=%p",this)); |
209 | #ifndef WITH_ROOT | |
630711ed | 210 | for ( UInt_t i = 0; i < fMotifPositions.size(); ++i ) |
f35ac2f6 | 211 | { |
212 | delete fMotifPositions[i]; | |
213 | } | |
214 | #endif | |
215 | ||
dee1d5f1 | 216 | } |
217 | ||
218 | //_____________________________________________________________________________ | |
219 | Double_t | |
220 | AliMpPCB::ActiveXmin() const | |
221 | { | |
71a2d3aa | 222 | /// |
223 | /// Returns the mininum x for which there is a pad in this PCB. | |
224 | /// Different from Xmin only for PCB which are not full of pads. | |
225 | /// | |
dee1d5f1 | 226 | |
227 | return fActiveXmin; | |
228 | } | |
229 | ||
230 | //_____________________________________________________________________________ | |
231 | Double_t | |
232 | AliMpPCB::ActiveXmax() const | |
233 | { | |
71a2d3aa | 234 | /// |
235 | /// Returns the maximum x for which there is a pad in this PCB. | |
236 | /// Different from Xmax only for PCB which are not full of pads. | |
237 | /// | |
dee1d5f1 | 238 | |
239 | return fActiveXmax; | |
240 | } | |
241 | ||
242 | //_____________________________________________________________________________ | |
243 | void | |
244 | AliMpPCB::Add(AliMpMotifType* mt, Int_t ix, Int_t iy) | |
245 | { | |
71a2d3aa | 246 | /// |
247 | /// Add a motif to this PCB. (ix,iy) indicates one corner position of the motif | |
248 | /// where the sign of ix and iy is used to indicate which corner is the | |
249 | /// reference (then for values, abs(ix) and abs(iy) are used indeed) : | |
250 | /// | |
251 | /// (ix>0,iy>0) : bottom-left corner | |
252 | /// (ix<0,iy>0) : bottom-right corner | |
253 | /// (ix<0,iy<0) : top-right corner | |
254 | /// (ix>0,iy<0) : top-left corner. | |
dee1d5f1 | 255 | |
f35ac2f6 | 256 | TString id(Form("%s-%e-%e",mt->GetID().Data(),PadSizeX(),PadSizeY())); |
257 | ||
258 | AliMpVMotif* motif = fMotifMap->FindMotif(id); | |
259 | ||
260 | if (!motif) | |
261 | { | |
262 | motif = new AliMpMotif(id,mt,TVector2(PadSizeX()/2.0,PadSizeY()/2.0)); | |
263 | AliDebug(1,Form("Adding motif %s to motifMap",id.Data())); | |
264 | fMotifMap->AddMotif(motif); | |
265 | } | |
266 | else | |
267 | { | |
268 | AliDebug(1,Form("Got motif %s from motifMap",id.Data())); | |
269 | } | |
270 | ||
b7762666 | 271 | TVector2 position; |
272 | Int_t ixmin(-1); | |
273 | Int_t iymin(-1); | |
274 | ||
275 | if ( ix >= 0 && iy >= 0 ) | |
276 | { | |
277 | position.Set(ix*PadSizeX(),iy*PadSizeY()); | |
278 | ixmin = ix; | |
279 | iymin = iy; | |
280 | } | |
281 | else | |
282 | if ( ix >= 0 && iy < 0 ) | |
283 | { | |
284 | position.Set(ix*PadSizeX(),Ymax()+iy*PadSizeY()); | |
285 | ixmin = ix; | |
286 | iymin = TMath::Nint(Ymax()/PadSizeY()) + iy; | |
287 | } | |
288 | else | |
289 | if ( ix < 0 && iy < 0 ) | |
290 | { | |
291 | position.Set(Xmax()+ix*PadSizeX(),Ymax()+iy*PadSizeY()); | |
292 | ixmin = TMath::Nint(Xmax()/PadSizeX()) + ix; | |
293 | iymin = TMath::Nint(Ymax()/PadSizeY()) + iy; | |
294 | } | |
295 | else | |
296 | if ( ix < 0 && iy >=0 ) | |
297 | { | |
298 | position.Set(Xmax()+ix*PadSizeX(),iy*PadSizeY()); | |
299 | ixmin = TMath::Nint(Xmax()/PadSizeX()) + ix; | |
300 | iymin = iy; | |
301 | } | |
302 | ||
dee1d5f1 | 303 | position += motif->Dimensions(); |
304 | ||
305 | AliMpMotifPosition* mp = new AliMpMotifPosition(-1,motif,position); | |
b7762666 | 306 | Int_t ixmax = ixmin + mt->GetNofPadsX() - 1; |
307 | Int_t iymax = iymin + mt->GetNofPadsY() - 1; | |
dee1d5f1 | 308 | |
309 | mp->SetLowIndicesLimit(AliMpIntPair(ixmin,iymin)); | |
310 | mp->SetHighIndicesLimit(AliMpIntPair(ixmax,iymax)); | |
311 | ||
312 | #ifdef WITH_ROOT | |
f35ac2f6 | 313 | fMotifPositions.AddLast(mp); |
dee1d5f1 | 314 | #else |
f35ac2f6 | 315 | fMotifPositions.push_back(mp); |
dee1d5f1 | 316 | #endif |
317 | ||
1b36647b | 318 | fIxmin = TMath::Min(fIxmin,ixmin); |
319 | fIxmax = TMath::Max(fIxmax,ixmax); | |
320 | fIymin = TMath::Min(fIymin,iymin); | |
321 | fIymax = TMath::Max(fIymax,iymax); | |
dee1d5f1 | 322 | |
323 | fActiveXmin = fIxmin*PadSizeX(); | |
324 | fActiveXmax = (fIxmax+1)*PadSizeX(); | |
efb408b3 | 325 | fNofPads += mt->GetNofPads(); |
dee1d5f1 | 326 | } |
327 | ||
f35ac2f6 | 328 | //_____________________________________________________________________________ |
329 | AliMpArea | |
330 | AliMpPCB::Area() const | |
331 | { | |
71a2d3aa | 332 | /// Return the area of this PCB |
333 | ||
f35ac2f6 | 334 | return AliMpArea(TVector2( (Xmin()+Xmax())/2.0,DY()), |
335 | TVector2( DX(), DY() ) ); | |
336 | } | |
337 | ||
dee1d5f1 | 338 | //_____________________________________________________________________________ |
339 | TObject* | |
340 | AliMpPCB::Clone(const char* /*newname*/) const | |
341 | { | |
71a2d3aa | 342 | /// |
343 | /// Return a full copy of this object. | |
344 | /// | |
f35ac2f6 | 345 | AliDebug(1,"begin"); |
346 | TObject* object = new AliMpPCB(*this); | |
347 | AliDebug(1,"end"); | |
348 | return object; | |
dee1d5f1 | 349 | } |
350 | ||
351 | //_____________________________________________________________________________ | |
352 | AliMpPCB* | |
353 | AliMpPCB::Clone(const TArrayI& manuids, Int_t ixOffset, Double_t xOffset) const | |
354 | { | |
71a2d3aa | 355 | /// |
356 | /// Get a full copy of *this, and then apply 2 changes to it : | |
357 | /// | |
358 | /// a) define the relationship motifType <-> manu id | |
359 | /// b) define the x-offset | |
360 | /// c) shift ix indices backwards to insure that e.g. the first | |
361 | /// pcb of a slat will start at ix=0 (only relevant for rounded pcbs). | |
362 | /// | |
dee1d5f1 | 363 | |
f35ac2f6 | 364 | AliDebug(1,"begin"); |
365 | ||
dee1d5f1 | 366 | // First get a full clone. |
367 | AliMpPCB* pcb = static_cast<AliMpPCB*>(Clone()); | |
368 | ||
c6e05ab2 | 369 | if ( Int_t(pcb->GetSize()) != manuids.GetSize() ) |
dee1d5f1 | 370 | { |
b7762666 | 371 | AliError(Form("Cannot Clone PCB %s because I do not get the correct number of " |
372 | "manu ids (got %d, wanted %d)",pcb->GetID(), | |
dee1d5f1 | 373 | manuids.GetSize(),pcb->GetSize())); |
374 | return 0; | |
375 | } | |
376 | ||
f35ac2f6 | 377 | AliMpIntPair shift(-fIxmin+ixOffset,0); |
dee1d5f1 | 378 | |
379 | // Then change the internal MotifPositions wrt manu id | |
380 | // and position (offset in x). | |
630711ed | 381 | for ( Int_t i = 0; i < pcb->GetSize(); ++i ) |
dee1d5f1 | 382 | { |
383 | AliMpMotifPosition* mp = pcb->GetMotifPosition(i); | |
384 | mp->SetID(manuids[i]); | |
f35ac2f6 | 385 | TVector2 pos(mp->Position()); |
386 | pos += TVector2(xOffset,0); | |
387 | mp->SetPosition(pos); | |
388 | AliMpIntPair offset(ixOffset,0); | |
389 | AliMpIntPair low(mp->GetLowIndicesLimit()); | |
390 | low += shift; | |
391 | mp->SetLowIndicesLimit(low); | |
392 | AliMpIntPair high(mp->GetHighIndicesLimit()); | |
393 | high += shift; | |
394 | mp->SetHighIndicesLimit(high); | |
dee1d5f1 | 395 | } |
396 | ||
f35ac2f6 | 397 | pcb->fIxmin += shift.GetFirst(); |
398 | pcb->fIxmax += shift.GetFirst(); | |
dee1d5f1 | 399 | pcb->fXoffset = xOffset; |
400 | ||
401 | pcb->fActiveXmin += xOffset; | |
402 | pcb->fActiveXmax += xOffset; | |
403 | ||
f35ac2f6 | 404 | AliDebug(1,"end"); |
405 | ||
dee1d5f1 | 406 | return pcb; |
407 | } | |
408 | ||
409 | //_____________________________________________________________________________ | |
410 | void | |
411 | AliMpPCB::Copy(TObject& o) const | |
412 | { | |
71a2d3aa | 413 | /// Copy *this into o |
85fec35d | 414 | |
f35ac2f6 | 415 | AliDebug(1,"begin"); |
416 | ||
dee1d5f1 | 417 | TObject::Copy(o); |
418 | AliMpPCB& pcb = static_cast<AliMpPCB&>(o); | |
419 | pcb.fId = fId; | |
420 | pcb.fPadSizeX = fPadSizeX; | |
421 | pcb.fPadSizeY = fPadSizeY; | |
422 | pcb.fEnveloppeSizeX = fEnveloppeSizeX; | |
423 | pcb.fEnveloppeSizeY = fEnveloppeSizeY; | |
424 | pcb.fXoffset = fXoffset; | |
425 | pcb.fIxmin = fIxmin; | |
426 | pcb.fIxmax = fIxmax; | |
427 | pcb.fIymin = fIymin; | |
428 | pcb.fIymax = fIymax; | |
429 | pcb.fActiveXmin = fActiveXmin; | |
430 | pcb.fActiveXmax = fActiveXmax; | |
431 | ||
432 | #ifdef WITH_ROOT | |
f35ac2f6 | 433 | AliDebug(1,"Deleting pcb.fMotifPositions"); |
434 | pcb.fMotifPositions.Delete(); | |
435 | AliDebug(1,"Deleting pcb.fMotifPositions : done"); | |
dee1d5f1 | 436 | #else |
630711ed | 437 | for ( UInt_t i = 0; i < pcb.fMotifPositions.size(); ++i ) |
f35ac2f6 | 438 | { |
439 | delete pcb.fMotifPositions[i]; | |
440 | } | |
dee1d5f1 | 441 | #endif |
442 | ||
443 | #ifdef WITH_ROOT | |
630711ed | 444 | for ( Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i ) |
dee1d5f1 | 445 | #else |
630711ed | 446 | for ( UInt_t i = 0; i < fMotifPositions.size(); ++i ) |
dee1d5f1 | 447 | #endif |
448 | { | |
f35ac2f6 | 449 | AliMpMotifPosition* pos = (AliMpMotifPosition*)fMotifPositions[i]; |
450 | AliMpMotifPosition* pcbpos = new AliMpMotifPosition(pos->GetID(), | |
451 | pos->GetMotif(), | |
452 | pos->Position()); | |
dee1d5f1 | 453 | pcbpos->SetLowIndicesLimit(pos->GetLowIndicesLimit()); |
454 | pcbpos->SetHighIndicesLimit(pos->GetHighIndicesLimit()); | |
455 | #ifdef WITH_ROOT | |
f35ac2f6 | 456 | pcb.fMotifPositions.AddLast(pcbpos); |
dee1d5f1 | 457 | #else |
f35ac2f6 | 458 | pcb.fMotifPositions.push_back(pcbpos); |
dee1d5f1 | 459 | #endif |
460 | } | |
efb408b3 | 461 | |
462 | pcb.fNofPads = fNofPads; | |
f35ac2f6 | 463 | |
464 | pcb.fMotifMap = fMotifMap; // warning : we do share the motifmap. | |
465 | ||
466 | AliDebug(1,"end"); | |
dee1d5f1 | 467 | } |
468 | ||
469 | //_____________________________________________________________________________ | |
470 | Double_t | |
471 | AliMpPCB::ActiveDX() const | |
472 | { | |
71a2d3aa | 473 | /// |
474 | /// Half-length (in x-direction) occupied by pads | |
475 | /// | |
dee1d5f1 | 476 | |
477 | return GetNofPadsX()*fPadSizeX/2.0; | |
478 | } | |
479 | ||
480 | //_____________________________________________________________________________ | |
481 | Double_t | |
482 | AliMpPCB::DX() const | |
483 | { | |
71a2d3aa | 484 | /// |
485 | /// Half-length (in x-direction) of the PCB. | |
486 | /// This length is the one of the virtual enveloppe of the PCB and might | |
487 | /// be bigger than the length occupied by pads (e.g. for rounded or short | |
488 | /// PCBs). | |
489 | /// See also ActiveDX(). | |
490 | /// | |
dee1d5f1 | 491 | |
492 | return fEnveloppeSizeX/2.0; | |
493 | } | |
494 | ||
495 | //_____________________________________________________________________________ | |
496 | Double_t | |
497 | AliMpPCB::ActiveDY() const | |
498 | { | |
71a2d3aa | 499 | /// |
500 | /// Half-length (in y-direction) occupied by pads | |
501 | /// | |
dee1d5f1 | 502 | |
503 | return GetNofPadsY()*fPadSizeY/2.0; | |
504 | } | |
505 | ||
506 | //_____________________________________________________________________________ | |
507 | Double_t | |
508 | AliMpPCB::DY() const | |
509 | { | |
71a2d3aa | 510 | /// |
511 | /// Half-length (in y-direction) of the PCB. | |
512 | /// This length is the one of the virtual enveloppe of the PCB and might | |
513 | /// be bigger than the length occupied by pads (e.g. for rounded or short | |
514 | /// PCBs). | |
515 | /// See also ActiveDY(). | |
516 | /// | |
dee1d5f1 | 517 | |
518 | return fEnveloppeSizeY/2.0; | |
519 | } | |
520 | ||
521 | //_____________________________________________________________________________ | |
522 | AliMpMotifPosition* | |
523 | AliMpPCB::FindMotifPosition(Int_t ix, Int_t iy) const | |
524 | { | |
71a2d3aa | 525 | /// |
526 | /// Returns the motifPosition located at the position referenced by | |
527 | /// integer indices (ix,iy). | |
528 | /// | |
dee1d5f1 | 529 | |
530 | #ifdef WITH_ROOT | |
630711ed | 531 | for (Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i ) |
dee1d5f1 | 532 | #else |
630711ed | 533 | for (UInt_t i = 0; i < fMotifPositions.size(); ++i ) |
dee1d5f1 | 534 | #endif |
535 | { | |
f35ac2f6 | 536 | AliMpMotifPosition* mp = (AliMpMotifPosition*)fMotifPositions[i]; |
3635f34f | 537 | if ( mp->HasPadByIndices(AliMpIntPair(ix,iy)) ) |
b7762666 | 538 | { |
539 | return mp; | |
540 | } | |
dee1d5f1 | 541 | } |
542 | return 0; | |
543 | } | |
544 | ||
545 | //_____________________________________________________________________________ | |
546 | AliMpMotifPosition* | |
547 | AliMpPCB::FindMotifPosition(Double_t x, Double_t y) const | |
548 | { | |
71a2d3aa | 549 | /// |
550 | /// Returns the motifPosition located at position (x,y) | |
551 | /// | |
dee1d5f1 | 552 | |
553 | #ifdef WITH_ROOT | |
630711ed | 554 | for (Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i ) |
dee1d5f1 | 555 | #else |
630711ed | 556 | for (UInt_t i = 0; i < fMotifPositions.size(); ++i ) |
dee1d5f1 | 557 | #endif |
558 | { | |
f35ac2f6 | 559 | AliMpMotifPosition* mp = (AliMpMotifPosition*)fMotifPositions[i]; |
dee1d5f1 | 560 | |
561 | TVector2 localPos( TVector2(x,y) - mp->Position() ); | |
562 | ||
563 | AliMpIntPair localIndices(mp->GetMotif()->PadIndicesLocal(localPos)); | |
564 | ||
3635f34f | 565 | if ( localIndices.IsValid() && mp->GetMotif()->GetMotifType()->HasPadByLocalIndices(localIndices) ) |
dee1d5f1 | 566 | { |
567 | return mp; | |
568 | } | |
569 | } | |
570 | return 0; | |
571 | } | |
572 | ||
573 | //_____________________________________________________________________________ | |
574 | const char* | |
575 | AliMpPCB::GetID() const | |
576 | { | |
71a2d3aa | 577 | /// |
578 | /// Returns the name of this PCB. | |
579 | /// | |
dee1d5f1 | 580 | |
581 | return fId.Data(); | |
582 | } | |
583 | ||
584 | //_____________________________________________________________________________ | |
585 | AliMpMotifPosition* | |
630711ed | 586 | AliMpPCB::GetMotifPosition(Int_t i) const |
dee1d5f1 | 587 | { |
71a2d3aa | 588 | /// |
589 | /// Get the i-th motifPosition stored in this PCB's internal array. | |
590 | /// | |
dee1d5f1 | 591 | |
592 | #ifdef WITH_ROOT | |
f35ac2f6 | 593 | if ( i >= fMotifPositions.GetEntriesFast() ) return 0; |
dee1d5f1 | 594 | #else |
630711ed | 595 | if ( i >= Int_t(fMotifPositions.size()) ) return 0; |
dee1d5f1 | 596 | #endif |
f35ac2f6 | 597 | return (AliMpMotifPosition*)fMotifPositions[i]; |
dee1d5f1 | 598 | } |
599 | ||
600 | //_____________________________________________________________________________ | |
601 | Int_t | |
602 | AliMpPCB::GetNofPadsX() const | |
603 | { | |
71a2d3aa | 604 | /// |
605 | /// Returns the number of pads in x-direction. | |
606 | /// | |
dee1d5f1 | 607 | |
608 | return fIxmax-fIxmin+1; | |
609 | } | |
610 | ||
611 | //_____________________________________________________________________________ | |
612 | Int_t | |
613 | AliMpPCB::GetNofPadsY() const | |
614 | { | |
71a2d3aa | 615 | /// |
616 | /// Returns the number of pads in y-direction. | |
617 | /// | |
dee1d5f1 | 618 | |
619 | return fIymax-fIymin+1; | |
620 | } | |
621 | ||
622 | //_____________________________________________________________________________ | |
630711ed | 623 | Int_t |
dee1d5f1 | 624 | AliMpPCB::GetSize() const |
625 | { | |
71a2d3aa | 626 | /// |
627 | /// Returns the number of motifPositions stored in this PCB. | |
628 | /// | |
dee1d5f1 | 629 | |
630 | #ifdef WITH_ROOT | |
f35ac2f6 | 631 | return fMotifPositions.GetEntriesFast(); |
dee1d5f1 | 632 | #else |
f35ac2f6 | 633 | return fMotifPositions.size(); |
dee1d5f1 | 634 | #endif |
635 | } | |
636 | ||
5f5c0c3d | 637 | //_____________________________________________________________________________ |
638 | Bool_t | |
639 | AliMpPCB::HasMotifPositionID(Int_t manuId) const | |
640 | { | |
641 | /// Returns whether or not we have manuId | |
642 | ||
643 | #ifdef WITH_ROOT | |
644 | TIter next(&fMotifPositions); | |
645 | AliMpMotifPosition* pos; | |
646 | while ( ( pos = static_cast<AliMpMotifPosition*>(next()) ) ) | |
647 | { | |
648 | if ( pos->GetID() == manuId ) return kTRUE; | |
649 | } | |
650 | return kFALSE; | |
651 | #else | |
630711ed | 652 | for ( UInt_t i=0; i<fMotifPositions.size(); ++i ) { |
653 | if ( fMotifPositions[i]->GetID() == manuId ) return kTRUE; | |
654 | } | |
655 | return kFALSE; | |
5f5c0c3d | 656 | #endif |
657 | } | |
658 | ||
dee1d5f1 | 659 | |
660 | //_____________________________________________________________________________ | |
661 | Int_t | |
662 | AliMpPCB::Ixmin() const | |
663 | { | |
71a2d3aa | 664 | /// |
665 | /// Returns the index value of the leftmost pad. | |
666 | /// | |
dee1d5f1 | 667 | |
668 | return fIxmin; | |
669 | } | |
670 | ||
671 | //_____________________________________________________________________________ | |
672 | Int_t | |
673 | AliMpPCB::Ixmax() const | |
674 | { | |
71a2d3aa | 675 | /// |
676 | /// Returns the index value of the rightmost pad. | |
677 | /// | |
dee1d5f1 | 678 | |
679 | return Ixmin() + GetNofPadsX() - 1; | |
680 | } | |
681 | ||
b7762666 | 682 | //_____________________________________________________________________________ |
683 | Int_t | |
684 | AliMpPCB::Iymin() const | |
685 | { | |
71a2d3aa | 686 | /// |
687 | /// Returns the index value of the bottom pad. | |
688 | /// | |
b7762666 | 689 | |
690 | return fIymin; | |
691 | } | |
692 | ||
693 | //_____________________________________________________________________________ | |
694 | Int_t | |
695 | AliMpPCB::Iymax() const | |
696 | { | |
71a2d3aa | 697 | /// |
698 | /// Returns the index value of the top pad. | |
699 | /// | |
b7762666 | 700 | |
701 | return Iymin() + GetNofPadsY() - 1; | |
702 | } | |
703 | ||
dee1d5f1 | 704 | //_____________________________________________________________________________ |
705 | Double_t | |
706 | AliMpPCB::PadSizeX() const | |
707 | { | |
71a2d3aa | 708 | /// |
709 | /// Returns the pad size in x-direction (in mm) | |
710 | /// | |
dee1d5f1 | 711 | |
712 | return fPadSizeX; | |
713 | } | |
714 | ||
715 | //_____________________________________________________________________________ | |
716 | Double_t | |
717 | AliMpPCB::PadSizeY() const | |
718 | { | |
71a2d3aa | 719 | /// |
720 | /// Returns the pad size in y-direction (in mm) | |
721 | /// | |
dee1d5f1 | 722 | |
723 | return fPadSizeY; | |
724 | } | |
725 | ||
726 | //_____________________________________________________________________________ | |
727 | void | |
728 | AliMpPCB::Print(Option_t* option) const | |
729 | { | |
71a2d3aa | 730 | /// |
731 | /// Printout of this PCB. | |
732 | /// If option="M", the contained motifs are printed too. | |
733 | /// | |
dee1d5f1 | 734 | |
735 | cout << "PCB " << GetID() << " PADSIZES=(" << fPadSizeX << "," | |
736 | << fPadSizeY << ") iMin=(" << fIxmin << "," << fIymin << ") " | |
737 | << "iMax=(" << fIxmax << "," << fIymax << ") " | |
738 | << " EnvXmin,max=(" << Xmin() << "," << Xmax() | |
739 | << ") Xmin,max=(" << ActiveXmin() << "," << ActiveXmax() << ")" | |
740 | << endl; | |
741 | ||
742 | if ( option && option[0] == 'M' ) | |
743 | { | |
744 | #ifdef WITH_ROOT | |
630711ed | 745 | for ( Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i ) |
dee1d5f1 | 746 | #else |
630711ed | 747 | for ( UInt_t i = 0; i < fMotifPositions.size(); ++i ) |
dee1d5f1 | 748 | #endif |
749 | { | |
750 | if (option) | |
751 | { | |
f35ac2f6 | 752 | fMotifPositions[i]->Print(option+1); |
dee1d5f1 | 753 | } |
754 | else | |
755 | { | |
f35ac2f6 | 756 | fMotifPositions[i]->Print(); |
dee1d5f1 | 757 | } |
758 | } | |
759 | } | |
760 | } | |
761 | ||
f35ac2f6 | 762 | //_____________________________________________________________________________ |
763 | void | |
764 | AliMpPCB::Save() const | |
765 | { | |
71a2d3aa | 766 | /// |
767 | /// Save this PCB in the file | |
144129ae | 768 | |
f35ac2f6 | 769 | TString fileName(fId); |
770 | fileName += ".pcb"; | |
771 | TList lines; | |
772 | lines.SetOwner(kTRUE); | |
773 | ||
6926db95 | 774 | #ifdef WITH_ROOT |
630711ed | 775 | for ( Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i ) |
6926db95 | 776 | #else |
630711ed | 777 | for ( UInt_t i = 0; i < fMotifPositions.size(); ++i ) |
6926db95 | 778 | #endif |
f35ac2f6 | 779 | { |
780 | AliMpMotifPosition* pos = GetMotifPosition(i); | |
781 | AliMpVMotif* motif = pos->GetMotif(); | |
782 | TVector2 lowerLeft(pos->Position()-pos->Dimensions()); | |
783 | TString id(motif->GetID()); | |
784 | // id is supposed to be of the form %s-%e-%e, and we're only | |
785 | // interested in the %s part of it | |
786 | Ssiz_t index = id.Index("-"); | |
787 | if ( index < 1 ) | |
788 | { | |
789 | AliError(Form("id=%s does not meet expectations",id.Data())); | |
790 | return; | |
791 | } | |
792 | TString motifName(id(0,index)); | |
793 | lines.Add(new TObjString(Form("MOTIF %s %d %d", | |
794 | motifName.Data(), | |
795 | TMath::Nint(lowerLeft.X()/fPadSizeX), | |
796 | TMath::Nint(lowerLeft.Y()/fPadSizeY)))); | |
797 | } | |
798 | ||
799 | ofstream out(fileName.Data()); | |
800 | out.precision(9); | |
801 | out << "SIZES " << fPadSizeX << " " << fPadSizeY | |
802 | << " " << fEnveloppeSizeX << " " << fEnveloppeSizeY | |
803 | << endl; | |
804 | ||
805 | TIter next(&lines); | |
806 | TObjString* s; | |
807 | while ( ( s = (TObjString*)next() ) ) | |
808 | { | |
809 | out << s->String().Data() << endl; | |
810 | } | |
811 | out.close(); | |
812 | } | |
813 | ||
dee1d5f1 | 814 | //_____________________________________________________________________________ |
815 | Double_t | |
816 | AliMpPCB::X() const | |
817 | { | |
71a2d3aa | 818 | /// |
819 | /// Returns the x-position of the PCB center. | |
820 | /// | |
dee1d5f1 | 821 | |
822 | return fXoffset + DX(); | |
823 | } | |
824 | ||
825 | //_____________________________________________________________________________ | |
826 | Double_t | |
827 | AliMpPCB::Xmin() const | |
828 | { | |
71a2d3aa | 829 | /// |
830 | /// Returns the leftmost x-position in this PCB. | |
831 | /// | |
dee1d5f1 | 832 | |
833 | return X() - DX(); | |
834 | } | |
835 | ||
836 | //_____________________________________________________________________________ | |
837 | Double_t | |
838 | AliMpPCB::Xmax() const | |
839 | { | |
71a2d3aa | 840 | /// |
841 | /// Returns the rightmost x-position in this PCB. | |
842 | /// | |
dee1d5f1 | 843 | |
844 | return X() + DX(); | |
845 | } | |
846 | ||
847 | //_____________________________________________________________________________ | |
848 | Double_t | |
849 | AliMpPCB::Y() const | |
850 | { | |
71a2d3aa | 851 | /// |
852 | /// Returns the y-position of the PCB center. | |
853 | /// | |
dee1d5f1 | 854 | |
855 | return DY(); // this works as PCB are organized in a single row within slats. | |
856 | } | |
857 | ||
858 | //_____________________________________________________________________________ | |
859 | Double_t | |
860 | AliMpPCB::Ymin() const | |
861 | { | |
71a2d3aa | 862 | /// |
863 | /// Returns the smallest y-position in this PCB. | |
864 | /// | |
dee1d5f1 | 865 | |
866 | return Y() - DY(); | |
867 | } | |
868 | ||
869 | //_____________________________________________________________________________ | |
870 | Double_t | |
871 | AliMpPCB::Ymax() const | |
872 | { | |
71a2d3aa | 873 | /// |
874 | /// Returns the largest y-position in this PCB. | |
875 | /// | |
dee1d5f1 | 876 | |
877 | return Y() + DY(); | |
878 | } | |
879 |