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.7 2006/03/02 16:35:20 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 AliDebug(3,Form("Converted input area wrt to slat center : "
80 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
81 "%7.2f,%7.2f->%7.2f,%7.2f ",
82 area.LeftBorder(),area.DownBorder(),
83 area.RightBorder(),area.UpBorder(),
84 a.LeftBorder(),a.DownBorder(),
85 a.RightBorder(),a.UpBorder()));
87 return new AliMpSlatPadIterator(fkSlat,a);
90 //_____________________________________________________________________________
92 AliMpSlatSegmentation::Dimensions() const
94 return Slat()->Dimensions();
97 //_____________________________________________________________________________
99 AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
101 Slat()->GetAllMotifPositionsIDs(ecn);
104 //_____________________________________________________________________________
106 AliMpSlatSegmentation::GetName() const
108 TString name("SlatSegmentation");
112 name += fkSlat->GetName();
117 //_____________________________________________________________________________
119 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
122 // Test if this slat has a pad located at the position referenced
123 // by the integer indices.
126 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
129 //_____________________________________________________________________________
131 AliMpSlatSegmentation::MaxPadIndexX()
134 // Returns the value of the largest pad index in x-direction.
137 return fkSlat->GetMaxPadIndexX();
140 //_____________________________________________________________________________
142 AliMpSlatSegmentation::MaxPadIndexY()
145 // Returns the value of the largest pad index in y-direction.
148 return fkSlat->GetMaxNofPadsY()-1;
151 //_____________________________________________________________________________
153 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
154 Bool_t warning) const
157 // Returns the pad specified by its location, where location is the
158 // pair (ManuID,ManuChannel).
159 // If warning=kTRUE and the pad does not exist, a warning message is
162 // AliMpPad::Invalid() is returned if there's no pad at the given location.
164 Int_t manuID = location.GetFirst();
166 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
172 AliWarning(Form("Manu ID %d not found in slat %s",
173 manuID, fkSlat->GetID()));
175 return AliMpPad::Invalid();
177 AliMpVMotif* motif = motifPos->GetMotif();
178 AliMpIntPair localIndices =
179 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
181 if (!localIndices.IsValid())
185 AliWarning(Form("The pad number %d doesn't exists",
186 location.GetSecond()));
188 return AliMpPad::Invalid();
191 return AliMpPad(location,
192 motifPos->GlobalIndices(localIndices),
194 + motif->PadPositionLocal(localIndices)
195 - fkSlat->Position(),
196 motif->GetPadDimensions(localIndices));
199 //_____________________________________________________________________________
201 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
202 Bool_t warning) const
205 // Returns the pad specified by its integer indices.
206 // If warning=kTRUE and the pad does not exist, a warning message is
209 // AliMpPad::Invalid() is returned if there's no pad at the given location.
212 // FIXME: except for the FindMotifPosition below, this method
213 // is exactly as the one in AliMpSectorSegmentation.
214 // See if we can merge them somehow.
216 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
217 indices.GetSecond());
222 AliWarning(Form("No motif found containing pad location (%d,%d)",
223 indices.GetFirst(),indices.GetSecond()));
225 return AliMpPad::Invalid();
228 AliMpVMotif* motif = motifPos->GetMotif();
229 AliMpMotifType* motifType = motif->GetMotifType();
230 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
231 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
237 AliWarning(Form("No connection for pad location (%d,%d)",
238 indices.GetFirst(),indices.GetSecond()));
240 return AliMpPad::Invalid();
243 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
246 + motif->PadPositionLocal(localIndices)
247 - fkSlat->Position(),
248 motif->GetPadDimensions(localIndices));
251 //_____________________________________________________________________________
253 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
254 Bool_t warning) const
257 // Returns the pad specified by its (floating point) position.
258 // If warning=kTRUE and the pad does not exist, a warning message is
261 // AliMpPad::Invalid() is returned if there's no pad at the given location.
264 TVector2 blPos(position+fkSlat->Position()); // position relative to
265 // bottom-left of the slat.
267 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
273 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
274 " outside limits",fkSlat->GetID(),
275 position.X(),position.Y(),
276 blPos.X(),blPos.Y()));
278 return AliMpPad::Invalid();
281 AliMpVMotif* motif = motifPos->GetMotif();
282 AliMpIntPair localIndices
283 = motif->PadIndicesLocal(blPos-motifPos->Position());
285 AliMpConnection* connect =
286 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
292 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
293 fkSlat->GetID(),localIndices.GetFirst(),
294 localIndices.GetSecond(),motif->GetID().Data()));
296 return AliMpPad::Invalid();
299 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
300 motifPos->GlobalIndices(localIndices),
302 + motif->PadPositionLocal(localIndices)
303 - fkSlat->Position(),
304 motif->GetPadDimensions(localIndices));
307 //_____________________________________________________________________________
309 AliMpSlatSegmentation::PlaneType() const
311 return Slat()->PlaneType();
314 //_____________________________________________________________________________
316 AliMpSlatSegmentation::Print(Option_t* opt) const
321 //_____________________________________________________________________________
323 AliMpSlatSegmentation::Slat() const
326 // Returns the pointer to the referenced slat.