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.6 2006/05/24 13:58:50 ivana Exp $
19 #include "AliMpSlat.h"
22 #include "AliMpMotifPosition.h"
25 #include "Riostream.h"
30 /// Representation of a slat cathode (bending or non-bending).
32 /// A slat can be viewed as a "collection" of PCBs of various densities
33 /// (the density is defined by the size of the pads composing the PCB).
35 /// All the PCBs have a least the same height, if not the same width. In most
36 /// of the case, height=width=40 cm, at least for St345 (for trigger,
39 /// \author Laurent Aphecetche
45 //_____________________________________________________________________________
46 AliMpSlat::AliMpSlat()
49 fPlaneType(AliMp::kNonBendingPlane),
62 AliDebug(1,Form("this=%p Empty ctor",this));
64 fPCBs.SetOwner(kTRUE);
66 fManuMap.SetOwner(kFALSE);
69 //_____________________________________________________________________________
70 AliMpSlat::AliMpSlat(const char* id, AliMp::PlaneType bendingOrNonBending)
73 fPlaneType(bendingOrNonBending),
86 AliDebug(1,Form("this=%p id=%s",this,id));
88 fPCBs.SetOwner(kTRUE);
90 fManuMap.SetOwner(kFALSE);
93 //_____________________________________________________________________________
94 AliMpSlat::~AliMpSlat()
99 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
103 for ( size_t i = 0; i < fPCBs.size(); ++i )
110 //_____________________________________________________________________________
112 AliMpSlat::Add(const AliMpPCB& pcbType, const TArrayI& manuList)
115 // Adds a PCB to this slat. The manuList specifies the ids of the manu
116 // that compose the PCB. The manuList ordering is important, as the
117 // assumption is that it's ordered counter-clockwise, starting from
118 // the lower-left of the PCB.
123 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
127 ixOffset = pcbType.Ixmin();
129 Double_t xOffset = DX()*2;
130 AliMpPCB* pcb = pcbType.Clone(manuList,ixOffset,xOffset);
134 fPCBs.push_back(pcb);
136 fDY = TMath::Max(pcb->DY(),fDY);
138 fNofPadsX += pcb->GetNofPadsX();
139 fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
140 for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
142 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
143 Int_t manuID = mp->GetID();
144 // Before inserting a new key, check if it's already there
146 TObject* there = fManuMap.GetValue(manuID);
149 fManuMap.Add(manuID,(TObject*)mp);
153 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType.GetID()));
156 // fManuMap[manuID] = mp;
159 fPosition.Set(DX(),DY());
160 fNofPads += pcb->NofPads();
163 //_____________________________________________________________________________
165 AliMpSlat::Dimensions() const
168 // Returns the half-sizes of the slat.
170 return TVector2(DX(),DY());
173 //_____________________________________________________________________________
175 AliMpSlat::DX() const
178 // Returns the x-half-size of the slat.
183 //_____________________________________________________________________________
185 AliMpSlat::DY() const
188 // Returns the y-half-size of the slat.
193 //_____________________________________________________________________________
195 AliMpSlat::FindMotifPosition(Int_t manuID) const
198 // Returns the motifPosition referenced by it manuID
201 return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
203 // std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
204 // if ( it != fManuMap.end() )
206 // return it->second;
215 //_____________________________________________________________________________
217 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
220 // 1. Find the PCB containing ix (iy not needed for this)
221 // 2. Forward the request to the PCB, using pcb local indices.
223 const AliMpPCB* pcb = FindPCB(ix);
226 return pcb->FindMotifPosition(ix,iy);
234 //_____________________________________________________________________________
236 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
239 // Returns the motifPosition containing position (x,y)
241 const AliMpPCB* pcb = FindPCB(x,y);
244 return pcb->FindMotifPosition(x,y);
252 //_____________________________________________________________________________
254 AliMpSlat::FindPCB(Int_t ix) const
257 // Returns the PCB containing x-integer-position ix
259 for ( Size_t i = 0; i < GetSize(); ++i )
261 AliMpPCB* pcb = GetPCB(i);
262 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
270 //_____________________________________________________________________________
272 AliMpSlat::FindPCBIndex(Int_t ix) const
275 // Returns the index of the PCB containing x-integer-position ix.
277 for ( Size_t i = 0; i < GetSize(); ++i )
279 AliMpPCB* pcb = GetPCB(i);
280 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
288 //_____________________________________________________________________________
290 AliMpSlat::FindPCB(Double_t x, Double_t y) const
293 // Returns the PCB containing position (x,y)
295 for ( Size_t i = 0; i < GetSize(); ++i )
297 AliMpPCB* pcb = GetPCB(i);
298 // if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
299 // y >= pcb->Ymin() && y < pcb->Ymax() )
303 if ( x < pcb->Xmin() || x >= pcb->Xmax() ||
304 y < pcb->Ymin() || y >= pcb->Ymax() )
313 //_____________________________________________________________________________
315 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
318 // Returns the index of the PCB containing position (x,y)
320 for ( Size_t i = 0; i < GetSize(); ++i )
322 AliMpPCB* pcb = GetPCB(i);
323 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
324 y >= pcb->Ymin() && y < pcb->Ymax() )
332 //_____________________________________________________________________________
334 AliMpSlat::ForcePosition(const TVector2& pos)
337 // Force the position to be different from (DX(),DY()).
338 // Normally only used by triggerSlats (for layers).
339 // Beware that this method must be called once all PCB have been added,
340 // as the Add() method resets the position.
345 //_____________________________________________________________________________
347 AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
350 // Return all the manuIds (=MotifPositionIDs) of this slat
352 ecn.Set(GetNofElectronicCards());
354 TExMapIter it(fManuMap.GetIterator());
358 while ( it.Next(key,value) == kTRUE )
360 ecn.AddAt((Int_t)(key),n);
368 //_____________________________________________________________________________
370 AliMpSlat::GetID() const
373 // Returns the name of this slat.
378 //_____________________________________________________________________________
380 AliMpSlat::GetMaxNofPadsY() const
383 // Returns the maximum number of pads to be found in this slat y-direction.
388 //_____________________________________________________________________________
390 AliMpSlat::GetMaxPadIndexX() const
393 // Returns the max ix that is valid for this slat.
395 AliMpPCB* last = GetPCB(GetSize()-1);
398 return last->Ixmax();
403 //_____________________________________________________________________________
405 AliMpSlat::GetName() const
408 // Returns the name of this slat, which is composed of its ID with
409 // the plane type as a suffix.
411 TString name(GetID());
412 if ( fPlaneType == AliMp::kBendingPlane )
416 else if ( fPlaneType == AliMp::kNonBendingPlane )
418 name += ".NonBending";
427 //_____________________________________________________________________________
429 AliMpSlat::GetNofElectronicCards() const
432 // Returns the number of manus that compose the readout of this slat.
434 return fManuMap.GetSize();
437 //_____________________________________________________________________________
439 AliMpSlat::GetNofPadsX() const
442 // Returns the number of pad in x-direction.
447 //_____________________________________________________________________________
449 AliMpSlat::GetPCB(AliMpSlat::Size_t i) const
452 // Returns the i-th PCB of this slat.
455 if ( i >= fPCBs.GetEntriesFast() ) return 0;
456 return (AliMpPCB*)fPCBs[i];
458 if ( i >= fPCBs.size() ) return 0;
463 //_____________________________________________________________________________
465 AliMpSlat::GetSize() const
468 // Returns the number of PCB in this slat.
471 return fPCBs.GetEntriesFast();
477 //_____________________________________________________________________________
479 AliMpSlat::Print(Option_t* option) const
482 // Prints the slat characteristics.
484 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
485 << " POS = " << Position().X() << "," << Position().Y()
486 << " NPADSX = " << GetNofPadsX()
487 << " MAXNPADSY = " << GetMaxNofPadsY()
488 << " NPCBs=" << GetSize() << endl;
490 TString soption(option);
492 if ( soption.Contains("P") )
494 for ( Size_t i = 0; i < GetSize() ; ++i )
499 fPCBs[i]->Print(option+1);
508 if ( soption.Contains("M") || soption.Contains("L") )
510 cout << fManuMap.GetSize() << " ";
511 cout << "Electronic card (manu or local board) Ids : ";
513 TExMapIter iter(fManuMap.GetIterator());
515 while ( iter.Next(key,value) )