]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpTriggerSegmentation.cxx
Generates realistic DDL sharing and buspatch number calculated from DDL (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 "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 {
61   //
62   // Normal ctor.
63   //
64   AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
65   
66   // Compute the number of strips.
67   // We have to loop over all possible pads, in order to properly take
68   // into account the fact that a given strip might be part of several
69   // layer. Otherwise we would double count pads.
70
71   fNofStrips = 0;
72   for ( Int_t ix = 0; ix <= MaxPadIndexX(); ++ix )
73   {
74     for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
75     {
76       if ( HasPad(AliMpIntPair(ix,iy)) )
77       {
78         ++fNofStrips;
79       }
80     }
81   }
82 }
83
84 //______________________________________________________________________________
85 AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTriggerSegmentation& right) 
86   : AliMpVSegmentation(right) 
87 {  
88 /// Protected copy constructor (not implemented)
89
90   AliFatal("Copy constructor not provided.");
91 }
92
93 //_____________________________________________________________________________
94 AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
95 {
96   //
97   // Dtor (empty).
98   //
99   AliDebug(1,Form("this=%p",this));                     
100 }
101
102 //______________________________________________________________________________
103 AliMpTriggerSegmentation& 
104 AliMpTriggerSegmentation::operator=(const AliMpTriggerSegmentation& right)
105 {
106 /// Protected assignement operator (not implemented)
107
108   // check assignement to self
109   if (this == &right) return *this;
110
111   AliFatal("Assignement operator not provided.");
112     
113   return *this;  
114 }    
115
116 //_____________________________________________________________________________
117 AliMpVPadIterator*
118 AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
119 {
120   //
121   // Returns an iterator to loop over the pad contained within given area.
122   // Not implemented for trigger.
123   
124   return 0;
125 }
126
127 //_____________________________________________________________________________
128 TVector2
129 AliMpTriggerSegmentation::Dimensions() const
130 {
131   return Slat()->Dimensions();
132 }
133
134 //_____________________________________________________________________________
135 void 
136 AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
137 {
138   Slat()->GetAllLocalBoardNumbers(ecn);
139 }
140
141 //_____________________________________________________________________________
142 const char*
143 AliMpTriggerSegmentation::GetName() const
144 {
145   // Name of that segmentation = TriggerSegmentation + slatName
146   TString name("TriggerSegmentation");
147   if ( fkSlat) 
148   {
149     name += ".";
150     name += fkSlat->GetName();
151   }
152   return name.Data();
153 }
154
155 //_____________________________________________________________________________
156 Bool_t
157 AliMpTriggerSegmentation::HasPad(const AliMpIntPair& indices) const
158 {
159   //
160   // Test if this slat has a pad located at the position referenced
161   // by the integer indices.
162   //
163   
164   return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
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(const AliMpIntPair& location, 
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   AliMpIntPair invloc;
204   
205   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
206   {
207     const AliMpSlat* slat = fkSlat->GetLayer(i);
208     AliMpSlatSegmentation seg(slat);
209     AliMpPad pi = seg.PadByLocation(location,kFALSE);
210     if ( pi.IsValid() ) 
211     {
212       if ( !pad.IsValid() )
213       {
214         pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
215         pad.AddLocation(pi.GetLocation());
216       }
217       else
218       {
219         pad.AddLocation(pi.GetLocation());
220       }  
221     }
222   }
223   if ( warning && !pad.IsValid()  )
224   {
225     AliWarning(Form("No pad found at location (%d,%d)",location.GetFirst(),
226                     location.GetSecond()));
227   }
228   return pad;
229 }
230
231 //_____________________________________________________________________________
232 AliMpPad
233 AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices, 
234                                     Bool_t warning) const
235 {
236   //
237   // Returns the pad specified by its integer indices.
238   // If warning=kTRUE and the pad does not exist, a warning message is 
239   // printed.
240   //
241   // AliMpPad::Invalid() is returned if there's no pad at the given location.
242   //
243   //  
244  
245   AliMpPad pad;
246   AliMpIntPair invloc;
247   
248   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
249   {
250     const AliMpSlat* slat = fkSlat->GetLayer(i);
251     AliMpSlatSegmentation seg(slat);
252     AliMpPad pi = seg.PadByIndices(indices,kFALSE);
253     if ( pi.IsValid() ) 
254     {      
255       if ( !pad.IsValid() )
256       {
257         pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
258         pad.AddLocation(pi.GetLocation());
259       }
260       else
261       {
262         pad.AddLocation(pi.GetLocation());
263       }  
264     }
265   }
266   if ( warning && !pad.IsValid()  )
267   {
268     AliWarning(Form("No pad found at indices (%d,%d)",indices.GetFirst(),
269                     indices.GetSecond()));
270   }
271   
272   return pad;
273 }
274
275 //_____________________________________________________________________________
276 AliMpPad
277 AliMpTriggerSegmentation::PadByPosition(const TVector2& position, 
278                                      Bool_t warning) const
279 {
280   //
281   // Returns the pad specified by its (floating point) position.
282   // If warning=kTRUE and the pad does not exist, a warning message is 
283   // printed.
284   //
285   // AliMpPad::Invalid() is returned if there's no pad at the given location.
286   //
287   AliMpPad pad;
288   AliMpIntPair invloc;
289   
290   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
291   {
292     const AliMpSlat* slat = fkSlat->GetLayer(i);
293     AliMpSlatSegmentation seg(slat);
294     AliMpPad pi = seg.PadByPosition(position,kFALSE);
295     if ( pi.IsValid() ) 
296     {
297       if ( !pad.IsValid() )
298       {
299         pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
300         pad.AddLocation(pi.GetLocation());
301       }
302       else
303       {
304         pad.AddLocation(pi.GetLocation());
305       }  
306     }
307   }
308   if ( warning && !pad.IsValid()  )
309   {
310     AliWarning(Form("No pad found at position (%e,%e)",position.X(),
311                     position.Y()));
312   }
313   
314   return pad;  
315 }
316
317 //_____________________________________________________________________________
318 AliMpPlaneType
319 AliMpTriggerSegmentation::PlaneType() const
320 {
321   return Slat()->PlaneType();
322 }
323
324 //_____________________________________________________________________________
325 const AliMpTrigger* 
326 AliMpTriggerSegmentation::Slat() const
327 {
328   //
329   // Returns the pointer to the referenced slat.
330   //
331   
332   return fkSlat;
333 }