1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpSlat.cxx,v 1.2 2005/09/19 19:01:31 ivana Exp $
19 #include "AliMpSlat.h"
22 #include "AliMpConnection.h"
23 #include "AliMpMotif.h"
24 #include "AliMpMotifPosition.h"
25 #include "AliMpMotifType.h"
27 #include "AliMpSlatPadIterator.h"
29 #include "Riostream.h"
35 //_____________________________________________________________________________
36 AliMpSlat::AliMpSlat()
39 fPlaneType(kNonBendingPlane),
49 AliDebug(1,Form("this=%p Empty ctor",this));
52 //_____________________________________________________________________________
53 AliMpSlat::AliMpSlat(const char* id, AliMpPlaneType bendingOrNonBending)
56 fPlaneType(bendingOrNonBending),
66 AliDebug(1,Form("this=%p id=%s",this,id));
69 //_____________________________________________________________________________
70 AliMpSlat::~AliMpSlat()
75 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
78 //_____________________________________________________________________________
80 AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
83 // Adds a PCB to this slat. The manuList speficy the ids of the manu
84 // that compose the PCB. The manuList ordering is important, as the
85 // assumption is that it's ordered counter-clockwise, starting from
86 // the lower-left of the PCB.
91 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
95 ixOffset = pcbType->Ixmin();
97 Double_t xOffset = DX()*2;
98 AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset);
102 fPCBs.push_back(pcb);
104 fDY = TMath::Max(pcb->DY(),fDY);
106 fNofPadsX += pcb->GetNofPadsX();
107 fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
108 for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
110 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
111 Int_t manuID = mp->GetID();
112 // Before inserting a new key, check if it's already there
114 TObject* there = fManuMap.GetValue(manuID);
117 fManuMap.Add(manuID,(TObject*)mp);
121 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType->GetID()));
124 fManuMap[manuID] = mp;
127 fPosition.Set(DX(),DY());
130 //_____________________________________________________________________________
132 AliMpSlat::Dimensions() const
135 // Returns the half-sizes of the slat.
137 return TVector2(DX(),DY());
140 //_____________________________________________________________________________
142 AliMpSlat::DX() const
145 // Returns the x-half-size of the slat.
150 //_____________________________________________________________________________
152 AliMpSlat::DY() const
155 // Returns the y-half-size of the slat.
160 //_____________________________________________________________________________
162 AliMpSlat::FindMotifPosition(Int_t manuID) const
165 // Returns the motifPosition referenced by it manuID
168 TObject* rv = fManuMap.GetValue(manuID);
171 return (AliMpMotifPosition*)(rv);
178 std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
179 if ( it != fManuMap.end() )
190 //_____________________________________________________________________________
192 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
195 // 1. Find the PCB containing ix (iy not needed for this)
196 // 2. Forward the request to the PCB, using pcb local indices.
198 const AliMpPCB* pcb = FindPCB(ix);
201 return pcb->FindMotifPosition(ix,iy);
209 //_____________________________________________________________________________
211 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
214 // Returns the motifPosition containing position (x,y)
216 const AliMpPCB* pcb = FindPCB(x,y);
219 return pcb->FindMotifPosition(x,y);
227 //_____________________________________________________________________________
229 AliMpSlat::FindPCB(Int_t ix) const
232 // Returns the PCB containing x-integer-position ix
234 for ( Size_t i = 0; i < GetSize(); ++i )
236 AliMpPCB* pcb = GetPCB(i);
237 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
245 //_____________________________________________________________________________
247 AliMpSlat::FindPCBIndex(Int_t ix) const
250 // Returns the index of the PCB containing x-integer-position ix.
252 for ( Size_t i = 0; i < GetSize(); ++i )
254 AliMpPCB* pcb = GetPCB(i);
255 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
263 //_____________________________________________________________________________
265 AliMpSlat::FindPCB(Double_t x, Double_t y) const
268 // Returns the PCB containing position (x,y)
270 for ( Size_t i = 0; i < GetSize(); ++i )
272 AliMpPCB* pcb = GetPCB(i);
273 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
274 y >= pcb->Ymin() && y < pcb->Ymax() )
282 //_____________________________________________________________________________
284 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
287 // Returns the index of the PCB containing position (x,y)
289 for ( Size_t i = 0; i < GetSize(); ++i )
291 AliMpPCB* pcb = GetPCB(i);
292 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
293 y >= pcb->Ymin() && y < pcb->Ymax() )
301 //_____________________________________________________________________________
303 AliMpSlat::ForcePosition(const TVector2& pos)
306 // Force the position to be different from (DX(),DY()).
307 // Normally only used by triggerSlats (for layers).
308 // Beware that this method must be called once all PCB have been added,
309 // as the Add() method resets the position.
314 //_____________________________________________________________________________
316 AliMpSlat::GetAllElectronicCardNumbers(TArrayI& ecn) const
318 ecn.Set(GetNofElectronicCards());
319 TExMapIter it(fManuMap.GetIterator());
323 while ( it.Next(key,value) == kTRUE )
325 ecn.AddAt((Int_t)(key),n);
330 //_____________________________________________________________________________
332 AliMpSlat::GetID() const
335 // Returns the name of this slat.
340 //_____________________________________________________________________________
342 AliMpSlat::GetMaxNofPadsY() const
345 // Returns the maximum number of pads to be found in this slat y-direction.
350 //_____________________________________________________________________________
352 AliMpSlat::GetMaxPadIndexX() const
354 AliMpPCB* last = GetPCB(GetSize()-1);
357 return last->Ixmax();
362 //_____________________________________________________________________________
364 AliMpSlat::GetName() const
366 TString name(GetID());
367 if ( fPlaneType == kBendingPlane )
371 else if ( fPlaneType == kNonBendingPlane )
373 name += ".NonBending";
382 //_____________________________________________________________________________
384 AliMpSlat::GetNofElectronicCards() const
386 return fManuMap.GetSize();
389 //_____________________________________________________________________________
391 AliMpSlat::GetNofPadsX() const
394 // Returns the number of pad in x-direction.
399 //_____________________________________________________________________________
401 AliMpSlat::GetPCB(AliMpSlat::Size_t i) const
404 // Returns the i-th PCB of this slat.
407 if ( i >= fPCBs.GetEntriesFast() ) return 0;
408 return (AliMpPCB*)fPCBs[i];
410 if ( i >= fPCBs.size() ) return 0;
415 //_____________________________________________________________________________
417 AliMpSlat::GetSize() const
420 // Returns the number of PCB in this slat.
423 return fPCBs.GetEntriesFast();
429 //_____________________________________________________________________________
431 AliMpSlat::Position() const
436 //_____________________________________________________________________________
438 AliMpSlat::Print(Option_t* option) const
441 // Prints the slat characteristics.
443 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
444 << " POS = " << Position().X() << "," << Position().Y()
445 << " NPADSX = " << GetNofPadsX()
446 << " MAXNPADSY = " << GetMaxNofPadsY()
447 << " NPCBs=" << GetSize() << endl;
449 TString soption(option);
451 if ( soption.Contains("P") )
453 for ( Size_t i = 0; i < GetSize() ; ++i )
458 fPCBs[i]->Print(option+1);
467 if ( soption.Contains("M") || soption.Contains("L") )
469 cout << fManuMap.GetSize() << " ";
470 cout << "Electronic card (manu or local board) Ids : ";
472 TExMapIter iter(fManuMap.GetIterator());
474 while ( iter.Next(key,value) )