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 //-----------------------------------------------------------------------------
49 //_____________________________________________________________________________
50 AliMpSlat::AliMpSlat(TRootIOCtor* ioCtor)
53 fPlaneType(AliMp::kNonBendingPlane),
66 AliDebug(1,Form("this=%p Empty ctor",this));
68 fPCBs.SetOwner(kTRUE);
69 fManuMap.SetOwner(kFALSE);
72 //_____________________________________________________________________________
73 AliMpSlat::AliMpSlat(const char* id, AliMp::PlaneType bendingOrNonBending)
76 fPlaneType(bendingOrNonBending),
89 AliDebug(1,Form("this=%p id=%s",this,id));
91 fPCBs.SetOwner(kTRUE);
92 fManuMap.SetOwner(kFALSE);
95 //_____________________________________________________________________________
96 AliMpSlat::~AliMpSlat()
101 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
106 //_____________________________________________________________________________
108 AliMpSlat::Add(const AliMpPCB& pcbType, const TArrayI& manuList)
111 /// Adds a PCB to this slat. The manuList specifies the ids of the manu
112 /// that compose the PCB. The manuList ordering is important, as the
113 /// assumption is that it's ordered counter-clockwise, starting from
114 /// the lower-left of the PCB.
119 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
123 ixOffset = pcbType.Ixmin();
125 Double_t xOffset = DX()*2;
126 AliMpPCB* pcb = pcbType.Clone(manuList,ixOffset,xOffset);
128 fDY = TMath::Max(pcb->DY(),fDY);
130 fNofPadsX += pcb->GetNofPadsX();
131 fMaxNofPadsY = TMath::Max(fMaxNofPadsY,pcb->GetNofPadsY());
133 for ( Int_t i = 0; i < pcb->GetSize(); ++i )
135 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
136 Int_t manuID = mp->GetID();
137 // Before inserting a new key, check if it's already there
138 TObject* there = fManuMap.GetValue(manuID);
142 AliDebug(1,Form("Adding %d-th manuId=%d (%d) to ManuMap (size=%d)",n,manuID,mp->GetID(),fManuMap.GetSize()));
143 fManuMap.Add(manuID,(TObject*)mp);
147 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType.GetID()));
150 fPosition.Set(DX(),DY());
151 fNofPads += pcb->NofPads();
154 //_____________________________________________________________________________
156 AliMpSlat::Dimensions() const
159 /// Returns the half-sizes of the slat.
161 return TVector2(DX(),DY());
164 //_____________________________________________________________________________
166 AliMpSlat::DX() const
169 /// Returns the x-half-size of the slat.
174 //_____________________________________________________________________________
176 AliMpSlat::DY() const
179 /// Returns the y-half-size of the slat.
184 //_____________________________________________________________________________
186 AliMpSlat::FindMotifPosition(Int_t manuID) const
189 /// Returns the motifPosition referenced by it manuID
191 return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
194 //_____________________________________________________________________________
196 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
199 /// - 1. Find the PCB containing ix (iy not needed for this)
200 /// - 2. Forward the request to the PCB, using pcb local indices.
202 const AliMpPCB* pcb = FindPCB(ix);
205 return pcb->FindMotifPosition(ix,iy);
213 //_____________________________________________________________________________
215 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
218 /// Returns the motifPosition containing position (x,y)
220 const AliMpPCB* pcb = FindPCB(x,y);
223 return pcb->FindMotifPosition(x,y);
231 //_____________________________________________________________________________
233 AliMpSlat::FindPCB(Int_t ix) const
236 /// Returns the PCB containing x-integer-position ix
238 for ( Int_t i = 0; i < GetSize(); ++i )
240 AliMpPCB* pcb = GetPCB(i);
241 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
249 //_____________________________________________________________________________
251 AliMpSlat::FindPCBIndex(Int_t ix) const
254 /// Returns the index of the PCB containing x-integer-position ix.
256 for ( Int_t i = 0; i < GetSize(); ++i )
258 AliMpPCB* pcb = GetPCB(i);
259 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
267 //_____________________________________________________________________________
269 AliMpSlat::FindPCB(Double_t x, Double_t y) const
272 /// Returns the PCB containing position (x,y)
274 for ( Int_t i = 0; i < GetSize(); ++i )
276 AliMpPCB* pcb = GetPCB(i);
277 // if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
278 // y >= pcb->Ymin() && y < pcb->Ymax() )
282 if ( x < pcb->Xmin() || x >= pcb->Xmax() ||
283 y < pcb->Ymin() || y >= pcb->Ymax() )
292 //_____________________________________________________________________________
294 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
297 /// Returns the index of the PCB containing position (x,y)
299 for ( Int_t i = 0; i < GetSize(); ++i )
301 AliMpPCB* pcb = GetPCB(i);
302 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
303 y >= pcb->Ymin() && y < pcb->Ymax() )
311 //_____________________________________________________________________________
313 AliMpSlat::FindPCBIndexByMotifPositionID(Int_t manuId) const
315 /// Find the index of the PCB containing a given manu
316 for ( Int_t i = 0; i< GetSize(); ++i )
318 AliMpPCB* pcb = GetPCB(i);
319 if ( pcb->HasMotifPositionID(manuId) ) return i;
324 //_____________________________________________________________________________
326 AliMpSlat::ForcePosition(const TVector2& pos)
329 /// Force the position to be different from (DX(),DY()).
330 /// Normally only used by triggerSlats (for layers).
331 /// Beware that this method must be called once all PCB have been added,
332 /// as the Add() method resets the position.
337 //_____________________________________________________________________________
339 AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
342 /// Return all the manuIds (=MotifPositionIDs) of this slat
344 Int_t nofElectronicCards(GetNofElectronicCards());
345 assert(nofElectronicCards>0);
346 ecn.Set(nofElectronicCards);
347 TIter next(fManuMap.CreateIterator());
348 AliMpMotifPosition* mp;
350 while ( ( mp = static_cast<AliMpMotifPosition*>(next()) ) )
352 ecn.AddAt(mp->GetID(),n);
355 assert(n==nofElectronicCards);
358 //_____________________________________________________________________________
360 AliMpSlat::GetID() const
363 /// Returns the name of this slat.
368 //_____________________________________________________________________________
370 AliMpSlat::GetMaxNofPadsY() const
373 /// Returns the maximum number of pads to be found in this slat y-direction.
378 //_____________________________________________________________________________
380 AliMpSlat::GetMaxPadIndexX() const
383 /// Returns the max ix that is valid for this slat.
385 AliMpPCB* last = GetPCB(GetSize()-1);
388 return last->Ixmax();
393 //_____________________________________________________________________________
395 AliMpSlat::GetName() const
398 /// Returns the name of this slat, which is composed of its ID with
399 /// the plane type as a suffix.
401 TString name(GetID());
402 if ( fPlaneType == AliMp::kBendingPlane )
406 else if ( fPlaneType == AliMp::kNonBendingPlane )
408 name += ".NonBending";
417 //_____________________________________________________________________________
419 AliMpSlat::GetNofElectronicCards() const
422 /// Returns the number of manus that compose the readout of this slat.
424 return fManuMap.GetSize();
427 //_____________________________________________________________________________
429 AliMpSlat::GetNofPadsX() const
432 /// Returns the number of pad in x-direction.
437 //_____________________________________________________________________________
439 AliMpSlat::GetPCB(Int_t i) const
442 /// Returns the i-th PCB of this slat.
444 if ( i >= fPCBs.GetEntriesFast() ) return 0;
445 return (AliMpPCB*)fPCBs[i];
448 //_____________________________________________________________________________
450 AliMpSlat::GetSize() const
453 /// Returns the number of PCB in this slat.
455 return fPCBs.GetEntriesFast();
458 //_____________________________________________________________________________
460 AliMpSlat::Print(Option_t* option) const
463 /// Prints the slat characteristics.
465 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
466 << " POS = " << Position().X() << "," << Position().Y()
467 << " NPADSX = " << GetNofPadsX()
468 << " MAXNPADSY = " << GetMaxNofPadsY()
469 << " NPCBs=" << GetSize() << endl;
471 TString soption(option);
473 if ( soption.Contains("P") )
475 for ( Int_t i = 0; i < GetSize() ; ++i )
480 fPCBs[i]->Print(option+1);
489 if ( soption.Contains("M") || soption.Contains("L") )
491 cout << fManuMap.GetSize() << " ";
492 cout << "Electronic card (manu or local board) Ids : ";
493 TIter next(fManuMap.CreateIterator());
494 AliMpMotifPosition* mp;
495 while ( ( mp = static_cast<AliMpMotifPosition*>(next())) )
497 cout << mp->GetID() << " ";