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