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