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.4 2006/03/02 16:35:20 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),
70 AliDebug(1,Form("this=%p id=%s",this,id));
73 //_____________________________________________________________________________
74 AliMpSlat::~AliMpSlat()
79 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
82 //_____________________________________________________________________________
84 AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
87 // Adds a PCB to this slat. The manuList specifies the ids of the manu
88 // that compose the PCB. The manuList ordering is important, as the
89 // assumption is that it's ordered counter-clockwise, starting from
90 // the lower-left of the PCB.
95 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
99 ixOffset = pcbType->Ixmin();
101 Double_t xOffset = DX()*2;
102 AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset);
106 fPCBs.push_back(pcb);
108 fDY = TMath::Max(pcb->DY(),fDY);
110 fNofPadsX += pcb->GetNofPadsX();
111 fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
112 for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
114 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
115 Int_t manuID = mp->GetID();
116 // Before inserting a new key, check if it's already there
118 TObject* there = fManuMap.GetValue(manuID);
121 fManuMap.Add(manuID,(TObject*)mp);
125 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType->GetID()));
128 // fManuMap[manuID] = mp;
131 fPosition.Set(DX(),DY());
134 //_____________________________________________________________________________
136 AliMpSlat::Dimensions() const
139 // Returns the half-sizes of the slat.
141 return TVector2(DX(),DY());
144 //_____________________________________________________________________________
146 AliMpSlat::DX() const
149 // Returns the x-half-size of the slat.
154 //_____________________________________________________________________________
156 AliMpSlat::DY() const
159 // Returns the y-half-size of the slat.
164 //_____________________________________________________________________________
166 AliMpSlat::FindMotifPosition(Int_t manuID) const
169 // Returns the motifPosition referenced by it manuID
172 return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
174 // std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
175 // if ( it != fManuMap.end() )
177 // return it->second;
186 //_____________________________________________________________________________
188 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
191 // 1. Find the PCB containing ix (iy not needed for this)
192 // 2. Forward the request to the PCB, using pcb local indices.
194 const AliMpPCB* pcb = FindPCB(ix);
197 return pcb->FindMotifPosition(ix,iy);
205 //_____________________________________________________________________________
207 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
210 // Returns the motifPosition containing position (x,y)
212 const AliMpPCB* pcb = FindPCB(x,y);
215 return pcb->FindMotifPosition(x,y);
223 //_____________________________________________________________________________
225 AliMpSlat::FindPCB(Int_t ix) const
228 // Returns the PCB containing x-integer-position ix
230 for ( Size_t i = 0; i < GetSize(); ++i )
232 AliMpPCB* pcb = GetPCB(i);
233 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
241 //_____________________________________________________________________________
243 AliMpSlat::FindPCBIndex(Int_t ix) const
246 // Returns the index of the PCB containing x-integer-position ix.
248 for ( Size_t i = 0; i < GetSize(); ++i )
250 AliMpPCB* pcb = GetPCB(i);
251 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
259 //_____________________________________________________________________________
261 AliMpSlat::FindPCB(Double_t x, Double_t y) const
264 // Returns the PCB containing position (x,y)
266 for ( Size_t i = 0; i < GetSize(); ++i )
268 AliMpPCB* pcb = GetPCB(i);
269 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
270 y >= pcb->Ymin() && y < pcb->Ymax() )
278 //_____________________________________________________________________________
280 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
283 // Returns the index of the PCB containing position (x,y)
285 for ( Size_t i = 0; i < GetSize(); ++i )
287 AliMpPCB* pcb = GetPCB(i);
288 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
289 y >= pcb->Ymin() && y < pcb->Ymax() )
297 //_____________________________________________________________________________
299 AliMpSlat::ForcePosition(const TVector2& pos)
302 // Force the position to be different from (DX(),DY()).
303 // Normally only used by triggerSlats (for layers).
304 // Beware that this method must be called once all PCB have been added,
305 // as the Add() method resets the position.
310 //_____________________________________________________________________________
312 AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
314 ecn.Set(GetNofElectronicCards());
316 TExMapIter it(fManuMap.GetIterator());
320 while ( it.Next(key,value) == kTRUE )
322 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::PlaneType() const
436 //_____________________________________________________________________________
438 AliMpSlat::Position() const
443 //_____________________________________________________________________________
445 AliMpSlat::Print(Option_t* option) const
448 // Prints the slat characteristics.
450 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
451 << " POS = " << Position().X() << "," << Position().Y()
452 << " NPADSX = " << GetNofPadsX()
453 << " MAXNPADSY = " << GetMaxNofPadsY()
454 << " NPCBs=" << GetSize() << endl;
456 TString soption(option);
458 if ( soption.Contains("P") )
460 for ( Size_t i = 0; i < GetSize() ; ++i )
465 fPCBs[i]->Print(option+1);
474 if ( soption.Contains("M") || soption.Contains("L") )
476 cout << fManuMap.GetSize() << " ";
477 cout << "Electronic card (manu or local board) Ids : ";
479 TExMapIter iter(fManuMap.GetIterator());
481 while ( iter.Next(key,value) )