Correct use of ROOT_INCLUDE_DIR
[u/mrichter/AliRoot.git] / MUON / MUONmapping / AliMpTriggerSegmentation.cxx
CommitLineData
ff7d3d1a 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: AliMpTriggerSegmentation.cxx,v 1.7 2006/05/24 13:58:52 ivana Exp $
ff7d3d1a 18
19#include "AliMpTriggerSegmentation.h"
20
21#include "AliLog.h"
22#include "AliMpConnection.h"
23#include "AliMpMotif.h"
24#include "AliMpMotifPosition.h"
25#include "AliMpMotifType.h"
26#include "AliMpPCB.h"
27#include "AliMpSlat.h"
ff7d3d1a 28#include "AliMpTrigger.h"
29
3d1463c8 30//-----------------------------------------------------------------------------
85fec35d 31/// \class AliMpTriggerSegmentation
32///
33/// Implementation of AliMpVSegmentation for trigger slats.
34///
35/// \todo Implement CreateIterator method, if needed.
36///
37/// \author Laurent Aphecetche
3d1463c8 38//-----------------------------------------------------------------------------
85fec35d 39
13985652 40/// \cond CLASSIMP
ff7d3d1a 41ClassImp(AliMpTriggerSegmentation)
13985652 42/// \endcond
ff7d3d1a 43
44//_____________________________________________________________________________
45AliMpTriggerSegmentation::AliMpTriggerSegmentation()
46: AliMpVSegmentation(),
c5b874d0 47 fkSlat(0),
48 fIsOwner(false),
49 fNofStrips(0)
ff7d3d1a 50{
71a2d3aa 51 ///
52 /// Default ctor. Not to be used really.
53 ///
ff7d3d1a 54 AliDebug(1,Form("this=%p Empty ctor",this));
55}
56
57//_____________________________________________________________________________
c5b874d0 58AliMpTriggerSegmentation::AliMpTriggerSegmentation(
59 const AliMpTrigger* slat, Bool_t own)
ff7d3d1a 60: AliMpVSegmentation(),
1657f946 61 fkSlat(slat),
c5b874d0 62 fIsOwner(own),
1657f946 63 fNofStrips(0)
ff7d3d1a 64{
71a2d3aa 65 ///
66 /// Normal ctor.
67 ///
ff7d3d1a 68 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
efb408b3 69
70 // Compute the number of strips.
71 // We have to loop over all possible pads, in order to properly take
72 // into account the fact that a given strip might be part of several
73 // layer. Otherwise we would double count pads.
74
1657f946 75
efb408b3 76 for ( Int_t ix = 0; ix <= MaxPadIndexX(); ++ix )
77 {
78 for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
79 {
168e9c4d 80 if ( HasPadByIndices(ix,iy) )
efb408b3 81 {
82 ++fNofStrips;
83 }
84 }
85 }
ff7d3d1a 86}
87
88//_____________________________________________________________________________
89AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
90{
71a2d3aa 91 ///
92 /// Dtor (empty).
93 ///
c5b874d0 94
95 if ( fIsOwner ) delete fkSlat;
96
ff7d3d1a 97 AliDebug(1,Form("this=%p",this));
98}
99
100//_____________________________________________________________________________
101AliMpVPadIterator*
102AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
103{
71a2d3aa 104 ///
105 /// Returns an iterator to loop over the pad contained within given area.
106 /// Not implemented for trigger.
264a9c47 107 AliError("Not implemented for trigger");
108 return 0;
109}
110
111//_____________________________________________________________________________
112AliMpVPadIterator*
113AliMpTriggerSegmentation::CreateIterator() const
114{
71a2d3aa 115 ///
116 /// Returns an iterator to loop over all the pads
117 /// Not implemented for trigger.
264a9c47 118 AliError("Not implemented for trigger");
ff7d3d1a 119
120 return 0;
121}
122
123//_____________________________________________________________________________
264a9c47 124Int_t
125AliMpTriggerSegmentation::GetNeighbours(const AliMpPad& /*pad*/,
126 TObjArray& /*neighbours*/,
127 Bool_t /*includeSelf*/,
128 Bool_t /*includeVoid*/) const
129{
130 /// not implemented.
131 AliError("Not implemented for trigger");
132 return 0;
133}
134
135//_____________________________________________________________________________
6e97fbb8 136Double_t
137AliMpTriggerSegmentation::GetDimensionX() const
63bcb3c3 138{
6e97fbb8 139/// Return slat x dimensions
140 return Slat()->GetDimensionX();
141}
71a2d3aa 142
6e97fbb8 143//_____________________________________________________________________________
144Double_t
145AliMpTriggerSegmentation::GetDimensionY() const
146{
147/// Return slat y dimensions
148 return Slat()->GetDimensionY();
63bcb3c3 149}
150
151//_____________________________________________________________________________
152void
153AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
154{
71a2d3aa 155/// Fill the array ecn with all manuIds
156
63bcb3c3 157 Slat()->GetAllLocalBoardNumbers(ecn);
158}
159
160//_____________________________________________________________________________
ff7d3d1a 161const char*
162AliMpTriggerSegmentation::GetName() const
163{
71a2d3aa 164 /// Name of that segmentation = TriggerSegmentation + slatName
ff7d3d1a 165 TString name("TriggerSegmentation");
166 if ( fkSlat)
167 {
168 name += ".";
169 name += fkSlat->GetName();
170 }
171 return name.Data();
172}
173
174//_____________________________________________________________________________
ff7d3d1a 175Int_t
026b7442 176AliMpTriggerSegmentation::MaxPadIndexX() const
ff7d3d1a 177{
71a2d3aa 178 ///
179 /// Returns the value of the largest pad index in x-direction.
180 ///
ff7d3d1a 181
182 return fkSlat->GetNofPadsX()-1;
183}
184
185//_____________________________________________________________________________
186Int_t
026b7442 187AliMpTriggerSegmentation::MaxPadIndexY() const
ff7d3d1a 188{
71a2d3aa 189 ///
190 /// Returns the value of the largest pad index in y-direction.
191 ///
ff7d3d1a 192
193 return fkSlat->GetMaxNofPadsY()-1;
194}
195
196//_____________________________________________________________________________
197AliMpPad
168e9c4d 198AliMpTriggerSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel,
ff7d3d1a 199 Bool_t warning) const
200{
71a2d3aa 201 ///
202 /// Returns the pad specified by its location, where location is the
203 /// pair (ManuID,ManuChannel).
204 /// If warning=kTRUE and the pad does not exist, a warning message is
205 /// printed.
206 ///
207 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
208 ///
ff7d3d1a 209 AliMpPad pad;
ff7d3d1a 210
211 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
212 {
c5b874d0 213 AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
168e9c4d 214 AliMpPad pi = seg->PadByLocation(manuId,manuChannel,kFALSE);
85fec35d 215 if ( pi.IsValid() )
ff7d3d1a 216 {
217 if ( !pad.IsValid() )
218 {
8c0b5e70 219 // uses PadByIndices to get the complete list of locations
168e9c4d 220 return PadByIndices(pi.GetIx(), pi.GetIy(), warning);
ff7d3d1a 221 }
ff7d3d1a 222 }
223 }
224 if ( warning && !pad.IsValid() )
225 {
168e9c4d 226 AliWarning(Form("No pad found at location (%d,%d)", manuId, manuChannel));
ff7d3d1a 227 }
228 return pad;
229}
230
231//_____________________________________________________________________________
232AliMpPad
168e9c4d 233AliMpTriggerSegmentation::PadByIndices(Int_t ix, Int_t iy,
234 Bool_t warning) const
ff7d3d1a 235{
71a2d3aa 236 ///
237 /// Returns the pad specified by its integer indices.
238 /// If warning=kTRUE and the pad does not exist, a warning message is
239 /// printed.
240 ///
241 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
242 ///
243 ///
ff7d3d1a 244
245 AliMpPad pad;
168e9c4d 246
ff7d3d1a 247 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
248 {
c5b874d0 249 AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
168e9c4d 250 AliMpPad pi = seg->PadByIndices(ix,iy,kFALSE);
85fec35d 251 if ( pi.IsValid() )
ff7d3d1a 252 {
253 if ( !pad.IsValid() )
254 {
168e9c4d 255 pad = AliMpPad(0, 0,
256 pi.GetIndices(),
6e97fbb8 257 pi.GetPositionX(),pi.GetPositionY(),
258 pi.GetDimensionX(), pi.GetDimensionY());
168e9c4d 259 pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
ff7d3d1a 260 }
261 else
262 {
168e9c4d 263 pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
ff7d3d1a 264 }
265 }
266 }
267 if ( warning && !pad.IsValid() )
268 {
168e9c4d 269 AliWarning(Form("No pad found at indices (%d,%d)",ix, iy));
ff7d3d1a 270 }
271
272 return pad;
273}
274
275//_____________________________________________________________________________
276AliMpPad
6e97fbb8 277AliMpTriggerSegmentation::PadByPosition(Double_t x, Double_t y,
ff7d3d1a 278 Bool_t warning) const
279{
71a2d3aa 280 ///
281 /// Returns the pad specified by its (floating point) position.
282 /// If warning=kTRUE and the pad does not exist, a warning message is
283 /// printed.
284 ///
285 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
286 ///
ff7d3d1a 287 AliMpPad pad;
ff7d3d1a 288
289 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
290 {
c5b874d0 291 AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
6e97fbb8 292 AliMpPad pi = seg->PadByPosition(x,y,kFALSE);
85fec35d 293 if ( pi.IsValid() )
ff7d3d1a 294 {
295 if ( !pad.IsValid() )
296 {
168e9c4d 297 pad = AliMpPad(0, 0,
298 pi.GetIndices(),
6e97fbb8 299 pi.GetPositionX(),pi.GetPositionY(),
300 pi.GetDimensionX(), pi.GetDimensionY());
168e9c4d 301 pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
ff7d3d1a 302 }
303 else
304 {
168e9c4d 305 pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
ff7d3d1a 306 }
307 }
308 }
309 if ( warning && !pad.IsValid() )
310 {
6e97fbb8 311 AliWarning(Form("No pad found at position (%e,%e)",x,y));
ff7d3d1a 312 }
313
314 return pad;
315}
316
317//_____________________________________________________________________________
cddd101e 318AliMp::PlaneType
63bcb3c3 319AliMpTriggerSegmentation::PlaneType() const
320{
71a2d3aa 321 /// Return plane type
322
63bcb3c3 323 return Slat()->PlaneType();
324}
325
326//_____________________________________________________________________________
ff7d3d1a 327const AliMpTrigger*
328AliMpTriggerSegmentation::Slat() const
329{
71a2d3aa 330 ///
331 /// Returns the pointer to the referenced slat.
332 ///
ff7d3d1a 333
334 return fkSlat;
335}
3635f34f 336
337//_____________________________________________________________________________
338Int_t
339AliMpTriggerSegmentation::GetNofElectronicCards() const
340{
341 /// Get the number of local board numbers
342
343 TArrayI ecn;
344 fkSlat->GetAllLocalBoardNumbers(ecn);
345 return ecn.GetSize();
346}
347
348//_____________________________________________________________________________
6e97fbb8 349Double_t
350AliMpTriggerSegmentation::GetPositionX() const
351{
352 /// Return x position of origin
353 return Slat()->GetPositionX();
354}
355
356//_____________________________________________________________________________
357Double_t
358AliMpTriggerSegmentation::GetPositionY() const
359{
360 /// Return y position of origin
361 return Slat()->GetPositionY();
3635f34f 362}
363
364//_____________________________________________________________________________
365AliMpMotifPosition*
366AliMpTriggerSegmentation::MotifPosition(Int_t /* manuId */) const
367{
368 /// No implemented (yet ?)
369 AliError("Not implemented");
370 return 0x0;
371}
372
373//_____________________________________________________________________________
374Bool_t
375AliMpTriggerSegmentation::HasMotifPosition(Int_t manuId) const
376{
377 /// Uses default implementation
378 return AliMpVSegmentation::HasMotifPosition(manuId);
379}