1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $
20 //-----------------------------------------------------------------------------
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 //-----------------------------------------------------------------------------
28 #include "AliMpSector.h"
29 #include "AliMpSectorPadIterator.h"
30 #include "AliMpZone.h"
32 #include "AliMpVRowSegment.h"
33 #include "AliMpVMotif.h"
34 #include "AliMpMotifMap.h"
35 #include "AliMpEncodePair.h"
36 #include "AliMpConstants.h"
40 #include <Riostream.h>
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", ""),
61 fDirection(direction),
62 fMinPadDimensionX(1.e6),
63 fMinPadDimensionY(1.e6),
64 fMaxPadDimensionX(0.),
65 fMaxPadDimensionY(0.),
69 /// Standard constructor
71 AliDebugStream(1) << "this = " << this << endl;
73 fMotifMap = new AliMpMotifMap;
75 for (Int_t izone = 0; izone<nofZones; izone++)
76 fZones.Add(new AliMpZone(izone+1));
78 for (Int_t irow = 0; irow<nofRows; irow++)
79 fRows.Add(new AliMpRow(irow, fMotifMap));
83 //_____________________________________________________________________________
84 AliMpSector::AliMpSector()
94 fDirection(AliMp::kX),
95 fMinPadDimensionX(0.),
96 fMinPadDimensionY(0.),
97 fMaxPadDimensionX(0.),
98 fMaxPadDimensionY(0.),
102 /// Default constructor
104 AliDebugStream(1) << "this = " << this << endl;
107 //_____________________________________________________________________________
108 AliMpSector::~AliMpSector()
112 AliDebugStream(1) << "this = " << this << endl;
115 for (Int_t izone = 0; izone<GetNofZones(); izone++)
116 delete fZones[izone];
118 for (Int_t irow = 0; irow<GetNofRows(); irow++)
128 //_____________________________________________________________________________
129 AliMpRow* AliMpSector::FindRow(Double_t y) const
131 /// Find the row for the specified y position. \n
132 /// If y is on border the lowest row is returned.
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];
143 //_____________________________________________________________________________
144 Int_t AliMpSector::FindMotifPositionId(Double_t x, Double_t y) const
146 /// Find the motif position ID in the specified position. \n
147 /// Return 0 if no motif is found.
149 // Find the row segment
150 AliMpVRowSegment* rowSegment = FindRowSegment(x,y);
152 if ( ! rowSegment ) return 0;
154 // Find motif position ID
155 return rowSegment->FindMotifPositionId(x, y);
158 //_____________________________________________________________________________
159 AliMpVRowSegment* AliMpSector::FindRowSegment(Double_t x, Double_t y) const
161 /// Find the row segment in the specified position. \n
162 /// Return if no motif is found.
165 AliMpRow* row = FindRow(y);
169 // Find the row segment and return its motif
170 AliMpVRowSegment* rowSegment = row->FindRowSegment(x);
175 //_____________________________________________________________________________
176 void AliMpSector::SetRowOffsets()
178 /// For each row check consitency of the row segments
179 /// and calculate the row offset.
181 Double_t offset = fOffsetY;
183 for (Int_t irow=0; irow<GetNofRows(); irow++)
184 offset = GetRow(irow)->SetOffsetY(offset);
187 //_____________________________________________________________________________
188 void AliMpSector::SetMotifPositions()
190 /// Create motif positions objects and fills them in the motif map.
192 for (Int_t i=0; i<GetNofRows(); i++)
193 GetRow(i)->SetMotifPositions();
196 //_____________________________________________________________________________
197 void AliMpSector::SetGlobalIndices()
199 /// Set the indices limits to all indexed elements
200 /// (row, row segment, motif positions).
202 AliMpRow* rowBefore=0;
203 for (Int_t i=0; i<GetNofRows(); i++) {
204 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
205 rowBefore = GetRow(i);
209 //_____________________________________________________________________________
210 void AliMpSector::SetMinMaxPadDimensions()
212 /// Set the minimal pad dimensions.
214 for (Int_t i=1; i<GetNofZones()+1; i++) {
215 Double_t dx = GetZone(i)->GetPadDimensionX();
216 Double_t dy = GetZone(i)->GetPadDimensionY();
218 if ( ( fDirection == AliMp::kX && dy > 0. && dy < fMinPadDimensionY ) ||
219 ( fDirection == AliMp::kY && dx > 0. && dx < fMinPadDimensionX ) ) {
221 fMinPadDimensionX = dx;
222 fMinPadDimensionY = dy;
225 if ( ( fDirection == AliMp::kX && dy > 0. && dy > fMaxPadDimensionY ) ||
226 ( fDirection == AliMp::kY && dx > 0. && dx > fMinPadDimensionX ) ) {
228 fMaxPadDimensionX = dx;
229 fMaxPadDimensionY = dy;
234 //_____________________________________________________________________________
235 void AliMpSector::SetMaxPadIndices()
237 /// Set maximum pad indices in x, y
239 if ( fLMaxPadIndices != 0 ) return;
241 Int_t maxIndexInX = 0;
242 Int_t maxIndexInY = 0;
243 for (Int_t i=0; i<GetNofRows(); i++) {
245 Int_t ixh = GetRow(i)->GetHighLimitIx();
246 if ( ixh > maxIndexInX ) maxIndexInX = ixh;
248 Int_t iyh = GetRow(i)->GetHighLimitIy();
249 if ( iyh > maxIndexInY ) maxIndexInY = iyh;
252 fLMaxPadIndices = AliMp::Pair(maxIndexInX, maxIndexInY);
256 //_____________________________________________________________________________
257 void AliMpSector::SetNofPads()
259 /// Set the total number of pads
261 fNofPads = fMotifMap->CalculateNofPads();
264 //_____________________________________________________________________________
265 void AliMpSector::SetDimensions()
267 /// Set the maximum halflengths in x, y.
272 for (Int_t i=0; i<GetNofRows(); i++) {
274 // take the largest x row dimension
275 if ( ((AliMpRow*)fRows[i])->GetDimensionX() > fDimensionX )
276 fDimensionX = ((AliMpRow*)fRows[i])->GetDimensionX();
278 // add all rows y dimensions
279 fDimensionY += ((AliMpRow*)fRows[i])->GetDimensionY();
287 //_____________________________________________________________________________
288 AliMpVPadIterator* AliMpSector::CreateIterator() const
290 /// Create sector pad iterator
292 return new AliMpSectorPadIterator(this);
296 //_____________________________________________________________________________
297 void AliMpSector::SetRowSegmentOffsets()
299 /// For all rows set the offset to all row segments.
301 for (Int_t irow=0; irow<GetNofRows(); irow++)
302 GetRow(irow)->SetRowSegmentOffsets(fOffsetX);
305 //_____________________________________________________________________________
306 void AliMpSector::Initialize()
308 /// Make needed settings after sector is read from
314 SetMinMaxPadDimensions();
320 //_____________________________________________________________________________
321 void AliMpSector::PrintGeometry() const
323 /// Print the positions of rows, rows segments
325 for (Int_t i=0; i<GetNofRows(); i++) {
326 AliMpRow* row = GetRow(i);
328 cout << "ROW " << row->GetID()
329 << " center Y " << row->GetPositionY() << endl;
331 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
332 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
334 cout << " ROW Segment " << j
336 << rowSegment->LeftBorderX() << " "
337 << rowSegment->RightBorderX()
339 << 2*rowSegment->GetDimensionX() << " "
346 //_____________________________________________________________________________
347 AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
349 /// Find the row with the the specified motif position. \n
350 /// Return 0 if no row is found.
352 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
354 if (segment) return segment->GetRow();
359 //_____________________________________________________________________________
360 AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
362 /// Find the row segment with the the specified motif position. \n
363 /// Return 0 if no row segment is found.
365 for (Int_t irow=0; irow<GetNofRows(); irow++) {
367 AliMpRow* row = (AliMpRow*)fRows[irow];
369 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
370 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
371 if (segment->HasMotifPosition(motifPositionId)) return segment;
378 //_____________________________________________________________________________
379 Double_t AliMpSector::GetPositionX() const
381 /// Return the sector offset.
387 //_____________________________________________________________________________
388 Double_t AliMpSector::GetPositionY() const
390 /// Return the sector offset.
395 //_____________________________________________________________________________
396 Double_t AliMpSector::GetDimensionX() const
398 /// Return the maximum halflengths in x.
403 //_____________________________________________________________________________
404 Double_t AliMpSector::GetDimensionY() const
406 /// Return the maximum halflengths in y.
411 //_____________________________________________________________________________
412 Int_t AliMpSector::GetNofZones() const
414 /// Return the number of zones.
416 return fZones.GetEntriesFast();
419 //_____________________________________________________________________________
420 AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
422 /// Return zone with specified ID.
424 if (zoneID < 1 || zoneID > GetNofZones()) {
425 AliWarningStream() << "Index outside range" << endl;
429 return (AliMpZone*)fZones[zoneID-1];
432 //_____________________________________________________________________________
433 Int_t AliMpSector::GetNofRows() const
435 /// Return the number of rows.
437 return fRows.GetEntriesFast();
440 //_____________________________________________________________________________
441 AliMpRow* AliMpSector::GetRow(Int_t rowID) const
443 /// Return row with specified ID.
445 if (rowID < 0 || rowID >= GetNofRows()) {
446 AliWarningStream() << "Index outside range" << endl;
450 return (AliMpRow*)fRows[rowID];
453 //_____________________________________________________________________________
455 AliMpSector::GetPlaneType() const
457 /// Return the plane type
459 return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane;
462 //_____________________________________________________________________________
464 AliMpSector::GetNofMotifPositions() const
466 /// Return the number of manus
468 return fMotifMap->GetNofMotifPositions();
471 //_____________________________________________________________________________
473 AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const
475 /// Return the array of all motif positions IDs
477 fMotifMap->GetAllMotifPositionsIDs(ecn);
480 //_____________________________________________________________________________
482 AliMpSector::Print(Option_t* opt) const
484 /// Print the map of motifs
486 cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
487 fMotifMap->Print(opt);