]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSlatSegmentation.cxx
Fixing Doxygen warnings
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSlatSegmentation.cxx
CommitLineData
dee1d5f1 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$
13985652 17// $MpId: AliMpSlatSegmentation.cxx,v 1.12 2006/05/24 13:58:50 ivana Exp $
dee1d5f1 18
3d1463c8 19//-----------------------------------------------------------------------------
1964cd2e 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.
3d1463c8 25//-----------------------------------------------------------------------------
1964cd2e 26
dee1d5f1 27#include "AliMpSlatSegmentation.h"
28
29#include "AliLog.h"
1964cd2e 30#include "AliMpArea.h"
dee1d5f1 31#include "AliMpConnection.h"
264a9c47 32#include "AliMpConstants.h"
33#include "AliLog.h"
dee1d5f1 34#include "AliMpMotif.h"
35#include "AliMpMotifPosition.h"
36#include "AliMpMotifType.h"
dee1d5f1 37#include "AliMpSlat.h"
38#include "AliMpSlatPadIterator.h"
168e9c4d 39#include "AliMpEncodePair.h"
dee1d5f1 40
13985652 41/// \cond CLASSIMP
dee1d5f1 42ClassImp(AliMpSlatSegmentation)
13985652 43/// \endcond
dee1d5f1 44
45//_____________________________________________________________________________
46AliMpSlatSegmentation::AliMpSlatSegmentation()
47: AliMpVSegmentation(),
41af6fb0 48 fkSlat(0),
49 fIsOwner(false)
dee1d5f1 50{
71a2d3aa 51 ///
52 /// Default ctor. Not to be used really.
53 ///
dee1d5f1 54 AliDebug(1,Form("this=%p Empty ctor",this));
55}
56
57//_____________________________________________________________________________
41af6fb0 58AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat, Bool_t own)
dee1d5f1 59: AliMpVSegmentation(),
41af6fb0 60 fkSlat(slat),
61 fIsOwner(own)
dee1d5f1 62{
71a2d3aa 63 ///
64 /// Normal ctor.
65 ///
dee1d5f1 66 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
67}
68
69//_____________________________________________________________________________
70AliMpSlatSegmentation::~AliMpSlatSegmentation()
71{
71a2d3aa 72 ///
73 /// Dtor (empty).
74 ///
41af6fb0 75
76 if ( fIsOwner ) delete fkSlat;
77
0b91d34d 78 // Int_t i(0);//just to be able to put a breakpoint in gdb
dee1d5f1 79 AliDebug(1,Form("this=%p",this));
80}
81
82//_____________________________________________________________________________
83AliMpVPadIterator*
84AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
85{
71a2d3aa 86 ///
87 /// Returns an iterator to loop over the pad contained within given area.
88 ///
6e97fbb8 89 AliMpArea a(area.GetPositionX()+fkSlat->GetPositionX(),
90 area.GetPositionY()+fkSlat->GetPositionY(),
91 area.GetDimensionX(),
92 area.GetDimensionY());
63bcb3c3 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
1964cd2e 101 return new AliMpSlatPadIterator(fkSlat,a);
dee1d5f1 102}
103
264a9c47 104//_____________________________________________________________________________
105AliMpVPadIterator*
106AliMpSlatSegmentation::CreateIterator() const
107{
108 /// Returns an iterator to loop over all pads of that segmentation
109 ///
110 /// FIXME: we currently just forward this to the other CreateIterator,
111 /// with the proper region. Might be more efficient to write a dedicated
112 /// iterator ? Test that idea.
113
6e97fbb8 114 AliMpArea area(0.0,0.0,fkSlat->DX(),fkSlat->DY());
264a9c47 115 return CreateIterator(area);
116}
117
118//_____________________________________________________________________________
119Int_t
120AliMpSlatSegmentation::GetNeighbours(const AliMpPad& pad,
121 TObjArray& neighbours,
122 Bool_t includeSelf,
123 Bool_t includeVoid) const
124{
125 /// Uses default implementation
126 return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
127}
128
63bcb3c3 129//_____________________________________________________________________________
6e97fbb8 130Double_t
131AliMpSlatSegmentation::GetDimensionX() const
63bcb3c3 132{
6e97fbb8 133/// Return slat x dimensions
134 return Slat()->DX();
135}
71a2d3aa 136
6e97fbb8 137//_____________________________________________________________________________
138Double_t
139AliMpSlatSegmentation::GetDimensionY() const
140{
141/// Return slat y dimensions
142 return Slat()->DY();
63bcb3c3 143}
144
145//_____________________________________________________________________________
146void
147AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
148{
71a2d3aa 149 /// Fill the array ecn with all manuIds
150
63bcb3c3 151 Slat()->GetAllMotifPositionsIDs(ecn);
152}
153
1faed5a9 154//_____________________________________________________________________________
155const char*
156AliMpSlatSegmentation::GetName() const
157{
71a2d3aa 158 /// The name of this segmentation is "SlatSegmentation"+slatName
85fec35d 159
1faed5a9 160 TString name("SlatSegmentation");
161 if ( fkSlat)
162 {
163 name += ".";
164 name += fkSlat->GetName();
165 }
166 return name.Data();
167}
168
dee1d5f1 169//_____________________________________________________________________________
170Int_t
026b7442 171AliMpSlatSegmentation::MaxPadIndexX() const
dee1d5f1 172{
71a2d3aa 173 ///
174 /// Returns the value of the largest pad index in x-direction.
175 ///
dee1d5f1 176
16e8fffd 177 return fkSlat->GetMaxPadIndexX();
dee1d5f1 178}
179
180//_____________________________________________________________________________
181Int_t
026b7442 182AliMpSlatSegmentation::MaxPadIndexY() const
dee1d5f1 183{
71a2d3aa 184 ///
185 /// Returns the value of the largest pad index in y-direction.
186 ///
dee1d5f1 187
188 return fkSlat->GetMaxNofPadsY()-1;
189}
190
026b7442 191//_____________________________________________________________________________
192Int_t
193AliMpSlatSegmentation::NofPads() const
194{
195/// Return number of pads defined in the slat
196
efb408b3 197 return fkSlat->NofPads();
026b7442 198}
199
dee1d5f1 200//_____________________________________________________________________________
201AliMpPad
168e9c4d 202AliMpSlatSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel,
dee1d5f1 203 Bool_t warning) const
204{
71a2d3aa 205 ///
206 /// Returns the pad specified by its location, where location is the
207 /// pair (ManuID,ManuChannel).
208 /// If warning=kTRUE and the pad does not exist, a warning message is
209 /// printed.
210 ///
211 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
212 ///
168e9c4d 213 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuId);
dee1d5f1 214
215 if (!motifPos)
168e9c4d 216 {
217 if (warning)
218 {
219 AliWarning(Form("Manu ID %d not found in slat %s",
220 manuId, fkSlat->GetID()));
1faed5a9 221 }
222 return AliMpPad::Invalid();
168e9c4d 223 }
dee1d5f1 224 AliMpVMotif* motif = motifPos->GetMotif();
168e9c4d 225 MpPair_t localIndices =
226 motif->GetMotifType()->FindLocalIndicesByGassiNum(manuChannel);
dee1d5f1 227
168e9c4d 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 }
6e97fbb8 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);
dee1d5f1 245
168e9c4d 246 return AliMpPad(manuId, manuChannel,
dee1d5f1 247 motifPos->GlobalIndices(localIndices),
6e97fbb8 248 posx, posy, dx, dy);
dee1d5f1 249}
250
251//_____________________________________________________________________________
252AliMpPad
168e9c4d 253AliMpSlatSegmentation::PadByIndices(Int_t ix, Int_t iy,
dee1d5f1 254 Bool_t warning) const
255{
71a2d3aa 256 ///
257 /// Returns the pad specified by its integer indices.
258 /// If warning=kTRUE and the pad does not exist, a warning message is
259 /// printed.
260 ///
261 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
262 ///
263 ///
264 /// FIXME: except for the FindMotifPosition below, this method
265 /// is exactly as the one in AliMpSectorSegmentation.
266 /// See if we can merge them somehow.
dee1d5f1 267
168e9c4d 268 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(ix,iy);
269
dee1d5f1 270 if (!motifPos)
168e9c4d 271 {
272 if ( warning )
273 {
274 AliWarning(Form("No motif found containing pad location (%d,%d)",ix,iy));
275 }
276 return AliMpPad::Invalid();
277 }
dee1d5f1 278
279 AliMpVMotif* motif = motifPos->GetMotif();
280 AliMpMotifType* motifType = motif->GetMotifType();
168e9c4d 281 MpPair_t localIndices = AliMp::Pair(ix,iy) - motifPos->GetLowIndicesLimit();
282 AliMpConnection* connection
283 = motifType->FindConnectionByLocalIndices(localIndices);
dee1d5f1 284
285 if (!connection)
168e9c4d 286 {
287 if ( warning )
288 {
289 AliWarning(Form("No connection for pad location (%d,%d)",ix,iy));
1faed5a9 290 }
291 return AliMpPad::Invalid();
168e9c4d 292 }
293
6e97fbb8 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
168e9c4d 302 return AliMpPad(motifPos->GetID(),connection->GetManuChannel(),
6e97fbb8 303 ix, iy, posx, posy, dx, dy);
dee1d5f1 304}
305
306//_____________________________________________________________________________
307AliMpPad
6e97fbb8 308AliMpSlatSegmentation::PadByPosition(Double_t x, Double_t y,
dee1d5f1 309 Bool_t warning) const
310{
71a2d3aa 311 ///
312 /// Returns the pad specified by its (floating point) position.
313 /// If warning=kTRUE and the pad does not exist, a warning message is
314 /// printed.
315 ///
316 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
317 ///
dee1d5f1 318
6e97fbb8 319 Double_t blPosX(x);
320 Double_t blPosY(y);
264a9c47 321
6e97fbb8 322 blPosX += fkSlat->GetPositionX();
323 blPosY += fkSlat->GetPositionY(); // position relative to bottom-left of the slat.
1964cd2e 324
6e97fbb8 325 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPosX,blPosY);
dee1d5f1 326
327 if (!motifPos)
6e97fbb8 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 }
dee1d5f1 337
338 AliMpVMotif* motif = motifPos->GetMotif();
6e97fbb8 339
340 blPosX -= motifPos->GetPositionX();
341 blPosY -= motifPos->GetPositionY();
342 MpPair_t localIndices = motif->PadIndicesLocal(blPosX, blPosY);
dee1d5f1 343
344 AliMpConnection* connect =
345 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
346
347 if (!connect)
6e97fbb8 348 {
349 if (warning)
350 {
351 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
168e9c4d 352 fkSlat->GetID(),AliMp::PairFirst(localIndices),
353 AliMp::PairSecond(localIndices),motif->GetID().Data()));
6e97fbb8 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
168e9c4d 366 return AliMpPad(motifPos->GetID(),connect->GetManuChannel(),
dee1d5f1 367 motifPos->GlobalIndices(localIndices),
6e97fbb8 368 posx, posy, dx, dy);
dee1d5f1 369}
370
63bcb3c3 371//_____________________________________________________________________________
cddd101e 372AliMp::PlaneType
63bcb3c3 373AliMpSlatSegmentation::PlaneType() const
374{
375 return Slat()->PlaneType();
376}
377
378//_____________________________________________________________________________
379void
380AliMpSlatSegmentation::Print(Option_t* opt) const
381{
71a2d3aa 382/// Printing
383
63bcb3c3 384 fkSlat->Print(opt);
385}
386
dee1d5f1 387//_____________________________________________________________________________
388const AliMpSlat*
389AliMpSlatSegmentation::Slat() const
390{
71a2d3aa 391 ///
392 /// Returns the pointer to the referenced slat.
393 ///
dee1d5f1 394
395 return fkSlat;
396}
3635f34f 397
398//_____________________________________________________________________________
399Bool_t
168e9c4d 400AliMpSlatSegmentation::HasPadByIndices(Int_t ix, Int_t iy) const
3635f34f 401{
402 /// Tell whether we have a pad at indices=(ix,iy)
403
168e9c4d 404 AliMpMotifPosition* motifPos = Slat()->FindMotifPosition(ix, iy);
3635f34f 405
168e9c4d 406 if (motifPos) return motifPos->HasPadByIndices(AliMp::Pair(ix, iy));
3635f34f 407
408 return kFALSE;
409}
410
411//_____________________________________________________________________________
412Bool_t
168e9c4d 413AliMpSlatSegmentation::HasPadByLocation(Int_t manuId, Int_t manuChannel) const
3635f34f 414{
415 /// Tell whether we have a pad at location=(manuId,manuChannel)
416
168e9c4d 417 AliMpMotifPosition* motifPos = Slat()->FindMotifPosition(manuId);
3635f34f 418
168e9c4d 419 if ( motifPos ) return motifPos->HasPadByManuChannel(manuChannel);
3635f34f 420
421 return kFALSE;
422}
423
424
425//_____________________________________________________________________________
426Int_t
427AliMpSlatSegmentation::GetNofElectronicCards() const
428{
429 /// Get the number of manus of this slat
430 return Slat()->GetNofElectronicCards();
431
432}
433
434//_____________________________________________________________________________
6e97fbb8 435Double_t
436AliMpSlatSegmentation::GetPositionX() const
3635f34f 437{
6e97fbb8 438/// Return x position of slat origin
439 return Slat()->GetPositionX();
440}
441
442//_____________________________________________________________________________
443Double_t
444AliMpSlatSegmentation::GetPositionY() const
445{
446/// Return y position of slat origin
447
448 return Slat()->GetPositionY();
3635f34f 449}
450
451//_____________________________________________________________________________
452Bool_t
453AliMpSlatSegmentation::HasMotifPosition(Int_t manuId) const
454{
455 /// Use default implementation
456 return AliMpVSegmentation::HasMotifPosition(manuId);
457}
458
459//_____________________________________________________________________________
460AliMpMotifPosition*
461AliMpSlatSegmentation::MotifPosition(Int_t manuId) const
462{
463 /// Get back a given manu
464 return Slat()->FindMotifPosition(manuId);
465}
466