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 "AliMpMotif.h"
31 #include "AliMpMotifPosition.h"
32 #include "AliMpMotifType.h"
33 #include "AliMpSlat.h"
34 #include "AliMpSlatPadIterator.h"
37 ClassImp(AliMpSlatSegmentation)
40 //_____________________________________________________________________________
41 AliMpSlatSegmentation::AliMpSlatSegmentation()
42 : AliMpVSegmentation(),
47 // Default ctor. Not to be used really.
49 AliDebug(1,Form("this=%p Empty ctor",this));
52 //_____________________________________________________________________________
53 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat, Bool_t own)
54 : AliMpVSegmentation(),
61 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
64 //_____________________________________________________________________________
65 AliMpSlatSegmentation::~AliMpSlatSegmentation()
71 if ( fIsOwner ) delete fkSlat;
73 // Int_t i(0);//just to be able to put a breakpoint in gdb
74 AliDebug(1,Form("this=%p",this));
77 //_____________________________________________________________________________
79 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
82 // Returns an iterator to loop over the pad contained within given area.
84 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
85 AliDebug(3,Form("Converted input area wrt to slat center : "
86 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
87 "%7.2f,%7.2f->%7.2f,%7.2f ",
88 area.LeftBorder(),area.DownBorder(),
89 area.RightBorder(),area.UpBorder(),
90 a.LeftBorder(),a.DownBorder(),
91 a.RightBorder(),a.UpBorder()));
93 return new AliMpSlatPadIterator(fkSlat,a);
96 //_____________________________________________________________________________
98 AliMpSlatSegmentation::Dimensions() const
100 return Slat()->Dimensions();
103 //_____________________________________________________________________________
105 AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
107 Slat()->GetAllMotifPositionsIDs(ecn);
110 //_____________________________________________________________________________
112 AliMpSlatSegmentation::GetName() const
114 // The name of this segmentation is "SlatSegmentation"+slatName
116 TString name("SlatSegmentation");
120 name += fkSlat->GetName();
125 //_____________________________________________________________________________
127 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
130 // Test if this slat has a pad located at the position referenced
131 // by the integer indices.
134 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
137 //_____________________________________________________________________________
139 AliMpSlatSegmentation::MaxPadIndexX() const
142 // Returns the value of the largest pad index in x-direction.
145 return fkSlat->GetMaxPadIndexX();
148 //_____________________________________________________________________________
150 AliMpSlatSegmentation::MaxPadIndexY() const
153 // Returns the value of the largest pad index in y-direction.
156 return fkSlat->GetMaxNofPadsY()-1;
159 //_____________________________________________________________________________
161 AliMpSlatSegmentation::NofPads() const
163 /// Return number of pads defined in the slat
165 return fkSlat->NofPads();
168 //_____________________________________________________________________________
170 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
171 Bool_t warning) const
174 // Returns the pad specified by its location, where location is the
175 // pair (ManuID,ManuChannel).
176 // If warning=kTRUE and the pad does not exist, a warning message is
179 // AliMpPad::Invalid() is returned if there's no pad at the given location.
181 Int_t manuID = location.GetFirst();
183 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
189 AliWarning(Form("Manu ID %d not found in slat %s",
190 manuID, fkSlat->GetID()));
192 return AliMpPad::Invalid();
194 AliMpVMotif* motif = motifPos->GetMotif();
195 AliMpIntPair localIndices =
196 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
198 if (!localIndices.IsValid())
202 AliWarning(Form("The pad number %d doesn't exists",
203 location.GetSecond()));
205 return AliMpPad::Invalid();
208 return AliMpPad(location,
209 motifPos->GlobalIndices(localIndices),
211 + motif->PadPositionLocal(localIndices)
212 - fkSlat->Position(),
213 motif->GetPadDimensions(localIndices));
216 //_____________________________________________________________________________
218 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
219 Bool_t warning) const
222 // Returns the pad specified by its integer indices.
223 // If warning=kTRUE and the pad does not exist, a warning message is
226 // AliMpPad::Invalid() is returned if there's no pad at the given location.
229 // FIXME: except for the FindMotifPosition below, this method
230 // is exactly as the one in AliMpSectorSegmentation.
231 // See if we can merge them somehow.
233 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
234 indices.GetSecond());
239 AliWarning(Form("No motif found containing pad location (%d,%d)",
240 indices.GetFirst(),indices.GetSecond()));
242 return AliMpPad::Invalid();
245 AliMpVMotif* motif = motifPos->GetMotif();
246 AliMpMotifType* motifType = motif->GetMotifType();
247 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
248 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
254 AliWarning(Form("No connection for pad location (%d,%d)",
255 indices.GetFirst(),indices.GetSecond()));
257 return AliMpPad::Invalid();
260 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
263 + motif->PadPositionLocal(localIndices)
264 - fkSlat->Position(),
265 motif->GetPadDimensions(localIndices));
268 //_____________________________________________________________________________
270 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
271 Bool_t warning) const
274 // Returns the pad specified by its (floating point) position.
275 // If warning=kTRUE and the pad does not exist, a warning message is
278 // AliMpPad::Invalid() is returned if there's no pad at the given location.
281 TVector2 blPos(position+fkSlat->Position()); // position relative to
282 // bottom-left of the slat.
284 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
290 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
291 " outside limits",fkSlat->GetID(),
292 position.X(),position.Y(),
293 blPos.X(),blPos.Y()));
295 return AliMpPad::Invalid();
298 AliMpVMotif* motif = motifPos->GetMotif();
299 AliMpIntPair localIndices
300 = motif->PadIndicesLocal(blPos-motifPos->Position());
302 AliMpConnection* connect =
303 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
309 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
310 fkSlat->GetID(),localIndices.GetFirst(),
311 localIndices.GetSecond(),motif->GetID().Data()));
313 return AliMpPad::Invalid();
316 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
317 motifPos->GlobalIndices(localIndices),
319 + motif->PadPositionLocal(localIndices)
320 - fkSlat->Position(),
321 motif->GetPadDimensions(localIndices));
324 //_____________________________________________________________________________
326 AliMpSlatSegmentation::PlaneType() const
328 return Slat()->PlaneType();
331 //_____________________________________________________________________________
333 AliMpSlatSegmentation::Print(Option_t* opt) const
338 //_____________________________________________________________________________
340 AliMpSlatSegmentation::Slat() const
343 // Returns the pointer to the referenced slat.