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.10 2006/03/17 16:42:33 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"
36 ClassImp(AliMpSlatSegmentation)
38 //_____________________________________________________________________________
39 AliMpSlatSegmentation::AliMpSlatSegmentation()
40 : AliMpVSegmentation(),
44 // Default ctor. Not to be used really.
46 AliDebug(1,Form("this=%p Empty ctor",this));
49 //_____________________________________________________________________________
50 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat)
51 : AliMpVSegmentation(),
57 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
60 //______________________________________________________________________________
61 AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlatSegmentation& right)
62 : AliMpVSegmentation(right)
64 /// Protected copy constructor (not implemented)
66 AliFatal("Copy constructor not provided.");
69 //_____________________________________________________________________________
70 AliMpSlatSegmentation::~AliMpSlatSegmentation()
75 // Int_t i(0);//just to be able to put a breakpoint in gdb
76 AliDebug(1,Form("this=%p",this));
79 //______________________________________________________________________________
80 AliMpSlatSegmentation&
81 AliMpSlatSegmentation::operator=(const AliMpSlatSegmentation& right)
83 /// Protected assignement operator (not implemented)
85 // check assignement to self
86 if (this == &right) return *this;
88 AliFatal("Assignement operator not provided.");
93 //_____________________________________________________________________________
95 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
98 // Returns an iterator to loop over the pad contained within given area.
100 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
101 AliDebug(3,Form("Converted input area wrt to slat center : "
102 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
103 "%7.2f,%7.2f->%7.2f,%7.2f ",
104 area.LeftBorder(),area.DownBorder(),
105 area.RightBorder(),area.UpBorder(),
106 a.LeftBorder(),a.DownBorder(),
107 a.RightBorder(),a.UpBorder()));
109 return new AliMpSlatPadIterator(fkSlat,a);
112 //_____________________________________________________________________________
114 AliMpSlatSegmentation::Dimensions() const
116 return Slat()->Dimensions();
119 //_____________________________________________________________________________
121 AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
123 Slat()->GetAllMotifPositionsIDs(ecn);
126 //_____________________________________________________________________________
128 AliMpSlatSegmentation::GetName() const
130 // The name of this segmentation is "SlatSegmentation"+slatName
132 TString name("SlatSegmentation");
136 name += fkSlat->GetName();
141 //_____________________________________________________________________________
143 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
146 // Test if this slat has a pad located at the position referenced
147 // by the integer indices.
150 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
153 //_____________________________________________________________________________
155 AliMpSlatSegmentation::MaxPadIndexX() const
158 // Returns the value of the largest pad index in x-direction.
161 return fkSlat->GetMaxPadIndexX();
164 //_____________________________________________________________________________
166 AliMpSlatSegmentation::MaxPadIndexY() const
169 // Returns the value of the largest pad index in y-direction.
172 return fkSlat->GetMaxNofPadsY()-1;
175 //_____________________________________________________________________________
177 AliMpSlatSegmentation::NofPads() const
179 /// Return number of pads defined in the slat
181 return fkSlat->NofPads();
184 //_____________________________________________________________________________
186 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
187 Bool_t warning) const
190 // Returns the pad specified by its location, where location is the
191 // pair (ManuID,ManuChannel).
192 // If warning=kTRUE and the pad does not exist, a warning message is
195 // AliMpPad::Invalid() is returned if there's no pad at the given location.
197 Int_t manuID = location.GetFirst();
199 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
205 AliWarning(Form("Manu ID %d not found in slat %s",
206 manuID, fkSlat->GetID()));
208 return AliMpPad::Invalid();
210 AliMpVMotif* motif = motifPos->GetMotif();
211 AliMpIntPair localIndices =
212 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
214 if (!localIndices.IsValid())
218 AliWarning(Form("The pad number %d doesn't exists",
219 location.GetSecond()));
221 return AliMpPad::Invalid();
224 return AliMpPad(location,
225 motifPos->GlobalIndices(localIndices),
227 + motif->PadPositionLocal(localIndices)
228 - fkSlat->Position(),
229 motif->GetPadDimensions(localIndices));
232 //_____________________________________________________________________________
234 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
235 Bool_t warning) const
238 // Returns the pad specified by its integer indices.
239 // If warning=kTRUE and the pad does not exist, a warning message is
242 // AliMpPad::Invalid() is returned if there's no pad at the given location.
245 // FIXME: except for the FindMotifPosition below, this method
246 // is exactly as the one in AliMpSectorSegmentation.
247 // See if we can merge them somehow.
249 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
250 indices.GetSecond());
255 AliWarning(Form("No motif found containing pad location (%d,%d)",
256 indices.GetFirst(),indices.GetSecond()));
258 return AliMpPad::Invalid();
261 AliMpVMotif* motif = motifPos->GetMotif();
262 AliMpMotifType* motifType = motif->GetMotifType();
263 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
264 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
270 AliWarning(Form("No connection for pad location (%d,%d)",
271 indices.GetFirst(),indices.GetSecond()));
273 return AliMpPad::Invalid();
276 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
279 + motif->PadPositionLocal(localIndices)
280 - fkSlat->Position(),
281 motif->GetPadDimensions(localIndices));
284 //_____________________________________________________________________________
286 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
287 Bool_t warning) const
290 // Returns the pad specified by its (floating point) position.
291 // If warning=kTRUE and the pad does not exist, a warning message is
294 // AliMpPad::Invalid() is returned if there's no pad at the given location.
297 TVector2 blPos(position+fkSlat->Position()); // position relative to
298 // bottom-left of the slat.
300 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
306 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
307 " outside limits",fkSlat->GetID(),
308 position.X(),position.Y(),
309 blPos.X(),blPos.Y()));
311 return AliMpPad::Invalid();
314 AliMpVMotif* motif = motifPos->GetMotif();
315 AliMpIntPair localIndices
316 = motif->PadIndicesLocal(blPos-motifPos->Position());
318 AliMpConnection* connect =
319 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
325 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
326 fkSlat->GetID(),localIndices.GetFirst(),
327 localIndices.GetSecond(),motif->GetID().Data()));
329 return AliMpPad::Invalid();
332 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
333 motifPos->GlobalIndices(localIndices),
335 + motif->PadPositionLocal(localIndices)
336 - fkSlat->Position(),
337 motif->GetPadDimensions(localIndices));
340 //_____________________________________________________________________________
342 AliMpSlatSegmentation::PlaneType() const
344 return Slat()->PlaneType();
347 //_____________________________________________________________________________
349 AliMpSlatSegmentation::Print(Option_t* opt) const
354 //_____________________________________________________________________________
356 AliMpSlatSegmentation::Slat() const
359 // Returns the pointer to the referenced slat.