AliRoot Core  d69033e (d69033e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpSlatSegmentation.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpSlatSegmentation.cxx,v 1.12 2006/05/24 13:58:50 ivana Exp $
18 
19 //-----------------------------------------------------------------------------
20 // Caution !!
21 // Implementation note.
22 // The position(s) used in the interface are supposed to be relative
23 // to the slat center (AliMpSlat::Position()), whereas internally
24 // the x,y are relative to bottom-left corner.
25 //-----------------------------------------------------------------------------
26 
27 #include "AliMpSlatSegmentation.h"
28 
29 #include "AliLog.h"
30 #include "AliMpArea.h"
31 #include "AliMpConnection.h"
32 #include "AliMpConstants.h"
33 #include "AliLog.h"
34 #include "AliMpMotif.h"
35 #include "AliMpMotifPosition.h"
36 #include "AliMpMotifType.h"
37 #include "AliMpSlat.h"
38 #include "AliMpSlatPadIterator.h"
39 #include "AliMpEncodePair.h"
40 
44 
45 //_____________________________________________________________________________
48  fkSlat(0),
49  fIsOwner(false)
50 {
54  AliDebug(1,Form("this=%p Empty ctor",this));
55 }
56 
57 //_____________________________________________________________________________
60  fkSlat(slat),
61  fIsOwner(own)
62 {
66  AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
67 }
68 
69 //_____________________________________________________________________________
71 {
75 
76  if ( fIsOwner ) delete fkSlat;
77 
78  // Int_t i(0);//just to be able to put a breakpoint in gdb
79  AliDebug(1,Form("this=%p",this));
80 }
81 
82 //_____________________________________________________________________________
85 {
91  area.GetDimensionX(),
92  area.GetDimensionY());
93  AliDebug(3,Form("Converted input area wrt to slat center : "
94  "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
95  "%7.2f,%7.2f->%7.2f,%7.2f ",
96  area.LeftBorder(),area.DownBorder(),
97  area.RightBorder(),area.UpBorder(),
98  a.LeftBorder(),a.DownBorder(),
99  a.RightBorder(),a.UpBorder()));
100 
101  return new AliMpSlatPadIterator(fkSlat,a);
102 }
103 
104 //_____________________________________________________________________________
107 {
113 
114  AliMpArea area(0.0,0.0,fkSlat->DX(),fkSlat->DY());
115  return CreateIterator(area);
116 }
117 
118 //_____________________________________________________________________________
119 Int_t
121  TObjArray& neighbours,
122  Bool_t includeSelf,
123  Bool_t includeVoid) const
124 {
126  return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
127 }
128 
129 //_____________________________________________________________________________
130 Double_t
132 {
134  return Slat()->DX();
135 }
136 
137 //_____________________________________________________________________________
138 Double_t
140 {
142  return Slat()->DY();
143 }
144 
145 //_____________________________________________________________________________
146 void
148 {
150 
152 }
153 
154 //_____________________________________________________________________________
155 const char*
157 {
159 
160  TString name("SlatSegmentation");
161  if ( fkSlat)
162  {
163  name += ".";
164  name += fkSlat->GetName();
165  }
166  return name.Data();
167 }
168 
169 //_____________________________________________________________________________
170 Int_t
172 {
176 
177  return fkSlat->GetMaxPadIndexX();
178 }
179 
180 //_____________________________________________________________________________
181 Int_t
183 {
187 
188  return fkSlat->GetMaxNofPadsY()-1;
189 }
190 
191 //_____________________________________________________________________________
192 Int_t
194 {
196 
197  return fkSlat->NofPads();
198 }
199 
200 //_____________________________________________________________________________
201 AliMpPad
202 AliMpSlatSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel,
203  Bool_t warning) const
204 {
213  AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuId);
214 
215  if (!motifPos)
216  {
217  if (warning)
218  {
219  AliWarning(Form("Manu ID %d not found in slat %s",
220  manuId, fkSlat->GetID()));
221  }
222  return AliMpPad::Invalid();
223  }
224  AliMpVMotif* motif = motifPos->GetMotif();
225  MpPair_t localIndices =
226  motif->GetMotifType()->FindLocalIndicesByGassiNum(manuChannel);
227 
228  if ( localIndices < 0 )
229  {
230  if (warning)
231  {
232  AliWarning(Form("The pad number %d doesn't exists",
233  manuChannel));
234  }
235  return AliMpPad::Invalid();
236  }
237 
238  Double_t posx, posy;
239  motif->PadPositionLocal(localIndices, posx, posy);
240  posx += motifPos->GetPositionX() - fkSlat->GetPositionX();
241  posy += motifPos->GetPositionY() - fkSlat->GetPositionY();
242 
243  Double_t dx, dy;
244  motif->GetPadDimensionsByIndices(localIndices, dx, dy);
245 
246  return AliMpPad(manuId, manuChannel,
247  motifPos->GlobalIndices(localIndices),
248  posx, posy, dx, dy);
249 }
250 
251 //_____________________________________________________________________________
252 AliMpPad
254  Bool_t warning) const
255 {
267 
268  AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(ix,iy);
269 
270  if (!motifPos)
271  {
272  if ( warning )
273  {
274  AliWarning(Form("No motif found containing pad location (%d,%d)",ix,iy));
275  }
276  return AliMpPad::Invalid();
277  }
278 
279  AliMpVMotif* motif = motifPos->GetMotif();
280  AliMpMotifType* motifType = motif->GetMotifType();
281  MpPair_t localIndices = AliMp::Pair(ix,iy) - motifPos->GetLowIndicesLimit();
282  AliMpConnection* connection
283  = motifType->FindConnectionByLocalIndices(localIndices);
284 
285  if (!connection)
286  {
287  if ( warning )
288  {
289  AliWarning(Form("No connection for pad location (%d,%d)",ix,iy));
290  }
291  return AliMpPad::Invalid();
292  }
293 
294  Double_t posx, posy;
295  motif->PadPositionLocal(localIndices, posx, posy);
296  posx += motifPos->GetPositionX() - fkSlat->GetPositionX();
297  posy += motifPos->GetPositionY() - fkSlat->GetPositionY();
298 
299  Double_t dx, dy;
300  motif->GetPadDimensionsByIndices(localIndices, dx, dy);
301 
302  return AliMpPad(motifPos->GetID(),connection->GetManuChannel(),
303  ix, iy, posx, posy, dx, dy);
304 }
305 
306 //_____________________________________________________________________________
307 AliMpPad
308 AliMpSlatSegmentation::PadByPosition(Double_t x, Double_t y,
309  Bool_t warning) const
310 {
318 
319  Double_t blPosX(x);
320  Double_t blPosY(y);
321 
322  blPosX += fkSlat->GetPositionX();
323  blPosY += fkSlat->GetPositionY(); // position relative to bottom-left of the slat.
324 
325  AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPosX,blPosY);
326 
327  if (!motifPos)
328  {
329  if (warning)
330  {
331  AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
332  " outside limits",fkSlat->GetID(),x,y,
333  blPosX,blPosY));
334  }
335  return AliMpPad::Invalid();
336  }
337 
338  AliMpVMotif* motif = motifPos->GetMotif();
339 
340  blPosX -= motifPos->GetPositionX();
341  blPosY -= motifPos->GetPositionY();
342  MpPair_t localIndices = motif->PadIndicesLocal(blPosX, blPosY);
343 
344  AliMpConnection* connect =
345  motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
346 
347  if (!connect)
348  {
349  if (warning)
350  {
351  AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
352  fkSlat->GetID(),AliMp::PairFirst(localIndices),
353  AliMp::PairSecond(localIndices),motif->GetID().Data()));
354  }
355  return AliMpPad::Invalid();
356  }
357 
358  Double_t posx, posy;
359  motif->PadPositionLocal(localIndices, posx, posy);
360  posx += motifPos->GetPositionX() - fkSlat->GetPositionX();
361  posy += motifPos->GetPositionY() - fkSlat->GetPositionY();
362 
363  Double_t dx, dy;
364  motif->GetPadDimensionsByIndices(localIndices, dx, dy);
365 
366  return AliMpPad(motifPos->GetID(),connect->GetManuChannel(),
367  motifPos->GlobalIndices(localIndices),
368  posx, posy, dx, dy);
369 }
370 
371 //_____________________________________________________________________________
374 {
375  return Slat()->PlaneType();
376 }
377 
378 //_____________________________________________________________________________
379 void
380 AliMpSlatSegmentation::Print(Option_t* opt) const
381 {
383 
384  fkSlat->Print(opt);
385 }
386 
387 //_____________________________________________________________________________
388 const AliMpSlat*
390 {
394 
395  return fkSlat;
396 }
397 
398 //_____________________________________________________________________________
399 Bool_t
400 AliMpSlatSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
401 {
403 
404  AliMpMotifPosition* motifPos = Slat()->FindMotifPosition(ix, iy);
405 
406  if (motifPos) return motifPos->HasPadByIndices(AliMp::Pair(ix, iy));
407 
408  return kFALSE;
409 }
410 
411 //_____________________________________________________________________________
412 Bool_t
413 AliMpSlatSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
414 {
416 
417  AliMpMotifPosition* motifPos = Slat()->FindMotifPosition(manuId);
418 
419  if ( motifPos ) return motifPos->HasPadByManuChannel(manuChannel);
420 
421  return kFALSE;
422 }
423 
424 
425 //_____________________________________________________________________________
426 Int_t
428 {
430  return Slat()->GetNofElectronicCards();
431 
432 }
433 
434 //_____________________________________________________________________________
435 Double_t
437 {
439  return Slat()->GetPositionX();
440 }
441 
442 //_____________________________________________________________________________
443 Double_t
445 {
447 
448  return Slat()->GetPositionY();
449 }
450 
451 //_____________________________________________________________________________
452 Bool_t
454 {
457 }
458 
459 //_____________________________________________________________________________
462 {
464  return Slat()->FindMotifPosition(manuId);
465 }
466 
Double_t GetPositionY() const
Return y position.
const AliMpSlat * Slat() const
virtual void Print(Option_t *opt) const
const AliMpSlat * fkSlat
Slat.
const char * GetName() const
Double_t GetDimensionY() const
Return y dimensions.
Definition: AliMpArea.h:81
virtual Bool_t HasMotifPosition(Int_t manuId) const =0
Whether or not we have a given manu.
void GetAllMotifPositionsIDs(TArrayI &ecn) const
Return the ids of the electronic cards (either manu or local board).
Definition: AliMpSlat.cxx:335
Double_t GetPositionY() const
Return y position.
Definition: AliMpArea.h:77
A connection properties.
#define TObjArray
Double_t LeftBorder() const
Definition: AliMpArea.cxx:124
virtual Int_t GetNofElectronicCards() const
Get the number of electronic card IDs.
Int_t MaxPadIndexX() const
Return maximum pad index in X direction.
virtual AliMp::PlaneType PlaneType() const
Return the plane type.
Double_t GetPositionY() const
Return y position.
Definition: AliMpSlat.h:62
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning) const
Find pad by indices.
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
Bool_t HasPadByIndices(MpPair_t indices) const
virtual Int_t GetNeighbours(const AliMpPad &pad, TObjArray &neighbours, Bool_t includeSelf=kFALSE, Bool_t includeVoid=kFALSE) const
AliMpConnection * FindConnectionByLocalIndices(MpPair_t localIndices) const
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
MpPair_t FindLocalIndicesByGassiNum(Int_t gassiNum) const
AliMpMotifType * GetMotifType() const
Return the motif type.
Definition: AliMpVMotif.h:87
static AliMpPad Invalid()
Return invalid pad.
Definition: AliMpPad.h:57
AliMpMotifPosition * FindMotifPosition(Double_t x, Double_t y) const
Returns the MotifPosition containing location (x,y).
Definition: AliMpSlat.cxx:210
Double_t DY() const
Definition: AliMpSlat.cxx:171
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
virtual Double_t GetPositionY() const
Return the y position of the origin of the detection element.
void Print(Option_t *option="") const
Definition: AliMpSlat.cxx:456
Int_t GetID() const
Return motif position ID = manu id.
TString GetID() const
Return the motif identifier.
Definition: AliMpVMotif.h:90
virtual AliMpPad PadByLocation(Int_t manuId, Int_t manuChannel, Bool_t warning) const
Find pad by location.
A placed motif.
Double_t DX() const
Definition: AliMpSlat.cxx:161
Double_t GetDimensionX() const
Return x dimensions.
Definition: AliMpArea.h:79
const char * GetName() const
Definition: AliMpSlat.cxx:391
An interface for an iterator over pads.
virtual AliMpVPadIterator * CreateIterator() const
Create a pad iterator over the whole area.
MpPair_t GetLowIndicesLimit() const
Double_t UpBorder() const
Definition: AliMpArea.cxx:140
AliMpVMotif * GetMotif() const
Return motif.
Int_t MaxPadIndexY() const
Return maximum pad index in Y direction.
Int_t GetMaxNofPadsY() const
Definition: AliMpSlat.cxx:366
virtual Bool_t HasPadByLocation(Int_t manuId, Int_t manuChannel) const
Return true if the pad with given location exists.
const char * GetID() const
Definition: AliMpSlat.cxx:356
Bool_t fIsOwner
Slat ownership.
Double_t GetPositionX() const
Return x position.
Definition: AliMpArea.h:75
virtual Bool_t HasMotifPosition(Int_t manuId) const
Whether or not we have a given manu.
virtual Double_t GetPositionX() const
Return the x position of the origin of the detection element.
virtual MpPair_t PadIndicesLocal(Double_t localPosX, Double_t localPosY) const =0
Return local indices of the pad specified by local position.
Implementation of AliMpVSegmentation for St345 slats.
virtual void PadPositionLocal(MpPair_t localIndices, Double_t &posx, Double_t &posy) const =0
Fill local position of the pad specified by local indices.
Int_t NofPads() const
Return the number of pads in the detection element.
Double_t DownBorder() const
Definition: AliMpArea.cxx:148
Double_t GetPositionX() const
Return x position.
Definition: AliMpSlat.h:60
Abstract base class for a motif with its unique ID and the motif type.
Definition: AliMpVMotif.h:24
Int_t MpPair_t
void GetAllElectronicCardIDs(TArrayI &ecn) const
Fill the given array with the electronic card IDs.
The abstract base class for the segmentation.
virtual MpPair_t GlobalIndices(MpPair_t localIndices) const
Int_t GetManuChannel() const
Return manu channel number.
Int_t GetMaxPadIndexX() const
Definition: AliMpSlat.cxx:376
Int_t NofPads() const
Return the number of pads in this slat.
Definition: AliMpSlat.h:134
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning) const
Find pad by position.
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
virtual Int_t GetNeighbours(const AliMpPad &pad, TObjArray &neighbours, Bool_t includeSelf=kFALSE, Bool_t includeVoid=kFALSE) const =0
AliMp::PlaneType PlaneType() const
Return the plane type.
Definition: AliMpSlat.h:131
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return x position.
Int_t PairSecond(MpPair_t pair)
Decode the second integer from encoded pair.
virtual Double_t GetDimensionX() const
Return the x half-sizes of the detection element.
Int_t GetNofElectronicCards() const
Return the number of electronic cards (either manu or local board).
Definition: AliMpSlat.cxx:415
virtual Bool_t HasPadByIndices(Int_t ix, Int_t iy) const
Bool_t HasPadByManuChannel(Int_t manuChannel) const
Double_t RightBorder() const
Definition: AliMpArea.cxx:132
Iterator for slat pads.
Class that defines the motif properties.
virtual AliMpMotifPosition * MotifPosition(Int_t manuId) const
Return the position of a given manu (aka motifPosition)
virtual void GetPadDimensionsByIndices(MpPair_t localIndices, Double_t &dx, Double_t &dy) const =0
Return the dimensions of the pad specified by localIndices.
virtual Double_t GetDimensionY() const
Return the y half-sizes of the detection element.