AliRoot Core  edcc906 (edcc906)
AliMpSector.cxx
Go to the documentation of this file.
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: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $
18 // Category: sector
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpSector
22 // -----------------
23 // Class describing the sector of the MUON chamber of station 1.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
27 
28 #include "AliMpSector.h"
29 #include "AliMpSectorPadIterator.h"
30 #include "AliMpZone.h"
31 #include "AliMpRow.h"
32 #include "AliMpVRowSegment.h"
33 #include "AliMpVMotif.h"
34 #include "AliMpMotifMap.h"
35 #include "AliMpEncodePair.h"
36 #include "AliMpConstants.h"
37 
38 #include "AliLog.h"
39 
40 #include <Riostream.h>
41 
42 using std::cout;
43 using std::endl;
45 ClassImp(AliMpSector)
47 
48 //_____________________________________________________________________________
49 AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
50  AliMp::Direction direction,
51  Double_t offsetx, Double_t offsety)
52  : TNamed("Sector", ""),
53  fID(id),
54  fOffsetX(offsetx),
55  fOffsetY(offsety),
56  fDimensionX(0.),
57  fDimensionY(0.),
58  fZones(),
59  fRows(),
60  fMotifMap(0),
61  fDirection(direction),
62  fMinPadDimensionX(1.e6),
63  fMinPadDimensionY(1.e6),
64  fMaxPadDimensionX(0.),
65  fMaxPadDimensionY(0.),
66  fLMaxPadIndices(0),
67  fNofPads(0)
68 {
70 
71  AliDebugStream(1) << "this = " << this << endl;
72 
73  fMotifMap = new AliMpMotifMap;
74 
75  for (Int_t izone = 0; izone<nofZones; izone++)
76  fZones.Add(new AliMpZone(izone+1));
77 
78  for (Int_t irow = 0; irow<nofRows; irow++)
79  fRows.Add(new AliMpRow(irow, fMotifMap));
80 
81 }
82 
83 //_____________________________________________________________________________
85  : TNamed(),
86  fID(""),
87  fOffsetX(0.),
88  fOffsetY(0.),
89  fDimensionX(0.),
90  fDimensionY(0.),
91  fZones(),
92  fRows(),
93  fMotifMap(0),
94  fDirection(AliMp::kX),
95  fMinPadDimensionX(0.),
96  fMinPadDimensionY(0.),
97  fMaxPadDimensionX(0.),
98  fMaxPadDimensionY(0.),
99  fLMaxPadIndices(0),
100  fNofPads(0)
101 {
103 
104  AliDebugStream(1) << "this = " << this << endl;
105 }
106 
107 //_____________________________________________________________________________
109 {
111 
112  AliDebugStream(1) << "this = " << this << endl;
113 
114  // deletes
115  for (Int_t izone = 0; izone<GetNofZones(); izone++)
116  delete fZones[izone];
117 
118  for (Int_t irow = 0; irow<GetNofRows(); irow++)
119  delete fRows[irow];
120 
121  delete fMotifMap;
122 }
123 
124 //
125 // private methods
126 //
127 
128 //_____________________________________________________________________________
129 AliMpRow* AliMpSector::FindRow(Double_t y) const
130 {
133 
134  for (Int_t i=0; i<GetNofRows(); i++) {
135  if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
136  y <= ((AliMpRow*)fRows[i])->UpperBorderY())
137  return (AliMpRow*)fRows[i];
138  }
139 
140  return 0;
141 }
142 
143 //_____________________________________________________________________________
144 Int_t AliMpSector::FindMotifPositionId(Double_t x, Double_t y) const
145 {
148 
149  // Find the row segment
150  AliMpVRowSegment* rowSegment = FindRowSegment(x,y);
151 
152  if ( ! rowSegment ) return 0;
153 
154  // Find motif position ID
155  return rowSegment->FindMotifPositionId(x, y);
156 }
157 
158 //_____________________________________________________________________________
159 AliMpVRowSegment* AliMpSector::FindRowSegment(Double_t x, Double_t y) const
160 {
163 
164  // Find row
165  AliMpRow* row = FindRow(y);
166 
167  if (!row) return 0;
168 
169  // Find the row segment and return its motif
170  AliMpVRowSegment* rowSegment = row->FindRowSegment(x);
171 
172  return rowSegment;
173 }
174 
175 //_____________________________________________________________________________
177 {
180 
181  Double_t offset = fOffsetY;
182 
183  for (Int_t irow=0; irow<GetNofRows(); irow++)
184  offset = GetRow(irow)->SetOffsetY(offset);
185 }
186 
187 //_____________________________________________________________________________
189 {
191 
192  for (Int_t i=0; i<GetNofRows(); i++)
194 }
195 
196 //_____________________________________________________________________________
198 {
201 
202  AliMpRow* rowBefore=0;
203  for (Int_t i=0; i<GetNofRows(); i++) {
204  GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
205  rowBefore = GetRow(i);
206  }
207 }
208 
209 //_____________________________________________________________________________
211 {
213 
214  for (Int_t i=1; i<GetNofZones()+1; i++) {
215  Double_t dx = GetZone(i)->GetPadDimensionX();
216  Double_t dy = GetZone(i)->GetPadDimensionY();
217 
218  if ( ( fDirection == AliMp::kX && dy > 0. && dy < fMinPadDimensionY ) ||
219  ( fDirection == AliMp::kY && dx > 0. && dx < fMinPadDimensionX ) ) {
220 
221  fMinPadDimensionX = dx;
222  fMinPadDimensionY = dy;
223  }
224 
225  if ( ( fDirection == AliMp::kX && dy > 0. && dy > fMaxPadDimensionY ) ||
226  ( fDirection == AliMp::kY && dx > 0. && dx > fMinPadDimensionX ) ) {
227 
228  fMaxPadDimensionX = dx;
229  fMaxPadDimensionY = dy;
230  }
231  }
232 }
233 
234 //_____________________________________________________________________________
236 {
238 
239  if ( fLMaxPadIndices != 0 ) return;
240 
241  Int_t maxIndexInX = 0;
242  Int_t maxIndexInY = 0;
243  for (Int_t i=0; i<GetNofRows(); i++) {
244 
245  Int_t ixh = GetRow(i)->GetHighLimitIx();
246  if ( ixh > maxIndexInX ) maxIndexInX = ixh;
247 
248  Int_t iyh = GetRow(i)->GetHighLimitIy();
249  if ( iyh > maxIndexInY ) maxIndexInY = iyh;
250  }
251 
252  fLMaxPadIndices = AliMp::Pair(maxIndexInX, maxIndexInY);
253 }
254 
255 
256 //_____________________________________________________________________________
258 {
260 
262 }
263 
264 //_____________________________________________________________________________
266 {
268 
269  fDimensionX = 0.;
270  fDimensionY = 0.;
271 
272  for (Int_t i=0; i<GetNofRows(); i++) {
273 
274  // take the largest x row dimension
275  if ( ((AliMpRow*)fRows[i])->GetDimensionX() > fDimensionX )
277 
278  // add all rows y dimensions
279  fDimensionY += ((AliMpRow*)fRows[i])->GetDimensionY();
280  }
281 }
282 
283 //
284 // public methods
285 //
286 
287 //_____________________________________________________________________________
289 {
291 
292  return new AliMpSectorPadIterator(this);
293 }
294 
295 
296 //_____________________________________________________________________________
298 {
300 
301  for (Int_t irow=0; irow<GetNofRows(); irow++)
303 }
304 
305 //_____________________________________________________________________________
307 {
310 
311  SetRowOffsets();
316  SetNofPads();
317  SetDimensions();
318 }
319 
320 //_____________________________________________________________________________
322 {
324 
325  for (Int_t i=0; i<GetNofRows(); i++) {
326  AliMpRow* row = GetRow(i);
327 
328  cout << "ROW " << row->GetID()
329  << " center Y " << row->GetPositionY() << endl;
330 
331  for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
332  AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
333 
334  cout << " ROW Segment " << j
335  << " borders "
336  << rowSegment->LeftBorderX() << " "
337  << rowSegment->RightBorderX()
338  << " x-size "
339  << 2*rowSegment->GetDimensionX() << " "
340  << endl;
341  }
342  }
343 }
344 
345 
346 //_____________________________________________________________________________
347 AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
348 {
351 
352  AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
353 
354  if (segment) return segment->GetRow();
355 
356  return 0;
357 }
358 
359 //_____________________________________________________________________________
360 AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
361 {
364 
365  for (Int_t irow=0; irow<GetNofRows(); irow++) {
366 
367  AliMpRow* row = (AliMpRow*)fRows[irow];
368 
369  for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
370  AliMpVRowSegment* segment = row->GetRowSegment(iseg);
371  if (segment->HasMotifPosition(motifPositionId)) return segment;
372  }
373  }
374 
375  return 0;
376 }
377 
378 //_____________________________________________________________________________
380 {
382 
383  return fOffsetX;
384 }
385 
386 
387 //_____________________________________________________________________________
389 {
391 
392  return fOffsetY;
393 }
394 
395 //_____________________________________________________________________________
397 {
399 
400  return fDimensionX;
401 }
402 
403 //_____________________________________________________________________________
405 {
407 
408  return fDimensionY;
409 }
410 
411 //_____________________________________________________________________________
413 {
415 
416  return fZones.GetEntriesFast();
417 }
418 
419 //_____________________________________________________________________________
420 AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
421 {
423 
424  if (zoneID < 1 || zoneID > GetNofZones()) {
425  AliWarningStream() << "Index outside range" << endl;
426  return 0;
427  }
428 
429  return (AliMpZone*)fZones[zoneID-1];
430 }
431 
432 //_____________________________________________________________________________
434 {
436 
437  return fRows.GetEntriesFast();
438 }
439 
440 //_____________________________________________________________________________
441 AliMpRow* AliMpSector::GetRow(Int_t rowID) const
442 {
444 
445  if (rowID < 0 || rowID >= GetNofRows()) {
446  AliWarningStream() << "Index outside range" << endl;
447  return 0;
448  }
449 
450  return (AliMpRow*)fRows[rowID];
451 }
452 
453 //_____________________________________________________________________________
456 {
458 
460 }
461 
462 //_____________________________________________________________________________
463 Int_t
465 {
467 
469 }
470 
471 //_____________________________________________________________________________
472 void
474 {
476 
478 }
479 
480 //_____________________________________________________________________________
481 void
482 AliMpSector::Print(Option_t* opt) const
483 {
485 
486  cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
487  fMotifMap->Print(opt);
488 }
Int_t GetNofRows() const
void SetNofPads()
virtual Bool_t HasMotifPosition(Int_t motifPositionId) const =0
Has the motif position with the given Id ?
UInt_t GetID() const
Return row ID.
Definition: AliMpRow.h:85
direction in x
virtual AliMpVPadIterator * CreateIterator() const
void SetRowOffsets()
Double_t fOffsetX
sector x position
Definition: AliMpSector.h:110
Double_t GetDimensionX() const
virtual AliMpRow * GetRow() const =0
Return the row.which this row segment belongs to.
virtual Double_t GetDimensionX() const =0
Return the x dimension of the row segment centre.
Int_t CalculateNofPads() const
Calculate total number of pads defined in the map.
AliMpMotifMap * fMotifMap
motif map
Definition: AliMpSector.h:116
Int_t fNofPads
total number of pads
Definition: AliMpSector.h:123
Double_t GetPositionY() const
Definition: AliMpRow.cxx:347
UInt_t GetNofMotifPositions() const
void SetRowSegmentOffsets(Double_t offsetx)
Definition: AliMpRow.cxx:372
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
TObjArray fRows
rows
Definition: AliMpSector.h:115
Int_t GetHighLimitIy() const
Double_t fMaxPadDimensionX
miximum pad x dimensions
Definition: AliMpSector.h:120
Double_t fOffsetY
sector y position
Definition: AliMpSector.h:111
TObjArray fZones
zones
Definition: AliMpSector.h:114
An iterator over the pads of a sector.
A region of pads of the same dimensions composed of subzones.
Definition: AliMpZone.h:25
virtual void Print(const char *option="ALL") const
Double_t fDimensionX
sector x dimension
Definition: AliMpSector.h:112
AliMp::PlaneType GetPlaneType() const
An interface for a row segment.
virtual void Print(Option_t *opt="") const
void SetMaxPadIndices()
Double_t fMinPadDimensionX
minimum pad x dimensions
Definition: AliMpSector.h:118
void PrintGeometry() const
AliMpVRowSegment * GetRowSegment(Int_t i) const
Definition: AliMpRow.cxx:433
void Initialize()
AliMpVRowSegment * FindRowSegment(Double_t x) const
Definition: AliMpRow.cxx:180
AliMp::Direction GetDirection() const
Return the direction of constant pad size.
Definition: AliMpSector.h:131
Motif map containers.
Definition: AliMpMotifMap.h:34
An interface for an iterator over pads.
void SetRowSegmentOffsets()
non-bending plane
TString PlaneTypeName(AliMp::PlaneType planeType)
Return name for given planeType.
Double_t GetPadDimensionY() const
Return pad y dimensions.
Definition: AliMpZone.h:70
Int_t GetNofZones() const
Double_t GetPositionX() const
Int_t FindMotifPositionId(Double_t x, Double_t y) const
A row composed of the row segments.
Definition: AliMpRow.h:26
Double_t fMinPadDimensionY
minimum pad y dimensions
Definition: AliMpSector.h:119
A sector (quadrant) of the MUON chamber of stations 1 and 2.
Definition: AliMpSector.h:34
Double_t GetPositionY() const
void SetGlobalIndices(AliMp::Direction constPadSizeDirection, AliMpRow *rowBefore)
Definition: AliMpRow.cxx:268
bending plane
Double_t SetOffsetY(Double_t offsetY)
Definition: AliMpRow.cxx:396
#define AliDebugStream(level)
Definition: AliLog.h:388
void SetMotifPositions()
void SetDimensions()
virtual ~AliMpSector()
#define AliWarningStream()
Definition: AliLog.h:581
AliMpRow * FindRow(Int_t motifPositionId) const
void SetGlobalIndices()
void SetMinMaxPadDimensions()
virtual Double_t LeftBorderX() const =0
Return the x coordinate of the left border in the global coordinate system.
void GetAllMotifPositionsIDs(TArrayI &ecn) const
AliMp::Direction fDirection
the direction of constant pad size
Definition: AliMpSector.h:117
Double_t GetPadDimensionX() const
Return pad x dimensions.
Definition: AliMpZone.h:66
AliMpVRowSegment * FindRowSegment(Int_t motifPositionId) const
Int_t GetNofRowSegments() const
Definition: AliMpRow.cxx:425
virtual Int_t FindMotifPositionId(Double_t x, Double_t y) const =0
Find the motif position Id in the given positions.
Int_t GetHighLimitIx() const
Double_t GetDimensionY() const
AliMpRow * GetRow(Int_t i) const
Int_t GetNofMotifPositions() const
virtual Double_t RightBorderX() const =0
Return the x coordinate of the right border in the global coordinate system.
AliMpZone * GetZone(Int_t i) const
The namespace for mapping enums and related functions.
Double_t fDimensionY
sector y dimension
Definition: AliMpSector.h:113
Double_t fMaxPadDimensionY
miximum pad y dimensions
Definition: AliMpSector.h:121
direction in y
void SetMotifPositions()
Definition: AliMpRow.cxx:229
MpPair_t fLMaxPadIndices
maximum pad indices
Definition: AliMpSector.h:122
void GetAllMotifPositionsIDs(TArrayI &enc) const
Find all motifPositionsIDs (=electronicCardNumbers) handled by this map.