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 $
20 // Implementation note.
21 // The position(s) used in the interface are supposed to be relative
22 // to the slat center (AliMpSlat::Position()), whereas internally
23 // the x,y are relative to bottom-left corner.
25 #include "AliMpSlatSegmentation.h"
28 #include "AliMpArea.h"
29 #include "AliMpConnection.h"
30 #include "AliMpConstants.h"
32 #include "AliMpMotif.h"
33 #include "AliMpMotifPosition.h"
34 #include "AliMpMotifType.h"
35 #include "AliMpSlat.h"
36 #include "AliMpSlatPadIterator.h"
39 ClassImp(AliMpSlatSegmentation)
42 //_____________________________________________________________________________
43 AliMpSlatSegmentation::AliMpSlatSegmentation()
44 : AliMpVSegmentation(),
49 // Default ctor. Not to be used really.
51 AliDebug(1,Form("this=%p Empty ctor",this));
54 //_____________________________________________________________________________
55 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat, Bool_t own)
56 : AliMpVSegmentation(),
63 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
66 //_____________________________________________________________________________
67 AliMpSlatSegmentation::~AliMpSlatSegmentation()
73 if ( fIsOwner ) delete fkSlat;
75 // Int_t i(0);//just to be able to put a breakpoint in gdb
76 AliDebug(1,Form("this=%p",this));
79 //_____________________________________________________________________________
81 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
84 // Returns an iterator to loop over the pad contained within given area.
86 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
87 AliDebug(3,Form("Converted input area wrt to slat center : "
88 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
89 "%7.2f,%7.2f->%7.2f,%7.2f ",
90 area.LeftBorder(),area.DownBorder(),
91 area.RightBorder(),area.UpBorder(),
92 a.LeftBorder(),a.DownBorder(),
93 a.RightBorder(),a.UpBorder()));
95 return new AliMpSlatPadIterator(fkSlat,a);
98 //_____________________________________________________________________________
100 AliMpSlatSegmentation::CreateIterator() const
102 /// Returns an iterator to loop over all pads of that segmentation
104 /// FIXME: we currently just forward this to the other CreateIterator,
105 /// with the proper region. Might be more efficient to write a dedicated
106 /// iterator ? Test that idea.
108 AliMpArea area(TVector2(0.0,0.0),fkSlat->Dimensions());
109 return CreateIterator(area);
112 //_____________________________________________________________________________
114 AliMpSlatSegmentation::GetNeighbours(const AliMpPad& pad,
115 TObjArray& neighbours,
117 Bool_t includeVoid) const
119 /// Uses default implementation
120 return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
123 //_____________________________________________________________________________
125 AliMpSlatSegmentation::Dimensions() const
127 return Slat()->Dimensions();
130 //_____________________________________________________________________________
132 AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
134 Slat()->GetAllMotifPositionsIDs(ecn);
137 //_____________________________________________________________________________
139 AliMpSlatSegmentation::GetName() const
141 // The name of this segmentation is "SlatSegmentation"+slatName
143 TString name("SlatSegmentation");
147 name += fkSlat->GetName();
152 //_____________________________________________________________________________
154 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
157 // Test if this slat has a pad located at the position referenced
158 // by the integer indices.
161 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
164 //_____________________________________________________________________________
166 AliMpSlatSegmentation::MaxPadIndexX() const
169 // Returns the value of the largest pad index in x-direction.
172 return fkSlat->GetMaxPadIndexX();
175 //_____________________________________________________________________________
177 AliMpSlatSegmentation::MaxPadIndexY() const
180 // Returns the value of the largest pad index in y-direction.
183 return fkSlat->GetMaxNofPadsY()-1;
186 //_____________________________________________________________________________
188 AliMpSlatSegmentation::NofPads() const
190 /// Return number of pads defined in the slat
192 return fkSlat->NofPads();
195 //_____________________________________________________________________________
197 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
198 Bool_t warning) const
201 // Returns the pad specified by its location, where location is the
202 // pair (ManuID,ManuChannel).
203 // If warning=kTRUE and the pad does not exist, a warning message is
206 // AliMpPad::Invalid() is returned if there's no pad at the given location.
208 Int_t manuID = location.GetFirst();
210 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
216 AliWarning(Form("Manu ID %d not found in slat %s",
217 manuID, fkSlat->GetID()));
219 return AliMpPad::Invalid();
221 AliMpVMotif* motif = motifPos->GetMotif();
222 AliMpIntPair localIndices =
223 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
225 if (!localIndices.IsValid())
229 AliWarning(Form("The pad number %d doesn't exists",
230 location.GetSecond()));
232 return AliMpPad::Invalid();
235 return AliMpPad(location,
236 motifPos->GlobalIndices(localIndices),
238 + motif->PadPositionLocal(localIndices)
239 - fkSlat->Position(),
240 motif->GetPadDimensions(localIndices));
243 //_____________________________________________________________________________
245 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
246 Bool_t warning) const
249 // Returns the pad specified by its integer indices.
250 // If warning=kTRUE and the pad does not exist, a warning message is
253 // AliMpPad::Invalid() is returned if there's no pad at the given location.
256 // FIXME: except for the FindMotifPosition below, this method
257 // is exactly as the one in AliMpSectorSegmentation.
258 // See if we can merge them somehow.
260 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
261 indices.GetSecond());
266 AliWarning(Form("No motif found containing pad location (%d,%d)",
267 indices.GetFirst(),indices.GetSecond()));
269 return AliMpPad::Invalid();
272 AliMpVMotif* motif = motifPos->GetMotif();
273 AliMpMotifType* motifType = motif->GetMotifType();
274 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
275 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
281 AliWarning(Form("No connection for pad location (%d,%d)",
282 indices.GetFirst(),indices.GetSecond()));
284 return AliMpPad::Invalid();
287 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
290 + motif->PadPositionLocal(localIndices)
291 - fkSlat->Position(),
292 motif->GetPadDimensions(localIndices));
295 //_____________________________________________________________________________
297 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
298 Bool_t warning) const
301 // Returns the pad specified by its (floating point) position.
302 // If warning=kTRUE and the pad does not exist, a warning message is
305 // AliMpPad::Invalid() is returned if there's no pad at the given location.
308 TVector2 blPos(position);
310 blPos += fkSlat->Position(); // position relative to bottom-left of the slat.
312 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
318 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
319 " outside limits",fkSlat->GetID(),
320 position.X(),position.Y(),
321 blPos.X(),blPos.Y()));
323 return AliMpPad::Invalid();
326 AliMpVMotif* motif = motifPos->GetMotif();
327 blPos -= motifPos->Position();
328 AliMpIntPair localIndices
329 = motif->PadIndicesLocal(blPos);
331 AliMpConnection* connect =
332 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
338 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
339 fkSlat->GetID(),localIndices.GetFirst(),
340 localIndices.GetSecond(),motif->GetID().Data()));
342 return AliMpPad::Invalid();
345 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
346 motifPos->GlobalIndices(localIndices),
348 + motif->PadPositionLocal(localIndices)
349 - fkSlat->Position(),
350 motif->GetPadDimensions(localIndices));
353 //_____________________________________________________________________________
355 AliMpSlatSegmentation::PlaneType() const
357 return Slat()->PlaneType();
360 //_____________________________________________________________________________
362 AliMpSlatSegmentation::Print(Option_t* opt) const
367 //_____________________________________________________________________________
369 AliMpSlatSegmentation::Slat() const
372 // Returns the pointer to the referenced slat.