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.9 2006/03/14 09:04:28 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(const AliMpSlatSegmentation& right)
63 : AliMpVSegmentation(right)
65 /// Protected copy constructor (not implemented)
67 AliFatal("Copy constructor not provided.");
70 //_____________________________________________________________________________
71 AliMpSlatSegmentation::~AliMpSlatSegmentation()
76 // Int_t i(0);//just to be able to put a breakpoint in gdb
77 AliDebug(1,Form("this=%p",this));
80 //______________________________________________________________________________
81 AliMpSlatSegmentation&
82 AliMpSlatSegmentation::operator=(const AliMpSlatSegmentation& right)
84 /// Protected assignement operator (not implemented)
86 // check assignement to self
87 if (this == &right) return *this;
89 AliFatal("Assignement operator not provided.");
94 //_____________________________________________________________________________
96 AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
99 // Returns an iterator to loop over the pad contained within given area.
101 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
102 AliDebug(3,Form("Converted input area wrt to slat center : "
103 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
104 "%7.2f,%7.2f->%7.2f,%7.2f ",
105 area.LeftBorder(),area.DownBorder(),
106 area.RightBorder(),area.UpBorder(),
107 a.LeftBorder(),a.DownBorder(),
108 a.RightBorder(),a.UpBorder()));
110 return new AliMpSlatPadIterator(fkSlat,a);
113 //_____________________________________________________________________________
115 AliMpSlatSegmentation::Dimensions() const
117 return Slat()->Dimensions();
120 //_____________________________________________________________________________
122 AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
124 Slat()->GetAllMotifPositionsIDs(ecn);
127 //_____________________________________________________________________________
129 AliMpSlatSegmentation::GetName() const
131 TString name("SlatSegmentation");
135 name += fkSlat->GetName();
140 //_____________________________________________________________________________
142 AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
145 // Test if this slat has a pad located at the position referenced
146 // by the integer indices.
149 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
152 //_____________________________________________________________________________
154 AliMpSlatSegmentation::MaxPadIndexX() const
157 // Returns the value of the largest pad index in x-direction.
160 return fkSlat->GetMaxPadIndexX();
163 //_____________________________________________________________________________
165 AliMpSlatSegmentation::MaxPadIndexY() const
168 // Returns the value of the largest pad index in y-direction.
171 return fkSlat->GetMaxNofPadsY()-1;
174 //_____________________________________________________________________________
176 AliMpSlatSegmentation::NofPads() const
178 /// Return number of pads defined in the slat
180 AliError("Not yet implemented");
185 //_____________________________________________________________________________
187 AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
188 Bool_t warning) const
191 // Returns the pad specified by its location, where location is the
192 // pair (ManuID,ManuChannel).
193 // If warning=kTRUE and the pad does not exist, a warning message is
196 // AliMpPad::Invalid() is returned if there's no pad at the given location.
198 Int_t manuID = location.GetFirst();
200 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
206 AliWarning(Form("Manu ID %d not found in slat %s",
207 manuID, fkSlat->GetID()));
209 return AliMpPad::Invalid();
211 AliMpVMotif* motif = motifPos->GetMotif();
212 AliMpIntPair localIndices =
213 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
215 if (!localIndices.IsValid())
219 AliWarning(Form("The pad number %d doesn't exists",
220 location.GetSecond()));
222 return AliMpPad::Invalid();
225 return AliMpPad(location,
226 motifPos->GlobalIndices(localIndices),
228 + motif->PadPositionLocal(localIndices)
229 - fkSlat->Position(),
230 motif->GetPadDimensions(localIndices));
233 //_____________________________________________________________________________
235 AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
236 Bool_t warning) const
239 // Returns the pad specified by its integer indices.
240 // If warning=kTRUE and the pad does not exist, a warning message is
243 // AliMpPad::Invalid() is returned if there's no pad at the given location.
246 // FIXME: except for the FindMotifPosition below, this method
247 // is exactly as the one in AliMpSectorSegmentation.
248 // See if we can merge them somehow.
250 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
251 indices.GetSecond());
256 AliWarning(Form("No motif found containing pad location (%d,%d)",
257 indices.GetFirst(),indices.GetSecond()));
259 return AliMpPad::Invalid();
262 AliMpVMotif* motif = motifPos->GetMotif();
263 AliMpMotifType* motifType = motif->GetMotifType();
264 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
265 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
271 AliWarning(Form("No connection for pad location (%d,%d)",
272 indices.GetFirst(),indices.GetSecond()));
274 return AliMpPad::Invalid();
277 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
280 + motif->PadPositionLocal(localIndices)
281 - fkSlat->Position(),
282 motif->GetPadDimensions(localIndices));
285 //_____________________________________________________________________________
287 AliMpSlatSegmentation::PadByPosition(const TVector2& position,
288 Bool_t warning) const
291 // Returns the pad specified by its (floating point) position.
292 // If warning=kTRUE and the pad does not exist, a warning message is
295 // AliMpPad::Invalid() is returned if there's no pad at the given location.
298 TVector2 blPos(position+fkSlat->Position()); // position relative to
299 // bottom-left of the slat.
301 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
307 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
308 " outside limits",fkSlat->GetID(),
309 position.X(),position.Y(),
310 blPos.X(),blPos.Y()));
312 return AliMpPad::Invalid();
315 AliMpVMotif* motif = motifPos->GetMotif();
316 AliMpIntPair localIndices
317 = motif->PadIndicesLocal(blPos-motifPos->Position());
319 AliMpConnection* connect =
320 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
326 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
327 fkSlat->GetID(),localIndices.GetFirst(),
328 localIndices.GetSecond(),motif->GetID().Data()));
330 return AliMpPad::Invalid();
333 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
334 motifPos->GlobalIndices(localIndices),
336 + motif->PadPositionLocal(localIndices)
337 - fkSlat->Position(),
338 motif->GetPadDimensions(localIndices));
341 //_____________________________________________________________________________
343 AliMpSlatSegmentation::PlaneType() const
345 return Slat()->PlaneType();
348 //_____________________________________________________________________________
350 AliMpSlatSegmentation::Print(Option_t* opt) const
355 //_____________________________________________________________________________
357 AliMpSlatSegmentation::Slat() const
360 // Returns the pointer to the referenced slat.