]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSlatSegmentation.cxx
Adding comment lines to class description needed for Root documentation,
[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"
39
13985652 40/// \cond CLASSIMP
dee1d5f1 41ClassImp(AliMpSlatSegmentation)
13985652 42/// \endcond
dee1d5f1 43
44//_____________________________________________________________________________
45AliMpSlatSegmentation::AliMpSlatSegmentation()
46: AliMpVSegmentation(),
41af6fb0 47 fkSlat(0),
48 fIsOwner(false)
dee1d5f1 49{
71a2d3aa 50 ///
51 /// Default ctor. Not to be used really.
52 ///
dee1d5f1 53 AliDebug(1,Form("this=%p Empty ctor",this));
54}
55
56//_____________________________________________________________________________
41af6fb0 57AliMpSlatSegmentation::AliMpSlatSegmentation(const AliMpSlat* slat, Bool_t own)
dee1d5f1 58: AliMpVSegmentation(),
41af6fb0 59 fkSlat(slat),
60 fIsOwner(own)
dee1d5f1 61{
71a2d3aa 62 ///
63 /// Normal ctor.
64 ///
dee1d5f1 65 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
66}
67
68//_____________________________________________________________________________
69AliMpSlatSegmentation::~AliMpSlatSegmentation()
70{
71a2d3aa 71 ///
72 /// Dtor (empty).
73 ///
41af6fb0 74
75 if ( fIsOwner ) delete fkSlat;
76
0b91d34d 77 // Int_t i(0);//just to be able to put a breakpoint in gdb
dee1d5f1 78 AliDebug(1,Form("this=%p",this));
79}
80
81//_____________________________________________________________________________
82AliMpVPadIterator*
83AliMpSlatSegmentation::CreateIterator(const AliMpArea& area) const
84{
71a2d3aa 85 ///
86 /// Returns an iterator to loop over the pad contained within given area.
87 ///
1964cd2e 88 AliMpArea a(area.Position()+fkSlat->Position(),area.Dimensions());
63bcb3c3 89 AliDebug(3,Form("Converted input area wrt to slat center : "
90 "%7.2f,%7.2f->%7.2f,%7.2f to wrt slat lower-left : "
91 "%7.2f,%7.2f->%7.2f,%7.2f ",
92 area.LeftBorder(),area.DownBorder(),
93 area.RightBorder(),area.UpBorder(),
94 a.LeftBorder(),a.DownBorder(),
95 a.RightBorder(),a.UpBorder()));
96
1964cd2e 97 return new AliMpSlatPadIterator(fkSlat,a);
dee1d5f1 98}
99
264a9c47 100//_____________________________________________________________________________
101AliMpVPadIterator*
102AliMpSlatSegmentation::CreateIterator() const
103{
104 /// Returns an iterator to loop over all pads of that segmentation
105 ///
106 /// FIXME: we currently just forward this to the other CreateIterator,
107 /// with the proper region. Might be more efficient to write a dedicated
108 /// iterator ? Test that idea.
109
110 AliMpArea area(TVector2(0.0,0.0),fkSlat->Dimensions());
111 return CreateIterator(area);
112}
113
114//_____________________________________________________________________________
115Int_t
116AliMpSlatSegmentation::GetNeighbours(const AliMpPad& pad,
117 TObjArray& neighbours,
118 Bool_t includeSelf,
119 Bool_t includeVoid) const
120{
121 /// Uses default implementation
122 return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid);
123}
124
63bcb3c3 125//_____________________________________________________________________________
126TVector2
127AliMpSlatSegmentation::Dimensions() const
128{
71a2d3aa 129 /// Return dimensions
130
63bcb3c3 131 return Slat()->Dimensions();
132}
133
134//_____________________________________________________________________________
135void
136AliMpSlatSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
137{
71a2d3aa 138 /// Fill the array ecn with all manuIds
139
63bcb3c3 140 Slat()->GetAllMotifPositionsIDs(ecn);
141}
142
1faed5a9 143//_____________________________________________________________________________
144const char*
145AliMpSlatSegmentation::GetName() const
146{
71a2d3aa 147 /// The name of this segmentation is "SlatSegmentation"+slatName
85fec35d 148
1faed5a9 149 TString name("SlatSegmentation");
150 if ( fkSlat)
151 {
152 name += ".";
153 name += fkSlat->GetName();
154 }
155 return name.Data();
156}
157
dee1d5f1 158//_____________________________________________________________________________
159Bool_t
160AliMpSlatSegmentation::HasPad(const AliMpIntPair& indices) const
161{
71a2d3aa 162 ///
163 /// Test if this slat has a pad located at the position referenced
164 /// by the integer indices.
165 ///
dee1d5f1 166
167 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
168}
169
170//_____________________________________________________________________________
171Int_t
026b7442 172AliMpSlatSegmentation::MaxPadIndexX() const
dee1d5f1 173{
71a2d3aa 174 ///
175 /// Returns the value of the largest pad index in x-direction.
176 ///
dee1d5f1 177
16e8fffd 178 return fkSlat->GetMaxPadIndexX();
dee1d5f1 179}
180
181//_____________________________________________________________________________
182Int_t
026b7442 183AliMpSlatSegmentation::MaxPadIndexY() const
dee1d5f1 184{
71a2d3aa 185 ///
186 /// Returns the value of the largest pad index in y-direction.
187 ///
dee1d5f1 188
189 return fkSlat->GetMaxNofPadsY()-1;
190}
191
026b7442 192//_____________________________________________________________________________
193Int_t
194AliMpSlatSegmentation::NofPads() const
195{
196/// Return number of pads defined in the slat
197
efb408b3 198 return fkSlat->NofPads();
026b7442 199}
200
dee1d5f1 201//_____________________________________________________________________________
202AliMpPad
203AliMpSlatSegmentation::PadByLocation(const AliMpIntPair& location,
204 Bool_t warning) const
205{
71a2d3aa 206 ///
207 /// Returns the pad specified by its location, where location is the
208 /// pair (ManuID,ManuChannel).
209 /// If warning=kTRUE and the pad does not exist, a warning message is
210 /// printed.
211 ///
212 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
213 ///
dee1d5f1 214 Int_t manuID = location.GetFirst();
215
216 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(manuID);
217
218 if (!motifPos)
219 {
220 if (warning)
221 {
222 AliWarning(Form("Manu ID %d not found in slat %s",
223 manuID, fkSlat->GetID()));
1faed5a9 224 }
225 return AliMpPad::Invalid();
dee1d5f1 226 }
227 AliMpVMotif* motif = motifPos->GetMotif();
228 AliMpIntPair localIndices =
229 motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond());
230
231 if (!localIndices.IsValid())
232 {
233 if (warning)
234 {
235 AliWarning(Form("The pad number %d doesn't exists",
236 location.GetSecond()));
237 }
238 return AliMpPad::Invalid();
239 }
240
241 return AliMpPad(location,
242 motifPos->GlobalIndices(localIndices),
1faed5a9 243 motifPos->Position()
244 + motif->PadPositionLocal(localIndices)
245 - fkSlat->Position(),
246 motif->GetPadDimensions(localIndices));
dee1d5f1 247}
248
249//_____________________________________________________________________________
250AliMpPad
251AliMpSlatSegmentation::PadByIndices(const AliMpIntPair& indices,
252 Bool_t warning) const
253{
71a2d3aa 254 ///
255 /// Returns the pad specified by its integer indices.
256 /// If warning=kTRUE and the pad does not exist, a warning message is
257 /// printed.
258 ///
259 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
260 ///
261 ///
262 /// FIXME: except for the FindMotifPosition below, this method
263 /// is exactly as the one in AliMpSectorSegmentation.
264 /// See if we can merge them somehow.
dee1d5f1 265
266 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(indices.GetFirst(),
267 indices.GetSecond());
268 if (!motifPos)
269 {
270 if ( warning )
271 {
272 AliWarning(Form("No motif found containing pad location (%d,%d)",
273 indices.GetFirst(),indices.GetSecond()));
274 }
275 return AliMpPad::Invalid();
276 }
277
278 AliMpVMotif* motif = motifPos->GetMotif();
279 AliMpMotifType* motifType = motif->GetMotifType();
280 AliMpIntPair localIndices(indices-motifPos->GetLowIndicesLimit());
1faed5a9 281 AliMpConnection* connection = motifType->FindConnectionByLocalIndices(localIndices);
dee1d5f1 282
283 if (!connection)
284 {
285 if ( warning )
286 {
287 AliWarning(Form("No connection for pad location (%d,%d)",
288 indices.GetFirst(),indices.GetSecond()));
1faed5a9 289 }
290 return AliMpPad::Invalid();
dee1d5f1 291 }
292
293 return AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()),
294 indices,
1faed5a9 295 motifPos->Position()
296 + motif->PadPositionLocal(localIndices)
297 - fkSlat->Position(),
298 motif->GetPadDimensions(localIndices));
dee1d5f1 299}
300
301//_____________________________________________________________________________
302AliMpPad
303AliMpSlatSegmentation::PadByPosition(const TVector2& position,
304 Bool_t warning) const
305{
71a2d3aa 306 ///
307 /// Returns the pad specified by its (floating point) position.
308 /// If warning=kTRUE and the pad does not exist, a warning message is
309 /// printed.
310 ///
311 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
312 ///
dee1d5f1 313
264a9c47 314 TVector2 blPos(position);
315
316 blPos += fkSlat->Position(); // position relative to bottom-left of the slat.
1964cd2e 317
318 AliMpMotifPosition* motifPos = fkSlat->FindMotifPosition(blPos.X(),blPos.Y());
dee1d5f1 319
320 if (!motifPos)
321 {
322 if (warning)
323 {
1964cd2e 324 AliWarning(Form("Slat %s Position (%e,%e)/center (%e,%e)/bottom-left cm "
325 " outside limits",fkSlat->GetID(),
326 position.X(),position.Y(),
327 blPos.X(),blPos.Y()));
dee1d5f1 328 }
329 return AliMpPad::Invalid();
330 }
331
332 AliMpVMotif* motif = motifPos->GetMotif();
264a9c47 333 blPos -= motifPos->Position();
dee1d5f1 334 AliMpIntPair localIndices
264a9c47 335 = motif->PadIndicesLocal(blPos);
dee1d5f1 336
337 AliMpConnection* connect =
338 motif->GetMotifType()->FindConnectionByLocalIndices(localIndices);
339
340 if (!connect)
341 {
342 if (warning)
343 {
1faed5a9 344 AliWarning(Form("Slat %s localIndices (%d,%d) outside motif %s limits",
345 fkSlat->GetID(),localIndices.GetFirst(),
346 localIndices.GetSecond(),motif->GetID().Data()));
dee1d5f1 347 }
348 return AliMpPad::Invalid();
349 }
350
351 return AliMpPad(AliMpIntPair(motifPos->GetID(),connect->GetGassiNum()),
352 motifPos->GlobalIndices(localIndices),
1faed5a9 353 motifPos->Position()
354 + motif->PadPositionLocal(localIndices)
355 - fkSlat->Position(),
356 motif->GetPadDimensions(localIndices));
dee1d5f1 357}
358
63bcb3c3 359//_____________________________________________________________________________
cddd101e 360AliMp::PlaneType
63bcb3c3 361AliMpSlatSegmentation::PlaneType() const
362{
363 return Slat()->PlaneType();
364}
365
366//_____________________________________________________________________________
367void
368AliMpSlatSegmentation::Print(Option_t* opt) const
369{
71a2d3aa 370/// Printing
371
63bcb3c3 372 fkSlat->Print(opt);
373}
374
dee1d5f1 375//_____________________________________________________________________________
376const AliMpSlat*
377AliMpSlatSegmentation::Slat() const
378{
71a2d3aa 379 ///
380 /// Returns the pointer to the referenced slat.
381 ///
dee1d5f1 382
383 return fkSlat;
384}