Line data Source code
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 18 : ClassImp(AliMpTriggerSegmentation)
42 : /// \endcond
43 :
44 : //_____________________________________________________________________________
45 : AliMpTriggerSegmentation::AliMpTriggerSegmentation()
46 0 : : AliMpVSegmentation(),
47 0 : fkSlat(0),
48 0 : fIsOwner(false),
49 0 : fNofStrips(0)
50 0 : {
51 : ///
52 : /// Default ctor. Not to be used really.
53 : ///
54 0 : AliDebug(1,Form("this=%p Empty ctor",this));
55 0 : }
56 :
57 : //_____________________________________________________________________________
58 : AliMpTriggerSegmentation::AliMpTriggerSegmentation(
59 : const AliMpTrigger* slat, Bool_t own)
60 432 : : AliMpVSegmentation(),
61 432 : fkSlat(slat),
62 432 : fIsOwner(own),
63 432 : fNofStrips(0)
64 1296 : {
65 : ///
66 : /// Normal ctor.
67 : ///
68 2160 : 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 59904 : for ( Int_t ix = 0; ix <= MaxPadIndexX(); ++ix )
77 : {
78 285552 : for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
79 : {
80 151296 : if ( HasPadByIndices(ix,iy) )
81 : {
82 62976 : ++fNofStrips;
83 62976 : }
84 : }
85 : }
86 864 : }
87 :
88 : //_____________________________________________________________________________
89 : AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
90 1728 : {
91 : ///
92 : /// Dtor (empty).
93 : ///
94 :
95 864 : if ( fIsOwner ) delete fkSlat;
96 :
97 1440 : AliDebug(1,Form("this=%p",this));
98 864 : }
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 0 : AliError("Not implemented for trigger");
108 0 : 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 0 : AliError("Not implemented for trigger");
119 :
120 0 : 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 0 : AliError("Not implemented for trigger");
132 0 : return 0;
133 : }
134 :
135 : //_____________________________________________________________________________
136 : Double_t
137 : AliMpTriggerSegmentation::GetDimensionX() const
138 : {
139 : /// Return slat x dimensions
140 288 : return Slat()->GetDimensionX();
141 : }
142 :
143 : //_____________________________________________________________________________
144 : Double_t
145 : AliMpTriggerSegmentation::GetDimensionY() const
146 : {
147 : /// Return slat y dimensions
148 288 : return Slat()->GetDimensionY();
149 : }
150 :
151 : //_____________________________________________________________________________
152 : void
153 : AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
154 : {
155 : /// Fill the array ecn with all manuIds
156 :
157 0 : Slat()->GetAllLocalBoardNumbers(ecn);
158 0 : }
159 :
160 : //_____________________________________________________________________________
161 : const char*
162 : AliMpTriggerSegmentation::GetName() const
163 : {
164 : /// Name of that segmentation = TriggerSegmentation + slatName
165 0 : TString name("TriggerSegmentation");
166 0 : if ( fkSlat)
167 : {
168 0 : name += ".";
169 0 : name += fkSlat->GetName();
170 : }
171 0 : return name.Data();
172 0 : }
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 39936 : 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 190368 : return fkSlat->GetMaxNofPadsY()-1;
194 : }
195 :
196 : //_____________________________________________________________________________
197 : AliMpPad
198 : AliMpTriggerSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel,
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 261689 : AliMpPad pad;
210 :
211 1148466 : for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
212 : {
213 357222 : AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
214 357222 : AliMpPad pi = seg->PadByLocation(manuId,manuChannel,kFALSE);
215 357222 : if ( pi.IsValid() )
216 : {
217 242489 : if ( !pad.IsValid() )
218 : {
219 : // uses PadByIndices to get the complete list of locations
220 969956 : return PadByIndices(pi.GetIx(), pi.GetIy(), warning);
221 : }
222 : }
223 471955 : }
224 19200 : if ( warning && !pad.IsValid() )
225 : {
226 0 : AliWarning(Form("No pad found at location (%d,%d)", manuId, manuChannel));
227 : }
228 38400 : return pad;
229 261689 : }
230 :
231 : //_____________________________________________________________________________
232 : AliMpPad
233 : AliMpTriggerSegmentation::PadByIndices(Int_t ix, Int_t iy,
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 553959 : AliMpPad pad;
246 :
247 4431600 : for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
248 : {
249 923241 : AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
250 923241 : AliMpPad pi = seg->PadByIndices(ix,iy,kFALSE);
251 923241 : if ( pi.IsValid() )
252 : {
253 796682 : if ( !pad.IsValid() )
254 : {
255 1622502 : pad = AliMpPad(0, 0,
256 540834 : pi.GetIndices(),
257 540834 : pi.GetPositionX(),pi.GetPositionY(),
258 540834 : pi.GetDimensionX(), pi.GetDimensionY());
259 1622502 : pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
260 : }
261 : else
262 : {
263 767544 : pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
264 : }
265 : }
266 923241 : }
267 870694 : if ( warning && !pad.IsValid() )
268 : {
269 0 : AliWarning(Form("No pad found at indices (%d,%d)",ix, iy));
270 : }
271 :
272 : return pad;
273 1107918 : }
274 :
275 : //_____________________________________________________________________________
276 : AliMpPad
277 : AliMpTriggerSegmentation::PadByPosition(Double_t x, Double_t y,
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 304 : AliMpPad pad;
288 :
289 2952 : for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
290 : {
291 680 : AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
292 680 : AliMpPad pi = seg->PadByPosition(x,y,kFALSE);
293 680 : if ( pi.IsValid() )
294 : {
295 522 : if ( !pad.IsValid() )
296 : {
297 912 : pad = AliMpPad(0, 0,
298 304 : pi.GetIndices(),
299 304 : pi.GetPositionX(),pi.GetPositionY(),
300 304 : pi.GetDimensionX(), pi.GetDimensionY());
301 912 : pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
302 : }
303 : else
304 : {
305 654 : pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
306 : }
307 : }
308 680 : }
309 304 : if ( warning && !pad.IsValid() )
310 : {
311 0 : AliWarning(Form("No pad found at position (%e,%e)",x,y));
312 : }
313 :
314 : return pad;
315 608 : }
316 :
317 : //_____________________________________________________________________________
318 : AliMp::PlaneType
319 : AliMpTriggerSegmentation::PlaneType() const
320 : {
321 : /// Return plane type
322 :
323 0 : return Slat()->PlaneType();
324 : }
325 :
326 : //_____________________________________________________________________________
327 : const AliMpTrigger*
328 : AliMpTriggerSegmentation::Slat() const
329 : {
330 : ///
331 : /// Returns the pointer to the referenced slat.
332 : ///
333 :
334 1944 : return fkSlat;
335 : }
336 :
337 : //_____________________________________________________________________________
338 : Int_t
339 : AliMpTriggerSegmentation::GetNofElectronicCards() const
340 : {
341 : /// Get the number of local board numbers
342 :
343 0 : TArrayI ecn;
344 0 : fkSlat->GetAllLocalBoardNumbers(ecn);
345 0 : return ecn.GetSize();
346 0 : }
347 :
348 : //_____________________________________________________________________________
349 : Double_t
350 : AliMpTriggerSegmentation::GetPositionX() const
351 : {
352 : /// Return x position of origin
353 0 : return Slat()->GetPositionX();
354 : }
355 :
356 : //_____________________________________________________________________________
357 : Double_t
358 : AliMpTriggerSegmentation::GetPositionY() const
359 : {
360 : /// Return y position of origin
361 0 : return Slat()->GetPositionY();
362 : }
363 :
364 : //_____________________________________________________________________________
365 : AliMpMotifPosition*
366 : AliMpTriggerSegmentation::MotifPosition(Int_t /* manuId */) const
367 : {
368 : /// No implemented (yet ?)
369 0 : AliError("Not implemented");
370 0 : return 0x0;
371 : }
372 :
373 : //_____________________________________________________________________________
374 : Bool_t
375 : AliMpTriggerSegmentation::HasMotifPosition(Int_t manuId) const
376 : {
377 : /// Uses default implementation
378 0 : return AliMpVSegmentation::HasMotifPosition(manuId);
379 : }
|