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.4 2005/09/19 19:01:31 ivana Exp $
19 #include "AliMpSlatSegmentation.h"
22 #include "AliMpConnection.h"
23 #include "AliMpMotif.h"
24 #include "AliMpMotifPosition.h"
25 #include "AliMpMotifType.h"
27 #include "AliMpSlat.h"
28 #include "AliMpSlatPadIterator.h"
30 ClassImp(AliMpSlatSegmentation)
32 //_____________________________________________________________________________
33 AliMpSlatSegmentation::AliMpSlatSegmentation()
34 : AliMpVSegmentation(),
38 // Default ctor. Not to be used really.
40 AliDebug(1,Form("this=%p Empty ctor",this));
43 //_____________________________________________________________________________
44 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat)
45 : AliMpVSegmentation(),
51 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
54 //_____________________________________________________________________________
55 AliMpSlatSegmentation::~AliMpSlatSegmentation()
60 AliDebug(1,Form("this=%p",this));
63 //_____________________________________________________________________________
65 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
68 // Returns an iterator to loop over the pad contained within given area.
71 return new AliMpSlatPadIterator(fkSlat,area);
74 //_____________________________________________________________________________
76 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
79 // Test if this slat has a pad located at the position referenced
80 // by the integer indices.
83 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
86 //_____________________________________________________________________________
88 AliMpSlatSegmentation::MaxPadIndexX()
91 // Returns the value of the largest pad index in x-direction.
94 return fkSlat->GetNofPadsX()-1;
97 //_____________________________________________________________________________
99 AliMpSlatSegmentation::MaxPadIndexY()
102 // Returns the value of the largest pad index in y-direction.
105 return fkSlat->GetMaxNofPadsY()-1;
108 //_____________________________________________________________________________
110 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
111 Bool_t warning) const
114 // Returns the pad specified by its location, where location is the
115 // pair (ManuID,ManuChannel).
116 // If warning=kTRUE and the pad does not exist, a warning message is
119 // AliMpPad::Invalid() is returned if there's no pad at the given location.
121 Int_t manuID = location.GetFirst();
123 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
129 AliWarning(Form("Manu ID %d not found in slat %s",
130 manuID, fkSlat->GetID()));
131 return AliMpPad::Invalid();
134 AliMpVMotif* motif = motifPos->GetMotif();
135 AliMpIntPair localIndices =
136 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
138 if (!localIndices.IsValid())
142 AliWarning(Form("The pad number %d doesn't exists",
143 location.GetSecond()));
145 return AliMpPad::Invalid();
148 return AliMpPad(location,
149 motifPos->GlobalIndices(localIndices),
151 + motif->PadPositionLocal(localIndices)
152 - TVector2(fkSlat->DX(),fkSlat->DY()),
153 motif->GetPadDimensions(localIndices));
156 //_____________________________________________________________________________
158 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
159 Bool_t warning) const
162 // Returns the pad specified by its integer indices.
163 // If warning=kTRUE and the pad does not exist, a warning message is
166 // AliMpPad::Invalid() is returned if there's no pad at the given location.
169 // FIXME: except for the FindMotifPosition below, this method
170 // is exactly as the one in AliMpSectorSegmentation.
171 // See if we can merge them somehow.
173 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
174 indices.GetSecond());
179 AliWarning(Form("No motif found containing pad location (%d,%d)",
180 indices.GetFirst(),indices.GetSecond()));
182 return AliMpPad::Invalid();
185 AliMpVMotif* motif = motifPos->GetMotif();
186 AliMpMotifType* motifType = motif->GetMotifType();
187 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
188 AliMpConnection* connection =
189 motifType->FindConnectionByLocalIndices(localIndices);
195 AliWarning(Form("No connection for pad location (%d,%d)",
196 indices.GetFirst(),indices.GetSecond()));
197 return AliMpPad::Invalid();
201 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
204 + motif->PadPositionLocal(localIndices)
205 - TVector2(fkSlat->DX(), fkSlat->DY()),
206 motif->GetPadDimensions(0));
209 //_____________________________________________________________________________
211 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
212 Bool_t warning) const
215 // Returns the pad specified by its (floating point) position.
216 // If warning=kTRUE and the pad does not exist, a warning message is
219 // AliMpPad::Invalid() is returned if there's no pad at the given location.
222 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(position.X(),position.Y());
228 AliWarning(Form("Position (%e,%e) mm outside limits",
229 position.X(),position.Y()));
231 return AliMpPad::Invalid();
234 AliMpVMotif* motif = motifPos->GetMotif();
235 AliMpIntPair localIndices
236 = motif->PadIndicesLocal(position-motifPos->Position());
238 AliMpConnection* connect =
239 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
245 AliWarning("Position outside motif limits");
247 return AliMpPad::Invalid();
250 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
251 motifPos->GlobalIndices(localIndices),
253 + motif->PadPositionLocal(localIndices)
254 - TVector2(fkSlat->DX(),fkSlat->DY()),
255 motif->GetPadDimensions(localIndices));
258 //_____________________________________________________________________________
260 AliMpSlatSegmentation::Slat() const
263 // Returns the pointer to the referenced slat.