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 $
22 // Class describing the sector of the MUON chamber of station 1.
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 #include "AliMpSector.h"
27 #include "AliMpSectorPadIterator.h"
28 #include "AliMpZone.h"
30 #include "AliMpVRowSegment.h"
31 #include "AliMpVMotif.h"
32 #include "AliMpMotifMap.h"
33 #include "AliMpIntPair.h"
34 #include "AliMpConstants.h"
36 #include <Riostream.h>
42 //_____________________________________________________________________________
43 AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
44 AliMpDirection direction, const TVector2& offset)
45 : TNamed("Sector", ""),
51 fDirection(direction),
52 fMinPadDimensions(TVector2(1.e6, 1.e6)),
53 fMaxPadIndices(AliMpIntPair::Invalid()),
56 /// Standard constructor
58 AliDebugStream(1) << "this = " << this << endl;
60 fMotifMap = new AliMpMotifMap(true);
61 //fMotifMap = new AliMpMotifMap();
64 for (Int_t izone = 0; izone<nofZones; izone++)
65 fZones.push_back(new AliMpZone(izone+1));
67 for (Int_t irow = 0; irow<nofRows; irow++)
68 fRows.push_back(new AliMpRow(irow, fMotifMap));
72 for (Int_t izone = 0; izone<nofZones; izone++)
73 fZones.Add(new AliMpZone(izone+1));
75 for (Int_t irow = 0; irow<nofRows; irow++)
76 fRows.Add(new AliMpRow(irow, fMotifMap));
80 //_____________________________________________________________________________
81 AliMpSector::AliMpSector()
84 fOffset(TVector2(0., 0.)),
89 fMinPadDimensions(TVector2(0., 0.)),
90 fMaxPadIndices(AliMpIntPair::Invalid()),
93 /// Default constructor
95 AliDebugStream(1) << "this = " << this << endl;
98 //_____________________________________________________________________________
99 AliMpSector::~AliMpSector()
103 AliDebugStream(1) << "this = " << this << endl;
106 for (Int_t izone = 0; izone<GetNofZones(); izone++)
107 delete fZones[izone];
109 for (Int_t irow = 0; irow<GetNofRows(); irow++)
119 //_____________________________________________________________________________
120 AliMpVPadIterator* AliMpSector::CreateIterator() const
122 /// Create sector pad iterator
124 return new AliMpSectorPadIterator(this);
128 //_____________________________________________________________________________
129 AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
131 /// Find the row segment in the specified position. \n
132 /// Return if no motif is found.
135 AliMpRow* row = FindRow(position);
139 // Find the row segment and return its motif
140 AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
145 //_____________________________________________________________________________
146 void AliMpSector::SetRowOffsets()
148 /// For each row check consitency of the row segments
149 /// and calculate the row offset.
151 Double_t offset = fOffset.Y();
153 for (Int_t irow=0; irow<GetNofRows(); irow++)
154 offset = GetRow(irow)->SetOffsetY(offset);
157 //_____________________________________________________________________________
158 void AliMpSector::SetMotifPositions()
160 /// Create motif positions objects and fills them in the motif map.
162 for (Int_t i=0; i<GetNofRows(); i++)
163 GetRow(i)->SetMotifPositions();
166 //_____________________________________________________________________________
167 void AliMpSector::SetGlobalIndices()
169 /// Set the indices limits to all indexed elements
170 /// (row, row segment, motif positions).
172 AliMpIntPair indices(0,0);
173 AliMpRow* rowBefore=0;
174 for (Int_t i=0; i<GetNofRows(); i++) {
175 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
176 rowBefore = GetRow(i);
180 //_____________________________________________________________________________
181 void AliMpSector::SetMinPadDimensions()
183 /// Set the minimal pad dimensions.
185 for (Int_t i=1; i<GetNofZones()+1; i++) {
186 TVector2 padDimensions = GetZone(i)->GetPadDimensions();
188 if ( fDirection == kX &&
189 padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() ||
191 padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X())
193 fMinPadDimensions = padDimensions;
197 //_____________________________________________________________________________
198 void AliMpSector::SetMaxPadIndices()
200 /// Set maximum pad indices in x, y
202 if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return;
204 Int_t maxIndexInX = 0;
205 Int_t maxIndexInY = 0;
206 for (Int_t i=0; i<GetNofRows(); i++) {
208 Int_t ixh = GetRow(i)->GetHighIndicesLimit().GetFirst();
209 if ( ixh > maxIndexInX ) maxIndexInX = ixh;
211 Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond();
212 if ( iyh > maxIndexInY ) maxIndexInY = iyh;
215 fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY);
219 //_____________________________________________________________________________
220 void AliMpSector::SetNofPads()
222 /// Set the total number of pads
224 fNofPads = fMotifMap->CalculateNofPads();
231 //_____________________________________________________________________________
232 void AliMpSector::SetRowSegmentOffsets()
234 /// For all rows set the offset to all row segments.
236 for (Int_t irow=0; irow<GetNofRows(); irow++)
237 GetRow(irow)->SetRowSegmentOffsets(fOffset);
240 //_____________________________________________________________________________
241 void AliMpSector::Initialize()
243 /// Make needed settings after sector is read from
249 SetMinPadDimensions();
254 //_____________________________________________________________________________
255 void AliMpSector::PrintGeometry() const
257 /// Print the positions of rows, rows segments
259 for (Int_t i=0; i<GetNofRows(); i++) {
260 AliMpRow* row = GetRow(i);
262 cout << "ROW " << row->GetID()
263 << " center Y " << row->Position().Y() << endl;
265 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
266 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
268 cout << " ROW Segment " << j
270 << rowSegment->LeftBorderX() << " "
271 << rowSegment->RightBorderX()
273 << 2*rowSegment->Dimensions().X() << " "
280 //_____________________________________________________________________________
281 AliMpRow* AliMpSector::FindRow(const TVector2& position) const
283 /// Find the row for the specified y position. \n
284 /// If y is on border the lowest row is returned.
286 Double_t y = position.Y();
289 for (Int_t i=0; i<GetNofRows(); i++) {
290 if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY())
296 for (Int_t i=0; i<GetNofRows(); i++) {
297 if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
298 y <= ((AliMpRow*)fRows[i])->UpperBorderY())
299 return (AliMpRow*)fRows[i];
306 //_____________________________________________________________________________
307 AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
309 /// Find the motif in the specified position. \n
310 /// Return 0 if no motif is found.
312 // Find the row segment
313 AliMpVRowSegment* rowSegment = FindRowSegment(position);
315 if (!rowSegment) return 0;
318 return rowSegment->FindMotif(position);
320 //_____________________________________________________________________________
321 Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
323 /// Find the motif position ID in the specified position. \n
324 /// Return 0 if no motif is found.
326 // Find the row segment
327 AliMpVRowSegment* rowSegment = FindRowSegment(position);
329 if (!rowSegment) return 0;
331 // Find motif position ID
332 return rowSegment->FindMotifPositionId(position);
335 //_____________________________________________________________________________
336 AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
338 /// Find the row with the the specified motif position. \n
339 /// Return 0 if no row is found.
341 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
343 if (segment) return segment->GetRow();
348 //_____________________________________________________________________________
349 AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
351 /// Find the row segment with the the specified motif position. \n
352 /// Return 0 if no row segment is found.
354 for (Int_t irow=0; irow<GetNofRows(); irow++) {
357 AliMpRow* row = fRows[irow];
360 AliMpRow* row = (AliMpRow*)fRows[irow];
363 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
364 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
365 if (segment->HasMotifPosition(motifPositionId)) return segment;
372 //_____________________________________________________________________________
373 TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
375 /// Find the position of the motif specified by its position Id. \n
376 /// Return 0 if no row segment is found.
378 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
381 AliWarningStream() << "Given motifPositionId not found." << endl;
385 return segment->MotifCenter(motifPositionId);
388 //_____________________________________________________________________________
389 AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
391 /// Find the zone with specified padDimensions.
393 for (Int_t i=0; i<GetNofZones(); i++) {
394 AliMpZone* zone = GetZone(i+1);
395 if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
399 // Return 0 if not found
403 //_____________________________________________________________________________
404 TVector2 AliMpSector::Position() const
406 /// Return the sector offset.
412 //_____________________________________________________________________________
413 TVector2 AliMpSector::Dimensions() const
415 /// Return the maximum halflengths in x, y.
419 for (Int_t i=0; i<GetNofRows(); i++) {
422 // take the largest x row dimension
423 if (fRows[i]->Dimensions().X() > x)
424 x = fRows[i]->Dimensions().X();
426 // add all rows y dimensions
427 y += fRows[i]->Dimensions().Y();
431 // take the largest x row dimension
432 if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x)
433 x = ((AliMpRow*)fRows[i])->Dimensions().X();
435 // add all rows y dimensions
436 y += ((AliMpRow*)fRows[i])->Dimensions().Y();
440 return TVector2(x, y);
443 //_____________________________________________________________________________
444 Int_t AliMpSector::GetNofZones() const
446 /// Return the number of zones.
449 return fZones.size();
453 return fZones.GetEntriesFast();
457 //_____________________________________________________________________________
458 AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
460 /// Return zone with specified ID.
462 if (zoneID < 1 || zoneID > GetNofZones()) {
463 AliWarningStream() << "Index outside range" << endl;
468 return fZones[zoneID-1];
472 return (AliMpZone*)fZones[zoneID-1];
476 //_____________________________________________________________________________
477 Int_t AliMpSector::GetNofRows() const
479 /// Return the number of rows.
486 return fRows.GetEntriesFast();
490 //_____________________________________________________________________________
491 AliMpRow* AliMpSector::GetRow(Int_t rowID) const
493 /// Return row with specified ID.
495 if (rowID < 0 || rowID >= GetNofRows()) {
496 AliWarningStream() << "Index outside range" << endl;
505 return (AliMpRow*)fRows[rowID];
509 //_____________________________________________________________________________
511 AliMpSector::GetPlaneType() const
513 /// Return the plane type
515 return GetDirection()==kY ? kBendingPlane : kNonBendingPlane;
518 //_____________________________________________________________________________
520 AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const
522 /// Return the array of all motif positions IDs
524 fMotifMap->GetAllMotifPositionsIDs(ecn);
527 //_____________________________________________________________________________
529 AliMpSector::Print(Option_t* opt) const
531 /// Print the map of motifs
533 cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
534 fMotifMap->Print(opt);