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.5 2005/10/28 15:26:01 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 "AliMpMotif.h"
31 #include "AliMpMotifPosition.h"
32 #include "AliMpMotifType.h"
34 #include "AliMpSlat.h"
35 #include "AliMpSlatPadIterator.h"
37 ClassImp(AliMpSlatSegmentation)
39 //_____________________________________________________________________________
40 AliMpSlatSegmentation::AliMpSlatSegmentation()
41 : AliMpVSegmentation(),
45 // Default ctor. Not to be used really.
47 AliDebug(1,Form("this=%p Empty ctor",this));
50 //_____________________________________________________________________________
51 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat)
52 : AliMpVSegmentation(),
58 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
61 //_____________________________________________________________________________
62 AliMpSlatSegmentation::~AliMpSlatSegmentation()
67 // Int_t i(0);//just to be able to put a breakpoint in gdb
68 AliDebug(1,Form("this=%p",this));
71 //_____________________________________________________________________________
73 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
76 // Returns an iterator to loop over the pad contained within given area.
78 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
79 return new AliMpSlatPadIterator(fkSlat,a);
82 //_____________________________________________________________________________
84 AliMpSlatSegmentation::GetName() const
86 TString name("SlatSegmentation");
90 name += fkSlat->GetName();
95 //_____________________________________________________________________________
97 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
100 // Test if this slat has a pad located at the position referenced
101 // by the integer indices.
104 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
107 //_____________________________________________________________________________
109 AliMpSlatSegmentation::MaxPadIndexX()
112 // Returns the value of the largest pad index in x-direction.
115 return fkSlat->GetMaxPadIndexX();
118 //_____________________________________________________________________________
120 AliMpSlatSegmentation::MaxPadIndexY()
123 // Returns the value of the largest pad index in y-direction.
126 return fkSlat->GetMaxNofPadsY()-1;
129 //_____________________________________________________________________________
131 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
132 Bool_t warning) const
135 // Returns the pad specified by its location, where location is the
136 // pair (ManuID,ManuChannel).
137 // If warning=kTRUE and the pad does not exist, a warning message is
140 // AliMpPad::Invalid() is returned if there's no pad at the given location.
142 Int_t manuID = location.GetFirst();
144 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
150 AliWarning(Form("Manu ID %d not found in slat %s",
151 manuID, fkSlat->GetID()));
153 return AliMpPad::Invalid();
155 AliMpVMotif* motif = motifPos->GetMotif();
156 AliMpIntPair localIndices =
157 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
159 if (!localIndices.IsValid())
163 AliWarning(Form("The pad number %d doesn't exists",
164 location.GetSecond()));
166 return AliMpPad::Invalid();
169 return AliMpPad(location,
170 motifPos->GlobalIndices(localIndices),
172 + motif->PadPositionLocal(localIndices)
173 - fkSlat->Position(),
174 motif->GetPadDimensions(localIndices));
177 //_____________________________________________________________________________
179 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
180 Bool_t warning) const
183 // Returns the pad specified by its integer indices.
184 // If warning=kTRUE and the pad does not exist, a warning message is
187 // AliMpPad::Invalid() is returned if there's no pad at the given location.
190 // FIXME: except for the FindMotifPosition below, this method
191 // is exactly as the one in AliMpSectorSegmentation.
192 // See if we can merge them somehow.
194 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
195 indices.GetSecond());
200 AliWarning(Form("No motif found containing pad location (%d,%d)",
201 indices.GetFirst(),indices.GetSecond()));
203 return AliMpPad::Invalid();
206 AliMpVMotif* motif = motifPos->GetMotif();
207 AliMpMotifType* motifType = motif->GetMotifType();
208 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
209 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
215 AliWarning(Form("No connection for pad location (%d,%d)",
216 indices.GetFirst(),indices.GetSecond()));
218 return AliMpPad::Invalid();
221 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
224 + motif->PadPositionLocal(localIndices)
225 - fkSlat->Position(),
226 motif->GetPadDimensions(localIndices));
229 //_____________________________________________________________________________
231 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
232 Bool_t warning) const
235 // Returns the pad specified by its (floating point) position.
236 // If warning=kTRUE and the pad does not exist, a warning message is
239 // AliMpPad::Invalid() is returned if there's no pad at the given location.
242 TVector2 blPos(position+fkSlat->Position()); // position relative to
243 // bottom-left of the slat.
245 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
251 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
252 " outside limits",fkSlat->GetID(),
253 position.X(),position.Y(),
254 blPos.X(),blPos.Y()));
256 return AliMpPad::Invalid();
259 AliMpVMotif* motif = motifPos->GetMotif();
260 AliMpIntPair localIndices
261 = motif->PadIndicesLocal(blPos-motifPos->Position());
263 AliMpConnection* connect =
264 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
270 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
271 fkSlat->GetID(),localIndices.GetFirst(),
272 localIndices.GetSecond(),motif->GetID().Data()));
274 return AliMpPad::Invalid();
277 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
278 motifPos->GlobalIndices(localIndices),
280 + motif->PadPositionLocal(localIndices)
281 - fkSlat->Position(),
282 motif->GetPadDimensions(localIndices));
285 //_____________________________________________________________________________
287 AliMpSlatSegmentation::Slat() const
290 // Returns the pointer to the referenced slat.