AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpSlat.cxx
Go to the documentation of this file.
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$
17 // $MpId: AliMpSlat.cxx,v 1.6 2006/05/24 13:58:50 ivana Exp $
18 
19 #include "AliMpSlat.h"
20 
21 #include "AliMpExMapIterator.h"
22 #include "AliLog.h"
23 #include "AliMpMotifPosition.h"
24 #include "AliMpPCB.h"
25 
26 #include "Riostream.h"
27 
28 #include "TArrayI.h"
29 
30 #include <cassert>
31 
32 //-----------------------------------------------------------------------------
41 //
43 //-----------------------------------------------------------------------------
44 
45 using std::cout;
46 using std::endl;
50 
51 //_____________________________________________________________________________
52 AliMpSlat::AliMpSlat(TRootIOCtor* ioCtor)
53 : TObject(),
54  fId(""),
55  fPlaneType(AliMp::kNonBendingPlane),
56  fDX(0),
57  fDY(0),
58  fNofPadsX(0),
59  fMaxNofPadsY(0),
60  fManuMap(ioCtor),
61  fPCBs(),
62  fPositionX(0.),
63  fPositionY(0.),
64  fNofPads(0)
65 {
69  AliDebug(1,Form("this=%p Empty ctor",this));
70 
71  fPCBs.SetOwner(kTRUE);
72  fManuMap.SetOwner(kFALSE);
73 }
74 
75 //_____________________________________________________________________________
76 AliMpSlat::AliMpSlat(const char* id, AliMp::PlaneType bendingOrNonBending)
77 : TObject(),
78  fId(id),
79  fPlaneType(bendingOrNonBending),
80  fDX(0),
81  fDY(0),
82  fNofPadsX(0),
83  fMaxNofPadsY(0),
84  fManuMap(),
85  fPCBs(),
86  fPositionX(0.),
87  fPositionY(0.),
88  fNofPads(0)
89 {
93  AliDebug(1,Form("this=%p id=%s",this,id));
94 
95  fPCBs.SetOwner(kTRUE);
96  fManuMap.SetOwner(kFALSE);
97 }
98 
99 //_____________________________________________________________________________
101 {
105  AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
106 
107  fPCBs.Delete();
108 }
109 
110 //_____________________________________________________________________________
111 void
112 AliMpSlat::Add(const AliMpPCB& pcbType, const TArrayI& manuList)
113 {
120  Int_t ixOffset = 0;
121  if ( GetSize() )
122  {
123  ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
124  }
125  else
126  {
127  ixOffset = pcbType.Ixmin();
128  }
129  Double_t xOffset = DX()*2;
130  AliMpPCB* pcb = pcbType.Clone(manuList,ixOffset,xOffset);
131  fPCBs.AddLast(pcb);
132  fDY = TMath::Max(pcb->DY(),fDY);
133  fDX += pcb->DX();
134  fNofPadsX += pcb->GetNofPadsX();
135  fMaxNofPadsY = TMath::Max(fMaxNofPadsY,pcb->GetNofPadsY());
136  Int_t n(0);
137  for ( Int_t i = 0; i < pcb->GetSize(); ++i )
138  {
139  AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
140  Int_t manuID = mp->GetID();
141  // Before inserting a new key, check if it's already there
142  TObject* there = fManuMap.GetValue(manuID);
143  if ( there == 0 )
144  {
145  ++n;
146  AliDebug(1,Form("Adding %d-th manuId=%d (%d) to ManuMap (size=%d)",n,manuID,mp->GetID(),fManuMap.GetSize()));
147  fManuMap.Add(manuID,(TObject*)mp);
148  }
149  else
150  {
151  AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType.GetID()));
152  }
153  }
154  fPositionX = DX();
155  fPositionY = DY();
156  fNofPads += pcb->NofPads();
157 }
158 
159 //_____________________________________________________________________________
160 Double_t
162 {
166  return fDX;
167 }
168 
169 //_____________________________________________________________________________
170 Double_t
172 {
176  return fDY;
177 }
178 
179 //_____________________________________________________________________________
181 AliMpSlat::FindMotifPosition(Int_t manuID) const
182 {
186  return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
187 }
188 
189 //_____________________________________________________________________________
191 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
192 {
196  //
197  const AliMpPCB* pcb = FindPCB(ix);
198  if ( pcb )
199  {
200  return pcb->FindMotifPosition(ix,iy);
201  }
202  else
203  {
204  return 0;
205  }
206 }
207 
208 //_____________________________________________________________________________
210 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
211 {
215  const AliMpPCB* pcb = FindPCB(x,y);
216  if (pcb)
217  {
218  return pcb->FindMotifPosition(x,y);
219  }
220  else
221  {
222  return 0;
223  }
224 }
225 
226 //_____________________________________________________________________________
227 AliMpPCB*
228 AliMpSlat::FindPCB(Int_t ix) const
229 {
233  for ( Int_t i = 0; i < GetSize(); ++i )
234  {
235  AliMpPCB* pcb = GetPCB(i);
236  if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
237  {
238  return pcb;
239  }
240  }
241  return 0;
242 }
243 
244 //_____________________________________________________________________________
245 Int_t
246 AliMpSlat::FindPCBIndex(Int_t ix) const
247 {
251  for ( Int_t i = 0; i < GetSize(); ++i )
252  {
253  AliMpPCB* pcb = GetPCB(i);
254  if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
255  {
256  return i;
257  }
258  }
259  return -1;
260 }
261 
262 //_____________________________________________________________________________
263 AliMpPCB*
264 AliMpSlat::FindPCB(Double_t x, Double_t y) const
265 {
269  for ( Int_t i = 0; i < GetSize(); ++i )
270  {
271  AliMpPCB* pcb = GetPCB(i);
272 // if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
273 // y >= pcb->Ymin() && y < pcb->Ymax() )
274 // {
275 // return pcb;
276 // }
277  if ( x < pcb->Xmin() || x >= pcb->Xmax() ||
278  y < pcb->Ymin() || y >= pcb->Ymax() )
279  {
280  continue;
281  }
282  return pcb;
283  }
284  return 0;
285 }
286 
287 //_____________________________________________________________________________
288 Int_t
289 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
290 {
294  for ( Int_t i = 0; i < GetSize(); ++i )
295  {
296  AliMpPCB* pcb = GetPCB(i);
297  if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
298  y >= pcb->Ymin() && y < pcb->Ymax() )
299  {
300  return i;
301  }
302  }
303  return -1;
304 }
305 
306 //_____________________________________________________________________________
307 Int_t
309 {
311  for ( Int_t i = 0; i< GetSize(); ++i )
312  {
313  AliMpPCB* pcb = GetPCB(i);
314  if ( pcb->HasMotifPositionID(manuId) ) return i;
315  }
316  return -1;
317 }
318 
319 //_____________________________________________________________________________
320 void
321 AliMpSlat::ForcePosition(Double_t x, Double_t y)
322 {
329  fPositionX = x;
330  fPositionY = y;
331 }
332 
333 //_____________________________________________________________________________
334 void
336 {
340  Int_t nofElectronicCards(GetNofElectronicCards());
341  assert(nofElectronicCards>0);
342  ecn.Set(nofElectronicCards);
343  TIter next(fManuMap.CreateIterator());
344  AliMpMotifPosition* mp;
345  Int_t n(0);
346  while ( ( mp = static_cast<AliMpMotifPosition*>(next()) ) )
347  {
348  ecn.AddAt(mp->GetID(),n);
349  ++n;
350  }
351  assert(n==nofElectronicCards);
352 }
353 
354 //_____________________________________________________________________________
355 const char*
357 {
361  return fId.Data();
362 }
363 
364 //_____________________________________________________________________________
365 Int_t
367 {
371  return fMaxNofPadsY;
372 }
373 
374 //_____________________________________________________________________________
375 Int_t
377 {
381  AliMpPCB* last = GetPCB(GetSize()-1);
382  if (last)
383  {
384  return last->Ixmax();
385  }
386  return 0;
387 }
388 
389 //_____________________________________________________________________________
390 const char*
392 {
397  TString name(GetID());
399  {
400  name += ".Bending";
401  }
402  else if ( fPlaneType == AliMp::kNonBendingPlane )
403  {
404  name += ".NonBending";
405  }
406  else
407  {
408  name += ".Invalid";
409  }
410  return name.Data();
411 }
412 
413 //_____________________________________________________________________________
414 Int_t
416 {
420  return fManuMap.GetSize();
421 }
422 
423 //_____________________________________________________________________________
424 Int_t
426 {
430  return fNofPadsX;
431 }
432 
433 //_____________________________________________________________________________
434 AliMpPCB*
435 AliMpSlat::GetPCB(Int_t i) const
436 {
440  if ( i >= fPCBs.GetEntriesFast() ) return 0;
441  return (AliMpPCB*)fPCBs[i];
442 }
443 
444 //_____________________________________________________________________________
445 Int_t
447 {
451  return fPCBs.GetEntriesFast();
452 }
453 
454 //_____________________________________________________________________________
455 void
456 AliMpSlat::Print(Option_t* option) const
457 {
461  cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
462  << " POS = " << GetPositionX() << "," << GetPositionY()
463  << " NPADSX = " << GetNofPadsX()
464  << " MAXNPADSY = " << GetMaxNofPadsY()
465  << " NPCBs=" << GetSize() << endl;
466 
467  TString soption(option);
468 
469  if ( soption.Contains("P") )
470  {
471  for ( Int_t i = 0; i < GetSize() ; ++i )
472  {
473  cout << " ";
474  if ( option )
475  {
476  fPCBs[i]->Print(option+1);
477  }
478  else
479  {
480  fPCBs[i]->Print();
481  }
482  }
483  }
484 
485  if ( soption.Contains("M") || soption.Contains("L") )
486  {
487  cout << fManuMap.GetSize() << " ";
488  cout << "Electronic card (manu or local board) Ids : ";
489  TIter next(fManuMap.CreateIterator());
490  AliMpMotifPosition* mp;
491  while ( ( mp = static_cast<AliMpMotifPosition*>(next())) )
492  {
493  cout << mp->GetID() << " ";
494  }
495  cout << endl;
496  }
497 }
Double_t DX() const
Definition: AliMpPCB.cxx:454
Bool_t HasMotifPositionID(Int_t manuId) const
Definition: AliMpPCB.cxx:599
TObjArray fPCBs
array of AliMpPCB*
Definition: AliMpSlat.h:151
AliMpPCB * FindPCB(Int_t ix) const
Find the PCB containing the pad at location (ix,any iy).
Definition: AliMpSlat.cxx:228
Int_t Ixmin() const
Definition: AliMpPCB.cxx:615
void GetAllMotifPositionsIDs(TArrayI &ecn) const
Return the ids of the electronic cards (either manu or local board).
Definition: AliMpSlat.cxx:335
Double_t GetPositionY() const
Return y position.
Definition: AliMpSlat.h:62
Int_t GetNofPadsX() const
Definition: AliMpPCB.cxx:566
Int_t Ixmax() const
Definition: AliMpPCB.cxx:626
AliMp::PlaneType fPlaneType
Whether it's bending or non-bending plane.
Definition: AliMpSlat.h:145
A PCB for station 3,4 or 5.
Definition: AliMpPCB.h:46
AliMpMotifPosition * FindMotifPosition(Int_t ix, Int_t iy) const
Returns the motifPosition which contains the pad at (ix,iy).
Definition: AliMpPCB.cxx:495
void Add(const AliMpPCB &pcbType, const TArrayI &manuList)
Definition: AliMpSlat.cxx:112
Int_t fNofPadsX
Actual number of pads in x direction.
Definition: AliMpSlat.h:148
Double_t Ymin() const
Definition: AliMpPCB.cxx:800
Int_t GetSize() const
The number of motifs, aka manus.
Definition: AliMpPCB.cxx:588
Int_t FindPCBIndexByMotifPositionID(Int_t manuId) const
Find the index of the PCB containing a given manu.
Definition: AliMpSlat.cxx:308
Double_t fPositionX
x Position of the slat center.
Definition: AliMpSlat.h:152
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
Double_t fPositionY
y Position of the slat center.
Definition: AliMpSlat.h:153
Double_t Xmin() const
Definition: AliMpPCB.cxx:767
Int_t GetNofPadsY() const
Definition: AliMpPCB.cxx:577
AliMpMotifPosition * FindMotifPosition(Double_t x, Double_t y) const
Returns the MotifPosition containing location (x,y).
Definition: AliMpSlat.cxx:210
void ForcePosition(Double_t x, Double_t y)
Definition: AliMpSlat.cxx:321
Double_t DY() const
Definition: AliMpSlat.cxx:171
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetSize() const
Definition: AliMpExMap.cxx:340
Int_t fNofPads
number of pads in this slat
Definition: AliMpSlat.h:154
void Print(Option_t *option="") const
Definition: AliMpSlat.cxx:456
Int_t GetID() const
Return motif position ID = manu id.
virtual ~AliMpSlat()
Definition: AliMpSlat.cxx:100
A placed motif.
Double_t DX() const
Definition: AliMpSlat.cxx:161
AliMpPCB * GetPCB(Int_t i) const
Returns the i-th PCB of this slat.
Definition: AliMpSlat.cxx:435
const char * GetID() const
Definition: AliMpPCB.cxx:542
const char * GetName() const
Definition: AliMpSlat.cxx:391
Int_t GetNofPadsX() const
Returns the number of pads in the x-direction contained in this slat.
Definition: AliMpSlat.cxx:425
non-bending plane
Int_t fMaxNofPadsY
Maximum number of pads in y direction.
Definition: AliMpSlat.h:149
Double_t fDY
Half-size in Y (cm)
Definition: AliMpSlat.h:147
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
Int_t GetMaxNofPadsY() const
Definition: AliMpSlat.cxx:366
Double_t fDX
Half-size in X (cm)
Definition: AliMpSlat.h:146
const char * GetID() const
Definition: AliMpSlat.cxx:356
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
AliMpMotifPosition * GetMotifPosition(Int_t i) const
Definition: AliMpPCB.cxx:553
void SetOwner(Bool_t owner)
Definition: AliMpExMap.cxx:332
Int_t FindPCBIndex(Int_t ix) const
Find the index of the PCB containing the pad at location ix.
Definition: AliMpSlat.cxx:246
Double_t GetPositionX() const
Return x position.
Definition: AliMpSlat.h:60
bending plane
Double_t DY() const
Definition: AliMpPCB.cxx:480
AliMpSlat()
Not implemented.
Int_t GetMaxPadIndexX() const
Definition: AliMpSlat.cxx:376
TObject * Clone(const char *newname="") const
Definition: AliMpPCB.cxx:328
Double_t Xmax() const
Definition: AliMpPCB.cxx:778
TString fId
The name of this slat, e.g. 112233N.
Definition: AliMpSlat.h:144
AliMpExMap fManuMap
map of int to AliMpMotifPosition*
Definition: AliMpSlat.h:150
Int_t GetNofElectronicCards() const
Return the number of electronic cards (either manu or local board).
Definition: AliMpSlat.cxx:415
Int_t NofPads() const
Return the number of pads in this PCB.
Definition: AliMpPCB.h:138
Int_t GetSize() const
Returns the number of PCBs of this slat.
Definition: AliMpSlat.cxx:446
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
Double_t Ymax() const
Definition: AliMpPCB.cxx:811