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