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"
21 #include "AliMpExMapIterator.h"
23 #include "AliMpMotifPosition.h"
26 #include "Riostream.h"
32 //-----------------------------------------------------------------------------
33 /// Representation of a slat cathode (bending or non-bending).
35 /// A slat can be viewed as a "collection" of PCBs of various densities
36 /// (the density is defined by the size of the pads composing the PCB).
38 /// All the PCBs have a least the same height, if not the same width. In most
39 /// of the case, height=width=40 cm, at least for St345 (for trigger,
42 /// \author Laurent Aphecetche
43 //-----------------------------------------------------------------------------
51 //_____________________________________________________________________________
52 AliMpSlat::AliMpSlat(TRootIOCtor* ioCtor)
55 fPlaneType(AliMp::kNonBendingPlane),
69 AliDebug(1,Form("this=%p Empty ctor",this));
71 fPCBs.SetOwner(kTRUE);
72 fManuMap.SetOwner(kFALSE);
75 //_____________________________________________________________________________
76 AliMpSlat::AliMpSlat(const char* id, AliMp::PlaneType bendingOrNonBending)
79 fPlaneType(bendingOrNonBending),
93 AliDebug(1,Form("this=%p id=%s",this,id));
95 fPCBs.SetOwner(kTRUE);
96 fManuMap.SetOwner(kFALSE);
99 //_____________________________________________________________________________
100 AliMpSlat::~AliMpSlat()
105 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
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);
132 fDY = TMath::Max(pcb->DY(),fDY);
134 fNofPadsX += pcb->GetNofPadsX();
135 fMaxNofPadsY = TMath::Max(fMaxNofPadsY,pcb->GetNofPadsY());
137 for ( Int_t i = 0; i < pcb->GetSize(); ++i )
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);
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);
151 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType.GetID()));
156 fNofPads += pcb->NofPads();
159 //_____________________________________________________________________________
161 AliMpSlat::DX() const
164 /// Returns the x-half-size of the slat.
169 //_____________________________________________________________________________
171 AliMpSlat::DY() const
174 /// Returns the y-half-size of the slat.
179 //_____________________________________________________________________________
181 AliMpSlat::FindMotifPosition(Int_t manuID) const
184 /// Returns the motifPosition referenced by it manuID
186 return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
189 //_____________________________________________________________________________
191 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
194 /// - 1. Find the PCB containing ix (iy not needed for this)
195 /// - 2. Forward the request to the PCB, using pcb local indices.
197 const AliMpPCB* pcb = FindPCB(ix);
200 return pcb->FindMotifPosition(ix,iy);
208 //_____________________________________________________________________________
210 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
213 /// Returns the motifPosition containing position (x,y)
215 const AliMpPCB* pcb = FindPCB(x,y);
218 return pcb->FindMotifPosition(x,y);
226 //_____________________________________________________________________________
228 AliMpSlat::FindPCB(Int_t ix) const
231 /// Returns the PCB containing x-integer-position ix
233 for ( Int_t i = 0; i < GetSize(); ++i )
235 AliMpPCB* pcb = GetPCB(i);
236 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
244 //_____________________________________________________________________________
246 AliMpSlat::FindPCBIndex(Int_t ix) const
249 /// Returns the index of the PCB containing x-integer-position ix.
251 for ( Int_t i = 0; i < GetSize(); ++i )
253 AliMpPCB* pcb = GetPCB(i);
254 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
262 //_____________________________________________________________________________
264 AliMpSlat::FindPCB(Double_t x, Double_t y) const
267 /// Returns the PCB containing position (x,y)
269 for ( Int_t i = 0; i < GetSize(); ++i )
271 AliMpPCB* pcb = GetPCB(i);
272 // if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
273 // y >= pcb->Ymin() && y < pcb->Ymax() )
277 if ( x < pcb->Xmin() || x >= pcb->Xmax() ||
278 y < pcb->Ymin() || y >= pcb->Ymax() )
287 //_____________________________________________________________________________
289 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
292 /// Returns the index of the PCB containing position (x,y)
294 for ( Int_t i = 0; i < GetSize(); ++i )
296 AliMpPCB* pcb = GetPCB(i);
297 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
298 y >= pcb->Ymin() && y < pcb->Ymax() )
306 //_____________________________________________________________________________
308 AliMpSlat::FindPCBIndexByMotifPositionID(Int_t manuId) const
310 /// Find the index of the PCB containing a given manu
311 for ( Int_t i = 0; i< GetSize(); ++i )
313 AliMpPCB* pcb = GetPCB(i);
314 if ( pcb->HasMotifPositionID(manuId) ) return i;
319 //_____________________________________________________________________________
321 AliMpSlat::ForcePosition(Double_t x, Double_t y)
324 /// Force the position to be different from (DX(),DY()).
325 /// Normally only used by triggerSlats (for layers).
326 /// Beware that this method must be called once all PCB have been added,
327 /// as the Add() method resets the position.
333 //_____________________________________________________________________________
335 AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
338 /// Return all the manuIds (=MotifPositionIDs) of this slat
340 Int_t nofElectronicCards(GetNofElectronicCards());
341 assert(nofElectronicCards>0);
342 ecn.Set(nofElectronicCards);
343 TIter next(fManuMap.CreateIterator());
344 AliMpMotifPosition* mp;
346 while ( ( mp = static_cast<AliMpMotifPosition*>(next()) ) )
348 ecn.AddAt(mp->GetID(),n);
351 assert(n==nofElectronicCards);
354 //_____________________________________________________________________________
356 AliMpSlat::GetID() const
359 /// Returns the name of this slat.
364 //_____________________________________________________________________________
366 AliMpSlat::GetMaxNofPadsY() const
369 /// Returns the maximum number of pads to be found in this slat y-direction.
374 //_____________________________________________________________________________
376 AliMpSlat::GetMaxPadIndexX() const
379 /// Returns the max ix that is valid for this slat.
381 AliMpPCB* last = GetPCB(GetSize()-1);
384 return last->Ixmax();
389 //_____________________________________________________________________________
391 AliMpSlat::GetName() const
394 /// Returns the name of this slat, which is composed of its ID with
395 /// the plane type as a suffix.
397 TString name(GetID());
398 if ( fPlaneType == AliMp::kBendingPlane )
402 else if ( fPlaneType == AliMp::kNonBendingPlane )
404 name += ".NonBending";
413 //_____________________________________________________________________________
415 AliMpSlat::GetNofElectronicCards() const
418 /// Returns the number of manus that compose the readout of this slat.
420 return fManuMap.GetSize();
423 //_____________________________________________________________________________
425 AliMpSlat::GetNofPadsX() const
428 /// Returns the number of pad in x-direction.
433 //_____________________________________________________________________________
435 AliMpSlat::GetPCB(Int_t i) const
438 /// Returns the i-th PCB of this slat.
440 if ( i >= fPCBs.GetEntriesFast() ) return 0;
441 return (AliMpPCB*)fPCBs[i];
444 //_____________________________________________________________________________
446 AliMpSlat::GetSize() const
449 /// Returns the number of PCB in this slat.
451 return fPCBs.GetEntriesFast();
454 //_____________________________________________________________________________
456 AliMpSlat::Print(Option_t* option) const
459 /// Prints the slat characteristics.
461 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
462 << " POS = " << GetPositionX() << "," << GetPositionY()
463 << " NPADSX = " << GetNofPadsX()
464 << " MAXNPADSY = " << GetMaxNofPadsY()
465 << " NPCBs=" << GetSize() << endl;
467 TString soption(option);
469 if ( soption.Contains("P") )
471 for ( Int_t i = 0; i < GetSize() ; ++i )
476 fPCBs[i]->Print(option+1);
485 if ( soption.Contains("M") || soption.Contains("L") )
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())) )
493 cout << mp->GetID() << " ";