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