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"
29 //-----------------------------------------------------------------------------
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
40 //-----------------------------------------------------------------------------
46 //_____________________________________________________________________________
47 AliMpSlat::AliMpSlat()
50 fPlaneType(AliMp::kNonBendingPlane),
63 AliDebug(1,Form("this=%p Empty ctor",this));
65 fPCBs.SetOwner(kTRUE);
67 fManuMap.SetOwner(kFALSE);
70 //_____________________________________________________________________________
71 AliMpSlat::AliMpSlat(const char* id, AliMp::PlaneType bendingOrNonBending)
74 fPlaneType(bendingOrNonBending),
87 AliDebug(1,Form("this=%p id=%s",this,id));
89 fPCBs.SetOwner(kTRUE);
91 fManuMap.SetOwner(kFALSE);
94 //_____________________________________________________________________________
95 AliMpSlat::~AliMpSlat()
100 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
104 for ( size_t i = 0; i < fPCBs.size(); ++i )
111 //_____________________________________________________________________________
113 AliMpSlat::Add(const AliMpPCB& pcbType, const TArrayI& manuList)
116 /// Adds a PCB to this slat. The manuList specifies the ids of the manu
117 /// that compose the PCB. The manuList ordering is important, as the
118 /// assumption is that it's ordered counter-clockwise, starting from
119 /// the lower-left of the PCB.
124 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
128 ixOffset = pcbType.Ixmin();
130 Double_t xOffset = DX()*2;
131 AliMpPCB* pcb = pcbType.Clone(manuList,ixOffset,xOffset);
135 fPCBs.push_back(pcb);
137 fDY = TMath::Max(pcb->DY(),fDY);
139 fNofPadsX += pcb->GetNofPadsX();
140 fMaxNofPadsY = TMath::Max(fMaxNofPadsY,pcb->GetNofPadsY());
141 for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
143 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
144 Int_t manuID = mp->GetID();
145 // Before inserting a new key, check if it's already there
147 TObject* there = fManuMap.GetValue(manuID);
150 fManuMap.Add(manuID,(TObject*)mp);
154 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType.GetID()));
157 // fManuMap[manuID] = mp;
160 fPosition.Set(DX(),DY());
161 fNofPads += pcb->NofPads();
164 //_____________________________________________________________________________
166 AliMpSlat::Dimensions() const
169 /// Returns the half-sizes of the slat.
171 return TVector2(DX(),DY());
174 //_____________________________________________________________________________
176 AliMpSlat::DX() const
179 /// Returns the x-half-size of the slat.
184 //_____________________________________________________________________________
186 AliMpSlat::DY() const
189 /// Returns the y-half-size of the slat.
194 //_____________________________________________________________________________
196 AliMpSlat::FindMotifPosition(Int_t manuID) const
199 /// Returns the motifPosition referenced by it manuID
202 return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
204 // std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
205 // if ( it != fManuMap.end() )
207 // return it->second;
216 //_____________________________________________________________________________
218 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
221 /// - 1. Find the PCB containing ix (iy not needed for this)
222 /// - 2. Forward the request to the PCB, using pcb local indices.
224 const AliMpPCB* pcb = FindPCB(ix);
227 return pcb->FindMotifPosition(ix,iy);
235 //_____________________________________________________________________________
237 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
240 /// Returns the motifPosition containing position (x,y)
242 const AliMpPCB* pcb = FindPCB(x,y);
245 return pcb->FindMotifPosition(x,y);
253 //_____________________________________________________________________________
255 AliMpSlat::FindPCB(Int_t ix) const
258 /// Returns the PCB containing x-integer-position ix
260 for ( Size_t i = 0; i < GetSize(); ++i )
262 AliMpPCB* pcb = GetPCB(i);
263 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
271 //_____________________________________________________________________________
273 AliMpSlat::FindPCBIndex(Int_t ix) const
276 /// Returns the index of the PCB containing x-integer-position ix.
278 for ( Size_t i = 0; i < GetSize(); ++i )
280 AliMpPCB* pcb = GetPCB(i);
281 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
289 //_____________________________________________________________________________
291 AliMpSlat::FindPCB(Double_t x, Double_t y) const
294 /// Returns the PCB containing position (x,y)
296 for ( Size_t i = 0; i < GetSize(); ++i )
298 AliMpPCB* pcb = GetPCB(i);
299 // if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
300 // y >= pcb->Ymin() && y < pcb->Ymax() )
304 if ( x < pcb->Xmin() || x >= pcb->Xmax() ||
305 y < pcb->Ymin() || y >= pcb->Ymax() )
314 //_____________________________________________________________________________
316 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
319 /// Returns the index of the PCB containing position (x,y)
321 for ( Size_t i = 0; i < GetSize(); ++i )
323 AliMpPCB* pcb = GetPCB(i);
324 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
325 y >= pcb->Ymin() && y < pcb->Ymax() )
333 //_____________________________________________________________________________
335 AliMpSlat::FindPCBIndexByMotifPositionID(Int_t manuId) const
337 /// Find the index of the PCB containing a given manu
338 for ( Size_t i = 0; i< GetSize(); ++i )
340 AliMpPCB* pcb = GetPCB(i);
341 if ( pcb->HasMotifPositionID(manuId) ) return i;
346 //_____________________________________________________________________________
348 AliMpSlat::ForcePosition(const TVector2& pos)
351 /// Force the position to be different from (DX(),DY()).
352 /// Normally only used by triggerSlats (for layers).
353 /// Beware that this method must be called once all PCB have been added,
354 /// as the Add() method resets the position.
359 //_____________________________________________________________________________
361 AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
364 /// Return all the manuIds (=MotifPositionIDs) of this slat
366 ecn.Set(GetNofElectronicCards());
368 TExMapIter it(fManuMap.GetIterator());
372 while ( it.Next(key,value) == kTRUE )
374 ecn.AddAt((Int_t)(key),n);
382 //_____________________________________________________________________________
384 AliMpSlat::GetID() const
387 /// Returns the name of this slat.
392 //_____________________________________________________________________________
394 AliMpSlat::GetMaxNofPadsY() const
397 /// Returns the maximum number of pads to be found in this slat y-direction.
402 //_____________________________________________________________________________
404 AliMpSlat::GetMaxPadIndexX() const
407 /// Returns the max ix that is valid for this slat.
409 AliMpPCB* last = GetPCB(GetSize()-1);
412 return last->Ixmax();
417 //_____________________________________________________________________________
419 AliMpSlat::GetName() const
422 /// Returns the name of this slat, which is composed of its ID with
423 /// the plane type as a suffix.
425 TString name(GetID());
426 if ( fPlaneType == AliMp::kBendingPlane )
430 else if ( fPlaneType == AliMp::kNonBendingPlane )
432 name += ".NonBending";
441 //_____________________________________________________________________________
443 AliMpSlat::GetNofElectronicCards() const
446 /// Returns the number of manus that compose the readout of this slat.
448 return fManuMap.GetSize();
451 //_____________________________________________________________________________
453 AliMpSlat::GetNofPadsX() const
456 /// Returns the number of pad in x-direction.
461 //_____________________________________________________________________________
463 AliMpSlat::GetPCB(AliMpSlat::Size_t i) const
466 /// Returns the i-th PCB of this slat.
469 if ( i >= fPCBs.GetEntriesFast() ) return 0;
470 return (AliMpPCB*)fPCBs[i];
472 if ( i >= fPCBs.size() ) return 0;
477 //_____________________________________________________________________________
479 AliMpSlat::GetSize() const
482 /// Returns the number of PCB in this slat.
485 return fPCBs.GetEntriesFast();
491 //_____________________________________________________________________________
493 AliMpSlat::Print(Option_t* option) const
496 /// Prints the slat characteristics.
498 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
499 << " POS = " << Position().X() << "," << Position().Y()
500 << " NPADSX = " << GetNofPadsX()
501 << " MAXNPADSY = " << GetMaxNofPadsY()
502 << " NPCBs=" << GetSize() << endl;
504 TString soption(option);
506 if ( soption.Contains("P") )
508 for ( Size_t i = 0; i < GetSize() ; ++i )
513 fPCBs[i]->Print(option+1);
522 if ( soption.Contains("M") || soption.Contains("L") )
524 cout << fManuMap.GetSize() << " ";
525 cout << "Electronic card (manu or local board) Ids : ";
527 TExMapIter iter(fManuMap.GetIterator());
529 while ( iter.Next(key,value) )