]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpTriggerSegmentation.cxx
Update manu serial number files (Christian)
[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 /// \cond CLASSIMP
40 ClassImp(AliMpTriggerSegmentation)
41 /// \endcond
42
43 //_____________________________________________________________________________
44 AliMpTriggerSegmentation::AliMpTriggerSegmentation() 
45 : AliMpVSegmentation(),
46   fkSlat(0),
47   fIsOwner(false),
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(
58                                const AliMpTrigger* slat, Bool_t own) 
59 : AliMpVSegmentation(), 
60   fkSlat(slat),
61   fIsOwner(own),
62   fNofStrips(0)
63 {
64   //
65   // Normal ctor.
66   //
67   AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
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
74
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   }
85 }
86
87 //_____________________________________________________________________________
88 AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
89 {
90   //
91   // Dtor (empty).
92   //
93
94   if ( fIsOwner ) delete fkSlat;
95
96   AliDebug(1,Form("this=%p",this));                     
97 }
98
99 //_____________________________________________________________________________
100 AliMpVPadIterator*
101 AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
102 {
103   //
104   // Returns an iterator to loop over the pad contained within given area.
105   // Not implemented for trigger.
106   AliError("Not implemented for trigger");
107   return 0;
108 }
109
110 //_____________________________________________________________________________
111 AliMpVPadIterator*
112 AliMpTriggerSegmentation::CreateIterator() const
113 {
114   //
115   // Returns an iterator to loop over all the pads
116   // Not implemented for trigger.
117   AliError("Not implemented for trigger");
118   
119   return 0;
120 }
121
122 //_____________________________________________________________________________
123 Int_t 
124 AliMpTriggerSegmentation::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
134 //_____________________________________________________________________________
135 TVector2
136 AliMpTriggerSegmentation::Dimensions() const
137 {
138   return Slat()->Dimensions();
139 }
140
141 //_____________________________________________________________________________
142 void 
143 AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
144 {
145   Slat()->GetAllLocalBoardNumbers(ecn);
146 }
147
148 //_____________________________________________________________________________
149 const char*
150 AliMpTriggerSegmentation::GetName() const
151 {
152   // Name of that segmentation = TriggerSegmentation + slatName
153   TString name("TriggerSegmentation");
154   if ( fkSlat) 
155   {
156     name += ".";
157     name += fkSlat->GetName();
158   }
159   return name.Data();
160 }
161
162 //_____________________________________________________________________________
163 Bool_t
164 AliMpTriggerSegmentation::HasPad(const AliMpIntPair& indices) const
165 {
166   //
167   // Test if this slat has a pad located at the position referenced
168   // by the integer indices.
169   //
170   
171   return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
172 }
173
174 //_____________________________________________________________________________
175 Int_t 
176 AliMpTriggerSegmentation::MaxPadIndexX() const
177 {
178   //
179   // Returns the value of the largest pad index in x-direction.
180   //
181   
182   return fkSlat->GetNofPadsX()-1;
183 }
184
185 //_____________________________________________________________________________
186 Int_t 
187 AliMpTriggerSegmentation::MaxPadIndexY() const
188 {
189   //
190   // Returns the value of the largest pad index in y-direction.
191   //
192   
193   return fkSlat->GetMaxNofPadsY()-1;
194 }
195
196 //_____________________________________________________________________________
197 AliMpPad
198 AliMpTriggerSegmentation::PadByLocation(const AliMpIntPair& location, 
199                                         Bool_t warning) const
200 {
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   //
209   AliMpPad pad;
210   AliMpIntPair invloc;
211   
212   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
213   {
214     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
215     AliMpPad pi = seg->PadByLocation(location,kFALSE);
216     if ( pi.IsValid() ) 
217     {
218       if ( !pad.IsValid() )
219       {
220         pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
221         pad.AddLocation(pi.GetLocation());
222       }
223       else
224       {
225         pad.AddLocation(pi.GetLocation());
226       }  
227     }
228   }
229   if ( warning && !pad.IsValid()  )
230   {
231     AliWarning(Form("No pad found at location (%d,%d)",location.GetFirst(),
232                     location.GetSecond()));
233   }
234   return pad;
235 }
236
237 //_____________________________________________________________________________
238 AliMpPad
239 AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices, 
240                                     Bool_t warning) const
241 {
242   //
243   // Returns the pad specified by its integer indices.
244   // If warning=kTRUE and the pad does not exist, a warning message is 
245   // printed.
246   //
247   // AliMpPad::Invalid() is returned if there's no pad at the given location.
248   //
249   //  
250  
251   AliMpPad pad;
252   AliMpIntPair invloc;
253   
254   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
255   {
256     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
257     AliMpPad pi = seg->PadByIndices(indices,kFALSE);
258     if ( pi.IsValid() ) 
259     {      
260       if ( !pad.IsValid() )
261       {
262         pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
263         pad.AddLocation(pi.GetLocation());
264       }
265       else
266       {
267         pad.AddLocation(pi.GetLocation());
268       }  
269     }
270   }
271   if ( warning && !pad.IsValid()  )
272   {
273     AliWarning(Form("No pad found at indices (%d,%d)",indices.GetFirst(),
274                     indices.GetSecond()));
275   }
276   
277   return pad;
278 }
279
280 //_____________________________________________________________________________
281 AliMpPad
282 AliMpTriggerSegmentation::PadByPosition(const TVector2& position, 
283                                      Bool_t warning) const
284 {
285   //
286   // Returns the pad specified by its (floating point) position.
287   // If warning=kTRUE and the pad does not exist, a warning message is 
288   // printed.
289   //
290   // AliMpPad::Invalid() is returned if there's no pad at the given location.
291   //
292   AliMpPad pad;
293   AliMpIntPair invloc;
294   
295   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
296   {
297     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
298     AliMpPad pi = seg->PadByPosition(position,kFALSE);
299     if ( pi.IsValid() ) 
300     {
301       if ( !pad.IsValid() )
302       {
303         pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
304         pad.AddLocation(pi.GetLocation());
305       }
306       else
307       {
308         pad.AddLocation(pi.GetLocation());
309       }  
310     }
311   }
312   if ( warning && !pad.IsValid()  )
313   {
314     AliWarning(Form("No pad found at position (%e,%e)",position.X(),
315                     position.Y()));
316   }
317   
318   return pad;  
319 }
320
321 //_____________________________________________________________________________
322 AliMp::PlaneType
323 AliMpTriggerSegmentation::PlaneType() const
324 {
325   return Slat()->PlaneType();
326 }
327
328 //_____________________________________________________________________________
329 const AliMpTrigger* 
330 AliMpTriggerSegmentation::Slat() const
331 {
332   //
333   // Returns the pointer to the referenced slat.
334   //
335   
336   return fkSlat;
337 }