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(kNonBendingPlane),
62 AliDebug(1,Form("this=%p Empty ctor",this));
65 //_____________________________________________________________________________
66 AliMpSlat::AliMpSlat(const char* id, AliMpPlaneType bendingOrNonBending)
69 fPlaneType(bendingOrNonBending),
82 AliDebug(1,Form("this=%p id=%s",this,id));
85 //_____________________________________________________________________________
86 AliMpSlat::~AliMpSlat()
91 AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
94 //_____________________________________________________________________________
96 AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
99 // Adds a PCB to this slat. The manuList specifies the ids of the manu
100 // that compose the PCB. The manuList ordering is important, as the
101 // assumption is that it's ordered counter-clockwise, starting from
102 // the lower-left of the PCB.
107 ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
111 ixOffset = pcbType->Ixmin();
113 Double_t xOffset = DX()*2;
114 AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset);
118 fPCBs.push_back(pcb);
120 fDY = TMath::Max(pcb->DY(),fDY);
122 fNofPadsX += pcb->GetNofPadsX();
123 fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
124 for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
126 AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
127 Int_t manuID = mp->GetID();
128 // Before inserting a new key, check if it's already there
130 TObject* there = fManuMap.GetValue(manuID);
133 fManuMap.Add(manuID,(TObject*)mp);
137 AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType->GetID()));
140 // fManuMap[manuID] = mp;
143 fPosition.Set(DX(),DY());
144 fNofPads += pcb->NofPads();
147 //_____________________________________________________________________________
149 AliMpSlat::Dimensions() const
152 // Returns the half-sizes of the slat.
154 return TVector2(DX(),DY());
157 //_____________________________________________________________________________
159 AliMpSlat::DX() const
162 // Returns the x-half-size of the slat.
167 //_____________________________________________________________________________
169 AliMpSlat::DY() const
172 // Returns the y-half-size of the slat.
177 //_____________________________________________________________________________
179 AliMpSlat::FindMotifPosition(Int_t manuID) const
182 // Returns the motifPosition referenced by it manuID
185 return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
187 // std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
188 // if ( it != fManuMap.end() )
190 // return it->second;
199 //_____________________________________________________________________________
201 AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
204 // 1. Find the PCB containing ix (iy not needed for this)
205 // 2. Forward the request to the PCB, using pcb local indices.
207 const AliMpPCB* pcb = FindPCB(ix);
210 return pcb->FindMotifPosition(ix,iy);
218 //_____________________________________________________________________________
220 AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
223 // Returns the motifPosition containing position (x,y)
225 const AliMpPCB* pcb = FindPCB(x,y);
228 return pcb->FindMotifPosition(x,y);
236 //_____________________________________________________________________________
238 AliMpSlat::FindPCB(Int_t ix) const
241 // Returns 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::FindPCBIndex(Int_t ix) const
259 // Returns the index of the PCB containing x-integer-position ix.
261 for ( Size_t i = 0; i < GetSize(); ++i )
263 AliMpPCB* pcb = GetPCB(i);
264 if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
272 //_____________________________________________________________________________
274 AliMpSlat::FindPCB(Double_t x, Double_t y) const
277 // Returns the PCB containing position (x,y)
279 for ( Size_t i = 0; i < GetSize(); ++i )
281 AliMpPCB* pcb = GetPCB(i);
282 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
283 y >= pcb->Ymin() && y < pcb->Ymax() )
291 //_____________________________________________________________________________
293 AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
296 // Returns the index of the PCB containing position (x,y)
298 for ( Size_t i = 0; i < GetSize(); ++i )
300 AliMpPCB* pcb = GetPCB(i);
301 if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
302 y >= pcb->Ymin() && y < pcb->Ymax() )
310 //_____________________________________________________________________________
312 AliMpSlat::ForcePosition(const TVector2& pos)
315 // Force the position to be different from (DX(),DY()).
316 // Normally only used by triggerSlats (for layers).
317 // Beware that this method must be called once all PCB have been added,
318 // as the Add() method resets the position.
323 //_____________________________________________________________________________
325 AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
328 // Return all the manuIds (=MotifPositionIDs) of this slat
330 ecn.Set(GetNofElectronicCards());
332 TExMapIter it(fManuMap.GetIterator());
336 while ( it.Next(key,value) == kTRUE )
338 ecn.AddAt((Int_t)(key),n);
346 //_____________________________________________________________________________
348 AliMpSlat::GetID() const
351 // Returns the name of this slat.
356 //_____________________________________________________________________________
358 AliMpSlat::GetMaxNofPadsY() const
361 // Returns the maximum number of pads to be found in this slat y-direction.
366 //_____________________________________________________________________________
368 AliMpSlat::GetMaxPadIndexX() const
371 // Returns the max ix that is valid for this slat.
373 AliMpPCB* last = GetPCB(GetSize()-1);
376 return last->Ixmax();
381 //_____________________________________________________________________________
383 AliMpSlat::GetName() const
386 // Returns the name of this slat, which is composed of its ID with
387 // the plane type as a suffix.
389 TString name(GetID());
390 if ( fPlaneType == kBendingPlane )
394 else if ( fPlaneType == kNonBendingPlane )
396 name += ".NonBending";
405 //_____________________________________________________________________________
407 AliMpSlat::GetNofElectronicCards() const
410 // Returns the number of manus that compose the readout of this slat.
412 return fManuMap.GetSize();
415 //_____________________________________________________________________________
417 AliMpSlat::GetNofPadsX() const
420 // Returns the number of pad in x-direction.
425 //_____________________________________________________________________________
427 AliMpSlat::GetPCB(AliMpSlat::Size_t i) const
430 // Returns the i-th PCB of this slat.
433 if ( i >= fPCBs.GetEntriesFast() ) return 0;
434 return (AliMpPCB*)fPCBs[i];
436 if ( i >= fPCBs.size() ) return 0;
441 //_____________________________________________________________________________
443 AliMpSlat::GetSize() const
446 // Returns the number of PCB in this slat.
449 return fPCBs.GetEntriesFast();
455 //_____________________________________________________________________________
457 AliMpSlat::Print(Option_t* option) const
460 // Prints the slat characteristics.
462 cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
463 << " POS = " << Position().X() << "," << Position().Y()
464 << " NPADSX = " << GetNofPadsX()
465 << " MAXNPADSY = " << GetMaxNofPadsY()
466 << " NPCBs=" << GetSize() << endl;
468 TString soption(option);
470 if ( soption.Contains("P") )
472 for ( Size_t i = 0; i < GetSize() ; ++i )
477 fPCBs[i]->Print(option+1);
486 if ( soption.Contains("M") || soption.Contains("L") )
488 cout << fManuMap.GetSize() << " ";
489 cout << "Electronic card (manu or local board) Ids : ";
491 TExMapIter iter(fManuMap.GetIterator());
493 while ( iter.Next(key,value) )