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()
47 AliDebug(1,Form("this=%p Empty ctor",this));
50 //_____________________________________________________________________________
51 AliMpSlat::AliMpSlat(const char* id)
62 AliDebug(1,Form("this=%p id=%s",this,id));
65 //_____________________________________________________________________________
66 AliMpSlat::~AliMpSlat()
71 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
74 //_____________________________________________________________________________
76 AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
79 // Adds a PCB to this slat. The manuList speficy the ids of the manu
80 // that compose the PCB. The manuList ordering is important, as the
81 // assumption is that it's ordered counter-clockwise, starting from
82 // the lower-left of the PCB.
87 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
89 Double_t xOffset = DX()*2;
90 AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset);
98 fNofPadsX += pcb->GetNofPadsX();
99 fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
100 for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
102 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
103 Int_t manuID = mp->GetID();
104 // Before inserting a new key, check if it's already there
106 Long_t there = fManuMap.GetValue((Long_t)manuID);
109 fManuMap.Add((Long_t)manuID,(Long_t)mp);
113 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType->GetID()));
116 fManuMap[manuID] = mp;
121 //_____________________________________________________________________________
123 AliMpSlat::Dimensions() const
126 // Returns the half-sizes of the slat.
128 return TVector2(DX(),DY());
131 //_____________________________________________________________________________
133 AliMpSlat::DX() const
136 // Returns the x-half-size of the slat.
141 //_____________________________________________________________________________
143 AliMpSlat::DY() const
146 // Returns the y-half-size of the slat.
151 //_____________________________________________________________________________
153 AliMpSlat::FindMotifPosition(Int_t manuID) const
156 // Returns the motifPosition referenced by it manuID
159 Long_t rv = fManuMap.GetValue((Long_t)manuID);
162 return (AliMpMotifPosition*)(rv);
169 std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
170 if ( it != fManuMap.end() )
181 //_____________________________________________________________________________
183 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
186 // 1. Find the PCB containing ix (iy not needed for this)
187 // 2. Forward the request to the PCB, using pcb local indices.
189 const AliMpPCB* pcb = FindPCB(ix);
192 return pcb->FindMotifPosition(ix,iy);
200 //_____________________________________________________________________________
202 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
205 // Returns the motifPosition containing position (x,y)
207 const AliMpPCB* pcb = FindPCB(x,y);
210 return pcb->FindMotifPosition(x,y);
218 //_____________________________________________________________________________
220 AliMpSlat::FindPCB(Int_t ix) const
223 // Returns the PCB containing x-integer-position ix
225 for ( Size_t i = 0; i < GetSize(); ++i )
227 AliMpPCB* pcb = GetPCB(i);
228 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
236 //_____________________________________________________________________________
238 AliMpSlat::FindPCBIndex(Int_t ix) const
241 // Returns the index of the PCB containing x-integer-position ix.
243 for ( Size_t i = 0; i < GetSize(); ++i )
245 AliMpPCB* pcb = GetPCB(i);
246 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
254 //_____________________________________________________________________________
256 AliMpSlat::FindPCB(Double_t x, Double_t y) const
259 // Returns the PCB containing position (x,y)
261 for ( Size_t i = 0; i < GetSize(); ++i )
263 AliMpPCB* pcb = GetPCB(i);
264 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
265 y >= pcb->Ymin() && y < pcb->Ymax() )
273 //_____________________________________________________________________________
275 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
278 // Returns the index of the PCB containing position (x,y)
280 for ( Size_t i = 0; i < GetSize(); ++i )
282 AliMpPCB* pcb = GetPCB(i);
283 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
284 y >= pcb->Ymin() && y < pcb->Ymax() )
292 //_____________________________________________________________________________
294 AliMpSlat::GetID() const
297 // Returns the name of this slat.
302 //_____________________________________________________________________________
304 AliMpSlat::GetMaxNofPadsY() const
307 // Returns the maximum number of pads to be found in this slat y-direction.
312 //_____________________________________________________________________________
314 AliMpSlat::GetNofPadsX() const
317 // Returns the number of pad in x-direction.
322 //_____________________________________________________________________________
324 AliMpSlat::GetPCB(AliMpSlat::Size_t i) const
327 // Returns the i-th PCB of this slat.
330 if ( i >= fPCBs.GetEntriesFast() ) return 0;
331 return (AliMpPCB*)fPCBs[i];
333 if ( i >= fPCBs.size() ) return 0;
338 //_____________________________________________________________________________
340 AliMpSlat::GetSize() const
343 // Returns the number of PCB in this slat.
346 return fPCBs.GetEntriesFast();
352 //_____________________________________________________________________________
354 AliMpSlat::Print(Option_t* option) const
357 // Prints the slat characteristics.
359 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
360 << " NPADSX = " << GetNofPadsX() << " NPCBs=" << GetSize() << endl;
362 if ( option && option[0] == 'P' )
364 for ( Size_t i = 0; i < GetSize() ; ++i )
369 fPCBs[i]->Print(option+1);