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: AliMpSlatSegmentation.cxx,v 1.12 2006/05/24 13:58:50 ivana Exp $
19 //-----------------------------------------------------------------------------
21 // Implementation note.
22 // The position(s) used in the interface are supposed to be relative
23 // to the slat center (AliMpSlat::Position()), whereas internally
24 // the x,y are relative to bottom-left corner.
25 //-----------------------------------------------------------------------------
27 #include "AliMpSlatSegmentation.h"
30 #include "AliMpArea.h"
31 #include "AliMpConnection.h"
32 #include "AliMpConstants.h"
34 #include "AliMpMotif.h"
35 #include "AliMpMotifPosition.h"
36 #include "AliMpMotifType.h"
37 #include "AliMpSlat.h"
38 #include "AliMpSlatPadIterator.h"
41 ClassImp(AliMpSlatSegmentation)
44 //_____________________________________________________________________________
45 AliMpSlatSegmentation::AliMpSlatSegmentation()
46 : AliMpVSegmentation(),
51 /// Default ctor. Not to be used really.
53 AliDebug(1,Form("this=%p Empty ctor",this));
56 //_____________________________________________________________________________
57 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat, Bool_t own)
58 : AliMpVSegmentation(),
65 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
68 //_____________________________________________________________________________
69 AliMpSlatSegmentation::~AliMpSlatSegmentation()
75 if ( fIsOwner ) delete fkSlat;
77 // Int_t i(0);//just to be able to put a breakpoint in gdb
78 AliDebug(1,Form("this=%p",this));
81 //_____________________________________________________________________________
83 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
86 /// Returns an iterator to loop over the pad contained within given area.
88 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
89 AliDebug(3,Form("Converted input area wrt to slat center : "
90 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
91 "%7.2f,%7.2f->%7.2f,%7.2f ",
92 area.LeftBorder(),area.DownBorder(),
93 area.RightBorder(),area.UpBorder(),
94 a.LeftBorder(),a.DownBorder(),
95 a.RightBorder(),a.UpBorder()));
97 return new AliMpSlatPadIterator(fkSlat,a);
100 //_____________________________________________________________________________
102 AliMpSlatSegmentation::CreateIterator() const
104 /// Returns an iterator to loop over all pads of that segmentation
106 /// FIXME: we currently just forward this to the other CreateIterator,
107 /// with the proper region. Might be more efficient to write a dedicated
108 /// iterator ? Test that idea.
110 AliMpArea area(TVector2(0.0,0.0),fkSlat->Dimensions());
111 return CreateIterator(area);
114 //_____________________________________________________________________________
116 AliMpSlatSegmentation::GetNeighbours(const AliMpPad& pad,
117 TObjArray& neighbours,
119 Bool_t includeVoid) const
121 /// Uses default implementation
122 return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
125 //_____________________________________________________________________________
127 AliMpSlatSegmentation::Dimensions() const
129 /// Return dimensions
131 return Slat()->Dimensions();
134 //_____________________________________________________________________________
136 AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
138 /// Fill the array ecn with all manuIds
140 Slat()->GetAllMotifPositionsIDs(ecn);
143 //_____________________________________________________________________________
145 AliMpSlatSegmentation::GetName() const
147 /// The name of this segmentation is "SlatSegmentation"+slatName
149 TString name("SlatSegmentation");
153 name += fkSlat->GetName();
158 //_____________________________________________________________________________
160 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
163 /// Test if this slat has a pad located at the position referenced
164 /// by the integer indices.
167 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
170 //_____________________________________________________________________________
172 AliMpSlatSegmentation::MaxPadIndexX() const
175 /// Returns the value of the largest pad index in x-direction.
178 return fkSlat->GetMaxPadIndexX();
181 //_____________________________________________________________________________
183 AliMpSlatSegmentation::MaxPadIndexY() const
186 /// Returns the value of the largest pad index in y-direction.
189 return fkSlat->GetMaxNofPadsY()-1;
192 //_____________________________________________________________________________
194 AliMpSlatSegmentation::NofPads() const
196 /// Return number of pads defined in the slat
198 return fkSlat->NofPads();
201 //_____________________________________________________________________________
203 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
204 Bool_t warning) const
207 /// Returns the pad specified by its location, where location is the
208 /// pair (ManuID,ManuChannel).
209 /// If warning=kTRUE and the pad does not exist, a warning message is
212 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
214 Int_t manuID = location.GetFirst();
216 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
222 AliWarning(Form("Manu ID %d not found in slat %s",
223 manuID, fkSlat->GetID()));
225 return AliMpPad::Invalid();
227 AliMpVMotif* motif = motifPos->GetMotif();
228 AliMpIntPair localIndices =
229 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
231 if (!localIndices.IsValid())
235 AliWarning(Form("The pad number %d doesn't exists",
236 location.GetSecond()));
238 return AliMpPad::Invalid();
241 return AliMpPad(location,
242 motifPos->GlobalIndices(localIndices),
244 + motif->PadPositionLocal(localIndices)
245 - fkSlat->Position(),
246 motif->GetPadDimensions(localIndices));
249 //_____________________________________________________________________________
251 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
252 Bool_t warning) const
255 /// Returns the pad specified by its integer indices.
256 /// If warning=kTRUE and the pad does not exist, a warning message is
259 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
262 /// FIXME: except for the FindMotifPosition below, this method
263 /// is exactly as the one in AliMpSectorSegmentation.
264 /// See if we can merge them somehow.
266 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
267 indices.GetSecond());
272 AliWarning(Form("No motif found containing pad location (%d,%d)",
273 indices.GetFirst(),indices.GetSecond()));
275 return AliMpPad::Invalid();
278 AliMpVMotif* motif = motifPos->GetMotif();
279 AliMpMotifType* motifType = motif->GetMotifType();
280 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
281 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
287 AliWarning(Form("No connection for pad location (%d,%d)",
288 indices.GetFirst(),indices.GetSecond()));
290 return AliMpPad::Invalid();
293 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
296 + motif->PadPositionLocal(localIndices)
297 - fkSlat->Position(),
298 motif->GetPadDimensions(localIndices));
301 //_____________________________________________________________________________
303 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
304 Bool_t warning) const
307 /// Returns the pad specified by its (floating point) position.
308 /// If warning=kTRUE and the pad does not exist, a warning message is
311 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
314 TVector2 blPos(position);
316 blPos += fkSlat->Position(); // position relative to bottom-left of the slat.
318 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
324 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
325 " outside limits",fkSlat->GetID(),
326 position.X(),position.Y(),
327 blPos.X(),blPos.Y()));
329 return AliMpPad::Invalid();
332 AliMpVMotif* motif = motifPos->GetMotif();
333 blPos -= motifPos->Position();
334 AliMpIntPair localIndices
335 = motif->PadIndicesLocal(blPos);
337 AliMpConnection* connect =
338 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
344 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
345 fkSlat->GetID(),localIndices.GetFirst(),
346 localIndices.GetSecond(),motif->GetID().Data()));
348 return AliMpPad::Invalid();
351 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
352 motifPos->GlobalIndices(localIndices),
354 + motif->PadPositionLocal(localIndices)
355 - fkSlat->Position(),
356 motif->GetPadDimensions(localIndices));
359 //_____________________________________________________________________________
361 AliMpSlatSegmentation::PlaneType() const
363 return Slat()->PlaneType();
366 //_____________________________________________________________________________
368 AliMpSlatSegmentation::Print(Option_t* opt) const
375 //_____________________________________________________________________________
377 AliMpSlatSegmentation::Slat() const
380 /// Returns the pointer to the referenced slat.