]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpTriggerSegmentation.cxx
Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTriggerSegmentation.cxx
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$
17 // $MpId: AliMpTriggerSegmentation.cxx,v 1.7 2006/05/24 13:58:52 ivana Exp $
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"
28 #include "AliMpTrigger.h"
29
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 //-----------------------------------------------------------------------------
39
40 /// \cond CLASSIMP
41 ClassImp(AliMpTriggerSegmentation)
42 /// \endcond
43
44 //_____________________________________________________________________________
45 AliMpTriggerSegmentation::AliMpTriggerSegmentation() 
46 : AliMpVSegmentation(),
47   fkSlat(0),
48   fIsOwner(false),
49   fNofStrips(0)
50 {
51   ///
52   /// Default ctor. Not to be used really.
53   ///
54   AliDebug(1,Form("this=%p Empty ctor",this));
55 }
56
57 //_____________________________________________________________________________
58 AliMpTriggerSegmentation::AliMpTriggerSegmentation(
59                                const AliMpTrigger* slat, Bool_t own) 
60 : AliMpVSegmentation(), 
61   fkSlat(slat),
62   fIsOwner(own),
63   fNofStrips(0)
64 {
65   ///
66   /// Normal ctor.
67   ///
68   AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
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
75
76   for ( Int_t ix = 0; ix <= MaxPadIndexX(); ++ix )
77   {
78     for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
79     {
80       if ( HasPadByIndices(ix,iy) )
81       {
82         ++fNofStrips;
83       }
84     }
85   }
86 }
87
88 //_____________________________________________________________________________
89 AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
90 {
91   ///
92   /// Dtor (empty).
93   ///
94
95   if ( fIsOwner ) delete fkSlat;
96
97   AliDebug(1,Form("this=%p",this));                     
98 }
99
100 //_____________________________________________________________________________
101 AliMpVPadIterator*
102 AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
103 {
104   ///
105   /// Returns an iterator to loop over the pad contained within given area.
106   /// Not implemented for trigger.
107   AliError("Not implemented for trigger");
108   return 0;
109 }
110
111 //_____________________________________________________________________________
112 AliMpVPadIterator*
113 AliMpTriggerSegmentation::CreateIterator() const
114 {
115   ///
116   /// Returns an iterator to loop over all the pads
117   /// Not implemented for trigger.
118   AliError("Not implemented for trigger");
119   
120   return 0;
121 }
122
123 //_____________________________________________________________________________
124 Int_t 
125 AliMpTriggerSegmentation::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 //_____________________________________________________________________________
136 TVector2
137 AliMpTriggerSegmentation::Dimensions() const
138 {
139 /// Return dimensions
140
141   return Slat()->Dimensions();
142 }
143
144 //_____________________________________________________________________________
145 void 
146 AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
147 {
148 /// Fill the array ecn with all manuIds
149
150   Slat()->GetAllLocalBoardNumbers(ecn);
151 }
152
153 //_____________________________________________________________________________
154 const char*
155 AliMpTriggerSegmentation::GetName() const
156 {
157   /// Name of that segmentation = TriggerSegmentation + slatName
158   TString name("TriggerSegmentation");
159   if ( fkSlat) 
160   {
161     name += ".";
162     name += fkSlat->GetName();
163   }
164   return name.Data();
165 }
166
167 //_____________________________________________________________________________
168 Int_t 
169 AliMpTriggerSegmentation::MaxPadIndexX() const
170 {
171   ///
172   /// Returns the value of the largest pad index in x-direction.
173   ///
174   
175   return fkSlat->GetNofPadsX()-1;
176 }
177
178 //_____________________________________________________________________________
179 Int_t 
180 AliMpTriggerSegmentation::MaxPadIndexY() const
181 {
182   ///
183   /// Returns the value of the largest pad index in y-direction.
184   ///
185   
186   return fkSlat->GetMaxNofPadsY()-1;
187 }
188
189 //_____________________________________________________________________________
190 AliMpPad
191 AliMpTriggerSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel, 
192                                         Bool_t warning) const
193 {
194   ///
195   /// Returns the pad specified by its location, where location is the 
196   /// pair (ManuID,ManuChannel).
197   /// If warning=kTRUE and the pad does not exist, a warning message is 
198   /// printed.
199   ///
200   /// AliMpPad::Invalid() is returned if there's no pad at the given location.
201   ///
202   AliMpPad pad;
203   
204   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
205   {
206     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
207     AliMpPad pi = seg->PadByLocation(manuId,manuChannel,kFALSE);
208     if ( pi.IsValid() ) 
209     {
210       if ( !pad.IsValid() )
211       {
212         // uses PadByIndices to get the complete list of locations
213         return PadByIndices(pi.GetIx(), pi.GetIy(), warning);
214       }
215     }
216   }
217   if ( warning && !pad.IsValid()  )
218   {
219     AliWarning(Form("No pad found at location (%d,%d)", manuId, manuChannel));
220   }
221   return pad;
222 }
223
224 //_____________________________________________________________________________
225 AliMpPad
226 AliMpTriggerSegmentation::PadByIndices(Int_t ix, Int_t iy, 
227                                        Bool_t warning) const
228 {
229   ///
230   /// Returns the pad specified by its integer indices.
231   /// If warning=kTRUE and the pad does not exist, a warning message is 
232   /// printed.
233   ///
234   /// AliMpPad::Invalid() is returned if there's no pad at the given location.
235   ///
236   ///  
237  
238   AliMpPad pad;
239
240   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
241   {
242     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
243     AliMpPad pi = seg->PadByIndices(ix,iy,kFALSE);
244     if ( pi.IsValid() ) 
245     {      
246       if ( !pad.IsValid() )
247       {
248         pad = AliMpPad(0, 0,
249                        pi.GetIndices(),
250                        pi.Position(),pi.Dimensions());
251         pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
252       }
253       else
254       {
255         pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
256       }  
257     }
258   }
259   if ( warning && !pad.IsValid()  )
260   {
261     AliWarning(Form("No pad found at indices (%d,%d)",ix, iy));
262   }
263   
264   return pad;
265 }
266
267 //_____________________________________________________________________________
268 AliMpPad
269 AliMpTriggerSegmentation::PadByPosition(const TVector2& position, 
270                                      Bool_t warning) const
271 {
272   ///
273   /// Returns the pad specified by its (floating point) position.
274   /// If warning=kTRUE and the pad does not exist, a warning message is 
275   /// printed.
276   ///
277   /// AliMpPad::Invalid() is returned if there's no pad at the given location.
278   ///
279   AliMpPad pad;
280   
281   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
282   {
283     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
284     AliMpPad pi = seg->PadByPosition(position,kFALSE);
285     if ( pi.IsValid() ) 
286     {
287       if ( !pad.IsValid() )
288       {
289         pad = AliMpPad(0, 0,
290                        pi.GetIndices(),
291                        pi.Position(),pi.Dimensions());
292         pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
293       }
294       else
295       {
296         pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
297       }  
298     }
299   }
300   if ( warning && !pad.IsValid()  )
301   {
302     AliWarning(Form("No pad found at position (%e,%e)",position.X(),
303                     position.Y()));
304   }
305   
306   return pad;  
307 }
308
309 //_____________________________________________________________________________
310 AliMp::PlaneType
311 AliMpTriggerSegmentation::PlaneType() const
312 {
313   /// Return plane type
314
315   return Slat()->PlaneType();
316 }
317
318 //_____________________________________________________________________________
319 const AliMpTrigger* 
320 AliMpTriggerSegmentation::Slat() const
321 {
322   ///
323   /// Returns the pointer to the referenced slat.
324   ///
325   
326   return fkSlat;
327 }
328
329 //_____________________________________________________________________________
330 Int_t 
331 AliMpTriggerSegmentation::GetNofElectronicCards() const
332 {
333   /// Get the number of local board numbers
334   
335   TArrayI ecn;
336   fkSlat->GetAllLocalBoardNumbers(ecn);
337   return ecn.GetSize();  
338 }
339
340 //_____________________________________________________________________________
341 TVector2 
342 AliMpTriggerSegmentation::Position() const 
343
344   /// Return position of origin
345   
346   return Slat()->Position();
347 }
348
349 //_____________________________________________________________________________
350 AliMpMotifPosition* 
351 AliMpTriggerSegmentation::MotifPosition(Int_t /* manuId */) const
352 {
353   /// No implemented (yet ?)
354   AliError("Not implemented");
355   return 0x0;
356 }
357
358 //_____________________________________________________________________________
359 Bool_t 
360 AliMpTriggerSegmentation::HasMotifPosition(Int_t manuId) const
361 {
362   /// Uses default implementation
363   return AliMpVSegmentation::HasMotifPosition(manuId);
364 }