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