New macro to keep track of timing performances of the segmentation methods (Laurent)
[u/mrichter/AliRoot.git] / MUON / mapping / 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 {
80 if ( HasPad(AliMpIntPair(ix,iy)) )
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//_____________________________________________________________________________
63bcb3c3 136TVector2
137AliMpTriggerSegmentation::Dimensions() const
138{
71a2d3aa 139/// Return dimensions
140
63bcb3c3 141 return Slat()->Dimensions();
142}
143
144//_____________________________________________________________________________
145void
146AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
147{
71a2d3aa 148/// Fill the array ecn with all manuIds
149
63bcb3c3 150 Slat()->GetAllLocalBoardNumbers(ecn);
151}
152
153//_____________________________________________________________________________
ff7d3d1a 154const char*
155AliMpTriggerSegmentation::GetName() const
156{
71a2d3aa 157 /// Name of that segmentation = TriggerSegmentation + slatName
ff7d3d1a 158 TString name("TriggerSegmentation");
159 if ( fkSlat)
160 {
161 name += ".";
162 name += fkSlat->GetName();
163 }
164 return name.Data();
165}
166
167//_____________________________________________________________________________
168Bool_t
169AliMpTriggerSegmentation::HasPad(const AliMpIntPair& indices) const
170{
71a2d3aa 171 ///
172 /// Test if this slat has a pad located at the position referenced
173 /// by the integer indices.
174 ///
ff7d3d1a 175
176 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
177}
178
179//_____________________________________________________________________________
180Int_t
026b7442 181AliMpTriggerSegmentation::MaxPadIndexX() const
ff7d3d1a 182{
71a2d3aa 183 ///
184 /// Returns the value of the largest pad index in x-direction.
185 ///
ff7d3d1a 186
187 return fkSlat->GetNofPadsX()-1;
188}
189
190//_____________________________________________________________________________
191Int_t
026b7442 192AliMpTriggerSegmentation::MaxPadIndexY() const
ff7d3d1a 193{
71a2d3aa 194 ///
195 /// Returns the value of the largest pad index in y-direction.
196 ///
ff7d3d1a 197
198 return fkSlat->GetMaxNofPadsY()-1;
199}
200
201//_____________________________________________________________________________
202AliMpPad
203AliMpTriggerSegmentation::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 ///
ff7d3d1a 214 AliMpPad pad;
215 AliMpIntPair invloc;
216
217 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
218 {
c5b874d0 219 AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
220 AliMpPad pi = seg->PadByLocation(location,kFALSE);
85fec35d 221 if ( pi.IsValid() )
ff7d3d1a 222 {
223 if ( !pad.IsValid() )
224 {
8c0b5e70 225 // uses PadByIndices to get the complete list of locations
226 return PadByIndices(pi.GetIndices(),warning);
ff7d3d1a 227 }
ff7d3d1a 228 }
229 }
230 if ( warning && !pad.IsValid() )
231 {
232 AliWarning(Form("No pad found at location (%d,%d)",location.GetFirst(),
233 location.GetSecond()));
234 }
235 return pad;
236}
237
238//_____________________________________________________________________________
239AliMpPad
240AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices,
241 Bool_t warning) const
242{
71a2d3aa 243 ///
244 /// Returns the pad specified by its integer indices.
245 /// If warning=kTRUE and the pad does not exist, a warning message is
246 /// printed.
247 ///
248 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
249 ///
250 ///
ff7d3d1a 251
252 AliMpPad pad;
253 AliMpIntPair invloc;
254
255 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
256 {
c5b874d0 257 AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
258 AliMpPad pi = seg->PadByIndices(indices,kFALSE);
85fec35d 259 if ( pi.IsValid() )
ff7d3d1a 260 {
261 if ( !pad.IsValid() )
262 {
85fec35d 263 pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
264 pad.AddLocation(pi.GetLocation());
ff7d3d1a 265 }
266 else
267 {
85fec35d 268 pad.AddLocation(pi.GetLocation());
ff7d3d1a 269 }
270 }
271 }
272 if ( warning && !pad.IsValid() )
273 {
274 AliWarning(Form("No pad found at indices (%d,%d)",indices.GetFirst(),
275 indices.GetSecond()));
276 }
277
278 return pad;
279}
280
281//_____________________________________________________________________________
282AliMpPad
283AliMpTriggerSegmentation::PadByPosition(const TVector2& position,
284 Bool_t warning) const
285{
71a2d3aa 286 ///
287 /// Returns the pad specified by its (floating point) position.
288 /// If warning=kTRUE and the pad does not exist, a warning message is
289 /// printed.
290 ///
291 /// AliMpPad::Invalid() is returned if there's no pad at the given location.
292 ///
ff7d3d1a 293 AliMpPad pad;
294 AliMpIntPair invloc;
295
296 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
297 {
c5b874d0 298 AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
299 AliMpPad pi = seg->PadByPosition(position,kFALSE);
85fec35d 300 if ( pi.IsValid() )
ff7d3d1a 301 {
302 if ( !pad.IsValid() )
303 {
85fec35d 304 pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
305 pad.AddLocation(pi.GetLocation());
ff7d3d1a 306 }
307 else
308 {
85fec35d 309 pad.AddLocation(pi.GetLocation());
ff7d3d1a 310 }
311 }
312 }
313 if ( warning && !pad.IsValid() )
314 {
315 AliWarning(Form("No pad found at position (%e,%e)",position.X(),
316 position.Y()));
317 }
318
319 return pad;
320}
321
322//_____________________________________________________________________________
cddd101e 323AliMp::PlaneType
63bcb3c3 324AliMpTriggerSegmentation::PlaneType() const
325{
71a2d3aa 326 /// Return plane type
327
63bcb3c3 328 return Slat()->PlaneType();
329}
330
331//_____________________________________________________________________________
ff7d3d1a 332const AliMpTrigger*
333AliMpTriggerSegmentation::Slat() const
334{
71a2d3aa 335 ///
336 /// Returns the pointer to the referenced slat.
337 ///
ff7d3d1a 338
339 return fkSlat;
340}
3635f34f 341
342//_____________________________________________________________________________
343Int_t
344AliMpTriggerSegmentation::GetNofElectronicCards() const
345{
346 /// Get the number of local board numbers
347
348 TArrayI ecn;
349 fkSlat->GetAllLocalBoardNumbers(ecn);
350 return ecn.GetSize();
351}
352
353//_____________________________________________________________________________
354TVector2
355AliMpTriggerSegmentation::Position() const
356{
357 /// Return position of origin
358
359 return Slat()->Position();
360}
361
362//_____________________________________________________________________________
363AliMpMotifPosition*
364AliMpTriggerSegmentation::MotifPosition(Int_t /* manuId */) const
365{
366 /// No implemented (yet ?)
367 AliError("Not implemented");
368 return 0x0;
369}
370
371//_____________________________________________________________________________
372Bool_t
373AliMpTriggerSegmentation::HasMotifPosition(Int_t manuId) const
374{
375 /// Uses default implementation
376 return AliMpVSegmentation::HasMotifPosition(manuId);
377}